-
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 #96772 - TaKO8Ki:suggest-fully-qualified-path-with-ap…
…propriate-params, r=compiler-errors Suggest fully qualified path with appropriate params closes #96291
- Loading branch information
Showing
3 changed files
with
107 additions
and
1 deletion.
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
24 changes: 24 additions & 0 deletions
24
src/test/ui/traits/suggest-fully-qualified-path-with-appropriate-params.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,24 @@ | ||
struct Thing; | ||
|
||
trait Method<T> { | ||
fn method(&self) -> T; | ||
fn mut_method(&mut self) -> T; | ||
} | ||
|
||
impl Method<i32> for Thing { | ||
fn method(&self) -> i32 { 0 } | ||
fn mut_method(&mut self) -> i32 { 0 } | ||
} | ||
|
||
impl Method<u32> for Thing { | ||
fn method(&self) -> u32 { 0 } | ||
fn mut_method(&mut self) -> u32 { 0 } | ||
} | ||
|
||
fn main() { | ||
let thing = Thing; | ||
thing.method(); | ||
//~^ ERROR type annotations needed | ||
//~| ERROR type annotations needed | ||
thing.mut_method(); //~ ERROR type annotations needed | ||
} |
61 changes: 61 additions & 0 deletions
61
src/test/ui/traits/suggest-fully-qualified-path-with-appropriate-params.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,61 @@ | ||
error[E0282]: type annotations needed | ||
--> $DIR/suggest-fully-qualified-path-with-appropriate-params.rs:20:11 | ||
| | ||
LL | thing.method(); | ||
| ------^^^^^^-- | ||
| | | | ||
| | cannot infer type for type parameter `T` declared on the trait `Method` | ||
| this method call resolves to `T` | ||
|
||
error[E0283]: type annotations needed | ||
--> $DIR/suggest-fully-qualified-path-with-appropriate-params.rs:20:11 | ||
| | ||
LL | thing.method(); | ||
| ------^^^^^^-- | ||
| | | | ||
| | cannot infer type for type parameter `T` declared on the trait `Method` | ||
| this method call resolves to `T` | ||
| | ||
note: multiple `impl`s satisfying `Thing: Method<_>` found | ||
--> $DIR/suggest-fully-qualified-path-with-appropriate-params.rs:8:1 | ||
| | ||
LL | impl Method<i32> for Thing { | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
... | ||
LL | impl Method<u32> for Thing { | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
help: use the fully qualified path for the potential candidates | ||
| | ||
LL | <Thing as Method<i32>>::method(&thing); | ||
| ++++++++++++++++++++++++++++++++ ~ | ||
LL | <Thing as Method<u32>>::method(&thing); | ||
| ++++++++++++++++++++++++++++++++ ~ | ||
|
||
error[E0283]: type annotations needed | ||
--> $DIR/suggest-fully-qualified-path-with-appropriate-params.rs:23:11 | ||
| | ||
LL | thing.mut_method(); | ||
| ------^^^^^^^^^^-- | ||
| | | | ||
| | cannot infer type for type parameter `T` declared on the trait `Method` | ||
| this method call resolves to `T` | ||
| | ||
note: multiple `impl`s satisfying `Thing: Method<_>` found | ||
--> $DIR/suggest-fully-qualified-path-with-appropriate-params.rs:8:1 | ||
| | ||
LL | impl Method<i32> for Thing { | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
... | ||
LL | impl Method<u32> for Thing { | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
help: use the fully qualified path for the potential candidates | ||
| | ||
LL | <Thing as Method<i32>>::mut_method(&mut thing); | ||
| +++++++++++++++++++++++++++++++++++++++ ~ | ||
LL | <Thing as Method<u32>>::mut_method(&mut thing); | ||
| +++++++++++++++++++++++++++++++++++++++ ~ | ||
|
||
error: aborting due to 3 previous errors | ||
|
||
Some errors have detailed explanations: E0282, E0283. | ||
For more information about an error, try `rustc --explain E0282`. |