Skip to content

Normalize region obligations before regionck#159649

Open
adwinwhite wants to merge 3 commits into
rust-lang:mainfrom
adwinwhite:norm-before-regionck
Open

Normalize region obligations before regionck#159649
adwinwhite wants to merge 3 commits into
rust-lang:mainfrom
adwinwhite:norm-before-regionck

Conversation

@adwinwhite

@adwinwhite adwinwhite commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

View all comments

We now normalize TypeOutlives predicates when evaluating them in the next solver.
So we don't need to normalize in regionck anymore.

r? @ShoyuVanilla
cc @lcnr

@rustbot

rustbot commented Jul 21, 2026

Copy link
Copy Markdown
Collaborator

Some changes occurred to the core trait solver

cc @rust-lang/initiative-trait-system-refactor

@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. WG-trait-system-refactor The Rustc Trait System Refactor Initiative (-Znext-solver) labels Jul 21, 2026
/// This function assumes that all infer variables are already constrained.
///
/// FIXME: this can probably be moved back to `rustc_infer` now that normalization is
/// on longer required. These two extention traits won't be needed then.

@adwinwhite adwinwhite Jul 21, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I didn't do this in this PR because a lot of stuff would be moved and I'm uncertain about some of them.

View changes since the review

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

want to put FIXME(#155345) here so that we do it as part of that refactor

// `TypeOutlives` is structural, so we should try to opportunistically resolve all
// region vids before processing regions, so we have a better chance to match clauses
// in our param-env.
let sup_type = self.shallow_resolve(sup_type);

@lcnr lcnr Jul 21, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

is that necessary/could we just use eager_resolve_vars here?

Hmm, also, shallow_resolve feels wrong? because we could have ?x which resolves to Vec<?y> where ?y can be resolved to u32 later on. I feel like this should have otherwise been resolve_vars_if_possible to recur into the type

View changes since the review

@adwinwhite adwinwhite Jul 22, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Without it we'll have unresolved infer var error later.
Yeah, it should be resolve_vars_if_possible. We had a resolve_vars_if_possible somewhere before.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

ye, my thoughts are that we could use

                let (sup_type, sub_region) = eager_resolve_vars(self, (sup_type, sub_region));

instead of

                let sup_type = self.shallow_resolve(sup_type); 
                let (sup_type, sub_region) =
                    (sup_type, sub_region).fold_with(&mut OpportunisticRegionResolver::new(self));

}

self.evaluate_added_goals_and_make_canonical_response(Certainty::Yes)
if ty.has_non_region_infer() || ty.has_non_rigid_aliases() {

@lcnr lcnr Jul 21, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

comment please :>

View changes since the review

}
}
}
if let Some(type_outlives) = bound.as_type_outlives_clause() {

@lcnr lcnr Jul 21, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

debug_assert: if next-solver && non-igid aliases => ICE

View changes since the review

@lcnr

lcnr commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

there's also normalize_and_add_type_outlives_constraints which can be removed now I think

@rust-log-analyzer

This comment has been minimized.

@rust-bors

This comment has been minimized.

/// This function assumes that all infer variables are already constrained.
///
/// FIXME: this can probably be moved back to `rustc_infer` now that normalization is
/// on longer required. These two extention traits won't be needed then.

@ShoyuVanilla ShoyuVanilla Jul 22, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
/// on longer required. These two extention traits won't be needed then.
/// no longer required. These two extension traits won't be needed then.

View changes since the review

@adwinwhite
adwinwhite force-pushed the norm-before-regionck branch from ce9170d to f5b6af2 Compare July 22, 2026 12:19
@rustbot

rustbot commented Jul 22, 2026

Copy link
Copy Markdown
Collaborator

This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed.

Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers.

@adwinwhite

Copy link
Copy Markdown
Contributor Author

@bors try @rust-timer queue

@rust-timer

This comment has been minimized.

@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Jul 22, 2026
@rust-bors

This comment has been minimized.

rust-bors Bot pushed a commit that referenced this pull request Jul 22, 2026
Normalize region obligations before regionck
@rust-log-analyzer

This comment has been minimized.

@adwinwhite

Copy link
Copy Markdown
Contributor Author

@bors try cancel

@rust-bors

rust-bors Bot commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

Try build cancelled. Cancelled workflows:

@adwinwhite

Copy link
Copy Markdown
Contributor Author

@bors try @rust-timer queue

@rust-timer

This comment has been minimized.

@rust-bors

This comment has been minimized.

rust-bors Bot pushed a commit that referenced this pull request Jul 23, 2026
Normalize region obligations before regionck
@rust-log-analyzer

This comment has been minimized.

@adwinwhite
adwinwhite force-pushed the norm-before-regionck branch from d4e81d8 to 7c1c571 Compare July 23, 2026 06:52
@rust-bors

rust-bors Bot commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

☀️ Try build successful (CI)
Build commit: d85ff7e (d85ff7ea0db7e79c08713eec21d583acd432bbdc)
Base parent: 390279b (390279b302ca98ae270f434100ae3730531d1246)

@rust-timer

This comment has been minimized.

@rust-timer

Copy link
Copy Markdown
Collaborator

Finished benchmarking commit (d85ff7e): comparison URL.

Overall result: ❌✅ regressions and improvements - no action needed

Benchmarking means the PR may be perf-sensitive. Consider adding rollup=never if this change is not fit for rolling up.

@rustbot label: -S-waiting-on-perf -perf-regression

Instruction count

Our most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
1.2% [1.2%, 1.2%] 3
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-0.3% [-0.3%, -0.3%] 2
All ❌✅ (primary) - - 0

Max RSS (memory usage)

Results (secondary 6.3%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
6.3% [6.3%, 6.3%] 1
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) - - 0

Cycles

Results (secondary 3.6%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
3.6% [3.6%, 3.6%] 1
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) - - 0

Binary size

This perf run didn't have relevant results for this metric.

Bootstrap: 486.724s -> 486.349s (-0.08%)
Artifact size: 387.61 MiB -> 390.01 MiB (0.62%)

@rustbot rustbot removed the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Jul 23, 2026
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. WG-trait-system-refactor The Rustc Trait System Refactor Initiative (-Znext-solver)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants