Description
Code
Test against rust-lang/cargo@7e9de3f with the current nightly.
cargo test --test testsuite future_incompat_report::test_multi_crate
Expected warning from Cargo v.s Actual
- warning: the following packages contain code that will be rejected by a future version of Rust: first-dep v0.0.1, second-dep v0.0.2
+ warning: the following packages contain code that will be rejected by a future version of Rust: first-dep v0.0.1, foo v0.0.0 (/home/runner/work/cargo/cargo/target/tmp/cit/t1414/foo), second-dep v0.0.2
Note that the primary package foo
is included because nightly compiler starts reporting main()
as a dead code in conjunction with -Zfuture-incompat-test
, which it used to display dependencies only.
And yes in Cargo we use -Zfuture-incompat-test
to fire a future-incompat warning for tests. This doesn't work anymore. See https://github.com/rust-lang/cargo/actions/runs/5850845391/job/15860819020?pr=12489
Version it worked on
searched nightlies: from nightly-2023-08-01 to nightly-2023-08-14
regressed nightly: nightly-2023-08-13
searched commit range: a6f8aa5...28eb857
regressed commit: 1e836d1
regressed PR: #114710
bisected with cargo-bisect-rustc v0.6.6
Host triple: aarch64-apple-darwin
Reproduce with:
cargo bisect-rustc --start 2023-08-01 --end 2023-08-14 -- test --test testsuite test_multi_crate
The versions of Cargo in nightly-2023-08-12
and nightly-2023-08-13
are the same, but only 08-13 regressed. Hence, I excluded Cargo as a source of this regression. I'll continue investigating but any help is pretty much welcome!
Not a proposed solution
Taking out the insertion from the if block works, though I believe it is not the correct way to solve this.
diff --git a/compiler/rustc_passes/src/dead.rs b/compiler/rustc_passes/src/dead.rs
index 2936c8fac7d..33d3921f926 100644
--- a/compiler/rustc_passes/src/dead.rs
+++ b/compiler/rustc_passes/src/dead.rs
@@ -318,9 +318,7 @@ fn mark_live_symbols(&mut self) {
// this "duplication" is essential as otherwise a function with `#[expect]`
// called from a `pub fn` may be falsely reported as not live, falsely
// triggering the `unfulfilled_lint_expectations` lint.
- if comes_from_allow_expect != ComesFromAllowExpect::Yes {
- self.live_symbols.insert(id);
- }
+ self.live_symbols.insert(id);
self.visit_node(node);
}
}
Activity
weihanglo commentedon Aug 14, 2023
cc @Urgau, as it looks like you made the change. Sorry I don't really understand rustc internals. Can't help here.
weihanglo commentedon Aug 14, 2023
To reproduce:
Output:
It only happend with
cargo test
. More specifically,cargo b --bins
doesn't have that warnings, whereascargo b --tests
contains warnings from the root binary package. Might be something related torustc --test
flag?Urgau commentedon Aug 14, 2023
Thanks you for the ping and the reproducer. ❤️
Before #114710, the
dead_code
lint took advantage of the presence of#[allow(dead_code)]
s to not emit itself, my PR changed that, the lint is now emitted regardless of the presence of the attribute. This shouldn't change anything for the user as the lint would still not being displayed. But when using the--test
flag forrustc
it creates a secondmain
shadowing the previous one and marking as#[allow(dead_code)]
:but
-Zfuture-incompat-test
:so
dead_code
now appears in the future incompatible report, as it probably should always have been.For the purpose of
cargo
changing the test to not be depend on the internal details ofrustc --test
would be good.@rustbot label +requires-nightly -needs-triage
test: bypass `rustc --test` impl details for `-Zfuture-incompat-test`
rustc --test
impl details for-Zfuture-incompat-test
rust-lang/cargo#12491Auto merge of #12491 - weihanglo:fix-future-incompat, r=ehuss
test: bypass `rustc --test` impl details for `-Zfuture-incompat-test`