@@ -1045,8 +1045,11 @@ impl Builder<'_> {
1045
1045
// so this line allows the use of custom libcs.
1046
1046
cargo. env ( "LIBC_CHECK_CFG" , "1" ) ;
1047
1047
1048
+ let mut lint_flags = Vec :: new ( ) ;
1049
+
1050
+ // Lints for all in-tree code: compiler, rustdoc, cranelift, gcc,
1051
+ // clippy, rustfmt, rust-analyzer, etc.
1048
1052
if source_type == SourceType :: InTree {
1049
- let mut lint_flags = Vec :: new ( ) ;
1050
1053
// When extending this list, add the new lints to the RUSTFLAGS of the
1051
1054
// build_bootstrap function of src/bootstrap/bootstrap.py as well as
1052
1055
// some code doesn't go through this `rustc` wrapper.
@@ -1058,27 +1061,31 @@ impl Builder<'_> {
1058
1061
rustdocflags. arg ( "-Dwarnings" ) ;
1059
1062
}
1060
1063
1061
- // This does not use RUSTFLAGS due to caching issues with Cargo.
1062
- // Clippy is treated as an "in tree" tool, but shares the same
1063
- // cache as other "submodule" tools. With these options set in
1064
- // RUSTFLAGS, that causes *every* shared dependency to be rebuilt.
1065
- // By injecting this into the rustc wrapper, this circumvents
1066
- // Cargo's fingerprint detection. This is fine because lint flags
1067
- // are always ignored in dependencies. Eventually this should be
1068
- // fixed via better support from Cargo.
1069
- cargo. env ( "RUSTC_LINT_FLAGS" , lint_flags. join ( " " ) ) ;
1070
-
1071
1064
rustdocflags. arg ( "-Wrustdoc::invalid_codeblock_attributes" ) ;
1072
1065
}
1073
1066
1067
+ // Lints just for `compiler/` crates.
1074
1068
if mode == Mode :: Rustc {
1075
- rustflags . arg ( "-Wrustc::internal" ) ;
1076
- rustflags . arg ( "-Drustc::symbol_intern_string_literal" ) ;
1069
+ lint_flags . push ( "-Wrustc::internal" ) ;
1070
+ lint_flags . push ( "-Drustc::symbol_intern_string_literal" ) ;
1077
1071
// FIXME(edition_2024): Change this to `-Wrust_2024_idioms` when all
1078
1072
// of the individual lints are satisfied.
1079
- rustflags. arg ( "-Wkeyword_idents_2024" ) ;
1080
- rustflags. arg ( "-Wunsafe_op_in_unsafe_fn" ) ;
1081
- }
1073
+ lint_flags. push ( "-Wkeyword_idents_2024" ) ;
1074
+ lint_flags. push ( "-Wunsafe_op_in_unsafe_fn" ) ;
1075
+ }
1076
+
1077
+ // This does not use RUSTFLAGS for two reasons.
1078
+ // - Due to caching issues with Cargo. Clippy is treated as an "in
1079
+ // tree" tool, but shares the same cache as other "submodule" tools.
1080
+ // With these options set in RUSTFLAGS, that causes *every* shared
1081
+ // dependency to be rebuilt. By injecting this into the rustc
1082
+ // wrapper, this circumvents Cargo's fingerprint detection. This is
1083
+ // fine because lint flags are always ignored in dependencies.
1084
+ // Eventually this should be fixed via better support from Cargo.
1085
+ // - RUSTFLAGS is ignored for proc macro crates that are being built on
1086
+ // the host (because `--target` is given). But we want the lint flags
1087
+ // to be applied to proc macro crates.
1088
+ cargo. env ( "RUSTC_LINT_FLAGS" , lint_flags. join ( " " ) ) ;
1082
1089
1083
1090
if self . config . rust_frame_pointers {
1084
1091
rustflags. arg ( "-Cforce-frame-pointers=true" ) ;
0 commit comments