Skip to content

Handle regions equivalent to 'static in non_local_bounds #139668

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

Merged
merged 2 commits into from
May 23, 2025

Conversation

matthewjasper
Copy link
Contributor

non_local_bounds would only find non local bounds that strictly bound a given region, but it's possible that a local region is equated to 'static when showing a type referencing a locally bound lifetime, such as dyn Any + 'a in the tests added, is well-formed. In this case we should return 'static.

closes #122704
closes #139004

@rustbot
Copy link
Collaborator

rustbot commented Apr 11, 2025

r? @nnethercote

rustbot has assigned @nnethercote.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@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 Apr 11, 2025
@rustbot
Copy link
Collaborator

rustbot commented Apr 11, 2025

This PR changes a file inside tests/crashes. If a crash was fixed, please move into the corresponding ui subdir and add 'Fixes #' to the PR description to autoclose the issue upon merge.

@compiler-errors
Copy link
Member

r? types

@rustbot rustbot added the T-types Relevant to the types team, which will review and decide on the PR/issue. label Apr 11, 2025
@rustbot rustbot assigned BoxyUwU and unassigned nnethercote Apr 11, 2025
@@ -133,7 +133,8 @@ impl UniversalRegionRelations<'_> {
assert!(self.universal_regions.is_universal_region(fr0));

let mut external_parents = vec![];
let mut queue = vec![fr0];

let mut queue = vec![relation.scc_representative(fr0)];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if you've explained why projecting the free region to its representative affects the set of non_local_bounds that we return. It's not obvious from the definition of TransitiveRelation::parents, at least.

Like, if these are actually SCC's then I'm not sure why shuffling around which element in that SCC fixes things.

Is there something subtle going on with the fact that 'static is the first first region vid we allocate?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If it has to do with the fact that TransitiveRelation::parents requires for us to pass the minimal element for this while loop to actually reach all of the parents, then perhaps we should rename thatfunction to minimal_scc_representative 🤔

Or maybe I'm totally misleading myself.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @matthewjasper, did you mean to resolve this without actually answering the question?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your second comment was correct and I renamed scc_representative to minimal_scc_representative

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah ok thanks

@compiler-errors
Copy link
Member

@rustbot author (waiting on questions)

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Apr 13, 2025
@rustbot
Copy link
Collaborator

rustbot commented Apr 13, 2025

Reminder, once the PR becomes ready for a review, use @rustbot ready.

`non_local_bounds` would only find non local bounds that strictly bound a given region,
but it's possible that a local region is equated to 'static when showing a type referencing
a locally bound lifetime, such as `dyn Any + 'a` in the tests added, is well-formed. In
this case we should return 'static.
@matthewjasper
Copy link
Contributor Author

@rustbot ready

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Apr 15, 2025
@compiler-errors
Copy link
Member

@bors r+

@bors
Copy link
Collaborator

bors commented May 22, 2025

📌 Commit c57ef29 has been approved by compiler-errors

It is now in the queue for this repository.

@compiler-errors
Copy link
Member

@bors rollup

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels May 22, 2025
bors added a commit to rust-lang-ci/rust that referenced this pull request May 22, 2025
…iaskrgr

Rollup of 7 pull requests

Successful merges:

 - rust-lang#135562 (Add ignore value suggestion in closure body)
 - rust-lang#139635 (Finalize repeat expr inference behaviour with inferred repeat counts)
 - rust-lang#139668 (Handle regions equivalent to 'static in non_local_bounds)
 - rust-lang#140218 (HIR ty lowering: Clean up & refactor the lowering of type-relative paths)
 - rust-lang#140435 (use uX::from instead of _ as uX in non - const contexts)
 - rust-lang#141130 (rustc_on_unimplemented cleanups)
 - rust-lang#141286 (Querify `coroutine_hidden_types`)

Failed merges:

 - rust-lang#140247 (Don't build `ParamEnv` and do trait solving in `ItemCtxt`s when lowering IATs)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 706dc70 into rust-lang:master May 23, 2025
6 checks passed
@rustbot rustbot added this to the 1.89.0 milestone May 23, 2025
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request May 23, 2025
Rollup merge of rust-lang#139668 - matthewjasper:upper-bound-fix, r=compiler-errors

Handle regions equivalent to 'static in non_local_bounds

`non_local_bounds` would only find non local bounds that strictly bound a given region, but it's possible that a local region is equated to 'static when showing a type referencing a locally bound lifetime, such as `dyn Any + 'a` in the tests added, is well-formed. In this case we should return 'static.

closes rust-lang#122704
closes rust-lang#139004
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-types Relevant to the types team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Rustc panics at free_region_relations.rs:93:9: "can't find an upper bound!?" ICE: can't find an upper bound in nll::compute_regions in rustc_borrowck
6 participants