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

Suggest fix when encountering different mutability from impl to trait #52412

Closed
estebank opened this issue Jul 16, 2018 · 0 comments
Closed

Suggest fix when encountering different mutability from impl to trait #52412

estebank opened this issue Jul 16, 2018 · 0 comments
Assignees
Labels
A-diagnostics Area: Messages for errors, warnings, and lints

Comments

@estebank
Copy link
Contributor

estebank commented Jul 16, 2018

Given

trait Foo {
    fn bar(&mut self, other: &mut Foo);
}
struct Baz;
impl Foo for Baz {
    fn bar(&mut self, other: &Foo) {}
}

the current output is


error[E0053]: method `bar` has an incompatible type for trait
  --> $DIR/issue-13033.rs:18:30
   |
LL |     fn bar(&mut self, other: &mut Foo);
   |                              -------- type in trait
...
LL |     fn bar(&mut self, other: &Foo) {}
   |                              ^^^^ types differ in mutability
   |
   = note: expected type `fn(&mut Baz, &mut dyn Foo)`
              found type `fn(&mut Baz, &dyn Foo)`

It should suggest to change the impl method signature to match the trait.

@estebank estebank added the A-diagnostics Area: Messages for errors, warnings, and lints label Jul 16, 2018
@csmoe csmoe self-assigned this Jul 25, 2018
Mark-Simulacrum added a commit to Mark-Simulacrum/rust that referenced this issue Jul 27, 2018
Suggest fix when encountering different mutability from impl to trait

Closes rust-lang#52412
r? @estebank
kennytm added a commit to kennytm/rust that referenced this issue Jul 28, 2018
Suggest fix when encountering different mutability from impl to trait

Closes rust-lang#52412
r? @estebank
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
Projects
None yet
Development

No branches or pull requests

2 participants