-
Notifications
You must be signed in to change notification settings - Fork 12.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
When suggesting assoc function with type params, include turbofish
- Loading branch information
Showing
3 changed files
with
52 additions
and
8 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
11 changes: 11 additions & 0 deletions
11
src/test/ui/suggestions/suggest-assoc-fn-call-with-turbofish.rs
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,11 @@ | ||
struct GenericAssocMethod<T>(T); | ||
|
||
impl<T> GenericAssocMethod<T> { | ||
fn default_hello() {} | ||
} | ||
|
||
fn main() { | ||
let x = GenericAssocMethod(33i32); | ||
x.default_hello(); | ||
//~^ ERROR no method named `default_hello` found for type `GenericAssocMethod<i32>` | ||
} |
22 changes: 22 additions & 0 deletions
22
src/test/ui/suggestions/suggest-assoc-fn-call-with-turbofish.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,22 @@ | ||
error[E0599]: no method named `default_hello` found for type `GenericAssocMethod<i32>` in the current scope | ||
--> $DIR/suggest-assoc-fn-call-with-turbofish.rs:9:7 | ||
| | ||
LL | struct GenericAssocMethod<T>(T); | ||
| -------------------------------- method `default_hello` not found for this | ||
... | ||
LL | x.default_hello(); | ||
| --^^^^^^^^^^^^^ | ||
| | | | ||
| | this is an associated function, not a method | ||
| help: use associated function syntax instead: `GenericAssocMethod::<i32>::default_hello` | ||
| | ||
= 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 `GenericAssocMethod<_>` | ||
--> $DIR/suggest-assoc-fn-call-with-turbofish.rs:4:5 | ||
| | ||
LL | fn default_hello() {} | ||
| ^^^^^^^^^^^^^^^^^^ | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0599`. |