-
Notifications
You must be signed in to change notification settings - Fork 13.2k
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
Bounds in HRTB are ignored #42181
Comments
This might be a dupe - either way, a potential backwards compat hazard. cc @nikomatsakis |
Yes, we should deal with this. Errors are best for now, though I hope to extend HRTB to support where-clauses. |
triage: P-medium This is old. But let's fix it. Might be a good E-mentor candidate. I'll try to write-up some instructions. |
Bounds in type aliases are similarily ignored: type Test<'a, 'b: 'static> = &'a mut &'b mut i32;
fn main() {
let x : Test = &mut &mut 0;
} Is that a separate bug? This seems closer to whatever lead to E0122 being added, which however seems to have happened long ago. EDIT: Same for |
It only doesn't behave that way because the bounds are forgotten... which is a real shame. |
What do you mean, add more projections? |
@RalfJung Right now we only have |
Ah so you're not talking about a new syntax, just a different implementation strategy. |
@RalfJung Right. The compiler has everything it needs, there just isn't a way to get the information to the uses. Inside functions it's not that hard, but outside there isn't really where to store it. |
Warn about ignored generic bounds in `for` This adds a new lint to fix #42181. For consistency and to avoid code duplication, I also moved the existing "bounds in type aliases are ignored" here. Questions to the reviewer: * Is it okay to just remove a diagnostic error code like this? Should I instead keep the warning about type aliases where it is? The old code provided a detailed explanation of what's going on when asked, that information is now lost. On the other hand, `span_warn!` seems deprecated (after this patch, it has exactly one user left!). * Did I miss any syntactic construct that can appear as `for` in the surface syntax? I covered function types (`for<'a> fn(...)`), generic traits (`for <'a> Fn(...)`, can appear both as bounds as as trait objects) and bounds (`for<'a> F: ...`). * For the sake of backwards compatibility, this adds a warning, not an error. @nikomatsakis suggested an error in #42181 (comment), but I feel that can only happen in a new epoch -- right? Cc @eddyb
Warn about ignored generic bounds in `for` This adds a new lint to fix #42181. For consistency and to avoid code duplication, I also moved the existing "bounds in type aliases are ignored" here. Questions to the reviewer: * Is it okay to just remove a diagnostic error code like this? Should I instead keep the warning about type aliases where it is? The old code provided a detailed explanation of what's going on when asked, that information is now lost. On the other hand, `span_warn!` seems deprecated (after this patch, it has exactly one user left!). * Did I miss any syntactic construct that can appear as `for` in the surface syntax? I covered function types (`for<'a> fn(...)`), generic traits (`for <'a> Fn(...)`, can appear both as bounds as as trait objects) and bounds (`for<'a> F: ...`). * For the sake of backwards compatibility, this adds a warning, not an error. @nikomatsakis suggested an error in #42181 (comment), but I feel that can only happen in a new epoch -- right? Cc @eddyb
The syntax
where for<'b: 'a> ...
is permitted without warning, however the: 'a
bound is not used to prove the identity; I would expect the following to compile:but it fails with
The text was updated successfully, but these errors were encountered: