Skip to content

Normalize non-rigid aliases in ty_known_to_outlive - #161246

Open
amirHdev wants to merge 1 commit into
rust-lang:mainfrom
amirHdev:fix-161067-non-rigid-alias
Open

amirHdev wants to merge 1 commit into
rust-lang:mainfrom
amirHdev:fix-161067-non-rigid-alias

Conversation

@amirHdev

@amirHdev amirHdev commented Aug 17, 2026

Copy link
Copy Markdown
Contributor

View all comments

Fixes #161067

ty_known_to_outlive directly registers a TypeOutlives region obligation without normalization. With the next solver, we do not expect non-rigid aliases in lexical region solving.

Normalize non-rigid aliases before registering the obligation while avoiding trait solving for inputs that do not contain them.

@amirHdev
amirHdev force-pushed the fix-161067-non-rigid-alias branch 2 times, most recently from 1103014 to b881312 Compare August 18, 2026 07:53
@rustbot rustbot added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Aug 18, 2026
@rust-log-analyzer

This comment has been minimized.

@amirHdev
amirHdev force-pushed the fix-161067-non-rigid-alias branch 3 times, most recently from d0aeadc to 8806add Compare August 20, 2026 10:51
@amirHdev amirHdev changed the title fix: normalize non-rigid aliases in ty_known_to_outlive Normalize non-rigid aliases in ty_known_to_outlive Aug 20, 2026
@amirHdev
amirHdev force-pushed the fix-161067-non-rigid-alias branch from 8806add to 52cc388 Compare August 21, 2026 13:55
@amirHdev
amirHdev marked this pull request as ready for review August 21, 2026 13:58
@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Aug 21, 2026
@rustbot

This comment was marked as outdated.

@fmease

fmease commented Aug 23, 2026

Copy link
Copy Markdown
Member

r? lcnr

@rustbot rustbot assigned lcnr and unassigned dingxiangfei2009 Aug 23, 2026
@lcnr

lcnr commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

r? adwinwhite I think

@rustbot rustbot assigned adwinwhite and unassigned lcnr Sep 7, 2026
parent_param_env,
&wf_tys,
t,
ty::Unnormalized::new_wip(t),

@adwinwhite adwinwhite Sep 15, 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.

We probably don't want to have trait solving inside liveness analysis.
The types here are actually Params so they don't need normalization.
A quick solution is to have a private ty_known_to_outlive in this module, duplicated from the original impl.
A minimal param outlives evaluator would be good but we need to handle region graph. Then it's no longer minimal :<

As a micro-optimization, we can use resolve_regions_with_outlives_env rather than resolve_regions in this private helper since the wf_tys are the same. This might not matter.

View changes since the review

})
let infcx = tcx.infer_ctxt().build(TypingMode::non_body_analysis());

let ty = ty.skip_norm_wip();

@adwinwhite adwinwhite Sep 15, 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.

We only need to skip in the old solver branch.

View changes since the review

