about summary refs log tree commit diff
path: root/compiler
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2025-04-15 16:05:15 +0000
committerbors <bors@rust-lang.org>2025-04-15 16:05:15 +0000
commit414da5b63d699c1c648088114ad2796deb0ce737 (patch)
tree3cda9f54dbef0650210b6c0ea08e15544bba2bc7 /compiler
parent40dacd50b7074783db748d73925ac5c3693a7ec1 (diff)
parent59e5920e298d7690d455b13adf31b11485b25dcd (diff)
downloadrust-414da5b63d699c1c648088114ad2796deb0ce737.tar.gz
rust-414da5b63d699c1c648088114ad2796deb0ce737.zip
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
Diffstat (limited to 'compiler')
-rw-r--r--compiler/rustc_session/src/output.rs7
1 files changed, 7 insertions, 0 deletions
diff --git a/compiler/rustc_session/src/output.rs b/compiler/rustc_session/src/output.rs
index a24919e434c..46dae9144cd 100644
--- a/compiler/rustc_session/src/output.rs
+++ b/compiler/rustc_session/src/output.rs
@@ -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];
     }