-
Notifications
You must be signed in to change notification settings - Fork 12.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Suggest associated type bounds on problematic associated equality bounds #122120
Changes from all commits
6b85f07
d3d77a8
22b9e96
3879acb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,10 +14,6 @@ parse_array_index_offset_of = array indexing not supported in offset_of | |
|
||
parse_assignment_else_not_allowed = <assignment> ... else {"{"} ... {"}"} is not allowed | ||
|
||
parse_assoc_lifetime = associated lifetimes are not supported | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This message was confusing imo, it talked about a “fictive” Rust feature, associated lifetimes as if that term was common knowledge. If at all, I would've expected this message to trigger on |
||
.label = the lifetime is given here | ||
.help = if you meant to specify a trait object, write `dyn Trait + 'lifetime` | ||
|
||
parse_associated_static_item_not_allowed = associated `static` items are not allowed | ||
|
||
parse_async_block_in_2015 = `async` blocks are only allowed in Rust 2018 or later | ||
|
@@ -445,6 +441,12 @@ parse_lifetime_in_borrow_expression = borrow expressions cannot be annotated wit | |
.suggestion = remove the lifetime annotation | ||
.label = annotated with lifetime here | ||
|
||
parse_lifetime_in_eq_constraint = lifetimes are not permitted in this context | ||
.label = lifetime is not allowed here | ||
.context_label = this introduces an associated item binding | ||
.help = if you meant to specify a trait object, write `dyn /* Trait */ + {$lifetime}` | ||
.colon_sugg = you might have meant to write a bound here | ||
|
||
parse_lone_slash = invalid trailing slash in literal | ||
.label = {parse_lone_slash} | ||
|
||
|
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() {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I never understood this FIXME whenever I came across these docs: The FIXME was created in the same commit as the one that introduced
TypeBindingKind
in favor of the now gone struct fieldty: P<Ty>
the FIXME mentions...