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#115347 - y21:generic-bound-impl-trait-ty, r…
…=compiler-errors suggest removing `impl` in generic trait bound position rustc already does this recovery in type param position (`<T: impl Trait>` -> `<T: Trait>`). This PR also adds that suggestion in trait bound position (e.g. `where T: impl Trait` or `trait Trait { type Assoc: impl Trait; }`)
- Loading branch information
Showing
3 changed files
with
66 additions
and
12 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,14 @@ | ||
trait Tr { | ||
type Assoc: impl Sized; | ||
//~^ ERROR expected a trait, found type | ||
//~| HELP use the trait bounds directly | ||
|
||
fn fn_with_generics<T>() | ||
where | ||
T: impl Sized | ||
//~^ ERROR expected a trait, found type | ||
//~| HELP use the trait bounds directly | ||
{} | ||
} | ||
|
||
fn main() {} |
26 changes: 26 additions & 0 deletions
26
tests/ui/associated-type-bounds/suggest-removing-impl.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,26 @@ | ||
error: expected a trait, found type | ||
--> $DIR/suggest-removing-impl.rs:2:17 | ||
| | ||
LL | type Assoc: impl Sized; | ||
| ^^^^^^^^^^ | ||
| | ||
help: use the trait bounds directly | ||
| | ||
LL - type Assoc: impl Sized; | ||
LL + type Assoc: Sized; | ||
| | ||
|
||
error: expected a trait, found type | ||
--> $DIR/suggest-removing-impl.rs:8:12 | ||
| | ||
LL | T: impl Sized | ||
| ^^^^^^^^^^ | ||
| | ||
help: use the trait bounds directly | ||
| | ||
LL - T: impl Sized | ||
LL + T: Sized | ||
| | ||
|
||
error: aborting due to 2 previous errors | ||
|