Skip to content

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

@spastorino

Description

@spastorino

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsD-incorrectDiagnostics: A diagnostic that is giving misleading or incorrect information.F-negative_impls#![feature(negative_impls)]F-rustc_attrsInternal rustc attributes gated on the `#[rustc_attrs]` feature gate.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions