Skip to content

Commit 00d9c5d

Browse files
committed
Use -Wunused_crate_dependencies for compiler crates.
It's very useful. There are some false positives involving integration tests in `rustc_pattern_analysis` and `rustc_serialize`. There is also a false positive involving `rustc_driver_impl`'s `rustc_randomized_layouts` feature. And I removed a `rustc_span` mention in a doc comment in `rustc_log` because it wasn't integral to the comment but caused a dev-dependency.
1 parent 75530e9 commit 00d9c5d

File tree

26 files changed

+37
-48
lines changed

26 files changed

+37
-48
lines changed

Diff for: Cargo.lock

-17
Original file line numberDiff line numberDiff line change
@@ -3204,7 +3204,6 @@ dependencies = [
32043204
"rustc_ast_ir",
32053205
"rustc_data_structures",
32063206
"rustc_index",
3207-
"rustc_lexer",
32083207
"rustc_macros",
32093208
"rustc_serialize",
32103209
"rustc_span",
@@ -3220,7 +3219,6 @@ dependencies = [
32203219
"rustc_data_structures",
32213220
"rustc_macros",
32223221
"rustc_serialize",
3223-
"rustc_span",
32243222
]
32253223

32263224
[[package]]
@@ -3239,7 +3237,6 @@ dependencies = [
32393237
"rustc_index",
32403238
"rustc_macros",
32413239
"rustc_middle",
3242-
"rustc_parse",
32433240
"rustc_session",
32443241
"rustc_span",
32453242
"rustc_target",
@@ -3274,7 +3271,6 @@ version = "0.0.0"
32743271
dependencies = [
32753272
"itertools",
32763273
"rustc_ast",
3277-
"rustc_data_structures",
32783274
"rustc_lexer",
32793275
"rustc_span",
32803276
"thin-vec",
@@ -3302,15 +3298,12 @@ dependencies = [
33023298
"rustc_ast",
33033299
"rustc_ast_pretty",
33043300
"rustc_attr_data_structures",
3305-
"rustc_data_structures",
33063301
"rustc_errors",
33073302
"rustc_feature",
33083303
"rustc_fluent_macro",
33093304
"rustc_hir",
33103305
"rustc_lexer",
33113306
"rustc_macros",
3312-
"rustc_middle",
3313-
"rustc_serialize",
33143307
"rustc_session",
33153308
"rustc_span",
33163309
"thin-vec",
@@ -3437,15 +3430,13 @@ dependencies = [
34373430
"rustc_abi",
34383431
"rustc_arena",
34393432
"rustc_ast",
3440-
"rustc_ast_pretty",
34413433
"rustc_attr_parsing",
34423434
"rustc_data_structures",
34433435
"rustc_errors",
34443436
"rustc_fluent_macro",
34453437
"rustc_fs_util",
34463438
"rustc_hashes",
34473439
"rustc_hir",
3448-
"rustc_hir_pretty",
34493440
"rustc_incremental",
34503441
"rustc_index",
34513442
"rustc_macros",
@@ -3893,7 +3884,6 @@ dependencies = [
38933884
"rustc_query_impl",
38943885
"rustc_query_system",
38953886
"rustc_resolve",
3896-
"rustc_serialize",
38973887
"rustc_session",
38983888
"rustc_span",
38993889
"rustc_symbol_mangling",
@@ -3969,7 +3959,6 @@ dependencies = [
39693959
name = "rustc_log"
39703960
version = "0.0.0"
39713961
dependencies = [
3972-
"rustc_span",
39733962
"tracing",
39743963
"tracing-core",
39753964
"tracing-subscriber",
@@ -4058,13 +4047,11 @@ dependencies = [
40584047
name = "rustc_mir_build"
40594048
version = "0.0.0"
40604049
dependencies = [
4061-
"either",
40624050
"itertools",
40634051
"rustc_abi",
40644052
"rustc_apfloat",
40654053
"rustc_arena",
40664054
"rustc_ast",
4067-
"rustc_attr_parsing",
40684055
"rustc_data_structures",
40694056
"rustc_errors",
40704057
"rustc_fluent_macro",
@@ -4345,7 +4332,6 @@ version = "0.0.0"
43454332
dependencies = [
43464333
"bitflags",
43474334
"rustc_abi",
4348-
"rustc_ast",
43494335
"rustc_data_structures",
43504336
"rustc_hir",
43514337
"rustc_middle",
@@ -4400,7 +4386,6 @@ name = "rustc_smir"
44004386
version = "0.0.0"
44014387
dependencies = [
44024388
"rustc_abi",
4403-
"rustc_ast",
44044389
"rustc_data_structures",
44054390
"rustc_hir",
44064391
"rustc_hir_pretty",
@@ -4442,7 +4427,6 @@ dependencies = [
44424427
"punycode",
44434428
"rustc-demangle",
44444429
"rustc_abi",
4445-
"rustc_ast",
44464430
"rustc_data_structures",
44474431
"rustc_errors",
44484432
"rustc_hashes",
@@ -4537,7 +4521,6 @@ version = "0.0.0"
45374521
dependencies = [
45384522
"itertools",
45394523
"rustc_abi",
4540-
"rustc_attr_parsing",
45414524
"rustc_data_structures",
45424525
"rustc_errors",
45434526
"rustc_fluent_macro",

Diff for: compiler/rustc_ast/Cargo.toml

-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ memchr = "2.7.4"
1111
rustc_ast_ir = { path = "../rustc_ast_ir" }
1212
rustc_data_structures = { path = "../rustc_data_structures" }
1313
rustc_index = { path = "../rustc_index" }
14-
rustc_lexer = { path = "../rustc_lexer" }
1514
rustc_macros = { path = "../rustc_macros" }
1615
rustc_serialize = { path = "../rustc_serialize" }
1716
rustc_span = { path = "../rustc_span" }

Diff for: compiler/rustc_ast_ir/Cargo.toml

-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ edition = "2024"
88
rustc_data_structures = { path = "../rustc_data_structures", optional = true }
99
rustc_macros = { path = "../rustc_macros", optional = true }
1010
rustc_serialize = { path = "../rustc_serialize", optional = true }
11-
rustc_span = { path = "../rustc_span", optional = true }
1211
# tidy-alphabetical-end
1312

1413
[features]
@@ -17,5 +16,4 @@ nightly = [
1716
"dep:rustc_serialize",
1817
"dep:rustc_data_structures",
1918
"dep:rustc_macros",
20-
"dep:rustc_span",
2119
]

Diff for: compiler/rustc_ast_lowering/Cargo.toml

-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ rustc_hir = { path = "../rustc_hir" }
2020
rustc_index = { path = "../rustc_index" }
2121
rustc_macros = { path = "../rustc_macros" }
2222
rustc_middle = { path = "../rustc_middle" }
23-
rustc_parse = { path = "../rustc_parse" }
2423
rustc_session = { path = "../rustc_session" }
2524
rustc_span = { path = "../rustc_span" }
2625
rustc_target = { path = "../rustc_target" }

Diff for: compiler/rustc_ast_pretty/Cargo.toml

+4-1
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,11 @@ edition = "2024"
77
# tidy-alphabetical-start
88
itertools = "0.12"
99
rustc_ast = { path = "../rustc_ast" }
10-
rustc_data_structures = { path = "../rustc_data_structures" }
1110
rustc_lexer = { path = "../rustc_lexer" }
1211
rustc_span = { path = "../rustc_span" }
12+
# tidy-alphabetical-end
13+
14+
[dev-dependencies]
15+
# tidy-alphabetical-start
1316
thin-vec = "0.2.12"
1417
# tidy-alphabetical-end

Diff for: compiler/rustc_attr_parsing/Cargo.toml

-3
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,12 @@ rustc_abi = { path = "../rustc_abi" }
99
rustc_ast = { path = "../rustc_ast" }
1010
rustc_ast_pretty = { path = "../rustc_ast_pretty" }
1111
rustc_attr_data_structures = { path = "../rustc_attr_data_structures" }
12-
rustc_data_structures = { path = "../rustc_data_structures" }
1312
rustc_errors = { path = "../rustc_errors" }
1413
rustc_feature = { path = "../rustc_feature" }
1514
rustc_fluent_macro = { path = "../rustc_fluent_macro" }
1615
rustc_hir = { path = "../rustc_hir" }
1716
rustc_lexer = { path = "../rustc_lexer" }
1817
rustc_macros = { path = "../rustc_macros" }
19-
rustc_middle = { path = "../rustc_middle" }
20-
rustc_serialize = { path = "../rustc_serialize" }
2118
rustc_session = { path = "../rustc_session" }
2219
rustc_span = { path = "../rustc_span" }
2320
thin-vec = "0.2.12"

Diff for: compiler/rustc_codegen_ssa/Cargo.toml

-2
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,13 @@ regex = "1.4"
1919
rustc_abi = { path = "../rustc_abi" }
2020
rustc_arena = { path = "../rustc_arena" }
2121
rustc_ast = { path = "../rustc_ast" }
22-
rustc_ast_pretty = { path = "../rustc_ast_pretty" }
2322
rustc_attr_parsing = { path = "../rustc_attr_parsing" }
2423
rustc_data_structures = { path = "../rustc_data_structures" }
2524
rustc_errors = { path = "../rustc_errors" }
2625
rustc_fluent_macro = { path = "../rustc_fluent_macro" }
2726
rustc_fs_util = { path = "../rustc_fs_util" }
2827
rustc_hashes = { path = "../rustc_hashes" }
2928
rustc_hir = { path = "../rustc_hir" }
30-
rustc_hir_pretty = { path = "../rustc_hir_pretty" }
3129
rustc_incremental = { path = "../rustc_incremental" }
3230
rustc_index = { path = "../rustc_index" }
3331
rustc_macros = { path = "../rustc_macros" }

Diff for: compiler/rustc_driver_impl/src/lib.rs

+4
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,10 @@ use rustc_errors::emitter::stderr_destination;
4444
use rustc_errors::registry::Registry;
4545
use rustc_errors::{ColorConfig, DiagCtxt, ErrCode, FatalError, PResult, markdown};
4646
use rustc_feature::find_gated_cfg;
47+
// This avoids a false positive with `-Wunused_crate_dependencies`.
48+
// `rust_index` isn't used in this crate's code, but it must be named in the
49+
// `Cargo.toml` for the `rustc_randomized_layouts` feature.
50+
use rustc_index as _;
4751
use rustc_interface::util::{self, get_codegen_backend};
4852
use rustc_interface::{Linker, create_and_enter_global_ctxt, interface, passes};
4953
use rustc_lint::unerased_lint_store;

Diff for: compiler/rustc_interface/Cargo.toml

+5-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ edition = "2024"
77
# tidy-alphabetical-start
88
rustc-rayon = { version = "0.5.0" }
99
rustc-rayon-core = { version = "0.5.0" }
10-
rustc_abi = { path = "../rustc_abi" }
1110
rustc_ast = { path = "../rustc_ast" }
1211
rustc_ast_lowering = { path = "../rustc_ast_lowering" }
1312
rustc_ast_passes = { path = "../rustc_ast_passes" }
@@ -41,7 +40,6 @@ rustc_privacy = { path = "../rustc_privacy" }
4140
rustc_query_impl = { path = "../rustc_query_impl" }
4241
rustc_query_system = { path = "../rustc_query_system" }
4342
rustc_resolve = { path = "../rustc_resolve" }
44-
rustc_serialize = { path = "../rustc_serialize" }
4543
rustc_session = { path = "../rustc_session" }
4644
rustc_span = { path = "../rustc_span" }
4745
rustc_symbol_mangling = { path = "../rustc_symbol_mangling" }
@@ -52,6 +50,11 @@ rustc_ty_utils = { path = "../rustc_ty_utils" }
5250
tracing = "0.1"
5351
# tidy-alphabetical-end
5452

53+
[dev-dependencies]
54+
# tidy-alphabetical-start
55+
rustc_abi = { path = "../rustc_abi" }
56+
# tidy-alphabetical-end
57+
5558
[features]
5659
# tidy-alphabetical-start
5760
llvm = ['dep:rustc_codegen_llvm']

Diff for: compiler/rustc_log/Cargo.toml

-5
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,6 @@ tracing-subscriber = { version = "0.3.3", default-features = false, features = [
1111
tracing-tree = "0.3.1"
1212
# tidy-alphabetical-end
1313

14-
[dev-dependencies]
15-
# tidy-alphabetical-start
16-
rustc_span = { path = "../rustc_span" }
17-
# tidy-alphabetical-end
18-
1914
[features]
2015
# tidy-alphabetical-start
2116
max_level_info = ['tracing/max_level_info']

Diff for: compiler/rustc_log/src/lib.rs

+1-6
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,12 @@
99
//! [dependencies]
1010
//! rustc_ast = { path = "../rust/compiler/rustc_ast" }
1111
//! rustc_log = { path = "../rust/compiler/rustc_log" }
12-
//! rustc_span = { path = "../rust/compiler/rustc_span" }
1312
//! ```
1413
//!
1514
//! ```
1615
//! fn main() {
1716
//! rustc_log::init_logger(rustc_log::LoggerConfig::from_env("LOG")).unwrap();
18-
//!
19-
//! let edition = rustc_span::edition::Edition::Edition2021;
20-
//! rustc_span::create_session_globals_then(edition, None, || {
21-
//! /* ... */
22-
//! });
17+
//! /* ... */
2318
//! }
2419
//! ```
2520
//!

Diff for: compiler/rustc_metadata/Cargo.toml

+5-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ edition = "2024"
66
[dependencies]
77
# tidy-alphabetical-start
88
bitflags = "2.4.1"
9-
libc = "0.2"
109
libloading = "0.8.0"
1110
odht = { version = "0.3.1", features = ["nightly"] }
1211
rustc_abi = { path = "../rustc_abi" }
@@ -30,3 +29,8 @@ rustc_target = { path = "../rustc_target" }
3029
tempfile = "3.2"
3130
tracing = "0.1"
3231
# tidy-alphabetical-end
32+
33+
[target.'cfg(target_os = "aix")'.dependencies]
34+
# tidy-alphabetical-start
35+
libc = "0.2"
36+
# tidy-alphabetical-end

Diff for: compiler/rustc_mir_build/Cargo.toml

-2
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,12 @@ edition = "2024"
55

66
[dependencies]
77
# tidy-alphabetical-start
8-
either = "1.5.0"
98
itertools = "0.12"
109

1110
rustc_abi = { path = "../rustc_abi" }
1211
rustc_apfloat = "0.2.0"
1312
rustc_arena = { path = "../rustc_arena" }
1413
rustc_ast = { path = "../rustc_ast" }
15-
rustc_attr_parsing = { path = "../rustc_attr_parsing" }
1614
rustc_data_structures = { path = "../rustc_data_structures" }
1715
rustc_errors = { path = "../rustc_errors" }
1816
rustc_fluent_macro = { path = "../rustc_fluent_macro" }

Diff for: compiler/rustc_parse_format/Cargo.toml

+3-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ edition = "2024"
66
[dependencies]
77
# tidy-alphabetical-start
88
literal-escaper = { path = "../../library/literal-escaper" }
9-
rustc_index = { path = "../rustc_index", default-features = false }
109
rustc_lexer = { path = "../rustc_lexer" }
1110
# tidy-alphabetical-end
11+
12+
[target.'cfg(target_pointer_width = "64")'.dependencies]
13+
rustc_index = { path = "../rustc_index", default-features = false }

Diff for: compiler/rustc_pattern_analysis/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
// tidy-alphabetical-start
66
#![allow(rustc::diagnostic_outside_of_impl)]
77
#![allow(rustc::untranslatable_diagnostic)]
8+
#![allow(unused_crate_dependencies)]
89
#![cfg_attr(feature = "rustc", feature(let_chains))]
910
// tidy-alphabetical-end
1011

Diff for: compiler/rustc_pattern_analysis/tests/complexity.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
//! Test the pattern complexity limit.
22
3+
#![allow(unused_crate_dependencies)]
4+
35
use common::*;
46
use rustc_pattern_analysis::MatchArm;
57
use rustc_pattern_analysis::pat::DeconstructedPat;

Diff for: compiler/rustc_pattern_analysis/tests/exhaustiveness.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
//! Test exhaustiveness checking.
22
3+
#![allow(unused_crate_dependencies)]
4+
35
use common::*;
46
use rustc_pattern_analysis::MatchArm;
57
use rustc_pattern_analysis::pat::{DeconstructedPat, WitnessPat};

Diff for: compiler/rustc_pattern_analysis/tests/intersection.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
//! Test the computation of arm intersections.
22
3+
#![allow(unused_crate_dependencies)]
4+
35
use common::*;
46
use rustc_pattern_analysis::MatchArm;
57
use rustc_pattern_analysis::pat::DeconstructedPat;

Diff for: compiler/rustc_sanitizers/Cargo.toml

-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ bitflags = "2.5.0"
88
tracing = "0.1"
99
twox-hash = "1.6.3"
1010
rustc_abi = { path = "../rustc_abi" }
11-
rustc_ast = { path = "../rustc_ast" }
1211
rustc_data_structures = { path = "../rustc_data_structures" }
1312
rustc_hir = { path = "../rustc_hir" }
1413
rustc_middle = { path = "../rustc_middle" }

Diff for: compiler/rustc_serialize/src/lib.rs

+2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
// tidy-alphabetical-start
44
#![allow(internal_features)]
55
#![allow(rustc::internal)]
6+
// FIXME
7+
#![allow(unused_crate_dependencies)]
68
#![cfg_attr(test, feature(test))]
79
#![doc(
810
html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/",

Diff for: compiler/rustc_serialize/tests/leb128.rs

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
// FIXME
2+
#![allow(unused_crate_dependencies)]
3+
14
use rustc_serialize::Decoder;
25
use rustc_serialize::leb128::*;
36
use rustc_serialize::opaque::{MAGIC_END_BYTES, MemDecoder};

Diff for: compiler/rustc_serialize/tests/opaque.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
#![allow(rustc::internal)]
2+
// FIXME
3+
#![allow(unused_crate_dependencies)]
24

35
use std::fmt::Debug;
46
use std::fs;

Diff for: compiler/rustc_smir/Cargo.toml

-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ edition = "2024"
66
[dependencies]
77
# tidy-alphabetical-start
88
rustc_abi = { path = "../rustc_abi" }
9-
rustc_ast = { path = "../rustc_ast" }
109
rustc_data_structures = { path = "../rustc_data_structures" }
1110
rustc_hir = { path = "../rustc_hir" }
1211
rustc_hir_pretty = { path = "../rustc_hir_pretty" }

Diff for: compiler/rustc_symbol_mangling/Cargo.toml

-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ punycode = "0.4.0"
99
rustc-demangle = "0.1.21"
1010

1111
rustc_abi = { path = "../rustc_abi" }
12-
rustc_ast = { path = "../rustc_ast" }
1312
rustc_data_structures = { path = "../rustc_data_structures" }
1413
rustc_errors = { path = "../rustc_errors" }
1514
rustc_hashes = { path = "../rustc_hashes" }

Diff for: compiler/rustc_ty_utils/Cargo.toml

-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ edition = "2024"
77
# tidy-alphabetical-start
88
itertools = "0.12"
99
rustc_abi = { path = "../rustc_abi" }
10-
rustc_attr_parsing = { path = "../rustc_attr_parsing" }
1110
rustc_data_structures = { path = "../rustc_data_structures" }
1211
rustc_errors = { path = "../rustc_errors" }
1312
rustc_fluent_macro = { path = "../rustc_fluent_macro" }

0 commit comments

Comments
 (0)