forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 7
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#122120 - fmease:sugg-assoc-ty-bound-on-eq-bound, r=compiler-errors Suggest associated type bounds on problematic associated equality bounds Fixes rust-lang#105056. TL;DR: Suggest `Trait<Ty: Bound>` on `Trait<Ty = Bound>` in Rust >=2021. ~~Blocked on rust-lang#122055 (stabilization of `associated_type_bounds`), I'd say.~~ (merged)
- Loading branch information
Showing
10 changed files
with
287 additions
and
99 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
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
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
30 changes: 30 additions & 0 deletions
30
tests/ui/associated-type-bounds/suggest-assoc-ty-bound-on-eq-bound.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,30 @@ | ||
// Regression test for issue #105056. | ||
//@ edition: 2021 | ||
|
||
fn f(_: impl Trait<T = Copy>) {} | ||
//~^ ERROR trait objects must include the `dyn` keyword | ||
//~| HELP add `dyn` keyword before this trait | ||
//~| HELP you might have meant to write a bound here | ||
//~| ERROR the trait `Copy` cannot be made into an object | ||
|
||
fn g(_: impl Trait<T = std::fmt::Debug + Eq>) {} | ||
//~^ ERROR trait objects must include the `dyn` keyword | ||
//~| HELP add `dyn` keyword before this trait | ||
//~| HELP you might have meant to write a bound here | ||
//~| ERROR only auto traits can be used as additional traits in a trait object | ||
//~| HELP consider creating a new trait | ||
//~| ERROR the trait `Eq` cannot be made into an object | ||
|
||
fn h(_: impl Trait<T<> = 'static + for<'a> Fn(&'a ())>) {} | ||
//~^ ERROR trait objects must include the `dyn` keyword | ||
//~| HELP add `dyn` keyword before this trait | ||
//~| HELP you might have meant to write a bound here | ||
|
||
// Don't suggest assoc ty bound in trait object types, that's not valid: | ||
type Obj = dyn Trait<T = Clone>; | ||
//~^ ERROR trait objects must include the `dyn` keyword | ||
//~| HELP add `dyn` keyword before this trait | ||
|
||
trait Trait { type T; } | ||
|
||
fn main() {} |
Oops, something went wrong.