@@ -1130,22 +1130,32 @@ impl<'a> Builder<'a> {
1130
1130
cargo. env ( "RUSTC_VERBOSE" , self . verbosity . to_string ( ) ) ;
1131
1131
1132
1132
if source_type == SourceType :: InTree {
1133
+ let mut lint_flags = Vec :: new ( ) ;
1133
1134
// When extending this list, add the new lints to the RUSTFLAGS of the
1134
1135
// build_bootstrap function of src/bootstrap/bootstrap.py as well as
1135
1136
// some code doesn't go through this `rustc` wrapper.
1136
- rustflags . arg ( "-Wrust_2018_idioms" ) ;
1137
- rustflags . arg ( "-Wunused_lifetimes" ) ;
1137
+ lint_flags . push ( "-Wrust_2018_idioms" ) ;
1138
+ lint_flags . push ( "-Wunused_lifetimes" ) ;
1138
1139
1139
1140
if self . config . deny_warnings {
1140
- rustflags . arg ( "-Dwarnings" ) ;
1141
+ lint_flags . push ( "-Dwarnings" ) ;
1141
1142
}
1142
1143
1143
1144
// FIXME(#58633) hide "unused attribute" errors in incremental
1144
1145
// builds of the standard library, as the underlying checks are
1145
1146
// not yet properly integrated with incremental recompilation.
1146
1147
if mode == Mode :: Std && compiler. stage == 0 && self . config . incremental {
1147
- rustflags . arg ( "-Aunused-attributes" ) ;
1148
+ lint_flags . push ( "-Aunused-attributes" ) ;
1148
1149
}
1150
+ // This does not use RUSTFLAGS due to caching issues with Cargo.
1151
+ // Clippy is treated as an "in tree" tool, but shares the same
1152
+ // cache as other "submodule" tools. With these options set in
1153
+ // RUSTFLAGS, that causes *every* shared dependency to be rebuilt.
1154
+ // By injecting this into the rustc wrapper, this circumvents
1155
+ // Cargo's fingerprint detection. This is fine because lint flags
1156
+ // are always ignored in dependencies. Eventually this should be
1157
+ // fixed via better support from Cargo.
1158
+ cargo. env ( "RUSTC_LINT_FLAGS" , lint_flags. join ( " " ) ) ;
1149
1159
}
1150
1160
1151
1161
if let Mode :: Rustc | Mode :: Codegen = mode {
0 commit comments