mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-01 06:51:58 +00:00
Fix suggestion when there are arguments in the method
This commit is contained in:
parent
85ff8889e4
commit
8bde5bbc07
@ -392,7 +392,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||
),
|
||||
match &args[..] {
|
||||
[] => (base.span.shrink_to_hi().with_hi(deref.span.hi()), ")".to_string()),
|
||||
[first, ..] => (base.span.until(first.span), String::new()),
|
||||
[first, ..] => (base.span.between(first.span), ", ".to_string()),
|
||||
},
|
||||
]
|
||||
})
|
||||
|
23
src/test/ui/suggestions/shadowed-lplace-method-2.rs
Normal file
23
src/test/ui/suggestions/shadowed-lplace-method-2.rs
Normal file
@ -0,0 +1,23 @@
|
||||
#![allow(unused)]
|
||||
|
||||
struct X {
|
||||
x: (),
|
||||
}
|
||||
pub trait A {
|
||||
fn foo(&mut self, _: usize) -> &mut ();
|
||||
}
|
||||
impl A for X {
|
||||
fn foo(&mut self, _: usize) -> &mut () {
|
||||
&mut self.x
|
||||
}
|
||||
}
|
||||
impl X {
|
||||
fn foo(&mut self, _: usize) -> &mut Self {
|
||||
self
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let mut x = X { x: () };
|
||||
*x.foo(0) = (); //~ ERROR E0308
|
||||
}
|
25
src/test/ui/suggestions/shadowed-lplace-method-2.stderr
Normal file
25
src/test/ui/suggestions/shadowed-lplace-method-2.stderr
Normal file
@ -0,0 +1,25 @@
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/shadowed-lplace-method-2.rs:22:17
|
||||
|
|
||||
LL | *x.foo(0) = ();
|
||||
| --------- ^^ expected struct `X`, found `()`
|
||||
| |
|
||||
| expected due to the type of this binding
|
||||
|
|
||||
note: the `foo` call is resolved to the method in `X`, shadowing the method of the same name on trait `A`
|
||||
--> $DIR/shadowed-lplace-method-2.rs:22:8
|
||||
|
|
||||
LL | *x.foo(0) = ();
|
||||
| ^^^ refers to `X::foo`
|
||||
help: you might have meant to call the other method; you can use the fully-qualified path to call it explicitly
|
||||
|
|
||||
LL | *<_ as A>::foo(&mut x, 0) = ();
|
||||
| ++++++++++++++++++ ~
|
||||
help: try wrapping the expression in `X`
|
||||
|
|
||||
LL | *x.foo(0) = X { x: () };
|
||||
| ++++++ +
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0308`.
|
Loading…
Reference in New Issue
Block a user