Skip to content

Commit d65cd4f

Browse files
committed
Use warn(unused_crate_dependencies) in compiler crates.
The commit also removes fifteen unnecessary dependencies from `Cargo.toml` files that this finds. And tweaks some conditional dependencies. There are three crates with false positives, relating to tests and doc comments. For these three crates `allow(unused_crate_dependencies)` is used along with an explanatory comment.
1 parent 7c4a55c commit d65cd4f

File tree

87 files changed

+109
-36
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

87 files changed

+109
-36
lines changed

Cargo.lock

-13
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",
@@ -4037,13 +4030,11 @@ dependencies = [
40374030
name = "rustc_mir_build"
40384031
version = "0.0.0"
40394032
dependencies = [
4040-
"either",
40414033
"itertools",
40424034
"rustc_abi",
40434035
"rustc_apfloat",
40444036
"rustc_arena",
40454037
"rustc_ast",
4046-
"rustc_attr_parsing",
40474038
"rustc_data_structures",
40484039
"rustc_errors",
40494040
"rustc_fluent_macro",
@@ -4250,7 +4241,6 @@ name = "rustc_query_impl"
42504241
version = "0.0.0"
42514242
dependencies = [
42524243
"measureme",
4253-
"rustc_attr_data_structures",
42544244
"rustc_data_structures",
42554245
"rustc_errors",
42564246
"rustc_hashes",
@@ -4324,7 +4314,6 @@ version = "0.0.0"
43244314
dependencies = [
43254315
"bitflags",
43264316
"rustc_abi",
4327-
"rustc_ast",
43284317
"rustc_data_structures",
43294318
"rustc_hir",
43304319
"rustc_middle",
@@ -4379,7 +4368,6 @@ name = "rustc_smir"
43794368
version = "0.0.0"
43804369
dependencies = [
43814370
"rustc_abi",
4382-
"rustc_ast",
43834371
"rustc_data_structures",
43844372
"rustc_hir",
43854373
"rustc_hir_pretty",
@@ -4421,7 +4409,6 @@ dependencies = [
44214409
"punycode",
44224410
"rustc-demangle",
44234411
"rustc_abi",
4424-
"rustc_ast",
44254412
"rustc_data_structures",
44264413
"rustc_errors",
44274414
"rustc_hashes",

compiler/rustc_abi/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#![cfg_attr(feature = "nightly", feature(rustdoc_internals))]
77
#![cfg_attr(feature = "nightly", feature(step_trait))]
88
#![warn(unreachable_pub)]
9+
#![warn(unused_crate_dependencies)]
910
// tidy-alphabetical-end
1011

1112
/*! ABI handling for rustc

compiler/rustc_arena/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#![feature(rustc_attrs)]
2525
#![feature(rustdoc_internals)]
2626
#![warn(unreachable_pub)]
27+
#![warn(unused_crate_dependencies)]
2728
// tidy-alphabetical-end
2829

2930
use std::alloc::Layout;

compiler/rustc_ast/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#![feature(rustdoc_internals)]
2121
#![feature(stmt_expr_attributes)]
2222
#![warn(unreachable_pub)]
23+
#![warn(unused_crate_dependencies)]
2324
// tidy-alphabetical-end
2425

2526
pub mod util {

compiler/rustc_ast_ir/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#![cfg_attr(feature = "nightly", feature(never_type))]
1111
#![cfg_attr(feature = "nightly", feature(rustc_attrs))]
1212
#![warn(unreachable_pub)]
13+
#![warn(unused_crate_dependencies)]
1314
// tidy-alphabetical-end
1415

1516
#[cfg(feature = "nightly")]

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_lowering/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
#![feature(let_chains)]
4040
#![feature(rustdoc_internals)]
4141
#![warn(unreachable_pub)]
42+
#![warn(unused_crate_dependencies)]
4243
// tidy-alphabetical-end
4344

4445
use std::sync::Arc;

compiler/rustc_ast_passes/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#![feature(let_chains)]
1212
#![feature(rustdoc_internals)]
1313
#![warn(unreachable_pub)]
14+
#![warn(unused_crate_dependencies)]
1415
// tidy-alphabetical-end
1516

1617
pub mod ast_validation;

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_ast_pretty/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#![feature(box_patterns)]
55
#![feature(rustdoc_internals)]
66
#![warn(unreachable_pub)]
7+
#![warn(unused_crate_dependencies)]
78
// tidy-alphabetical-end
89

910
mod helpers;

compiler/rustc_attr_data_structures/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#![feature(let_chains)]
55
#![feature(rustdoc_internals)]
66
#![warn(unreachable_pub)]
7+
#![warn(unused_crate_dependencies)]
78
// tidy-alphabetical-end
89

910
mod attributes;

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_attr_parsing/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@
8181
#![feature(let_chains)]
8282
#![feature(rustdoc_internals)]
8383
#![warn(unreachable_pub)]
84+
#![warn(unused_crate_dependencies)]
8485
// tidy-alphabetical-end
8586

8687
#[macro_use]

compiler/rustc_baked_icu_data/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
#![doc(rust_logo)]
2727
#![feature(rustdoc_internals)]
2828
// #![warn(unreachable_pub)] // don't use because this crate is mostly generated code
29+
#![warn(unused_crate_dependencies)]
2930
// tidy-alphabetical-end
3031

3132
mod data {

compiler/rustc_borrowck/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#![feature(stmt_expr_attributes)]
1515
#![feature(try_blocks)]
1616
#![warn(unreachable_pub)]
17+
#![warn(unused_crate_dependencies)]
1718
// tidy-alphabetical-end
1819

1920
use std::borrow::Cow;

compiler/rustc_builtin_macros/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#![feature(string_from_utf8_lossy_owned)]
2020
#![feature(try_blocks)]
2121
#![warn(unreachable_pub)]
22+
#![warn(unused_crate_dependencies)]
2223
// tidy-alphabetical-end
2324

2425
extern crate proc_macro;

compiler/rustc_codegen_cranelift/build_system/main.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#![warn(rust_2018_idioms)]
22
#![warn(unused_lifetimes)]
33
#![warn(unreachable_pub)]
4+
#![warn(unused_crate_dependencies)]
45

56
use std::path::PathBuf;
67
use std::{env, process};

compiler/rustc_codegen_cranelift/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
// Note: please avoid adding other feature gates where possible
1010
#![warn(rust_2018_idioms)]
1111
#![warn(unreachable_pub)]
12+
#![warn(unused_crate_dependencies)]
1213
#![warn(unused_lifetimes)]
1314
// tidy-alphabetical-end
1415

compiler/rustc_codegen_gcc/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#![allow(broken_intra_doc_links)]
2121
#![recursion_limit = "256"]
2222
#![warn(rust_2018_idioms)]
23+
#![warn(unused_crate_dependencies)]
2324
#![warn(unused_lifetimes)]
2425
#![deny(clippy::pattern_type_mismatch)]
2526
#![allow(clippy::needless_lifetimes)]

compiler/rustc_codegen_llvm/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#![feature(slice_as_array)]
2222
#![feature(try_blocks)]
2323
#![warn(unreachable_pub)]
24+
#![warn(unused_crate_dependencies)]
2425
// tidy-alphabetical-end
2526

2627
use std::any::Any;

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_codegen_ssa/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#![feature(trait_alias)]
1616
#![feature(try_blocks)]
1717
#![warn(unreachable_pub)]
18+
#![warn(unused_crate_dependencies)]
1819
// tidy-alphabetical-end
1920

2021
//! This crate contains codegen code that is used by all codegen backends (LLVM and others).

compiler/rustc_const_eval/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#![feature(yeet_expr)]
1818
#![warn(unqualified_local_imports)]
1919
#![warn(unreachable_pub)]
20+
#![warn(unused_crate_dependencies)]
2021
// tidy-alphabetical-end
2122

2223
pub mod check_consts;

compiler/rustc_data_structures/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
#![feature(thread_id_value)]
3838
#![feature(type_alias_impl_trait)]
3939
#![feature(unwrap_infallible)]
40+
#![warn(unused_crate_dependencies)]
4041
// tidy-alphabetical-end
4142

4243
use std::fmt;

compiler/rustc_driver/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#![allow(internal_features)]
66
#![doc(rust_logo)]
77
#![feature(rustdoc_internals)]
8+
#![warn(unused_crate_dependencies)]
89
// tidy-alphabetical-end
910

1011
pub use rustc_driver_impl::*;

compiler/rustc_driver_impl/Cargo.toml

-2
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ rustc_hir_analysis = { path = "../rustc_hir_analysis" }
2424
rustc_hir_pretty = { path = "../rustc_hir_pretty" }
2525
rustc_hir_typeck = { path = "../rustc_hir_typeck" }
2626
rustc_incremental = { path = "../rustc_incremental" }
27-
rustc_index = { path = "../rustc_index" }
2827
rustc_infer = { path = "../rustc_infer" }
2928
rustc_interface = { path = "../rustc_interface" }
3029
rustc_lint = { path = "../rustc_lint" }
@@ -75,7 +74,6 @@ ctrlc = "3.4.4"
7574
llvm = ['rustc_interface/llvm']
7675
max_level_info = ['rustc_log/max_level_info']
7776
rustc_randomized_layouts = [
78-
'rustc_index/rustc_randomized_layouts',
7977
'rustc_middle/rustc_randomized_layouts'
8078
]
8179
# tidy-alphabetical-end

compiler/rustc_driver_impl/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#![feature(rustdoc_internals)]
1818
#![feature(try_blocks)]
1919
#![warn(unreachable_pub)]
20+
#![warn(unused_crate_dependencies)]
2021
// tidy-alphabetical-end
2122

2223
use std::cmp::max;

compiler/rustc_error_codes/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#![doc(rust_logo)]
88
#![feature(rustdoc_internals)]
99
#![warn(unreachable_pub)]
10+
#![warn(unused_crate_dependencies)]
1011
// tidy-alphabetical-end
1112

1213
// This higher-order macro defines the error codes that are in use. It is used

compiler/rustc_error_messages/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#![feature(rustdoc_internals)]
66
#![feature(type_alias_impl_trait)]
77
#![warn(unreachable_pub)]
8+
#![warn(unused_crate_dependencies)]
89
// tidy-alphabetical-end
910

1011
use std::borrow::Cow;

compiler/rustc_errors/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
#![feature(try_blocks)]
2626
#![feature(yeet_expr)]
2727
#![warn(unreachable_pub)]
28+
#![warn(unused_crate_dependencies)]
2829
// tidy-alphabetical-end
2930

3031
extern crate self as rustc_errors;

compiler/rustc_expand/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#![feature(try_blocks)]
1515
#![feature(yeet_expr)]
1616
#![warn(unreachable_pub)]
17+
#![warn(unused_crate_dependencies)]
1718
// tidy-alphabetical-end
1819

1920
extern crate proc_macro as pm;

compiler/rustc_feature/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#![doc(rust_logo)]
1717
#![feature(rustdoc_internals)]
1818
#![warn(unreachable_pub)]
19+
#![warn(unused_crate_dependencies)]
1920
// tidy-alphabetical-end
2021

2122
mod accepted;

compiler/rustc_fluent_macro/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#![feature(rustdoc_internals)]
99
#![feature(track_path)]
1010
#![warn(unreachable_pub)]
11+
#![warn(unused_crate_dependencies)]
1112
// tidy-alphabetical-end
1213

1314
use proc_macro::TokenStream;

compiler/rustc_fs_util/src/lib.rs

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
// tidy-alphabetical-start
2+
#![warn(unused_crate_dependencies)]
3+
// tidy-alphabetical-end
4+
15
use std::ffi::CString;
26
use std::path::{Path, PathBuf, absolute};
37
use std::{fs, io};

compiler/rustc_graphviz/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,7 @@
278278
#![doc(rust_logo)]
279279
#![feature(rustdoc_internals)]
280280
#![warn(unreachable_pub)]
281+
#![warn(unused_crate_dependencies)]
281282
// tidy-alphabetical-end
282283

283284
use std::borrow::Cow;

0 commit comments

Comments
 (0)