-
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
Underscore lifetimes are incorrectly accepted as lifetime bounds in impl headers #54902
Comments
visited for triage. Agreed that P-high and RC2 milestones are appropriate. @nikomatsakis is going to work first on mentorship; if that fails to find a volunter, they will fallback to fixing it themself. |
Actually, I'm not sure if this is an error or not. We currently permit Example 1 (playground): trait Foo<'a> { }
struct Bar<T> { t: T }
impl<T: Foo<'_>> Bar<T> { }
fn main() { } and example 2 (playground): trait Foo<'a> { }
struct Bar<T> { t: T }
impl<T> Bar<T> where T: Foo<'_> { }
fn main() { } Are we comfortable with those, but just not this? (I guess because this is clearly useless, whereas those .. may be useful?) |
For some reason, I thought maybe we were not going to permit |
Survey of current behavior. In Rust 2018 on nightly, all of the following are accepted. Using
|
Survey of current behavior. In Rust 2015 on nightly, all are errors. |
We discussed this in the @rust-lang/lang meeting and there seemed to be consensus that we ought to make it an error to use (I have first hand observed confusion on this point.) Given that the behavior is only accepted in Rust 2018, it seems we still have room to change this without requiring backporting. |
See also #45667 |
Fixed in #55162 |
…mandry handle underscore bounds in unexpected places Per the discussion on #54902, I made it a hard error to use lifetime bounds in various places where they used to be permitted: - `where Foo: Bar<'_>` for example I also moved error reporting to HIR lowering and added `Error` variants to let us suppress downstream errors that result. I (imo) improved the error message wording to be clearer, as well. In the process, I fixed the ICE in #52098. Fixes #54902 Fixes #52098
Stabilize impl_header_lifetime_elision in 2015 ~~This is currently blocked on #54902; it should be good after that~~ It's already stable in 2018; this finishes the stabilization. FCP completed (#15872 (comment)), proposal (#15872 (comment)). Tracking issue: #15872 Usage examples (from libcore): #54687
This is currently accepted in 2018: https://play.rust-lang.org/?gist=7ba2dee1134f9848b54b7364ea9568aa&version=nightly&edition=2018
AFAICT, it desugars to
So it's "fine", but useless.
It should error, as trying to do this does in other places, such as
Tracking issue for the
impl_header_lifetime_elision
feature: #15872On the current beta this gives
so this was at least exposed by #54458
The text was updated successfully, but these errors were encountered: