Skip to content

ICE: ConstArgHasType has escaping bound vars, so it cannot be wrapped in a dummy binder. #131534

Open
@matthiaskrgr

Description

@matthiaskrgr

auto-reduced (treereduce-rust):

#![feature(generic_const_exprs)]
type Value<'v> = &[[u8; SIZE]];

trait Trait: Fn(Value) -> Value {}

original:

type Value<'v> = &[[u8; SIZE]];

trait Trait: Fn(Value) -> Value {}

impl<F: Indexer<Foo> + Indexer<Bar>> Trait for F {
    type A: Iterator<Item: Copy>;
    //~^ ERROR associated type bounds are unstable

    type B: Iterator<Item: 'static>;
    //~^ ERROR associated type bounds are unstable
}

fn main() {
    let _: Box<dyn Trait> = Box::new(|v: Value| v);
}

Version information

rustc 1.83.0-nightly (0321e73d1 2024-10-11)
binary: rustc
commit-hash: 0321e73d1cb3f739caa806927344eca6f96257b5
commit-date: 2024-10-11
host: x86_64-unknown-linux-gnu
release: 1.83.0-nightly
LLVM version: 19.1.1

Command:
/home/matthias/.rustup/toolchains/master/bin/rustc -Zcrate-attr=feature(generic_const_exprs)

Program output

error[E0106]: missing lifetime specifier
 --> /tmp/icemaker_global_tempdir.P3GyuBNzInxV/rustc_testrunner_tmpdir_reporting.lgaymy8wn468/mvce.rs:1:18
  |
1 | type Value<'v> = &[[u8; SIZE]];
  |                  ^ expected named lifetime parameter
  |
help: consider using the `'v` lifetime
  |
1 | type Value<'v> = &'v [[u8; SIZE]];
  |                   ++

error[E0425]: cannot find value `SIZE` in this scope
 --> /tmp/icemaker_global_tempdir.P3GyuBNzInxV/rustc_testrunner_tmpdir_reporting.lgaymy8wn468/mvce.rs:1:25
  |
1 | type Value<'v> = &[[u8; SIZE]];
  |                         ^^^^ not found in this scope

warning: the feature `generic_const_exprs` is incomplete and may not be safe to use and/or cause compiler crashes
 --> <crate attribute>:1:9
  |
1 | feature(generic_const_exprs)
  |         ^^^^^^^^^^^^^^^^^^^
  |
  = note: see issue #76560 <https://github.com/rust-lang/rust/issues/76560> for more information
  = note: `#[warn(incomplete_features)]` on by default

error[E0601]: `main` function not found in crate `mvce`
 --> /tmp/icemaker_global_tempdir.P3GyuBNzInxV/rustc_testrunner_tmpdir_reporting.lgaymy8wn468/mvce.rs:3:35
  |
3 | trait Trait: Fn(Value) -> Value {}
  |                                   ^ consider adding a `main` function to `/tmp/icemaker_global_tempdir.P3GyuBNzInxV/rustc_testrunner_tmpdir_reporting.lgaymy8wn468/mvce.rs`

thread 'rustc' panicked at compiler/rustc_trait_selection/src/traits/wf.rs:687:21:
`ConstArgHasType(UnevaluatedConst { def: DefId(0:6 ~ mvce[ff9f]::Value::{constant#0}), args: ['^0.Named(DefId(0:7 ~ mvce[ff9f]::Trait::'_), "'_")] }, usize)` has escaping bound vars, so it cannot be wrapped in a dummy binder.
stack backtrace:
   0:     0x7d62025de57a - <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt::h0c0d2e67483a7ce1
   1:     0x7d6202e034a6 - core::fmt::write::h19fbfdd1fd25c23b
   2:     0x7d62040c4091 - std::io::Write::write_fmt::hf8ab2da8ebc932a0
   3:     0x7d62025de3d2 - std::sys::backtrace::BacktraceLock::print::h3d864635116d695a
   4:     0x7d62025e08a6 - std::panicking::default_hook::{{closure}}::h2aa94d113a45cc15
   5:     0x7d62025e06f0 - std::panicking::default_hook::h97fbe8692dbb54b4
   6:     0x7d62016331df - std[b2c81c0a9485f2e4]::panicking::update_hook::<alloc[c9d20cda7901ded3]::boxed::Box<rustc_driver_impl[8c3cd927c140555]::install_ice_hook::{closure#0}>>::{closure#0}
   7:     0x7d62025e0fb8 - std::panicking::rust_panic_with_hook::hc4ff1f67175d51bb
   8:     0x7d62025e0d8a - std::panicking::begin_panic_handler::{{closure}}::h064adafafa3d3d91
   9:     0x7d62025dea29 - std::sys::backtrace::__rust_end_short_backtrace::hfd346037bc0f3979
  10:     0x7d62025e0a4c - rust_begin_unwind
  11:     0x7d620004cd00 - core::panicking::panic_fmt::hcd11b748a515a987
  12:     0x7d61ff2b7c5e - <rustc_trait_selection[9580d8cfdaacc399]::traits::wf::WfPredicates as rustc_type_ir[89eb6eb643500842]::visit::TypeVisitor<rustc_middle[3ffb7b0bf421448c]::ty::context::TyCtxt>>::visit_ty
  13:     0x7d620358cc09 - rustc_trait_selection[9580d8cfdaacc399]::traits::wf::clause_obligations
  14:     0x7d62035908bd - rustc_hir_analysis[94092c3b015c4ea3]::check::wfcheck::check_where_clauses
  15:     0x7d6203563b9c - rustc_hir_analysis[94092c3b015c4ea3]::check::wfcheck::check_trait
  16:     0x7d62007c1787 - rustc_hir_analysis[94092c3b015c4ea3]::check::wfcheck::check_well_formed
  17:     0x7d62037cee6b - rustc_query_impl[fa1174e4896087c1]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[fa1174e4896087c1]::query_impl::check_well_formed::dynamic_query::{closure#2}::{closure#0}, rustc_middle[3ffb7b0bf421448c]::query::erase::Erased<[u8; 1usize]>>
  18:     0x7d62037ce5d1 - rustc_query_system[3cba1a04b5b15b8a]::query::plumbing::try_execute_query::<rustc_query_impl[fa1174e4896087c1]::DynamicConfig<rustc_query_system[3cba1a04b5b15b8a]::query::caches::VecCache<rustc_span[6af75d8d312d6eec]::def_id::LocalDefId, rustc_middle[3ffb7b0bf421448c]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[fa1174e4896087c1]::plumbing::QueryCtxt, false>
  19:     0x7d62037ce250 - rustc_query_impl[fa1174e4896087c1]::query_impl::check_well_formed::get_query_non_incr::__rust_end_short_backtrace
  20:     0x7d62037cf0ff - rustc_hir_analysis[94092c3b015c4ea3]::check::wfcheck::check_mod_type_wf
  21:     0x7d62037cef25 - rustc_query_impl[fa1174e4896087c1]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[fa1174e4896087c1]::query_impl::check_mod_type_wf::dynamic_query::{closure#2}::{closure#0}, rustc_middle[3ffb7b0bf421448c]::query::erase::Erased<[u8; 1usize]>>
  22:     0x7d6203bb7b7b - rustc_query_system[3cba1a04b5b15b8a]::query::plumbing::try_execute_query::<rustc_query_impl[fa1174e4896087c1]::DynamicConfig<rustc_query_system[3cba1a04b5b15b8a]::query::caches::DefaultCache<rustc_span[6af75d8d312d6eec]::def_id::LocalModDefId, rustc_middle[3ffb7b0bf421448c]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[fa1174e4896087c1]::plumbing::QueryCtxt, false>
  23:     0x7d6203bb792d - rustc_query_impl[fa1174e4896087c1]::query_impl::check_mod_type_wf::get_query_non_incr::__rust_end_short_backtrace
  24:     0x7d62032340fb - rustc_hir_analysis[94092c3b015c4ea3]::check_crate
  25:     0x7d6203230e57 - rustc_interface[b91e754c6773c007]::passes::run_required_analyses
  26:     0x7d620391fb1e - rustc_interface[b91e754c6773c007]::passes::analysis
  27:     0x7d620391faf1 - rustc_query_impl[fa1174e4896087c1]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[fa1174e4896087c1]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[3ffb7b0bf421448c]::query::erase::Erased<[u8; 1usize]>>
  28:     0x7d6203d26dae - rustc_query_system[3cba1a04b5b15b8a]::query::plumbing::try_execute_query::<rustc_query_impl[fa1174e4896087c1]::DynamicConfig<rustc_query_system[3cba1a04b5b15b8a]::query::caches::SingleCache<rustc_middle[3ffb7b0bf421448c]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[fa1174e4896087c1]::plumbing::QueryCtxt, false>
  29:     0x7d6203d26a8f - rustc_query_impl[fa1174e4896087c1]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
  30:     0x7d6203b4edde - rustc_interface[b91e754c6773c007]::interface::run_compiler::<core[15204f05ba262a1b]::result::Result<(), rustc_span[6af75d8d312d6eec]::ErrorGuaranteed>, rustc_driver_impl[8c3cd927c140555]::run_compiler::{closure#0}>::{closure#1}
  31:     0x7d6203c32d10 - std[b2c81c0a9485f2e4]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[b91e754c6773c007]::util::run_in_thread_with_globals<rustc_interface[b91e754c6773c007]::util::run_in_thread_pool_with_globals<rustc_interface[b91e754c6773c007]::interface::run_compiler<core[15204f05ba262a1b]::result::Result<(), rustc_span[6af75d8d312d6eec]::ErrorGuaranteed>, rustc_driver_impl[8c3cd927c140555]::run_compiler::{closure#0}>::{closure#1}, core[15204f05ba262a1b]::result::Result<(), rustc_span[6af75d8d312d6eec]::ErrorGuaranteed>>::{closure#0}, core[15204f05ba262a1b]::result::Result<(), rustc_span[6af75d8d312d6eec]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[15204f05ba262a1b]::result::Result<(), rustc_span[6af75d8d312d6eec]::ErrorGuaranteed>>
  32:     0x7d6203c333d7 - <<std[b2c81c0a9485f2e4]::thread::Builder>::spawn_unchecked_<rustc_interface[b91e754c6773c007]::util::run_in_thread_with_globals<rustc_interface[b91e754c6773c007]::util::run_in_thread_pool_with_globals<rustc_interface[b91e754c6773c007]::interface::run_compiler<core[15204f05ba262a1b]::result::Result<(), rustc_span[6af75d8d312d6eec]::ErrorGuaranteed>, rustc_driver_impl[8c3cd927c140555]::run_compiler::{closure#0}>::{closure#1}, core[15204f05ba262a1b]::result::Result<(), rustc_span[6af75d8d312d6eec]::ErrorGuaranteed>>::{closure#0}, core[15204f05ba262a1b]::result::Result<(), rustc_span[6af75d8d312d6eec]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[15204f05ba262a1b]::result::Result<(), rustc_span[6af75d8d312d6eec]::ErrorGuaranteed>>::{closure#1} as core[15204f05ba262a1b]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  33:     0x7d6203c342c1 - std::sys::pal::unix::thread::Thread::new::thread_start::h4694c2beab690665
  34:     0x7d62053ab39d - <unknown>
  35:     0x7d620543049c - <unknown>
  36:                0x0 - <unknown>

error: the compiler unexpectedly panicked. this is a bug.

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.83.0-nightly (0321e73d1 2024-10-11) running on x86_64-unknown-linux-gnu

note: compiler flags: -Z crate-attr=feature(generic_const_exprs) -Z dump-mir-dir=dir

query stack during panic:
#0 [check_well_formed] checking that `Trait` is well-formed
#1 [check_mod_type_wf] checking that types are well-formed in top-level module
end of query stack
error: aborting due to 3 previous errors; 1 warning emitted

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

@rustbot label +F-generic_const_exprs

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.F-generic_const_exprs`#![feature(generic_const_exprs)]`I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️S-bug-has-testStatus: This bug is tracked inside the repo by a `known-bug` test.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions