diff --git a/src/cargo/core/compiler/mod.rs b/src/cargo/core/compiler/mod.rs index 5dc34616d91..93859e914b9 100644 --- a/src/cargo/core/compiler/mod.rs +++ b/src/cargo/core/compiler/mod.rs @@ -696,10 +696,8 @@ fn prepare_rustc(build_runner: &BuildRunner<'_, '_>, unit: &Unit) -> CargoResult base.inherit_jobserver(&build_runner.jobserver); build_deps_args(&mut base, build_runner, unit)?; add_cap_lints(build_runner.bcx, unit, &mut base); - if cargo_rustc_higher_args_precedence(build_runner) { - if let Some(args) = build_runner.bcx.extra_args_for(unit) { - base.args(args); - } + if let Some(args) = build_runner.bcx.extra_args_for(unit) { + base.args(args); } base.args(&unit.rustflags); if build_runner.bcx.gctx.cli_unstable().binary_dep_depinfo { @@ -754,12 +752,6 @@ fn prepare_rustdoc(build_runner: &BuildRunner<'_, '_>, unit: &Unit) -> CargoResu rustdoc.args(unit.pkg.manifest().lint_rustflags()); - if !cargo_rustc_higher_args_precedence(build_runner) { - if let Some(args) = build_runner.bcx.extra_args_for(unit) { - rustdoc.args(args); - } - } - let metadata = build_runner.metadata_for_doc_units[unit]; rustdoc .arg("-C") @@ -800,10 +792,8 @@ fn prepare_rustdoc(build_runner: &BuildRunner<'_, '_>, unit: &Unit) -> CargoResu rustdoc::add_output_format(build_runner, unit, &mut rustdoc)?; - if cargo_rustc_higher_args_precedence(build_runner) { - if let Some(args) = build_runner.bcx.extra_args_for(unit) { - rustdoc.args(args); - } + if let Some(args) = build_runner.bcx.extra_args_for(unit) { + rustdoc.args(args); } rustdoc.args(&unit.rustdocflags); @@ -1107,11 +1097,6 @@ fn build_base_args( cmd.args(unit.pkg.manifest().lint_rustflags()); cmd.args(&profile_rustflags); - if !cargo_rustc_higher_args_precedence(build_runner) { - if let Some(args) = build_runner.bcx.extra_args_for(unit) { - cmd.args(args); - } - } // `-C overflow-checks` is implied by the setting of `-C debug-assertions`, // so we only need to provide `-C overflow-checks` if it differs from @@ -2007,19 +1992,3 @@ fn scrape_output_path(build_runner: &BuildRunner<'_, '_>, unit: &Unit) -> CargoR .outputs(unit) .map(|outputs| outputs[0].path.clone()) } - -/// Provides a way to change the precedence of `cargo rustc -- `. -/// -/// This is intended to be a short-live function. -/// -/// See -fn cargo_rustc_higher_args_precedence(build_runner: &BuildRunner<'_, '_>) -> bool { - build_runner.bcx.gctx.nightly_features_allowed - && build_runner - .bcx - .gctx - .get_env("__CARGO_RUSTC_ORIG_ARGS_PRIO") - .ok() - .as_deref() - != Some("1") -} diff --git a/tests/testsuite/rustc.rs b/tests/testsuite/rustc.rs index 2041c006706..34d00b7833f 100644 --- a/tests/testsuite/rustc.rs +++ b/tests/testsuite/rustc.rs @@ -28,7 +28,7 @@ fn lib() { p.cargo("rustc --lib -v -- -C debug-assertions=off") .with_stderr_data(str![[r#" [COMPILING] foo v0.0.1 ([ROOT]/foo) -[RUNNING] `rustc --crate-name foo --edition=2015 src/lib.rs [..]--crate-type lib --emit=[..]link[..]-C debuginfo=2 [..]-C debug-assertions=off[..]-C metadata=[..] [..]--out-dir [ROOT]/foo/target/debug/deps -L dependency=[ROOT]/foo/target/debug/deps` +[RUNNING] `rustc --crate-name foo --edition=2015 src/lib.rs [..]--crate-type lib --emit=[..]link[..]-C debuginfo=2 [..]-C metadata=[..] [..]--out-dir [ROOT]/foo/target/debug/deps -L dependency=[ROOT]/foo/target/debug/deps[..]-C debug-assertions=off[..]` [FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s "#]]) @@ -46,7 +46,7 @@ fn build_main_and_allow_unstable_options() { .with_stderr_data(str![[r#" [COMPILING] foo v0.0.1 ([ROOT]/foo) [RUNNING] `rustc --crate-name foo --edition=2015 src/lib.rs [..]--crate-type lib --emit=[..]link[..]-C debuginfo=2 [..]-C metadata=[..] --out-dir [ROOT]/foo/target/debug/deps -L dependency=[ROOT]/foo/target/debug/deps` -[RUNNING] `rustc --crate-name foo --edition=2015 src/main.rs [..]--crate-type bin --emit=[..]link[..]-C debuginfo=2 [..]-C debug-assertions[..]-C metadata=[..] --out-dir [ROOT]/foo/target/debug/deps -L dependency=[ROOT]/foo/target/debug/deps --extern foo=[ROOT]/foo/target/debug/deps/libfoo-[HASH].rlib` +[RUNNING] `rustc --crate-name foo --edition=2015 src/main.rs [..]--crate-type bin --emit=[..]link[..]-C debuginfo=2 [..]-C metadata=[..] --out-dir [ROOT]/foo/target/debug/deps -L dependency=[ROOT]/foo/target/debug/deps --extern foo=[ROOT]/foo/target/debug/deps/libfoo-[HASH].rlib[..]-C debug-assertions[..]` [FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s "#]]) @@ -83,7 +83,7 @@ fn build_with_args_to_one_of_multiple_binaries() { .with_stderr_data(str![[r#" [COMPILING] foo v0.0.1 ([ROOT]/foo) [RUNNING] `rustc --crate-name foo --edition=2015 src/lib.rs [..]--crate-type lib --emit=[..]link[..]-C debuginfo=2 [..]-C metadata=[..] --out-dir [..]` -[RUNNING] `rustc --crate-name bar --edition=2015 src/bin/bar.rs [..]--crate-type bin --emit=[..]link[..]-C debuginfo=2 [..]-C debug-assertions [..]` +[RUNNING] `rustc --crate-name bar --edition=2015 src/bin/bar.rs [..]--crate-type bin --emit=[..]link[..]-C debuginfo=2 [..]-C debug-assertions[..]` [FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s "#]]) @@ -358,7 +358,7 @@ fn build_with_args_to_one_of_multiple_tests() { .with_stderr_data(str![[r#" [COMPILING] foo v0.0.1 ([ROOT]/foo) [RUNNING] `rustc --crate-name foo --edition=2015 src/lib.rs [..]--crate-type lib --emit=[..]link[..]-C debuginfo=2 [..]-C metadata=[..] --out-dir [..]` -[RUNNING] `rustc --crate-name bar --edition=2015 tests/bar.rs [..]--emit=[..]link[..]-C debuginfo=2 [..]-C debug-assertions --test[..]` +[RUNNING] `rustc --crate-name bar --edition=2015 tests/bar.rs [..]--emit=[..]link[..]-C debuginfo=2 [..]--test[..]-C debug-assertions[..]` [FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s "#]]) @@ -395,7 +395,7 @@ fn build_foo_with_bar_dependency() { [COMPILING] bar v0.1.0 ([ROOT]/bar) [RUNNING] `rustc --crate-name bar [..] -C debuginfo=2[..]` [COMPILING] foo v0.0.1 ([ROOT]/foo) -[RUNNING] `rustc --crate-name foo [..] -C debuginfo=2 [..]-C debug-assertions [..]` +[RUNNING] `rustc --crate-name foo [..] -C debuginfo=2 [..]-C debug-assertions[..]` [FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s "#]]) @@ -430,7 +430,7 @@ fn build_only_bar_dependency() { .with_stderr_data(str![[r#" [LOCKING] 1 package to latest compatible version [COMPILING] bar v0.1.0 ([ROOT]/bar) -[RUNNING] `rustc --crate-name bar [..]--crate-type lib [..] -C debug-assertions [..]` +[RUNNING] `rustc --crate-name bar [..]--crate-type lib [..] -C debug-assertions[..]` [FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s "#]]) @@ -599,7 +599,7 @@ fn rustc_fingerprint() { p.cargo("rustc -v -- -C debug-assertions") .with_stderr_data(str![[r#" [COMPILING] foo v0.5.0 ([ROOT]/foo) -[RUNNING] `rustc --crate-name foo [..]-C debug-assertions [..]` +[RUNNING] `rustc --crate-name foo [..]-C debug-assertions[..]` [FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s "#]]) @@ -657,7 +657,7 @@ fn rustc_test_with_implicit_bin() { .with_stderr_data( str![[r#" [COMPILING] foo v0.5.0 ([ROOT]/foo) -[RUNNING] `rustc --crate-name test1 --edition=2015 tests/test1.rs [..] --cfg foo [..]` +[RUNNING] `rustc --crate-name test1 --edition=2015 tests/test1.rs [..] --cfg foo[..]` [RUNNING] `rustc --crate-name foo --edition=2015 src/main.rs [..]` ... [FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s @@ -816,7 +816,6 @@ fn precedence() { p.cargo("rustc --release -v -- --cfg cargo_rustc -C strip=symbols") .env("RUSTFLAGS", "--cfg from_rustflags") - .masquerade_as_nightly_cargo(&["cargo-rustc-precedence"]) .with_stderr_data(str![[r#" [COMPILING] foo v0.0.0 ([ROOT]/foo) [RUNNING] `rustc [..]-C strip=debuginfo [..]--cfg cargo_rustc -C strip=symbols --cfg from_rustflags` @@ -824,34 +823,4 @@ fn precedence() { "#]]) .run(); - - // Ensure the short-live env var to work - p.cargo("clean").run(); - p.cargo("rustc --release -v -- --cfg cargo_rustc -C strip=symbols") - .env("RUSTFLAGS", "--cfg from_rustflags") - .env("__CARGO_RUSTC_ORIG_ARGS_PRIO", "1") - .masquerade_as_nightly_cargo(&["cargo-rustc-precedence"]) - .with_stderr_data( - str![[r#" -[COMPILING] foo v0.0.0 ([ROOT]/foo) -[RUNNING] `rustc [..]--cfg cargo_rustc -C strip=symbols [..]-C strip=debuginfo [..]--cfg from_rustflags` -[FINISHED] `release` profile [optimized] target(s) in [ELAPSED]s - -"#]] - ) - .run(); - - // Ensure non-nightly to work as before - p.cargo("clean").run(); - p.cargo("rustc --release -v -- --cfg cargo_rustc -C strip=symbols") - .env("RUSTFLAGS", "--cfg from_rustflags") - .with_stderr_data( - str![[r#" -[COMPILING] foo v0.0.0 ([ROOT]/foo) -[RUNNING] `rustc [..]--cfg cargo_rustc -C strip=symbols [..]-C strip=debuginfo [..]--cfg from_rustflags` -[FINISHED] `release` profile [optimized] target(s) in [ELAPSED]s - -"#]] - ) - .run(); } diff --git a/tests/testsuite/rustdoc.rs b/tests/testsuite/rustdoc.rs index 3a7977cb8cc..a502dd27222 100644 --- a/tests/testsuite/rustdoc.rs +++ b/tests/testsuite/rustdoc.rs @@ -106,7 +106,7 @@ fn rustdoc_args() { p.cargo("rustdoc -v -- --cfg=foo") .with_stderr_data(str![[r#" [DOCUMENTING] foo v0.0.1 ([ROOT]/foo) -[RUNNING] `rustdoc [..] --crate-name foo src/lib.rs -o [ROOT]/foo/target/doc [..] --cfg=foo -C metadata=[..] -L dependency=[ROOT]/foo/target/debug/deps [..]` +[RUNNING] `rustdoc [..] --crate-name foo src/lib.rs -o [ROOT]/foo/target/doc [..]-C metadata=[..] -L dependency=[ROOT]/foo/target/debug/deps [..]--cfg=foo[..]` [FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s [GENERATED] [ROOT]/foo/target/doc/foo/index.html @@ -159,7 +159,7 @@ fn rustdoc_foo_with_bar_dependency() { [CHECKING] bar v0.0.1 ([ROOT]/bar) [RUNNING] `rustc [..] [ROOT]/bar/src/lib.rs [..]` [DOCUMENTING] foo v0.0.1 ([ROOT]/foo) -[RUNNING] `rustdoc [..] --crate-name foo src/lib.rs -o [ROOT]/foo/target/doc [..] --cfg=foo -C metadata=[..] -L dependency=[ROOT]/foo/target/debug/deps --extern [..]` +[RUNNING] `rustdoc [..] --crate-name foo src/lib.rs -o [ROOT]/foo/target/doc [..]-C metadata=[..] -L dependency=[ROOT]/foo/target/debug/deps --extern [..]--cfg=foo[..]` [FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s [GENERATED] [ROOT]/foo/target/doc/foo/index.html @@ -195,7 +195,7 @@ fn rustdoc_only_bar_dependency() { .with_stderr_data(str![[r#" [LOCKING] 1 package to latest compatible version [DOCUMENTING] bar v0.0.1 ([ROOT]/bar) -[RUNNING] `rustdoc [..] --crate-name bar [ROOT]/bar/src/lib.rs -o [ROOT]/foo/target/doc [..] --cfg=foo -C metadata=[..] -L dependency=[ROOT]/foo/target/debug/deps [..]` +[RUNNING] `rustdoc [..] --crate-name bar [ROOT]/bar/src/lib.rs -o [ROOT]/foo/target/doc [..]-C metadata=[..] -L dependency=[ROOT]/foo/target/debug/deps [..]--cfg=foo[..]` [FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s [GENERATED] [ROOT]/foo/target/doc/bar/index.html @@ -213,7 +213,7 @@ fn rustdoc_same_name_documents_lib() { p.cargo("rustdoc -v -- --cfg=foo") .with_stderr_data(str![[r#" [DOCUMENTING] foo v0.0.1 ([ROOT]/foo) -[RUNNING] `rustdoc [..] --crate-name foo src/lib.rs -o [ROOT]/foo/target/doc [..] --cfg=foo -C metadata=[..] -L dependency=[ROOT]/foo/target/debug/deps [..]` +[RUNNING] `rustdoc [..] --crate-name foo src/lib.rs -o [ROOT]/foo/target/doc [..]-C metadata=[..] -L dependency=[ROOT]/foo/target/debug/deps [..]--cfg=foo[..]` [FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s [GENERATED] [ROOT]/foo/target/doc/foo/index.html