-
Notifications
You must be signed in to change notification settings - Fork 13.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of #103550 - notriddle:notriddle/no-suggest-static-candi…
…dates, r=wesleywiser diagnostics: do not suggest static candidates as traits to import If it's a static candidate, then it's already implemented. Do not suggest it a second time for implementing. Partial fix for #102354
- Loading branch information
Showing
3 changed files
with
52 additions
and
6 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,10 @@ | ||
trait Trait { | ||
fn func() {} | ||
} | ||
|
||
impl Trait for i32 {} | ||
|
||
fn main() { | ||
let x: i32 = 123; | ||
x.func(); //~ERROR no method | ||
} |
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,24 @@ | ||
error[E0599]: no method named `func` found for type `i32` in the current scope | ||
--> $DIR/issue-102354.rs:9:7 | ||
| | ||
LL | x.func(); | ||
| ^^^^ this is an associated function, not a method | ||
| | ||
= note: found the following associated functions; to be used as methods, functions must have a `self` parameter | ||
note: the candidate is defined in the trait `Trait` | ||
--> $DIR/issue-102354.rs:2:5 | ||
| | ||
LL | fn func() {} | ||
| ^^^^^^^^^ | ||
help: use associated function syntax instead | ||
| | ||
LL | i32::func(); | ||
| ~~~~~~~~~ | ||
help: disambiguate the associated function for the candidate | ||
| | ||
LL | <i32 as Trait>::func(x); | ||
| ~~~~~~~~~~~~~~~~~~~~~~~ | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0599`. |