-
Notifications
You must be signed in to change notification settings - Fork 13k
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 E0053 (values differ in mutability) has a too general span #18760
Comments
This appears to still be a problem. The use std::ops::Deref;
struct Foo(u8);
impl Deref for Foo {
type Target = u8;
fn deref<'a>(&'a mut self) -> &'a u8 {
&self.0
}
}
fn main() {} The result:
|
simplified version: trait A {
fn b(c: i32);
}
impl A for () {
fn b(c: ()) { }
} This occurs because the check re-uses the type inference/relation code for creating the error message, but the type inference/relation code does not use sub-spans for checking inner types and thus doesn't/can't attach spans to the error object. |
error[E0053]: method `b` has an incompatible type for trait
--> <anon>:6:13
|
2 | fn b(c: i32);
| --- type in trait
...
6 | fn b(c: ()) { }
| ^^ expected i32, found ()
|
= note: expected type `fn(i32)`
found type `fn(())` |
Closing as fixed, tests already exist -- ui/mismatched_types/trait-impl-fn-incompatibility.rs. trait A {
fn b(c: &i32);
}
impl A for () {
fn b(c: &mut i32) { }
}
|
internal: Workaround salsa cycles leaking
An example: http://is.gd/GuGCDC
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.
The text was updated successfully, but these errors were encountered: