Skip to content

Support leak check for new style region constraint - #164350

Draft
adwinwhite wants to merge 2 commits into
rust-lang:mainfrom
adwinwhite:abby_leak_check2
Draft

adwinwhite wants to merge 2 commits into
rust-lang:mainfrom
adwinwhite:abby_leak_check2

Conversation

@adwinwhite

@adwinwhite adwinwhite commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

Supporting leak check is straightforward now that we have a constraint list like before.
TODO: write description to reflect latest changes.
Blocked: handle leaf region constraints from relating.

r? Boxyuwu

@rustbot rustbot added 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. WG-trait-system-refactor The Rustc Trait System Refactor Initiative (-Znext-solver) labels Oct 15, 2026
@rustbot

rustbot commented Oct 15, 2026

Copy link
Copy Markdown
Collaborator

Boxyuwu is currently at their maximum review capacity.
They may take a while to respond.

Comment on lines +775 to +776
// FIXME: unsure about whether the inherited `VisibleForLeakCheck` is correct.
candidates.push(RegionOutlives(ub, lb, visible_for_leak_check, ()));

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

unsure about whether the inheriting is correct 🤔

View changes since the review

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.

yep seems right to me

@rust-log-analyzer

This comment has been minimized.

@rust-bors

This comment has been minimized.

@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/type_relation_binders_inside_solver-1.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/type_relation_binders_inside_solver-1.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/type_relation_binders_inside_solver-1" "-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]error: internal compiler error: compiler/rustc_infer/src/infer/region_constraints/leak_check.rs:480:25: We use the old region constraint when assumptions_on_binders is on


thread 'rustc' (31687) panicked at compiler/rustc_infer/src/infer/region_constraints/leak_check.rs:480:25:
Box<dyn Any>
stack backtrace:
   0: std::panicking::begin_panic::<rustc_span::macros::ExplicitBug>
   1: rustc_span::macros::bug_impl
   2: <rustc_infer::infer::region_constraints::RegionConstraintCollector>::leak_check
   3: <rustc_infer::infer::InferCtxt>::leak_check
   4: <rustc_infer::infer::InferCtxt>::commit_if_ok::<rustc_infer::infer::InferOk<rustc_middle::ty::Ty>, rustc_type_ir::error::TypeError<rustc_middle::ty::context::TyCtxt>, <rustc_hir_typeck::coercion::Coerce>::unify_raw::{closure#0}>
   5: <rustc_hir_typeck::coercion::Coerce>::coerce
   6: <rustc_hir_typeck::fn_ctxt::FnCtxt>::coerce
   7: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_argument_types
   8: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_expr_call
   9: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  10: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_expr_block
  11: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  12: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_return_or_body_tail
  13: rustc_hir_typeck::check::check_fn
  14: rustc_hir_typeck::typeck_with_inspect
      [... omitted 1 frame ...]
  15: <rustc_middle::query::calls::TyCtxtEnsureOk>::typeck::<rustc_span::def_id::LocalDefId>
  16: <rustc_middle::ty::context::TyCtxt>::par_hir_body_owners::<rustc_hir_analysis::check_crate::{closure#1}>::{closure#0}
  17: rustc_data_structures::sync::parallel::par_for_each_in::<rustc_span::def_id::LocalDefId, [rustc_span::def_id::LocalDefId], <rustc_middle::ty::context::TyCtxt>::par_hir_body_owners<rustc_hir_analysis::check_crate::{closure#1}>::{closure#0}>
  18: rustc_hir_analysis::check_crate
  19: rustc_interface::passes::analysis
      [... omitted 1 frame ...]
  20: <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>>
  21: <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}>
  22: rustc_interface::passes::create_and_enter_global_ctxt::<core::option::Option<rustc_interface::queries::Linker>, rustc_driver_impl::compiler_entrypoint::{closure#0}::{closure#1}>
  23: <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}, ()>
  24: 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.

note: we would appreciate a bug report: https://github.com/rust-lang/rust/issues/new?labels=C-bug%2C+I-ICE%2C+T-compiler&template=ice.md

note: please make sure that you have updated to the latest nightly

note: rustc 1.102.0-nightly (ec44847fc 2026-11-10) 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 -Z assumptions-on-binders -Z next-solver=globally

query stack during panic:
#0 [typeck_root] type-checking `bar`
#1 [analysis] running analysis passes on crate `type_relation_binders_inside_solver_1`
end of query stack
error: aborting due to 1 previous error
------------------------------------------

---- [ui] tests/ui/assumptions_on_binders/type_relation_binders_inside_solver-1.rs stdout end ----
---- [ui] tests/ui/assumptions_on_binders/type_relation_binders_inside_solver-2.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/type_relation_binders_inside_solver-2.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/type_relation_binders_inside_solver-2" "-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]error: internal compiler error: compiler/rustc_infer/src/infer/region_constraints/leak_check.rs:480:25: We use the old region constraint when assumptions_on_binders is on


thread 'rustc' (31695) panicked at compiler/rustc_infer/src/infer/region_constraints/leak_check.rs:480:25:
Box<dyn Any>
stack backtrace:
   0: std::panicking::begin_panic::<rustc_span::macros::ExplicitBug>
   1: rustc_span::macros::bug_impl
   2: <rustc_infer::infer::region_constraints::RegionConstraintCollector>::leak_check
   3: <rustc_infer::infer::InferCtxt>::leak_check
   4: <rustc_infer::infer::InferCtxt>::commit_if_ok::<rustc_infer::infer::InferOk<rustc_middle::ty::Ty>, rustc_type_ir::error::TypeError<rustc_middle::ty::context::TyCtxt>, <rustc_hir_typeck::coercion::Coerce>::unify_raw::{closure#0}>
   5: <rustc_hir_typeck::coercion::Coerce>::coerce
   6: <rustc_hir_typeck::fn_ctxt::FnCtxt>::coerce
   7: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_argument_types
   8: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_expr_call
   9: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  10: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_expr_block
  11: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  12: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_return_or_body_tail
  13: rustc_hir_typeck::check::check_fn
  14: rustc_hir_typeck::typeck_with_inspect
      [... omitted 1 frame ...]
  15: <rustc_middle::query::calls::TyCtxtEnsureOk>::typeck::<rustc_span::def_id::LocalDefId>
  16: <rustc_middle::ty::context::TyCtxt>::par_hir_body_owners::<rustc_hir_analysis::check_crate::{closure#1}>::{closure#0}
  17: rustc_data_structures::sync::parallel::par_for_each_in::<rustc_span::def_id::LocalDefId, [rustc_span::def_id::LocalDefId], <rustc_middle::ty::context::TyCtxt>::par_hir_body_owners<rustc_hir_analysis::check_crate::{closure#1}>::{closure#0}>
  18: rustc_hir_analysis::check_crate
  19: rustc_interface::passes::analysis
      [... omitted 1 frame ...]
  20: <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>>
  21: <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}>
  22: rustc_interface::passes::create_and_enter_global_ctxt::<core::option::Option<rustc_interface::queries::Linker>, rustc_driver_impl::compiler_entrypoint::{closure#0}::{closure#1}>
  23: <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}, ()>
  24: 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.

note: we would appreciate a bug report: https://github.com/rust-lang/rust/issues/new?labels=C-bug%2C+I-ICE%2C+T-compiler&template=ice.md

note: please make sure that you have updated to the latest nightly

note: rustc 1.102.0-nightly (ec44847fc 2026-11-10) 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 -Z assumptions-on-binders -Z next-solver=globally

query stack during panic:
#0 [typeck_root] type-checking `bar`
#1 [analysis] running analysis passes on crate `type_relation_binders_inside_solver_2`
end of query stack
error: aborting due to 1 previous error
------------------------------------------

---- [ui] tests/ui/assumptions_on_binders/type_relation_binders_inside_solver-2.rs stdout end ----

Important

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

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. 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.

4 participants