diff --git a/src/cargo/core/compiler/build_context/target_info.rs b/src/cargo/core/compiler/build_context/target_info.rs index 1844073ae45..6a0bea3f79e 100644 --- a/src/cargo/core/compiler/build_context/target_info.rs +++ b/src/cargo/core/compiler/build_context/target_info.rs @@ -206,6 +206,10 @@ impl TargetInfo { process.arg("--print=crate-name"); // `___` as a delimiter. process.arg("--print=cfg"); + // parse_crate_type() relies on "unsupported/unknown crate type" error message, + // so make warnings always emitted as warnings. + process.arg("-Wwarnings"); + let (output, error) = rustc .cached_output(&process, extra_fingerprint) .with_context(|| { diff --git a/tests/testsuite/cross_compile.rs b/tests/testsuite/cross_compile.rs index 6dbf4919df9..f80fa302b69 100644 --- a/tests/testsuite/cross_compile.rs +++ b/tests/testsuite/cross_compile.rs @@ -1283,11 +1283,11 @@ fn always_emit_warnings_as_warnings_when_learning_target_info() { p.cargo("build -v --target") .env("RUSTFLAGS", "-Awarnings") .arg(&target) - .with_status(101) .with_stderr_data(str![[r#" -[ERROR] output of --print=file-names missing when learning about target-specific information from rustc -command was: `rustc - --crate-name ___ --print=file-names -Awarnings --target wasm32-unknown-unknown --crate-type bin --crate-type rlib --crate-type dylib --crate-type cdylib --crate-type staticlib --crate-type proc-macro --print=sysroot --print=split-debuginfo --print=crate-name --print=cfg` -... +[COMPILING] foo v0.0.0 ([ROOT]/foo) +[RUNNING] `rustc --crate-name foo [..]-Awarnings[..]` +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s + "#]]) .run(); }