-
Notifications
You must be signed in to change notification settings - Fork 12.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Noisy conflicting implementations error for a trait which has a const generic parameter that panics in multiple implementations #103369
Comments
I meant to use the Diagnostic issue template but I guess I clicked on the wrong one... |
No worries. |
Update: I found some additional variants to this issue. If the first const evaluation is successful it still reports a conflicting implementation error but reports the first successful value in the error (playground): pub trait ConstGenericTrait<const N: u32> {}
impl ConstGenericTrait<{my_fn(3)}> for () {}
impl ConstGenericTrait<{my_fn(1)}> for () {}
impl ConstGenericTrait<{my_fn(2)}> for () {}
const fn my_fn(v: u32) -> u32 {
if v == 2 {
panic!("Some error occurred")
} else {
v
}
}
And if the first evaluation fails (but the others would be successful) it sees all implemenations as conflicting and shows the original pub trait ConstGenericTrait<const N: u32> {}
impl ConstGenericTrait<{my_fn(2)}> for () {}
impl ConstGenericTrait<{my_fn(3)}> for () {}
impl ConstGenericTrait<{my_fn(1)}> for () {}
const fn my_fn(v: u32) -> u32 {
if v == 2 {
panic!("Some error occurred")
} else {
v
}
}
Compiler version |
Rollup of 10 pull requests Successful merges: - rust-lang#120716 (Change leak check and suspicious auto trait lint warning messages) - rust-lang#121195 (unstable-book: Separate testing and production sanitizers) - rust-lang#121205 (Merge `CompilerError::CompilationFailed` and `CompilerError::ICE`.) - rust-lang#121233 (Move the extra directives for `Mode::CoverageRun` into `iter_header`) - rust-lang#121256 (Allow AST and HIR visitors to return `ControlFlow`) - rust-lang#121307 (Drive-by `DUMMY_SP` -> `Span` and fmt changes) - rust-lang#121308 (Add regression test for rust-lang#103369) - rust-lang#121310 (Remove an old hack for rustdoc) - rust-lang#121311 (Make `is_nonoverlapping` `#[inline]`) - rust-lang#121319 (return `ty::Error` when equating `ty::Error`) r? `@ghost` `@rustbot` modify labels: rollup
Rollup merge of rust-lang#121308 - kadiwa4:test_103369, r=TaKO8Ki Add regression test for rust-lang#103369 The issue was fixed in 1.70.0. Closes rust-lang#103369.
I tried this code:
I expected to see this happen:
Only errors due to the const panic being displayed
Instead, this happened:
In addition to the expected errors there is a conflicting implementation error showing the const generic as `[const error]`
This introduces excessive noise in the error output when there are many implementations like this.
https://play.rust-lang.org/?version=nightly&mode=debug&edition=2021&gist=5d63f992f258ee299a5d13cfa4b0d4a1
Meta
Present on all toolchains on the playground (at the time of posting):
Locally I'm using an older nightly toolchain:
rustc --version --verbose
:The text was updated successfully, but these errors were encountered: