Skip to content

Commit ad65b1f

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.
1 parent 7c4a55c commit ad65b1f

File tree

24 files changed

+38
-41
lines changed

24 files changed

+38
-41
lines changed

Cargo.lock

-14
Original file line numberDiff line numberDiff line change
@@ -3216,7 +3216,6 @@ dependencies = [
32163216
"rustc_index",
32173217
"rustc_macros",
32183218
"rustc_middle",
3219-
"rustc_parse",
32203219
"rustc_session",
32213220
"rustc_span",
32223221
"rustc_target",
@@ -3251,7 +3250,6 @@ version = "0.0.0"
32513250
dependencies = [
32523251
"itertools",
32533252
"rustc_ast",
3254-
"rustc_data_structures",
32553253
"rustc_lexer",
32563254
"rustc_span",
32573255
"thin-vec",
@@ -3279,14 +3277,12 @@ dependencies = [
32793277
"rustc_ast",
32803278
"rustc_ast_pretty",
32813279
"rustc_attr_data_structures",
3282-
"rustc_data_structures",
32833280
"rustc_errors",
32843281
"rustc_feature",
32853282
"rustc_fluent_macro",
32863283
"rustc_hir",
32873284
"rustc_lexer",
32883285
"rustc_macros",
3289-
"rustc_serialize",
32903286
"rustc_session",
32913287
"rustc_span",
32923288
"thin-vec",
@@ -3413,15 +3409,13 @@ dependencies = [
34133409
"rustc_abi",
34143410
"rustc_arena",
34153411
"rustc_ast",
3416-
"rustc_ast_pretty",
34173412
"rustc_attr_parsing",
34183413
"rustc_data_structures",
34193414
"rustc_errors",
34203415
"rustc_fluent_macro",
34213416
"rustc_fs_util",
34223417
"rustc_hashes",
34233418
"rustc_hir",
3424-
"rustc_hir_pretty",
34253419
"rustc_incremental",
34263420
"rustc_index",
34273421
"rustc_macros",
@@ -3872,7 +3866,6 @@ dependencies = [
38723866
"rustc_query_impl",
38733867
"rustc_query_system",
38743868
"rustc_resolve",
3875-
"rustc_serialize",
38763869
"rustc_session",
38773870
"rustc_span",
38783871
"rustc_symbol_mangling",
@@ -3948,7 +3941,6 @@ dependencies = [
39483941
name = "rustc_log"
39493942
version = "0.0.0"
39503943
dependencies = [
3951-
"rustc_span",
39523944
"tracing",
39533945
"tracing-core",
39543946
"tracing-subscriber",
@@ -4037,13 +4029,11 @@ dependencies = [
40374029
name = "rustc_mir_build"
40384030
version = "0.0.0"
40394031
dependencies = [
4040-
"either",
40414032
"itertools",
40424033
"rustc_abi",
40434034
"rustc_apfloat",
40444035
"rustc_arena",
40454036
"rustc_ast",
4046-
"rustc_attr_parsing",
40474037
"rustc_data_structures",
40484038
"rustc_errors",
40494039
"rustc_fluent_macro",
@@ -4250,7 +4240,6 @@ name = "rustc_query_impl"
42504240
version = "0.0.0"
42514241
dependencies = [
42524242
"measureme",
4253-
"rustc_attr_data_structures",
42544243
"rustc_data_structures",
42554244
"rustc_errors",
42564245
"rustc_hashes",
@@ -4324,7 +4313,6 @@ version = "0.0.0"
43244313
dependencies = [
43254314
"bitflags",
43264315
"rustc_abi",
4327-
"rustc_ast",
43284316
"rustc_data_structures",
43294317
"rustc_hir",
43304318
"rustc_middle",
@@ -4379,7 +4367,6 @@ name = "rustc_smir"
43794367
version = "0.0.0"
43804368
dependencies = [
43814369
"rustc_abi",
4382-
"rustc_ast",
43834370
"rustc_data_structures",
43844371
"rustc_hir",
43854372
"rustc_hir_pretty",
@@ -4421,7 +4408,6 @@ dependencies = [
44214408
"punycode",
44224409
"rustc-demangle",
44234410
"rustc_abi",
4424-
"rustc_ast",
44254411
"rustc_data_structures",
44264412
"rustc_errors",
44274413
"rustc_hashes",

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" }

compiler/rustc_ast_pretty/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_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

-2
Original file line numberDiff line numberDiff line change
@@ -9,14 +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_serialize = { path = "../rustc_serialize" }
2018
rustc_session = { path = "../rustc_session" }
2119
rustc_span = { path = "../rustc_span" }
2220
thin-vec = "0.2.12"

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" }

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 `unused_crate_dependencies`. `rust_index`
48+
// isn't used in this crate's code, but it must be named in the `Cargo.toml`
49+
// 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;

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']

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']

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
//!

compiler/rustc_metadata/Cargo.toml

+6-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" }
@@ -31,3 +30,9 @@ rustc_type_ir = { path = "../rustc_type_ir" }
3130
tempfile = "3.2"
3231
tracing = "0.1"
3332
# tidy-alphabetical-end
33+
34+
[target.'cfg(target_os = "aix")'.dependencies]
35+
# tidy-alphabetical-start
36+
libc = "0.2"
37+
# tidy-alphabetical-end
38+

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" }

compiler/rustc_parse_format/Cargo.toml

+3-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ 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
10+
11+
[target.'cfg(target_pointer_width = "64")'.dependencies]
12+
rustc_index = { path = "../rustc_index", default-features = false }

compiler/rustc_pattern_analysis/src/lib.rs

+2
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
#![warn(unreachable_pub)]
1012
// tidy-alphabetical-end

compiler/rustc_pattern_analysis/tests/complexity.rs

+3
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

+3
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

+3
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

-1
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

-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" }

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/",

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};

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;

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" }

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" }

src/bootstrap/src/core/builder/cargo.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1078,6 +1078,7 @@ impl Builder<'_> {
10781078
// of the individual lints are satisfied.
10791079
rustflags.arg("-Wkeyword_idents_2024");
10801080
rustflags.arg("-Wunsafe_op_in_unsafe_fn");
1081+
rustflags.arg("-Wunused_crate_dependencies");
10811082
}
10821083

10831084
if self.config.rust_frame_pointers {

0 commit comments

Comments
 (0)