-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: wrong trait import suggestion for T:
- Loading branch information
Bruno Felipe Francisco
committed
Apr 13, 2022
1 parent
e3c43e6
commit 9b9f677
Showing
3 changed files
with
32 additions
and
2 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,9 @@ | ||
// Test for #95898: The trait suggestion had an extra `:` after the trait. | ||
// edition:2021 | ||
|
||
fn foo<T:>(t: T) { | ||
t.clone(); | ||
//~^ ERROR no method named `clone` found for type parameter `T` in the current scope | ||
} | ||
|
||
fn main() {} |
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 @@ | ||
error[E0599]: no method named `clone` found for type parameter `T` in the current scope | ||
--> $DIR/issue-95898.rs:5:7 | ||
| | ||
LL | t.clone(); | ||
| ^^^^^ method not found in `T` | ||
| | ||
= help: items from traits can only be used if the type parameter is bounded by the trait | ||
help: the following trait defines an item `clone`, perhaps you need to restrict type parameter `T` with it: | ||
| | ||
LL | fn foo<T: Clone>(t: T) { | ||
| ~~~~~~~~ | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0599`. |