Comment thread compiler/rustc_trait_selection/src/regions.rs Outdated
Comment thread compiler/rustc_trait_selection/src/regions.rs Outdated
ty: Unnormalized<'tcx, Ty<'tcx>>,
region: ty::Region<'tcx>,
) -> bool {
test_region_obligations(tcx, id, param_env, wf_tys, |infcx| {

@adwinwhite adwinwhite Sep 15, 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.

we can still use test_region_obligations and just normalize the ty?

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 that's the part I overlooked 😬 I reused test_region_obligations here

@adwinwhite

Copy link
Copy Markdown
Contributor

Thanks for working on this!

@rustbot author

@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 Sep 15, 2026
@rustbot

rustbot commented Sep 15, 2026

Copy link
Copy Markdown
Collaborator

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

@rustbot

This comment has been minimized.

@rustbot

rustbot commented Sep 15, 2026

Copy link
Copy Markdown
Collaborator

⚠️ Warning ⚠️

  • The following commits have merge commits (commits with multiple parents) in your changes. We have a no merge policy so these commits will need to be removed for this pull request to be merged.

    You can start a rebase with the following commands:

    $ # rebase
    $ git pull --rebase https://github.com/rust-lang/rust.git main
    $ git push --force-with-lease
    

@rustbot rustbot added the has-merge-commits PR has merge commits, merge with caution. label Sep 15, 2026
@amirHdev
amirHdev force-pushed the fix-161067-non-rigid-alias branch from b7361f8 to ed266c7 Compare September 15, 2026 11:05
@rust-log-analyzer

This comment has been minimized.

@amirHdev
amirHdev force-pushed the fix-161067-non-rigid-alias branch from ed266c7 to 66801ea Compare September 15, 2026 11:15
@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Sep 16, 2026
@rust-log-analyzer

This comment has been minimized.

@amirHdev
amirHdev force-pushed the fix-161067-non-rigid-alias branch from 816b78c to b1a9216 Compare September 16, 2026 07:35
@rust-log-analyzer

This comment has been minimized.

@amirHdev
amirHdev force-pushed the fix-161067-non-rigid-alias branch from b1a9216 to 7f7e359 Compare September 16, 2026 07:45
@adwinwhite

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 Sep 17, 2026
@rust-bors

This comment has been minimized.

rust-bors Bot pushed a commit that referenced this pull request Sep 17, 2026
Normalize non-rigid aliases in ty_known_to_outlive
@rust-bors

rust-bors Bot commented Sep 17, 2026

Copy link
Copy Markdown
Contributor

☀️ Try build successful (CI)
Build commit: 8fb5e25 (8fb5e252455e58022a18ace472331d58600f2600)
Base parent: 923c95c (923c95cdf5ba65cea505aa2ea829f578e1506ed8)

@rust-timer

This comment has been minimized.

@rust-timer

Copy link
Copy Markdown
Collaborator

Finished benchmarking commit (8fb5e25): comparison URL.

Overall result: no relevant changes - 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

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

Max RSS (memory usage)

Results (secondary -2.1%)

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.4% [2.3%, 4.5%] 2
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-4.0% [-4.7%, -1.6%] 6
All ❌✅ (primary) - - 0

Cycles

Results (secondary 2.5%)

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

Binary size

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

Bootstrap: 497.899s -> 498.337s (0.09%)
Artifact size: 406.75 MiB -> 408.85 MiB (0.51%)

@rustbot rustbot removed the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Sep 17, 2026
@adwinwhite

Copy link
Copy Markdown
Contributor

@bors r+ rollup

@rust-bors

rust-bors Bot commented Sep 17, 2026

Copy link
Copy Markdown
Contributor

📌 Commit 7f7e359 has been approved by adwinwhite

It is now in the queue for this repository.

@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 Sep 17, 2026
Zalathar added a commit to Zalathar/rust that referenced this pull request Sep 17, 2026
…s, r=adwinwhite

Normalize non-rigid aliases in ty_known_to_outlive

Fixes rust-lang#161067

`ty_known_to_outlive` directly registers a TypeOutlives region obligation without normalization. With the next solver, we do not expect non-rigid aliases in lexical region solving.

Normalize non-rigid aliases before registering the obligation while avoiding trait solving for inputs that do not contain them.
rust-bors Bot pushed a commit that referenced this pull request Sep 17, 2026
Rollup of 16 pull requests

Successful merges:

 - #161596 (coretests: Add more pattern tests.)
 - #162796 (libtest: do not early exit from test runners)
 - #162844 (Add loan reachability traces to polonius MIR dumps)
 - #162876 (Move operations out of `rustc_middle::query::job`)
 - #160108 (Stabilize `windows_process_extensions_main_thread_handle`)
 - #160212 (traits: Fix rigid alias liveness matching)
 - #160544 (Stabilize `feature(trim_prefix_suffix)` (`{str, [T], Path}::trim_prefix` and `{str, [T]}::trim_suffix`))
 - #161246 (Normalize non-rigid aliases in ty_known_to_outlive)
 - #161305 (Use the entire type of a dropped local to compute variance (edge direction) for Polonius alpha)
 - #161838 (tests: accept LLVM 24 optimization in this test)
 - #162805 (Add `must_use` lint to `ExitCode`)
 - #162825 (core: Add examples for `debug_closure_helpers`)
 - #162841 (enable asm tests for xtensa targets)
 - #162842 (reintroduce check RibKind::ConstParamTy did in direct consts)
 - #162845 (mgca: fix issue with mismatched array valtree/valtree tys)
 - #162856 (Stabilize CommandExt::show_window)
@@ -0,0 +1,17 @@
//@ compile-flags: -Zassumptions-on-binders
//@ needs-rustc-debug-assertions
//@ normalize-stderr: "(\n)\n$" -> "$1"

@lcnr lcnr Sep 17, 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.

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.

this was only normalizing an extra trailing newline in stderr

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.

pls remove, that doesn't feel worth it

param_env: ty::ParamEnv<'tcx>,
wf_tys: &FxIndexSet<Ty<'tcx>>,
add_constraints: impl FnOnce(&InferCtxt<'tcx>),
add_constraints: impl FnOnce(&InferCtxt<'tcx>) -> bool,

@lcnr lcnr Sep 17, 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.

maybe Result<(), ()> instead of bool?

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.

the bool is only being used to signal normalization failure. I think Result is clearer here

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.

do you want me to update this and cleanup now ?

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.

either now, or in a separate PR. I guess if u fix the ui test, doing it in this PR would be easier

Signed-off-by: Amirhossein Akhlaghpour <m9.akhlaghpoor@gmail.com>
@amirHdev
amirHdev force-pushed the fix-161067-non-rigid-alias branch from 7f7e359 to c6c7dfd Compare September 17, 2026 11:39
@rust-bors rust-bors Bot 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-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Sep 17, 2026
@rust-bors

rust-bors Bot commented Sep 17, 2026

Copy link
Copy Markdown
Contributor

⚠️ A new commit c6c7dfd27c2dfcfba28372a3612e5169d61834ee was pushed.

This pull request was unapproved.

This PR was contained in a rollup (#162887), which was closed.

@amirHdev
amirHdev requested a review from lcnr September 17, 2026 11:40
wf_tys: &FxIndexSet<Ty<'tcx>>,
add_constraints: impl FnOnce(&InferCtxt<'tcx>),
add_constraints: impl FnOnce(&InferCtxt<'tcx>) -> Result<(), ()>,
) -> bool {

@lcnr lcnr Sep 17, 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.

don't have to do it in this PR, but you can also return Result here and imo should do so then you can do ?

View changes since the review

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

has-merge-commits PR has merge commits, merge with caution. S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. 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]: Alias has non-rigid aliases

8 participants