Skip to content

Commit 3160090

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`; subsequent commits will fix these. 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 385970f commit 3160090

File tree

24 files changed

+37
-43
lines changed

24 files changed

+37
-43
lines changed

Cargo.lock

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3227,7 +3227,6 @@ dependencies = [
32273227
"rustc_index",
32283228
"rustc_macros",
32293229
"rustc_middle",
3230-
"rustc_parse",
32313230
"rustc_session",
32323231
"rustc_span",
32333232
"rustc_target",
@@ -3262,7 +3261,6 @@ version = "0.0.0"
32623261
dependencies = [
32633262
"itertools",
32643263
"rustc_ast",
3265-
"rustc_data_structures",
32663264
"rustc_lexer",
32673265
"rustc_span",
32683266
"thin-vec",
@@ -3290,15 +3288,12 @@ dependencies = [
32903288
"rustc_ast",
32913289
"rustc_ast_pretty",
32923290
"rustc_attr_data_structures",
3293-
"rustc_data_structures",
32943291
"rustc_errors",
32953292
"rustc_feature",
32963293
"rustc_fluent_macro",
32973294
"rustc_hir",
32983295
"rustc_lexer",
32993296
"rustc_macros",
3300-
"rustc_middle",
3301-
"rustc_serialize",
33023297
"rustc_session",
33033298
"rustc_span",
33043299
"thin-vec",
@@ -3425,15 +3420,13 @@ dependencies = [
34253420
"rustc_abi",
34263421
"rustc_arena",
34273422
"rustc_ast",
3428-
"rustc_ast_pretty",
34293423
"rustc_attr_parsing",
34303424
"rustc_data_structures",
34313425
"rustc_errors",
34323426
"rustc_fluent_macro",
34333427
"rustc_fs_util",
34343428
"rustc_hashes",
34353429
"rustc_hir",
3436-
"rustc_hir_pretty",
34373430
"rustc_incremental",
34383431
"rustc_index",
34393432
"rustc_macros",
@@ -3884,7 +3877,6 @@ dependencies = [
38843877
"rustc_query_impl",
38853878
"rustc_query_system",
38863879
"rustc_resolve",
3887-
"rustc_serialize",
38883880
"rustc_session",
38893881
"rustc_span",
38903882
"rustc_symbol_mangling",
@@ -3960,7 +3952,6 @@ dependencies = [
39603952
name = "rustc_log"
39613953
version = "0.0.0"
39623954
dependencies = [
3963-
"rustc_span",
39643955
"tracing",
39653956
"tracing-core",
39663957
"tracing-subscriber",
@@ -4050,13 +4041,11 @@ dependencies = [
40504041
name = "rustc_mir_build"
40514042
version = "0.0.0"
40524043
dependencies = [
4053-
"either",
40544044
"itertools",
40554045
"rustc_abi",
40564046
"rustc_apfloat",
40574047
"rustc_arena",
40584048
"rustc_ast",
4059-
"rustc_attr_parsing",
40604049
"rustc_data_structures",
40614050
"rustc_errors",
40624051
"rustc_fluent_macro",
@@ -4263,7 +4252,6 @@ name = "rustc_query_impl"
42634252
version = "0.0.0"
42644253
dependencies = [
42654254
"measureme",
4266-
"rustc_attr_data_structures",
42674255
"rustc_data_structures",
42684256
"rustc_errors",
42694257
"rustc_hashes",
@@ -4337,7 +4325,6 @@ version = "0.0.0"
43374325
dependencies = [
43384326
"bitflags",
43394327
"rustc_abi",
4340-
"rustc_ast",
43414328
"rustc_data_structures",
43424329
"rustc_hir",
43434330
"rustc_middle",
@@ -4392,7 +4379,6 @@ name = "rustc_smir"
43924379
version = "0.0.0"
43934380
dependencies = [
43944381
"rustc_abi",
4395-
"rustc_ast",
43964382
"rustc_data_structures",
43974383
"rustc_hir",
43984384
"rustc_hir_pretty",
@@ -4434,7 +4420,6 @@ dependencies = [
44344420
"punycode",
44354421
"rustc-demangle",
44364422
"rustc_abi",
4437-
"rustc_ast",
44384423
"rustc_data_structures",
44394424
"rustc_errors",
44404425
"rustc_hashes",

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ exclude = [
7676
keyword_idents_2024 = "warn"
7777
unreachable_pub = "warn"
7878
unsafe_op_in_unsafe_fn = "warn"
79+
unused_crate_dependencies = "warn"
7980

8081
[profile.release.package.rustc-rayon-core]
8182
# The rustc fork of Rayon has deadlock detection code which intermittently

compiler/rustc_ast_lowering/Cargo.toml

Lines changed: 0 additions & 1 deletion
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" }

compiler/rustc_ast_pretty/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ 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" }
1312
thin-vec = "0.2.12"

compiler/rustc_attr_parsing/Cargo.toml

Lines changed: 0 additions & 3 deletions
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"

compiler/rustc_codegen_ssa/Cargo.toml

Lines changed: 0 additions & 2 deletions
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" }

compiler/rustc_driver_impl/src/lib.rs

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

compiler/rustc_interface/Cargo.toml

Lines changed: 5 additions & 2 deletions
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']

compiler/rustc_log/Cargo.toml

Lines changed: 0 additions & 5 deletions
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']

compiler/rustc_log/src/lib.rs

Lines changed: 1 addition & 6 deletions
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
//!

compiler/rustc_metadata/Cargo.toml

Lines changed: 5 additions & 1 deletion
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" }
@@ -32,5 +31,10 @@ tempfile = "3.2"
3231
tracing = "0.1"
3332
# tidy-alphabetical-end
3433

34+
[target.'cfg(target_os = "aix")'.dependencies]
35+
# tidy-alphabetical-start
36+
libc = "0.2"
37+
# tidy-alphabetical-end
38+
3539
[lints]
3640
workspace = true

compiler/rustc_mir_build/Cargo.toml

Lines changed: 0 additions & 2 deletions
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" }

compiler/rustc_parse_format/Cargo.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,11 @@ edition = "2024"
55

66
[dependencies]
77
# tidy-alphabetical-start
8-
rustc_index = { path = "../rustc_index", default-features = false }
98
rustc_lexer = { path = "../rustc_lexer" }
109
# tidy-alphabetical-end
1110

11+
[target.'cfg(target_pointer_width = "64")'.dependencies]
12+
rustc_index = { path = "../rustc_index", default-features = false }
13+
1214
[lints]
1315
workspace = true

compiler/rustc_pattern_analysis/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
// tidy-alphabetical-start
66
#![allow(rustc::diagnostic_outside_of_impl)]
77
#![allow(rustc::untranslatable_diagnostic)]
8+
// FIXME
9+
#![allow(unused_crate_dependencies)]
810
#![cfg_attr(feature = "rustc", feature(let_chains))]
911
// tidy-alphabetical-end
1012

compiler/rustc_pattern_analysis/tests/complexity.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
//! Test the pattern complexity limit.
22
3+
// FIXME
4+
#![allow(unused_crate_dependencies)]
5+
36
use common::*;
47
use rustc_pattern_analysis::MatchArm;
58
use rustc_pattern_analysis::pat::DeconstructedPat;

compiler/rustc_pattern_analysis/tests/exhaustiveness.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
//! Test exhaustiveness checking.
22
3+
// FIXME
4+
#![allow(unused_crate_dependencies)]
5+
36
use common::*;
47
use rustc_pattern_analysis::MatchArm;
58
use rustc_pattern_analysis::pat::{DeconstructedPat, WitnessPat};

compiler/rustc_pattern_analysis/tests/intersection.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
//! Test the computation of arm intersections.
22
3+
// FIXME
4+
#![allow(unused_crate_dependencies)]
5+
36
use common::*;
47
use rustc_pattern_analysis::MatchArm;
58
use rustc_pattern_analysis::pat::DeconstructedPat;

compiler/rustc_query_impl/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ edition = "2024"
66
[dependencies]
77
# tidy-alphabetical-start
88
measureme = "11"
9-
rustc_attr_data_structures = { path = "../rustc_attr_data_structures" }
109
rustc_data_structures = { path = "../rustc_data_structures" }
1110
rustc_errors = { path = "../rustc_errors" }
1211
rustc_hashes = { path = "../rustc_hashes" }

compiler/rustc_sanitizers/Cargo.toml

Lines changed: 0 additions & 1 deletion
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" }

compiler/rustc_serialize/src/lib.rs

Lines changed: 2 additions & 0 deletions
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/",

compiler/rustc_serialize/tests/leb128.rs

Lines changed: 3 additions & 0 deletions
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};

compiler/rustc_serialize/tests/opaque.rs

Lines changed: 2 additions & 0 deletions
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;

compiler/rustc_smir/Cargo.toml

Lines changed: 0 additions & 1 deletion
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" }

compiler/rustc_symbol_mangling/Cargo.toml

Lines changed: 0 additions & 1 deletion
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" }

0 commit comments

Comments
 (0)