Skip to content

Fix negative traits coherence checks compile error message for type aliases #90259

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

Open
spastorino opened this issue Oct 25, 2021 · 1 comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints D-incorrect Diagnostics: A diagnostic that is giving misleading or incorrect information. F-negative_impls #![feature(negative_impls)] F-rustc_attrs Internal rustc attributes gated on the `#[rustc_attrs]` feature gate. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@spastorino
Copy link
Member

Follow up of this comment on #90104

This test https://github.com/rust-lang/rust/pull/90104/files#diff-2c291b05493bf924a05c167ef3923655ca244b6fd8bc2303ffdc2ed2132498cc is giving an ungreat error message.

#![feature(rustc_attrs)]
#![feature(trait_alias)]

trait A {}
trait B {}
trait AB = A + B;

impl A for u32 {}
impl B for u32 {}

trait C {}
#[rustc_strict_coherence]
impl<T: AB> C for T {}
#[rustc_strict_coherence]
impl C for u32 {}
//~^ ERROR
// FIXME it's giving an ungreat error but unsure if we care given that it's using an internal rustc
// attribute and an artificial code path for testing purposes

fn main() {}

fails with ...

error[E0283]: type annotations needed
  --> $DIR/coherence-overlap-trait-alias.rs:15:6
   |
LL | impl C for u32 {}
   |      ^ cannot infer type for type `u32`
   |
   = note: cannot satisfy `u32: C`
note: required by a bound in `C`
  --> $DIR/coherence-overlap-trait-alias.rs:11:1
   |
LL | trait C {}
   | ^^^^^^^ required by this bound in `C`

error: aborting due to previous error

Error should mention about conflicting implementations for u32 or something like that. More similar to what happens without using the rustc_strict_coherence attribute.

@spastorino spastorino added F-negative_impls #![feature(negative_impls)] T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Oct 25, 2021
@spastorino
Copy link
Member Author

spastorino commented Oct 25, 2021

As an effect of @estebank's PR #89427 this error is now a bit better but it's still not there compared with the no strict version.
Anyway, not a extremely important thing given that this can only be raised by using rustc_strict_coherence which is an internal rustc attribute.

@estebank estebank added A-diagnostics Area: Messages for errors, warnings, and lints D-incorrect Diagnostics: A diagnostic that is giving misleading or incorrect information. labels Oct 25, 2021
@workingjubilee workingjubilee added the F-rustc_attrs Internal rustc attributes gated on the `#[rustc_attrs]` feature gate. label Mar 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints D-incorrect Diagnostics: A diagnostic that is giving misleading or incorrect information. F-negative_impls #![feature(negative_impls)] F-rustc_attrs Internal rustc attributes gated on the `#[rustc_attrs]` feature gate. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

3 participants