Skip to content

normalize in relations, not generalize, when relating infer with alias - #160443

Merged
rust-bors[bot] merged 2 commits into
rust-lang:mainfrom
khyperia:move-normalize-to-relations
Aug 5, 2026
Merged

normalize in relations, not generalize, when relating infer with alias#160443
rust-bors[bot] merged 2 commits into
rust-lang:mainfrom
khyperia:move-normalize-to-relations

Conversation

@khyperia

@khyperia khyperia commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

This removes the wonky <?0 as Trait>::Assoc == ?0 handling in generalize, as the alias will be normalized before generalization gets invoked. (... in the new solver, the old solver is not touched).

My gut feeling is that change is potentially minorly perf-sensitive I think, I've had perf impacts here before, and we're slightly changing the way aliases are handled - especially invariant relations now generate an extra var then immediately do a equate_ty_vids_raw, it short-circuited before.

r? lcnr

@rustbot

rustbot commented Aug 3, 2026

Copy link
Copy Markdown
Collaborator

changes to the core type system

cc @lcnr

@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 Aug 3, 2026
@rust-log-analyzer

This comment has been minimized.

@khyperia
khyperia force-pushed the move-normalize-to-relations branch from 04d970b to 7ca8a78 Compare August 4, 2026 06:45
@rustbot rustbot added the WG-trait-system-refactor The Rustc Trait System Refactor Initiative (-Znext-solver) label Aug 4, 2026
self.param_env(),
ty::ProjectionPredicate { projection_term: alias.into(), term: new_var.into() },
)]);
self.tys(new_var, b)?;

@lcnr lcnr Aug 4, 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.

that one is cool as it means for non-rigid eq non-rigid we emit two projection goals right away, for const aliases we currently do Projection(non-rigid, other-non-rigid). THinking whether creating a const infer var and then relating that would be better, even if for consts it's not strictly required as they are always equated, so no subtyping

View changes since the review

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.

yeah mood. idk!

@lcnr

lcnr commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

@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 Aug 4, 2026
@rust-bors

This comment has been minimized.

rust-bors Bot pushed a commit that referenced this pull request Aug 4, 2026
normalize in relations, not generalize, when relating infer with alias
@khyperia
khyperia force-pushed the move-normalize-to-relations branch from 7ca8a78 to ad05b23 Compare August 4, 2026 07:51
mut structurally_normalize: impl FnMut(Ty<'tcx>) -> Ty<'tcx>,
mut handle_field: impl FnMut(Ty<'tcx>, Option<VariantIdx>, FieldIdx, T) -> Ty<'tcx>,
// FIXME(#155345): This should only normalize when actually required.
mut structurally_normalize: impl FnMut(Unnormalized<'tcx, Ty<'tcx>>) -> Ty<'tcx>,

@lcnr lcnr Aug 4, 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.

rename to normalize :> nothing structural about this anymore

View changes since the review

}
}
Ok(a)
panic!("Non-rigid aliases should be handled in the caller of super_combine_tys")

@lcnr lcnr Aug 4, 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.

Suggested change
panic!("Non-rigid aliases should be handled in the caller of super_combine_tys")
panic!("non-rigid aliases should be handled in the caller of super_combine_tys")

View changes since the review

@khyperia
khyperia force-pushed the move-normalize-to-relations branch from ad05b23 to 3dc2ef8 Compare August 4, 2026 08:46
@rust-bors

rust-bors Bot commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

☀️ Try build successful (CI)
Build commit: 0721d75 (0721d75742e22defdc7ffd82ae6395cc274dedd7)
Base parent: c9ff496 (c9ff496891c278ad660bc0ab85c1f0b72059464a)

@rust-timer

This comment has been minimized.

@lcnr lcnr left a comment

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.

r=me with good perf

View changes since this review

@rust-timer

Copy link
Copy Markdown
Collaborator

Finished benchmarking commit (0721d75): comparison URL.

Overall result: ❌ regressions - 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.0% [1.0%, 1.0%] 1
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) - - 0

Max RSS (memory usage)

Results (primary 0.1%, secondary -0.5%)

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

mean range count
Regressions ❌
(primary)
2.5% [0.4%, 4.5%] 2
Regressions ❌
(secondary)
1.5% [0.4%, 2.6%] 2
Improvements ✅
(primary)
-0.5% [-0.8%, -0.4%] 7
Improvements ✅
(secondary)
-0.7% [-2.5%, -0.4%] 21
All ❌✅ (primary) 0.1% [-0.8%, 4.5%] 9

Cycles

Results (primary -0.2%, secondary 0.3%)

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

mean range count
Regressions ❌
(primary)
0.7% [0.5%, 1.0%] 9
Regressions ❌
(secondary)
0.8% [0.4%, 1.3%] 7
Improvements ✅
(primary)
-2.7% [-6.3%, -0.8%] 3
Improvements ✅
(secondary)
-0.5% [-0.8%, -0.4%] 5
All ❌✅ (primary) -0.2% [-6.3%, 1.0%] 12

Binary size

Results (secondary -0.0%)

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)
- - 0
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-0.0% [-0.0%, -0.0%] 1
All ❌✅ (primary) - - 0

Bootstrap: 489.838s -> 490.783s (0.19%)
Artifact size: 390.28 MiB -> 390.30 MiB (0.01%)

@rustbot rustbot removed the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Aug 4, 2026
@khyperia

khyperia commented Aug 4, 2026

Copy link
Copy Markdown
Contributor Author

@bors r=lcnr

@rust-bors

rust-bors Bot commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

📌 Commit 3dc2ef8 has been approved by lcnr

It is now in the queue for this repository.

🌲 The tree is currently closed for pull requests below priority 10. This pull request will be tested once the tree is reopened.

Reason for tree closure: manually handling queue due to backlog

@rust-bors rust-bors Bot 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 Aug 4, 2026
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Aug 4, 2026
…ns, r=lcnr

normalize in relations, not generalize, when relating infer with alias

This removes the wonky `<?0 as Trait>::Assoc == ?0` handling in generalize, as the alias will be normalized before generalization gets invoked. (... in the new solver, the old solver is not touched).

My gut feeling is that change is potentially minorly perf-sensitive I think, I've had perf impacts here before, and we're slightly changing the way aliases are handled - especially invariant relations now generate an extra var then immediately do a `equate_ty_vids_raw`, it short-circuited before.

r? lcnr
rust-bors Bot pushed a commit that referenced this pull request Aug 5, 2026
…uwer

Rollup of 22 pull requests

Successful merges:

 - #160426 (`rust-analyzer` subtree update)
 - #160372 (Derive the allocator used by tools from rustc's allocator)
 - #146882 (fully deprecate the legacy integral modules)
 - #158727 (std: use `readdir` on nearly all UNIX platforms)
 - #159727 (Various steps in moving away from the big reflection enum to reflection functions)
 - #160443 (normalize in relations, not generalize, when relating infer with alias)
 - #160457 (implement -Zllvm-target-feature)
 - #160480 (Single-pass ASCII lower/upper case conversion)
 - #160502 (Reduce number of miri tests executed on PR CI)
 - #157430 (std::random: use little-endian for reproducibility)
 - #158110 (fix macro attribute feature-gate span)
 - #159975 (Use real ThinVec in StmtDebugInfos)
 - #160001 (Suggest mutable method when iterating over binding)
 - #160024 (Fix mono reachability with no-op landing pads)
 - #160154 (Add regression test for HRTB associated type projection closure)
 - #160176 (No more `tests/ui/issues`!)
 - #160326 (Remove hidden_glob_reexports)
 - #160407 (Add regression tests for a number of ICEs and diagnostics issues labelled `E-needs-test`)
 - #160430 (bootstrap: Don't produce mutated/filtered PathSets during command-line matching)
 - #160472 (Minor fixes to `core::io` & `alloc::io` Documentation)
 - #160486 (Remove unused `FreeRegionsVisitor`)
 - #160496 (clarify non-determinism docs for algebraic operations)

Failed merges:

 - #160501 (Add bootstrap CLI snapshot test for testing miri)
@rust-bors
rust-bors Bot merged commit 9dcaf05 into rust-lang:main Aug 5, 2026
13 checks passed
@rustbot rustbot added this to the 1.99.0 milestone Aug 5, 2026
rust-timer added a commit that referenced this pull request Aug 5, 2026
Rollup merge of #160443 - khyperia:move-normalize-to-relations, r=lcnr

normalize in relations, not generalize, when relating infer with alias

This removes the wonky `<?0 as Trait>::Assoc == ?0` handling in generalize, as the alias will be normalized before generalization gets invoked. (... in the new solver, the old solver is not touched).

My gut feeling is that change is potentially minorly perf-sensitive I think, I've had perf impacts here before, and we're slightly changing the way aliases are handled - especially invariant relations now generate an extra var then immediately do a `equate_ty_vids_raw`, it short-circuited before.

r? lcnr
RalfJung pushed a commit to rust-lang/miri that referenced this pull request Aug 5, 2026
…uwer

Rollup of 22 pull requests

Successful merges:

 - rust-lang/rust#160426 (`rust-analyzer` subtree update)
 - rust-lang/rust#160372 (Derive the allocator used by tools from rustc's allocator)
 - rust-lang/rust#146882 (fully deprecate the legacy integral modules)
 - rust-lang/rust#158727 (std: use `readdir` on nearly all UNIX platforms)
 - rust-lang/rust#159727 (Various steps in moving away from the big reflection enum to reflection functions)
 - rust-lang/rust#160443 (normalize in relations, not generalize, when relating infer with alias)
 - rust-lang/rust#160457 (implement -Zllvm-target-feature)
 - rust-lang/rust#160480 (Single-pass ASCII lower/upper case conversion)
 - rust-lang/rust#160502 (Reduce number of miri tests executed on PR CI)
 - rust-lang/rust#157430 (std::random: use little-endian for reproducibility)
 - rust-lang/rust#158110 (fix macro attribute feature-gate span)
 - rust-lang/rust#159975 (Use real ThinVec in StmtDebugInfos)
 - rust-lang/rust#160001 (Suggest mutable method when iterating over binding)
 - rust-lang/rust#160024 (Fix mono reachability with no-op landing pads)
 - rust-lang/rust#160154 (Add regression test for HRTB associated type projection closure)
 - rust-lang/rust#160176 (No more `tests/ui/issues`!)
 - rust-lang/rust#160326 (Remove hidden_glob_reexports)
 - rust-lang/rust#160407 (Add regression tests for a number of ICEs and diagnostics issues labelled `E-needs-test`)
 - rust-lang/rust#160430 (bootstrap: Don't produce mutated/filtered PathSets during command-line matching)
 - rust-lang/rust#160472 (Minor fixes to `core::io` & `alloc::io` Documentation)
 - rust-lang/rust#160486 (Remove unused `FreeRegionsVisitor`)
 - rust-lang/rust#160496 (clarify non-determinism docs for algebraic operations)

Failed merges:

 - rust-lang/rust#160501 (Add bootstrap CLI snapshot test for testing miri)
@khyperia
khyperia deleted the move-normalize-to-relations branch August 5, 2026 07:29
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. 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.

5 participants