Skip to content

-Zassumptions-on-binders: rewrite alias outlives constraints more goodly - #163938

Open
BoxyUwU wants to merge 2 commits into
rust-lang:mainfrom
BoxyUwU:abby_more_correct_alias_rewriting
Open

BoxyUwU wants to merge 2 commits into
rust-lang:mainfrom
BoxyUwU:abby_more_correct_alias_rewriting

Conversation

@BoxyUwU

@BoxyUwU BoxyUwU commented Oct 7, 2026

Copy link
Copy Markdown
Member

r? @khyperia

best reviewed commit by commit. there are two improvements here.

First, we no longer rewrite alias outlives constraints if they're not in the current universe. Previously we did so and it resulted in rewriting alias outlives constraints to false because of there being no assumptions available (because we only know assumptions for the current universe). I think this was just a whoopsie from my original PR because the other places we compute candidates do check the universe first lol.

Second I merged the two codepaths which compute candidates via replacing current-universe-placeholders with bound vars. One of them did this for the whole constraint, the other did this just for the alias and elaborated the outlived region in Alias: 'a into an OR of all the regions larger than 'a. e.g. OR(Alias: 'b, Alias: 'c) given assumptions that 'a: 'b and 'a: 'c hold.

Merging them together makes the code a lot nicer but also is a slight correctness improvement as we can now get more specific constraints back when rewriting alias outlives, which means we need less general assumptions to prove them :3 See added test in the commit.

Though, after updating the expect in that test it still passed on main before this PR because of rust-lang/project-assumptions-on-binders#26

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

rustbot commented Oct 7, 2026

Copy link
Copy Markdown
Collaborator

khyperia is not on the review rotation at the moment.
They may take a while to respond.

@rust-log-analyzer

Copy link
Copy Markdown
Collaborator

The job test-x86_64-gnu-gcc failed! Check out the build log: (web) (plain enhanced) (plain)

Click to see the possible cause of the failure (guessed by this bot)
---- [ui] tests/ui/assumptions_on_binders/lower_universe_alias_outlives.rs stdout ----

error: test compilation failed although it shouldn't!
status: exit status: 101
command: env -u RUSTC_LOG_COLOR RUSTC_ICE="0" RUST_BACKTRACE="short" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/tests/ui/assumptions_on_binders/lower_universe_alias_outlives.rs" "-Zsimulate-remapped-rust-src-base=/rustc/FAKE_PREFIX" "-Ztranslate-remapped-path-to-local-path=no" "-Z" "ignore-directory-in-diagnostics-source-blocks=/cargo" "-Z" "ignore-directory-in-diagnostics-source-blocks=/checkout/vendor" "--sysroot" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2" "-Zcodegen-backend=gcc" "--target=x86_64-unknown-linux-gnu" "--check-cfg" "cfg(test,FALSE)" "--error-format" "json" "--json" "future-incompat" "-Ccodegen-units=1" "-Zui-testing" "-Zdeduplicate-diagnostics=no" "-Zwrite-long-types-to-disk=no" "-Cstrip=debuginfo" "--emit" "metadata" "-C" "prefer-dynamic" "--out-dir" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/assumptions_on_binders/lower_universe_alias_outlives" "-Znext-solver=coherence" "-A" "unused" "-W" "unused_attributes" "-A" "internal_features" "-A" "incomplete_features" "-A" "unused_parens" "-A" "unused_braces" "-Crpath" "-Cdebuginfo=0" "-Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "--edition=2015"
stdout: none
--- stderr -------------------------------

thread 'rustc' (30830) panicked at compiler/rustc_type_ir/src/region_constraint.rs:692:21:
assertion failed: max_universe(infcx, c.clone()) < u
stack backtrace:
   0: __rustc::rust_begin_unwind
   1: core::panicking::panic_fmt
   2: core::panicking::panic
   3: rustc_type_ir::region_constraint::eagerly_handle_placeholders_in_universe::<rustc_infer::infer::InferCtxt, rustc_middle::ty::context::TyCtxt>
   4: <rustc_infer::infer::InferCtxt>::enter_forall::<rustc_hir_analysis::check::wfcheck::WithWhereClauses<rustc_hir_analysis::check::wfcheck::TestBinderBody>, (), <rustc_hir_analysis::check::wfcheck::WfCheckingCtxt>::check_test_binder_forall::{closure#0}>
   5: <rustc_hir_analysis::check::wfcheck::WfCheckingCtxt>::check_test_binder_body
   6: rustc_hir_analysis::check::wfcheck::enter_wf_checking_ctxt::<rustc_hir_analysis::check::check::check_item_type::{closure#3}>
   7: rustc_hir_analysis::check::check::check_item_type
   8: rustc_hir_analysis::check::wfcheck::check_well_formed
      [... omitted 1 frame ...]
   9: rustc_data_structures::sync::parallel::try_par_for_each_in::<&[rustc_hir::hir::ItemId], rustc_span::ErrorGuaranteed, <rustc_middle::hir::ModuleItems>::par_items<rustc_hir_analysis::check::wfcheck::check_type_wf::{closure#0}>::{closure#0}>
  10: rustc_hir_analysis::check::wfcheck::check_type_wf
      [... omitted 1 frame ...]
  11: rustc_hir_analysis::check_crate
  12: rustc_interface::passes::analysis
      [... omitted 1 frame ...]
  13: <std::thread::local::LocalKey<core::cell::Cell<*const ()>>>::with::<rustc_middle::ty::context::tls::enter_context<<rustc_middle::ty::context::GlobalCtxt>::enter<rustc_interface::passes::create_and_enter_global_ctxt<core::option::Option<rustc_interface::queries::Linker>, rustc_driver_impl::compiler_entrypoint::{closure#0}::{closure#1}>::{closure#2}, core::option::Option<rustc_interface::queries::Linker>>::{closure#1}, core::option::Option<rustc_interface::queries::Linker>>::{closure#0}, core::option::Option<rustc_interface::queries::Linker>>
  14: <rustc_middle::ty::context::TyCtxt>::create_global_ctxt::<core::option::Option<rustc_interface::queries::Linker>, rustc_interface::passes::create_and_enter_global_ctxt<core::option::Option<rustc_interface::queries::Linker>, rustc_driver_impl::compiler_entrypoint::{closure#0}::{closure#1}>::{closure#2}>
  15: rustc_interface::passes::create_and_enter_global_ctxt::<core::option::Option<rustc_interface::queries::Linker>, rustc_driver_impl::compiler_entrypoint::{closure#0}::{closure#1}>
  16: <scoped_tls::ScopedKey<rustc_span::SessionGlobals>>::set::<rustc_interface::util::run_in_thread_with_globals<rustc_interface::util::run_in_thread_pool_with_globals<rustc_interface::interface::run_compiler<(), rustc_driver_impl::compiler_entrypoint::{closure#0}>::{closure#2}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}::{closure#0}, ()>
  17: rustc_span::create_session_globals_then::<(), rustc_interface::util::run_in_thread_with_globals<rustc_interface::util::run_in_thread_pool_with_globals<rustc_interface::interface::run_compiler<(), rustc_driver_impl::compiler_entrypoint::{closure#0}>::{closure#2}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}::{closure#0}>
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

error: the compiler unexpectedly panicked. This is a bug

note: using internal features is not supported and expected to cause internal compiler errors when used incorrectly

note: rustc 1.101.0-nightly (a75e6a934 2026-10-07) running on x86_64-unknown-linux-gnu

note: compiler flags: -Z simulate-remapped-rust-src-base=/rustc/FAKE_PREFIX -Z translate-remapped-path-to-local-path=no -Z ignore-directory-in-diagnostics-source-blocks=/cargo -Z ignore-directory-in-diagnostics-source-blocks=/checkout/vendor -Z codegen-backend=gcc -C codegen-units=1 -Z ui-testing -Z deduplicate-diagnostics=no -Z write-long-types-to-disk=no -C strip=debuginfo -C prefer-dynamic -Z next-solver=coherence -C rpath -C debuginfo=0

query stack during panic:
#0 [check_well_formed] checking that `{test_binder_constraints#0}` is well-formed
#1 [check_type_wf] checking that types are well-formed
#2 [analysis] running analysis passes on crate `lower_universe_alias_outlives`
end of query stack
------------------------------------------

---- [ui] tests/ui/assumptions_on_binders/lower_universe_alias_outlives.rs stdout end ----
---
70                'static,
+                $DIR/test-infra-fails-properly.rs:58:9: 58:15 (#0),
71            )
72 
73 error: bound type test binder constraint must be alias (it's a AliasTyOutlivesViaEnv)

Note: some mismatched output was normalized before being compared
-                /checkout/tests/ui/assumptions_on_binders/test-infra-fails-properly.rs:63:17: 63:23 (#0),
-                /checkout/tests/ui/assumptions_on_binders/test-infra-fails-properly.rs:58:9: 58:15 (#0),
+                $DIR/test-infra-fails-properly.rs:63:17: 63:23 (#0),
---
To only update this specific test, also pass `--test-args assumptions_on_binders/test-infra-fails-properly.rs`

error: 1 errors occurred comparing output.
status: exit status: 1
command: env -u RUSTC_LOG_COLOR RUSTC_ICE="0" RUST_BACKTRACE="short" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/tests/ui/assumptions_on_binders/test-infra-fails-properly.rs" "-Zsimulate-remapped-rust-src-base=/rustc/FAKE_PREFIX" "-Ztranslate-remapped-path-to-local-path=no" "-Z" "ignore-directory-in-diagnostics-source-blocks=/cargo" "-Z" "ignore-directory-in-diagnostics-source-blocks=/checkout/vendor" "--sysroot" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2" "-Zcodegen-backend=gcc" "--target=x86_64-unknown-linux-gnu" "--check-cfg" "cfg(test,FALSE)" "--error-format" "json" "--json" "future-incompat" "-Ccodegen-units=1" "-Zui-testing" "-Zdeduplicate-diagnostics=no" "-Zwrite-long-types-to-disk=no" "-Cstrip=debuginfo" "--emit" "metadata" "-C" "prefer-dynamic" "--out-dir" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/assumptions_on_binders/test-infra-fails-properly" "-Znext-solver=coherence" "-A" "unused" "-W" "unused_attributes" "-A" "internal_features" "-A" "incomplete_features" "-A" "unused_parens" "-A" "unused_braces" "-Crpath" "-Cdebuginfo=0" "-Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "--edition=2015" "-Zassumptions-on-binders" "-Znext-solver=globally"
stdout: none
--- stderr -------------------------------
error: expected one of `!`, `(`, `+`, `::`, `:`, or `<`, found `{`
##[error]  --> /checkout/tests/ui/assumptions_on_binders/test-infra-fails-properly.rs:15:20
   |
LL |             forall { }
   |                    ^ expected one of `!`, `(`, `+`, `::`, `:`, or `<`

error: expected one of `!`, `(`, `+`, `::`, `:`, or `<`, found `{`
##[error]  --> /checkout/tests/ui/assumptions_on_binders/test-infra-fails-properly.rs:24:20
   |
LL |             forall { }
   |                    ^ expected one of `!`, `(`, `+`, `::`, `:`, or `<`

error: expected lifetime, found keyword `for`
##[error]  --> /checkout/tests/ui/assumptions_on_binders/test-infra-fails-properly.rs:41:12
   |
LL |         T: for<'b> Trait<'b>,
---
   |                ^
   |
   = note: see issue #108185 <https://github.com/rust-lang/rust/issues/108185> for more information
   = help: add `#![feature(non_lifetime_binders)]` to the crate attributes to enable
   = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date

error: higher-ranked lifetime bound could not be satisfied
##[error]  --> /checkout/tests/ui/assumptions_on_binders/test-infra-fails-properly.rs:7:9
   |
LL |         'a: 'b
   |         ^^^^^^

error: the lhs of a ty outlives must be a placeholder
##[error]  --> /checkout/tests/ui/assumptions_on_binders/test-infra-fails-properly.rs:34:9
   |
LL |         dyn for<'b> Trait<'b>: 'a,
   |         ^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: it is a (dyn for<'b> Trait<'b> + 'static)
   = note: and here it is `Debug`ged :3 dyn [Binder { value: Trait(Trait<'b>), bound_vars: [Region(BrNamed(DefId(0:11 ~ test_infra_fails_properly[2377]::{test_binder_constraints#1}::'b)))] }] + 'static

error: the lhs of a ty outlives must be a placeholder
##[error]  --> /checkout/tests/ui/assumptions_on_binders/test-infra-fails-properly.rs:50:13
   |
LL |             T: 'a,
   |             ^^^^^
   |
   = note: it is a {type error}
   = note: and here it is `Debug`ged :3 {type error}

error: forall expect clause failed
##[error]  --> /checkout/tests/ui/assumptions_on_binders/test-infra-fails-properly.rs:63:17
   |
LL |                 'b: 'c,
---
               'static,
               /checkout/tests/ui/assumptions_on_binders/test-infra-fails-properly.rs:58:9: 58:15 (#0),
           )

error: bound type test binder constraint must be alias (it's a AliasTyOutlivesViaEnv)
##[error]  --> /checkout/tests/ui/assumptions_on_binders/test-infra-fails-properly.rs:72:15
   |
LL |         for<> T: 'a
   |               ^

Important

For more information how to resolve CI failures of this job, visit this link.

@BoxyUwU

BoxyUwU commented Oct 7, 2026

Copy link
Copy Markdown
Member Author

is there nothing good in this world of ours

@BoxyUwU

BoxyUwU commented Oct 7, 2026

Copy link
Copy Markdown
Member Author

blocked on #163937 I guess lol

@khyperia khyperia left a comment •

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.

new version is so much easier to read, nice! lgtm, r=me when test bless garbage blah blah

View changes since this review

@khyperia khyperia 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 Oct 8, 2026
@rust-bors

rust-bors Bot commented Oct 8, 2026

Copy link
Copy Markdown
Contributor

☔ The latest upstream changes (presumably #163970) made this pull request unmergeable. Please resolve the merge conflicts by rebasing.

This branch has not been deployed

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

Labels

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.

4 participants