Skip to content
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

Closed
wants to merge 1 commit into from

Conversation

bvanjoi
Copy link
Contributor

@bvanjoi bvanjoi commented Dec 16, 2023

Fixes #118697

Rearrange the sequence to ensure that no null def id is read when lowering the lifetime.

@rustbot
Copy link
Collaborator

rustbot commented Dec 16, 2023

r? @davidtwco

(rustbot has picked a reviewer for you, use r? to override)

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Dec 16, 2023
@@ -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 ()) -> _`
Copy link
Contributor Author

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)| {
Copy link
Member

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?

Copy link
Contributor Author

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(());
Copy link
Member

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.

Copy link
Contributor Author

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.

@bvanjoi
Copy link
Contributor Author

bvanjoi commented Dec 23, 2023

in favor of #119042

@bvanjoi bvanjoi closed this Dec 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ICE: ast lowering: no entry for node id: NodeId(26)
4 participants