File tree Expand file tree Collapse file tree 1 file changed +14
-3
lines changed Expand file tree Collapse file tree 1 file changed +14
-3
lines changed Original file line number Diff line number Diff line change @@ -233,9 +233,20 @@ impl rustc_driver::Callbacks for MiriBeRustCompilerCalls {
233233 #[ allow( rustc:: potential_query_instability) ] // rustc_codegen_ssa (where this code is copied from) also allows this lint
234234 fn config ( & mut self , config : & mut Config ) {
235235 if config. opts . prints . is_empty ( ) && self . target_crate {
236- // Avoid warnings about unsupported crate types
237- #[ allow( rustc:: bad_opt_access) ]
238- config. opts . crate_types . retain ( |& c| c == CrateType :: Executable || c == CrateType :: Rlib ) ;
236+ #[ allow( rustc:: bad_opt_access) ] // tcx does not exist yet
237+ {
238+ let any_crate_types = !config. opts . crate_types . is_empty ( ) ;
239+ // Avoid warnings about unsupported crate types.
240+ config
241+ . opts
242+ . crate_types
243+ . retain ( |& c| c == CrateType :: Executable || c == CrateType :: Rlib ) ;
244+ if any_crate_types {
245+ // Assert that we didn't remove all crate types if any crate type was passed on
246+ // the cli. Otherwise we might silently change what kind of crate we are building.
247+ assert ! ( !config. opts. crate_types. is_empty( ) ) ;
248+ }
249+ }
239250
240251 // Queries overridden here affect the data stored in `rmeta` files of dependencies,
241252 // which will be used later in non-`MIRI_BE_RUSTC` mode.
You can’t perform that action at this time.
0 commit comments