Skip to content
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

Misleading error message when there is a generic trait impl for all types implementing other trait #32704

Closed
VFLashM opened this issue Apr 3, 2016 · 1 comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-trait-system Area: Trait system T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@VFLashM
Copy link
Contributor

VFLashM commented Apr 3, 2016

See example.
Error message mentions trait 'Base', even thought only 'Marker' trait is required.

trait Base {}
trait Marker {}
impl<T: Base> Marker for T {}
impl Marker for i32 {}

fn requires_marker<T: Marker>(value: &T) {}

fn main() {
    let i: i32 = 0;
    let u: u32 = 0;
    requires_marker(&i); // fine, i32 is unrelated to Base
    requires_marker(&u); // error: the trait `Base` is not implemented for the type `u32`
}
@Aatch Aatch added A-diagnostics Area: Messages for errors, warnings, and lints A-trait-system Area: Trait system labels Apr 3, 2016
@steveklabnik steveklabnik added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Mar 9, 2017
@Mark-Simulacrum
Copy link
Member

I believe this is a duplicate of #28894; the compiler tries to see through the Marker bound and goes too far instead of stating that Marker isn't implemented.

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 A-trait-system Area: Trait system 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

4 participants