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 for mismatched &Trait vs. &mut Trait" could be improved #13033

Closed
bachm opened this issue Mar 20, 2014 · 2 comments · Fixed by #16568
Closed

error message for mismatched &Trait vs. &mut Trait" could be improved #13033

bachm opened this issue Mar 20, 2014 · 2 comments · Fixed by #16568
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

@bachm
Copy link

bachm commented Mar 20, 2014

The error message doesn't say that the problem is mismatching mutability.

trait Foo {
    fn bar(&mut self, other: &mut Foo);
}

struct Baz;

impl Foo for Baz {
    fn bar(&mut self, other: &Foo) {}
}
test.rs:8:5: 8:38 error: method `bar` has an incompatible type: expected trait Foo but found trait Foo
test.rs:8     fn bar(&mut self, other: &Foo) {}
@jfager
Copy link
Contributor

jfager commented Jul 26, 2014

Looks like this can be closed, this is now:

$ rustc r13033.rs 
r13033.rs:8:5: 8:38 error: method `bar` has an incompatible type for trait: values differ in mutability [E0053]
r13033.rs:8     fn bar(&mut self, other: &Foo) {}
                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
error: aborting due to previous error

Edit: though now the complaint might be that it doesn't single out 'other'

@alexcrichton
Copy link
Member

Flagging as needstest (just in case a test doesn't already exist)

bors added a commit that referenced this issue Aug 18, 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.

5 participants