-
Notifications
You must be signed in to change notification settings - Fork 13.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Do autoderef to match impl against rcvr
- Loading branch information
1 parent
bf607da
commit 5497317
Showing
4 changed files
with
95 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// run-rustfix | ||
|
||
#![allow(unused)] | ||
|
||
struct Foo<T>(T); | ||
|
||
impl<T> Foo<T> { | ||
fn test() -> i32 { 1 } | ||
} | ||
|
||
fn main() { | ||
let x = Box::new(Foo(1i32)); | ||
Foo::<i32>::test(); | ||
//~^ ERROR no method named `test` found for struct `Box<Foo<i32>>` in the current scope | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// run-rustfix | ||
|
||
#![allow(unused)] | ||
|
||
struct Foo<T>(T); | ||
|
||
impl<T> Foo<T> { | ||
fn test() -> i32 { 1 } | ||
} | ||
|
||
fn main() { | ||
let x = Box::new(Foo(1i32)); | ||
x.test(); | ||
//~^ ERROR no method named `test` found for struct `Box<Foo<i32>>` in the current scope | ||
} |
19 changes: 19 additions & 0 deletions
19
src/test/ui/suggestions/suggest-assoc-fn-call-deref.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
error[E0599]: no method named `test` found for struct `Box<Foo<i32>>` in the current scope | ||
--> $DIR/suggest-assoc-fn-call-deref.rs:13:7 | ||
| | ||
LL | x.test(); | ||
| --^^^^-- | ||
| | | | ||
| | this is an associated function, not a method | ||
| help: use associated function syntax instead: `Foo::<i32>::test()` | ||
| | ||
= note: found the following associated functions; to be used as methods, functions must have a `self` parameter | ||
note: the candidate is defined in an impl for the type `Foo<T>` | ||
--> $DIR/suggest-assoc-fn-call-deref.rs:8:5 | ||
| | ||
LL | fn test() -> i32 { 1 } | ||
| ^^^^^^^^^^^^^^^^ | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0599`. |