Auto merge of #138906 - thaliaarchi:unsupported-test-exe, r=bjorn3

Reject test executables when not supported by target

Currently, compiling tests for SOLID produces an ICE, because SOLID does not support executables.

See https://github.com/rust-lang/rust/issues/138047
This commit is contained in:
bors 2025-04-15 16:05:15 +00:00
commit 414da5b63d

View file

@ -177,6 +177,13 @@ pub fn collect_crate_types(session: &Session, attrs: &[ast::Attribute]) -> Vec<C
// If we're generating a test executable, then ignore all other output
// styles at all other locations
if session.opts.test {
if !session.target.executables {
session.dcx().emit_warn(errors::UnsupportedCrateTypeForTarget {
crate_type: CrateType::Executable,
target_triple: &session.opts.target_triple,
});
return Vec::new();
}
return vec![CrateType::Executable];
}