-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
create LifetimeRes::Fresh
firstly when lower lifetime binder
#119021
Conversation
r? @davidtwco (rustbot has picked a reviewer for you, use r? to override) |
@@ -26,7 +26,7 @@ LL | f2(|_: (), _: ()| {}); | |||
| | | |||
| expected due to this | |||
| | |||
= note: expected closure signature `for<'a, 'b> fn(&'a (), &'b ()) -> _` | |||
= note: expected closure signature `for<'b, 'a> fn(&'a (), &'b ()) -> _` |
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.
This seems acceptable. Alternatively, we could sort this before displaying the diagnostics?
let extra_lifetimes = self.resolver.take_extra_lifetime_params(binder); | ||
debug!(?extra_lifetimes); | ||
generic_params.extend(extra_lifetimes.into_iter().filter_map(|(ident, node_id, res)| { | ||
params.extend(extra_lifetimes.into_iter().filter_map(|(ident, node_id, res)| { |
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.
Why does this fix the issue?
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.
An invocation of a def_id
in extra_lifetimes
occurs during lower_generic_params_mut
. This rearrangement ensures that the def_id
is not None.
#![allow(incomplete_features)] | ||
#![feature(non_lifetime_binders)] | ||
|
||
type T = dyn for<V = A(&())> Fn(()); |
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.
We should probably just ban parameter defaults in non-lifetime binders before we get to AST->HIR lowering.
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.
Yes, I agree this is a promising approach. I'll give it a try.
in favor of #119042 |
Fixes #118697
Rearrange the sequence to ensure that no null def id is read when lowering the lifetime.