Rename `lib.rs` to `bindings.rs` and minor BUILD cleanup.
Among other things, this fixes the following warning:
```
warning: found module declaration for lib.rs
--> third_party/crubit/cc_bindings_from_rs/cc_bindings_from_rs.rs:22:1
|
22 | mod lib;
| ^^^^^^^^
|
= note: `#[warn(special_module_name)]` on by default
= note: lib.rs is the root of this crate's library target
= help: to refer to it from other targets, use the library's name as the path
```
PiperOrigin-RevId: 478108617
diff --git a/cc_bindings_from_rs/BUILD b/cc_bindings_from_rs/BUILD
index d51dc25..a02b304 100644
--- a/cc_bindings_from_rs/BUILD
+++ b/cc_bindings_from_rs/BUILD
@@ -17,9 +17,9 @@
rust_binary(
name = "cc_bindings_from_rs",
srcs = [
+ "bindings.rs",
"cc_bindings_from_rs.rs",
"cmdline.rs",
- "lib.rs",
],
crate_root = "cc_bindings_from_rs.rs",
# TODO(b/242703401): Remove once cc_common.link works for rustc libraries.
@@ -30,7 +30,6 @@
"nobuilder",
"notap",
],
- visibility = ["//:__subpackages__"],
deps = [
"//common:rust_allocator_shims",
"//common:token_stream_printer",
@@ -40,7 +39,6 @@
"@crate_index//:itertools",
"@crate_index//:proc-macro2",
"@crate_index//:quote",
- "@crate_index//:tracing",
],
)
diff --git a/cc_bindings_from_rs/lib.rs b/cc_bindings_from_rs/bindings.rs
similarity index 100%
rename from cc_bindings_from_rs/lib.rs
rename to cc_bindings_from_rs/bindings.rs
diff --git a/cc_bindings_from_rs/cc_bindings_from_rs.rs b/cc_bindings_from_rs/cc_bindings_from_rs.rs
index 9938f03..4f9d53e 100644
--- a/cc_bindings_from_rs/cc_bindings_from_rs.rs
+++ b/cc_bindings_from_rs/cc_bindings_from_rs.rs
@@ -16,18 +16,26 @@
extern crate rustc_session;
extern crate rustc_span;
-// TODO(lukasza): Make `cmdline` and `lib` a separate crate (once we move to
-// Bazel).
+// TODO(lukasza): Make `bindings` and `cmdline` separate crates (once we move to
+// Bazel). This hasn't been done that yet, because:
+// * Today it would require replicating `rustc_driver`-related `BUILD` hacks
+// into additional targets. And since this particular problem will go away on
+// its own in Q4 2022 or Q1 2023, maybe for now we can ignore having
+// multi-source-file crate?
+// * To avoid the ickyness above, one may want to start by making `cmdline.rs`
+// `rustc_driver`-agnostic first (switching `@herefile` to a `clap`-based,
+// manually coded behavior). But this refactoring feels a bit arbitrary and
+// needs more discussion (maybe we want to keep `@file` support from rustc?).
+mod bindings;
mod cmdline;
-mod lib;
use anyhow::Context;
use itertools::Itertools;
use rustc_middle::ty::TyCtxt;
use std::path::Path;
+use bindings::GeneratedBindings;
use cmdline::Cmdline;
-use lib::GeneratedBindings;
use token_stream_printer::tokens_to_string;
/// This mostly wraps and simplifies a subset of APIs from the `rustc_driver`
@@ -39,7 +47,7 @@
use rustc_interface::Queries;
use rustc_middle::ty::TyCtxt;
- use crate::lib::enter_tcx;
+ use crate::bindings::enter_tcx;
/// Wrapper around `rustc_driver::RunCompiler::run` that exposes a
/// simplified API:
@@ -204,7 +212,7 @@
mod tests {
use super::run_with_cmdline_args;
- use crate::lib::tests::get_sysroot_for_testing;
+ use crate::bindings::tests::get_sysroot_for_testing;
use itertools::Itertools;
use std::path::PathBuf;
use tempfile::{tempdir, TempDir};