forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 1
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 rust-lang#63811 - estebank:impl-trait-arg, r=cramertj
Correctly suggest adding bounds to `impl Trait` argument Fix rust-lang#63706.
- Loading branch information
Showing
4 changed files
with
71 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
20 changes: 20 additions & 0 deletions
20
src/test/ui/suggestions/impl-trait-with-missing-trait-bounds-in-arg.fixed
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,20 @@ | ||
// run-rustfix | ||
|
||
trait Foo {} | ||
|
||
trait Bar { | ||
fn hello(&self) {} | ||
} | ||
|
||
struct S; | ||
|
||
impl Foo for S {} | ||
impl Bar for S {} | ||
|
||
fn test(foo: impl Foo + Bar) { | ||
foo.hello(); //~ ERROR E0599 | ||
} | ||
|
||
fn main() { | ||
test(S); | ||
} |
20 changes: 20 additions & 0 deletions
20
src/test/ui/suggestions/impl-trait-with-missing-trait-bounds-in-arg.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,20 @@ | ||
// run-rustfix | ||
|
||
trait Foo {} | ||
|
||
trait Bar { | ||
fn hello(&self) {} | ||
} | ||
|
||
struct S; | ||
|
||
impl Foo for S {} | ||
impl Bar for S {} | ||
|
||
fn test(foo: impl Foo) { | ||
foo.hello(); //~ ERROR E0599 | ||
} | ||
|
||
fn main() { | ||
test(S); | ||
} |
15 changes: 15 additions & 0 deletions
15
src/test/ui/suggestions/impl-trait-with-missing-trait-bounds-in-arg.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,15 @@ | ||
error[E0599]: no method named `hello` found for type `impl Foo` in the current scope | ||
--> $DIR/impl-trait-with-missing-trait-bounds-in-arg.rs:15:9 | ||
| | ||
LL | foo.hello(); | ||
| ^^^^^ | ||
| | ||
= help: items from traits can only be used if the type parameter is bounded by the trait | ||
help: the following trait defines an item `hello`, perhaps you need to restrict type parameter `impl Foo` with it: | ||
| | ||
LL | fn test(foo: impl Foo + Bar) { | ||
| ^^^^^^^^^^^^^^ | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0599`. |