Skip to content

Error E0053 (values differ in mutability) has a too general span #18760

@mcpherrinm

Description

@mcpherrinm

An example: http://is.gd/GuGCDC

:4:5: 7:4 error: method `add` has an incompatible type for trait: values differ in mutability [E0053]
:4     fn add(&self, _rhs: &mut Foo) -> Foo {
:5       println!("Adding!");
:6       *self
:7   }

A better error might have a span showing just the mut (or the parameter) and a suggested correct signature. Right now I have to go look the trait up, either in the code or the docs.

 fn add(&self, _rhs: &mut Foo) -> Foo {
                      ^~~
 Note: The correct signature would be
 fn add(&self, _rhs: &Foo) -> Foo {

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions