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

error message claims struct does not have field that it clearly does have #14541

Closed
pnkfelix opened this issue May 30, 2014 · 0 comments · Fixed by #14562
Closed

error message claims struct does not have field that it clearly does have #14541

pnkfelix opened this issue May 30, 2014 · 0 comments · Fixed by #14562

Comments

@pnkfelix
Copy link
Member

This is one of those bugs where an earlier error is leading to poor error reporting later on in the output. So it should not be considered high priority.

Nonetheless, it would be nice if we could strive for error messages to be sane when considered in isolation, which this example violates:

bug.rs

#![crate_type="lib"]

pub struct vec2 { y: f32, }
pub struct vec3 { y: f32, z: f32, }

pub trait Foo { fn make(self); }

impl Foo for vec2 {
    fn make(self) {
        let vec3{y:_,z:_} = self;
    }
}

Transcript:

% rustc /tmp/bug.rs
/tmp/bug.rs:10:13: 10:26 error: mismatched types: expected `vec2` but found `vec3`
/tmp/bug.rs:10         let vec3{y:_,z:_} = self;
                           ^~~~~~~~~~~~~
/tmp/bug.rs:10:13: 10:26 error: struct `vec3` does not have a field named `z`
/tmp/bug.rs:10         let vec3{y:_,z:_} = self;
                           ^~~~~~~~~~~~~
error: aborting due to 2 previous errors

The issue is that the second message claims that vec3 does not have a field named z, but it clearly does. I could understand this message if it said vec2 does not have a field named z.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant