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

Confusing error message when accessing non-existing field #14721

Closed
nwin opened this issue Jun 7, 2014 · 0 comments · Fixed by #18324
Closed

Confusing error message when accessing non-existing field #14721

nwin opened this issue Jun 7, 2014 · 0 comments · Fixed by #18324
Labels
A-diagnostics Area: Messages for errors, warnings, and lints E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added.

Comments

@nwin
Copy link
Contributor

nwin commented Jun 7, 2014

The snippet

fn main() {
    let foo = "str";
    println!("{}", foo.desc);
}

produces the two error messages

error: attempted access of field `desc` on type `&'static str`, but no field with that name was found
bug.rs:3     println!("{}", foo.desc);
                            ^~~~~~~~
error: cannot determine a type for this bounded type parameter: unconstrained type
bug.rs:3     println!("{}", foo.desc);
                            ^~~~~~~~

that are possibly separated by some notes from the compiler such that the first one is not directly visible.

The problem is, that the second message is absolutely not helpful and leads to confusion if the first one is overlooked. I get why the second message is issued but I don't think that it's relevant since the first error is the sole cause for the second error.

@ghost ghost added the E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. label Oct 25, 2014
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 E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants