Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ICE: escaping bound type during canonicalization #132530

Closed
matthiaskrgr opened this issue Nov 2, 2024 · 1 comment · Fixed by #132832
Closed

ICE: escaping bound type during canonicalization #132530

matthiaskrgr opened this issue Nov 2, 2024 · 1 comment · Fixed by #132832
Labels
C-bug Category: This is a bug. F-non_lifetime_binders `#![feature(non_lifetime_binders)]` I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ S-bug-has-test Status: This bug is tracked inside the repo by a `known-bug` test. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@matthiaskrgr
Copy link
Member

snippet:

#![feature(non_lifetime_binders)]

trait Trait<'a, A, B> {
    type Assoc<'a> = i32;
}

fn produce() -> impl for<T> Trait<(), Assoc = impl Trait<T>> {
    16
}

Version information

rustc 1.84.0-nightly (588a42035 2024-11-02)
binary: rustc
commit-hash: 588a4203508ed7c76750c96b482641261630ed36
commit-date: 2024-11-02
host: x86_64-unknown-linux-gnu
release: 1.84.0-nightly
LLVM version: 19.1.3

Possibly related line of code:

t,
)
}
ty::Bound(debruijn, _) => {
if debruijn >= self.binder_index {
bug!("escaping bound type during canonicalization")
} else {
t
}
}
ty::Closure(..)

Command:
/home/matthias/.rustup/toolchains/master/bin/rustc

Program output

error[E0496]: lifetime name `'a` shadows a lifetime name that is already in scope
 --> /tmp/icemaker_global_tempdir.zyPSUovK6G46/rustc_testrunner_tmpdir_reporting.xCCgbBIdqPg5/mvce.rs:4:16
  |
3 | trait Trait<'a, A, B> {
  |             -- first declared here
4 |     type Assoc<'a> = i32;
  |                ^^ lifetime `'a` already in scope

error[E0106]: missing lifetime specifiers
 --> /tmp/icemaker_global_tempdir.zyPSUovK6G46/rustc_testrunner_tmpdir_reporting.xCCgbBIdqPg5/mvce.rs:7:34
  |
7 | fn produce() -> impl for<T> Trait<(), Assoc = impl Trait<T>> {
  |                                  ^                      ^ expected named lifetime parameter
  |                                  |
  |                                  expected named lifetime parameter
  |
  = help: this function's return type contains a borrowed value, but there is no value for it to be borrowed from
help: consider using the `'static` lifetime, but this is uncommon unless you're returning a borrowed value from a `const` or a `static`
  |
7 | fn produce() -> impl for<T> Trait<'static, (), Assoc = impl Trait<'static, T>> {
  |                                   ++++++++                        ++++++++

error[E0658]: associated type defaults are unstable
 --> /tmp/icemaker_global_tempdir.zyPSUovK6G46/rustc_testrunner_tmpdir_reporting.xCCgbBIdqPg5/mvce.rs:4:5
  |
4 |     type Assoc<'a> = i32;
  |     ^^^^^^^^^^^^^^^^^^^^^
  |
  = note: see issue #29661 <https://github.com/rust-lang/rust/issues/29661> for more information
  = help: add `#![feature(associated_type_defaults)]` to the crate attributes to enable
  = note: this compiler was built on 2024-11-02; consider upgrading it if it is out of date

warning: the feature `non_lifetime_binders` is incomplete and may not be safe to use and/or cause compiler crashes
 --> /tmp/icemaker_global_tempdir.zyPSUovK6G46/rustc_testrunner_tmpdir_reporting.xCCgbBIdqPg5/mvce.rs:1:12
  |
1 | #![feature(non_lifetime_binders)]
  |            ^^^^^^^^^^^^^^^^^^^^
  |
  = note: see issue #108185 <https://github.com/rust-lang/rust/issues/108185> for more information
  = note: `#[warn(incomplete_features)]` on by default

error[E0601]: `main` function not found in crate `mvce`
 --> /tmp/icemaker_global_tempdir.zyPSUovK6G46/rustc_testrunner_tmpdir_reporting.xCCgbBIdqPg5/mvce.rs:9:2
  |
9 | }
  |  ^ consider adding a `main` function to `/tmp/icemaker_global_tempdir.zyPSUovK6G46/rustc_testrunner_tmpdir_reporting.xCCgbBIdqPg5/mvce.rs`

error[E0107]: trait takes 2 generic arguments but 1 generic argument was supplied
 --> /tmp/icemaker_global_tempdir.zyPSUovK6G46/rustc_testrunner_tmpdir_reporting.xCCgbBIdqPg5/mvce.rs:7:29
  |
7 | fn produce() -> impl for<T> Trait<(), Assoc = impl Trait<T>> {
  |                             ^^^^^ -- supplied 1 generic argument
  |                             |
  |                             expected 2 generic arguments
  |
note: trait defined here, with 2 generic parameters: `A`, `B`
 --> /tmp/icemaker_global_tempdir.zyPSUovK6G46/rustc_testrunner_tmpdir_reporting.xCCgbBIdqPg5/mvce.rs:3:7
  |
3 | trait Trait<'a, A, B> {
  |       ^^^^^     -  -
help: add missing generic argument
  |
7 | fn produce() -> impl for<T> Trait<(), B, Assoc = impl Trait<T>> {
  |                                     +++

error[E0107]: missing generics for associated type `Trait::Assoc`
 --> /tmp/icemaker_global_tempdir.zyPSUovK6G46/rustc_testrunner_tmpdir_reporting.xCCgbBIdqPg5/mvce.rs:7:39
  |
7 | fn produce() -> impl for<T> Trait<(), Assoc = impl Trait<T>> {
  |                                       ^^^^^ expected 1 lifetime argument
  |
note: associated type defined here, with 1 lifetime parameter: `'_`
 --> /tmp/icemaker_global_tempdir.zyPSUovK6G46/rustc_testrunner_tmpdir_reporting.xCCgbBIdqPg5/mvce.rs:4:10
  |
4 |     type Assoc<'a> = i32;
  |          ^^^^^ --
help: add missing lifetime argument
  |
7 | fn produce() -> impl for<T> Trait<(), Assoc<'_> = impl Trait<T>> {
  |                                            ++++

error[E0107]: trait takes 2 generic arguments but 1 generic argument was supplied
 --> /tmp/icemaker_global_tempdir.zyPSUovK6G46/rustc_testrunner_tmpdir_reporting.xCCgbBIdqPg5/mvce.rs:7:52
  |
7 | fn produce() -> impl for<T> Trait<(), Assoc = impl Trait<T>> {
  |                                                    ^^^^^ - supplied 1 generic argument
  |                                                    |
  |                                                    expected 2 generic arguments
  |
note: trait defined here, with 2 generic parameters: `A`, `B`
 --> /tmp/icemaker_global_tempdir.zyPSUovK6G46/rustc_testrunner_tmpdir_reporting.xCCgbBIdqPg5/mvce.rs:3:7
  |
3 | trait Trait<'a, A, B> {
  |       ^^^^^     -  -
help: add missing generic argument
  |
7 | fn produce() -> impl for<T> Trait<(), Assoc = impl Trait<T, B>> {
  |                                                           +++

error: internal compiler error: compiler/rustc_infer/src/infer/canonical/canonicalizer.rs:419:21: escaping bound type during canonicalization

thread 'rustc' panicked at compiler/rustc_infer/src/infer/canonical/canonicalizer.rs:419:21:
Box<dyn Any>
stack backtrace:
   0:     0x7c70fd05720a - <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt::hb6cd0a6bac89b6a6
   1:     0x7c70fd8040ca - core::fmt::write::haf33c0c90f8a330f
   2:     0x7c70fe7de991 - std::io::Write::write_fmt::h8e68b0ac6f9ed075
   3:     0x7c70fd057062 - std::sys::backtrace::BacktraceLock::print::hfcb510b62adfb854
   4:     0x7c70fd059566 - std::panicking::default_hook::{{closure}}::h04e002fdca100125
   5:     0x7c70fd0593b0 - std::panicking::default_hook::h4e6c1c73a1b39936
   6:     0x7c70fc0dcc49 - std[938f00e4f3f8ec0a]::panicking::update_hook::<alloc[f5b601f10d0c9e52]::boxed::Box<rustc_driver_impl[f21e318f0b376187]::install_ice_hook::{closure#0}>>::{closure#0}
   7:     0x7c70fd059c78 - std::panicking::rust_panic_with_hook::h7c34462f21943817
   8:     0x7c70fc116421 - std[938f00e4f3f8ec0a]::panicking::begin_panic::<rustc_errors[3e6fc96cf6e3ecf4]::ExplicitBug>::{closure#0}
   9:     0x7c70fc1093f6 - std[938f00e4f3f8ec0a]::sys::backtrace::__rust_end_short_backtrace::<std[938f00e4f3f8ec0a]::panicking::begin_panic<rustc_errors[3e6fc96cf6e3ecf4]::ExplicitBug>::{closure#0}, !>
  10:     0x7c70fc10918e - std[938f00e4f3f8ec0a]::panicking::begin_panic::<rustc_errors[3e6fc96cf6e3ecf4]::ExplicitBug>
  11:     0x7c70fc11fff1 - <rustc_errors[3e6fc96cf6e3ecf4]::diagnostic::BugAbort as rustc_errors[3e6fc96cf6e3ecf4]::diagnostic::EmissionGuarantee>::emit_producing_guarantee
  12:     0x7c70fc7994f3 - rustc_middle[b1d1e394adbcd929]::util::bug::opt_span_bug_fmt::<rustc_span[d3d4eeacb399f824]::span_encoding::Span>::{closure#0}
  13:     0x7c70fc77faea - rustc_middle[b1d1e394adbcd929]::ty::context::tls::with_opt::<rustc_middle[b1d1e394adbcd929]::util::bug::opt_span_bug_fmt<rustc_span[d3d4eeacb399f824]::span_encoding::Span>::{closure#0}, !>::{closure#0}
  14:     0x7c70fc77f97b - rustc_middle[b1d1e394adbcd929]::ty::context::tls::with_context_opt::<rustc_middle[b1d1e394adbcd929]::ty::context::tls::with_opt<rustc_middle[b1d1e394adbcd929]::util::bug::opt_span_bug_fmt<rustc_span[d3d4eeacb399f824]::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
  15:     0x7c70fa8cdf10 - rustc_middle[b1d1e394adbcd929]::util::bug::bug_fmt
  16:     0x7c70fe045364 - <rustc_infer[4c18d0e6e4ed5823]::infer::canonical::canonicalizer::Canonicalizer as rustc_type_ir[9c2cdde8392b485]::fold::TypeFolder<rustc_middle[b1d1e394adbcd929]::ty::context::TyCtxt>>::fold_ty
  17:     0x7c70fb32c660 - <rustc_trait_selection[f44409a29212fa61]::traits::fulfill::FulfillProcessor>::process_trait_obligation
  18:     0x7c70fdbda7df - <rustc_trait_selection[f44409a29212fa61]::traits::fulfill::FulfillProcessor as rustc_data_structures[8ffdaab02f4582f3]::obligation_forest::ObligationProcessor>::process_obligation
  19:     0x7c70fd80f3ad - <rustc_data_structures[8ffdaab02f4582f3]::obligation_forest::ObligationForest<rustc_trait_selection[f44409a29212fa61]::traits::fulfill::PendingPredicateObligation>>::process_obligations::<rustc_trait_selection[f44409a29212fa61]::traits::fulfill::FulfillProcessor>
  20:     0x7c70fd8d7849 - <rustc_hir_typeck[64dee917abf8f083]::fn_ctxt::FnCtxt>::coerce
  21:     0x7c70fe565dc7 - <rustc_hir_typeck[64dee917abf8f083]::fn_ctxt::FnCtxt>::check_block_with_expected
  22:     0x7c70fe56be70 - <rustc_hir_typeck[64dee917abf8f083]::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  23:     0x7c70fdae945b - rustc_hir_typeck[64dee917abf8f083]::check::check_fn
  24:     0x7c70fdadef35 - rustc_hir_typeck[64dee917abf8f083]::typeck
  25:     0x7c70fdade8d3 - rustc_query_impl[a29eb052c37ab918]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[a29eb052c37ab918]::query_impl::typeck::dynamic_query::{closure#2}::{closure#0}, rustc_middle[b1d1e394adbcd929]::query::erase::Erased<[u8; 8usize]>>
  26:     0x7c70fdeaa4c1 - rustc_query_system[3c80327c1b2e9be7]::query::plumbing::try_execute_query::<rustc_query_impl[a29eb052c37ab918]::DynamicConfig<rustc_query_system[3c80327c1b2e9be7]::query::caches::VecCache<rustc_span[d3d4eeacb399f824]::def_id::LocalDefId, rustc_middle[b1d1e394adbcd929]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[a29eb052c37ab918]::plumbing::QueryCtxt, false>
  27:     0x7c70fdea898d - rustc_query_impl[a29eb052c37ab918]::query_impl::typeck::get_query_non_incr::__rust_end_short_backtrace
  28:     0x7c70fe1b892b - rustc_middle[b1d1e394adbcd929]::query::plumbing::query_get_at::<rustc_query_system[3c80327c1b2e9be7]::query::caches::VecCache<rustc_span[d3d4eeacb399f824]::def_id::LocalDefId, rustc_middle[b1d1e394adbcd929]::query::erase::Erased<[u8; 8usize]>>>
  29:     0x7c70fe8197be - rustc_hir_analysis[4467b4076426cba3]::collect::type_of::type_of_opaque
  30:     0x7c70fe819711 - rustc_query_impl[a29eb052c37ab918]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[a29eb052c37ab918]::query_impl::type_of_opaque::dynamic_query::{closure#2}::{closure#0}, rustc_middle[b1d1e394adbcd929]::query::erase::Erased<[u8; 8usize]>>
  31:     0x7c70fd9b26aa - rustc_query_system[3c80327c1b2e9be7]::query::plumbing::try_execute_query::<rustc_query_impl[a29eb052c37ab918]::DynamicConfig<rustc_query_system[3c80327c1b2e9be7]::query::caches::DefIdCache<rustc_middle[b1d1e394adbcd929]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[a29eb052c37ab918]::plumbing::QueryCtxt, false>
  32:     0x7c70fea0f2b5 - rustc_query_impl[a29eb052c37ab918]::query_impl::type_of_opaque::get_query_non_incr::__rust_end_short_backtrace
  33:     0x7c70fdd5c500 - rustc_middle[b1d1e394adbcd929]::query::plumbing::query_get_at::<rustc_query_system[3c80327c1b2e9be7]::query::caches::DefIdCache<rustc_middle[b1d1e394adbcd929]::query::erase::Erased<[u8; 8usize]>>>
  34:     0x7c70fac14889 - rustc_hir_analysis[4467b4076426cba3]::collect::type_of::type_of
  35:     0x7c70fd9b3a2a - rustc_query_impl[a29eb052c37ab918]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[a29eb052c37ab918]::query_impl::type_of::dynamic_query::{closure#2}::{closure#0}, rustc_middle[b1d1e394adbcd929]::query::erase::Erased<[u8; 8usize]>>
  36:     0x7c70fd9b26aa - rustc_query_system[3c80327c1b2e9be7]::query::plumbing::try_execute_query::<rustc_query_impl[a29eb052c37ab918]::DynamicConfig<rustc_query_system[3c80327c1b2e9be7]::query::caches::DefIdCache<rustc_middle[b1d1e394adbcd929]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[a29eb052c37ab918]::plumbing::QueryCtxt, false>
  37:     0x7c70fd9b223f - rustc_query_impl[a29eb052c37ab918]::query_impl::type_of::get_query_non_incr::__rust_end_short_backtrace
  38:     0x7c70fdd5c500 - rustc_middle[b1d1e394adbcd929]::query::plumbing::query_get_at::<rustc_query_system[3c80327c1b2e9be7]::query::caches::DefIdCache<rustc_middle[b1d1e394adbcd929]::query::erase::Erased<[u8; 8usize]>>>
  39:     0x7c70fe8296c4 - rustc_hir_analysis[4467b4076426cba3]::check::check::check_item_type
  40:     0x7c70fb1fcba3 - rustc_hir_analysis[4467b4076426cba3]::check::wfcheck::check_well_formed
  41:     0x7c70fe3acb07 - rustc_query_impl[a29eb052c37ab918]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[a29eb052c37ab918]::query_impl::check_well_formed::dynamic_query::{closure#2}::{closure#0}, rustc_middle[b1d1e394adbcd929]::query::erase::Erased<[u8; 1usize]>>
  42:     0x7c70fe3ac258 - rustc_query_system[3c80327c1b2e9be7]::query::plumbing::try_execute_query::<rustc_query_impl[a29eb052c37ab918]::DynamicConfig<rustc_query_system[3c80327c1b2e9be7]::query::caches::VecCache<rustc_span[d3d4eeacb399f824]::def_id::LocalDefId, rustc_middle[b1d1e394adbcd929]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[a29eb052c37ab918]::plumbing::QueryCtxt, false>
  43:     0x7c70fe3abed0 - rustc_query_impl[a29eb052c37ab918]::query_impl::check_well_formed::get_query_non_incr::__rust_end_short_backtrace
  44:     0x7c70fe3acb87 - rustc_middle[b1d1e394adbcd929]::query::plumbing::query_ensure_error_guaranteed::<rustc_query_system[3c80327c1b2e9be7]::query::caches::VecCache<rustc_span[d3d4eeacb399f824]::def_id::LocalDefId, rustc_middle[b1d1e394adbcd929]::query::erase::Erased<[u8; 1usize]>>, ()>
  45:     0x7c70fe3ad134 - rustc_hir_analysis[4467b4076426cba3]::check::wfcheck::check_mod_type_wf
  46:     0x7c70fe3acbaf - rustc_query_impl[a29eb052c37ab918]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[a29eb052c37ab918]::query_impl::check_mod_type_wf::dynamic_query::{closure#2}::{closure#0}, rustc_middle[b1d1e394adbcd929]::query::erase::Erased<[u8; 1usize]>>
  47:     0x7c70fe3a61bd - rustc_query_system[3c80327c1b2e9be7]::query::plumbing::try_execute_query::<rustc_query_impl[a29eb052c37ab918]::DynamicConfig<rustc_query_system[3c80327c1b2e9be7]::query::caches::DefaultCache<rustc_span[d3d4eeacb399f824]::def_id::LocalModDefId, rustc_middle[b1d1e394adbcd929]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[a29eb052c37ab918]::plumbing::QueryCtxt, false>
  48:     0x7c70fe3a5f58 - rustc_query_impl[a29eb052c37ab918]::query_impl::check_mod_type_wf::get_query_non_incr::__rust_end_short_backtrace
  49:     0x7c70fdea6265 - rustc_hir_analysis[4467b4076426cba3]::check_crate
  50:     0x7c70fdd4324a - rustc_interface[71aa3b1bf0e9b32c]::passes::run_required_analyses
  51:     0x7c70fe5f709e - rustc_interface[71aa3b1bf0e9b32c]::passes::analysis
  52:     0x7c70fe5f706f - rustc_query_impl[a29eb052c37ab918]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[a29eb052c37ab918]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[b1d1e394adbcd929]::query::erase::Erased<[u8; 1usize]>>
  53:     0x7c70fe788e2e - rustc_query_system[3c80327c1b2e9be7]::query::plumbing::try_execute_query::<rustc_query_impl[a29eb052c37ab918]::DynamicConfig<rustc_query_system[3c80327c1b2e9be7]::query::caches::SingleCache<rustc_middle[b1d1e394adbcd929]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[a29eb052c37ab918]::plumbing::QueryCtxt, false>
  54:     0x7c70fe788b0e - rustc_query_impl[a29eb052c37ab918]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
  55:     0x7c70fe67421d - rustc_interface[71aa3b1bf0e9b32c]::interface::run_compiler::<core[87cd10b3002d899c]::result::Result<(), rustc_span[d3d4eeacb399f824]::ErrorGuaranteed>, rustc_driver_impl[f21e318f0b376187]::run_compiler::{closure#0}>::{closure#1}
  56:     0x7c70fe6f3010 - std[938f00e4f3f8ec0a]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[71aa3b1bf0e9b32c]::util::run_in_thread_with_globals<rustc_interface[71aa3b1bf0e9b32c]::util::run_in_thread_pool_with_globals<rustc_interface[71aa3b1bf0e9b32c]::interface::run_compiler<core[87cd10b3002d899c]::result::Result<(), rustc_span[d3d4eeacb399f824]::ErrorGuaranteed>, rustc_driver_impl[f21e318f0b376187]::run_compiler::{closure#0}>::{closure#1}, core[87cd10b3002d899c]::result::Result<(), rustc_span[d3d4eeacb399f824]::ErrorGuaranteed>>::{closure#0}, core[87cd10b3002d899c]::result::Result<(), rustc_span[d3d4eeacb399f824]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[87cd10b3002d899c]::result::Result<(), rustc_span[d3d4eeacb399f824]::ErrorGuaranteed>>
  57:     0x7c70fe6f342b - <<std[938f00e4f3f8ec0a]::thread::Builder>::spawn_unchecked_<rustc_interface[71aa3b1bf0e9b32c]::util::run_in_thread_with_globals<rustc_interface[71aa3b1bf0e9b32c]::util::run_in_thread_pool_with_globals<rustc_interface[71aa3b1bf0e9b32c]::interface::run_compiler<core[87cd10b3002d899c]::result::Result<(), rustc_span[d3d4eeacb399f824]::ErrorGuaranteed>, rustc_driver_impl[f21e318f0b376187]::run_compiler::{closure#0}>::{closure#1}, core[87cd10b3002d899c]::result::Result<(), rustc_span[d3d4eeacb399f824]::ErrorGuaranteed>>::{closure#0}, core[87cd10b3002d899c]::result::Result<(), rustc_span[d3d4eeacb399f824]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[87cd10b3002d899c]::result::Result<(), rustc_span[d3d4eeacb399f824]::ErrorGuaranteed>>::{closure#1} as core[87cd10b3002d899c]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  58:     0x7c70fe6f3ef9 - std::sys::pal::unix::thread::Thread::new::thread_start::h2150c7c4a48ccbb3
  59:     0x7c70ffef939d - <unknown>
  60:     0x7c70fff7e49c - <unknown>
  61:                0x0 - <unknown>

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.84.0-nightly (588a42035 2024-11-02) running on x86_64-unknown-linux-gnu

query stack during panic:
#0 [typeck] type-checking `produce`
#1 [type_of_opaque] computing type of opaque `produce::{opaque#0}`
end of query stack
error: aborting due to 8 previous errors; 1 warning emitted

Some errors have detailed explanations: E0106, E0107, E0496, E0601, E0658.
For more information about an error, try `rustc --explain E0106`.

@rustbot label +F-non_lifetime_binders

@matthiaskrgr matthiaskrgr added C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Nov 2, 2024
@rustbot rustbot added needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. F-non_lifetime_binders `#![feature(non_lifetime_binders)]` labels Nov 2, 2024
@matthiaskrgr
Copy link
Member Author

matthiaskrgr commented Nov 2, 2024

#![feature(non_lifetime_binders)]

trait Trait<'a, A> {
    type Assoc<'a> = i32;
}

fn a() -> impl for<T> Trait<Assoc = impl Trait<T>> {}

@saethlin saethlin removed the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Nov 2, 2024
@matthiaskrgr matthiaskrgr added the S-bug-has-test Status: This bug is tracked inside the repo by a `known-bug` test. label Nov 7, 2024
@bors bors closed this as completed in a1c98ca Nov 17, 2024
rust-timer added a commit to rust-lang-ci/rust that referenced this issue Nov 17, 2024
Rollup merge of rust-lang#132832 - compiler-errors:late-ty, r=cjgillot

Deny capturing late-bound ty/const params in nested opaques

First, this reverts a7f6095. I can't exactly remember why I approved this specific bit of rust-lang#132466; specifically, I don't know that the purpose of that commit is, and afaict we will never have an opaque that captures late-bound params through a const because opaques can't be used inside of anon consts. Am I missing something `@cjgillot?` Since I can't see a case where this matters, and no tests seem to fail.

The second commit adds a `deny_late_regions: bool` to distinguish `Scope::LateBoundary` which should deny *any* late-bound params or just ty/consts. Then, when resolving opaques we wrap ourselves in a `Scope::LateBoundary { deny_late_regions: false }` so that we deny late-bound ty/const, which fixes a bunch of ICEs that all vaguely look like `impl for<T> Trait<Assoc = impl OtherTrait<T>>`.

I guess this could be achieved other ways; for example, with a different scope kind, or maybe we could just reuse `Scope::Opaque`. But this seems a bit more verbose. I'm open to feedback anyways.

Fixes rust-lang#131535
Fixes rust-lang#131637
Fixes rust-lang#132530

I opted to remove those crashes tests ^ without adding them as regular tests, since they're basically triggering uninteresting late-bound ICEs far off in the trait solver, and the reason that existing tests such as `tests/ui/type-alias-impl-trait/non-lifetime-binder-in-constraint.rs` don't ICE are kinda just coincidental (i.e. due to a missing impl block). I don't really feel motivated to add random permutations to tests just to exercise non-lifetime binders.

r? cjgillot
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug. F-non_lifetime_binders `#![feature(non_lifetime_binders)]` I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ S-bug-has-test Status: This bug is tracked inside the repo by a `known-bug` test. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants