Skip to content

ICE: inference variables in normalized parameter environment: unconstrained type #124171

Closed as not planned
@cicilzx

Description

@cicilzx

Code

#![feature(non_lifetime_binders)]
pub trait Foo<T: ?Sized> {
    type Bar<K: ?Sized>: ?Sized;
}
impl Foo<usize> for () {
    type Bar<K: ?Sized> = K;
}
pub fn f<T1, T2>(a: T1, b: T2)
where
    T1: for<T> Foo<usize, Bar< > = T>,
    T2: for<T> Foo<usize, Bar<T> = <T1 as Foo<usize>>::Bar<T>>,
{
}
fn it_works() {
    f((), ());
}
fn main() {}

Meta

rustc --version --verbose:

rustc 1.79.0-nightly (e3181b091 2024-04-18)

Error output

  Compiling playground v0.0.1 (/playground)
warning: the feature `non_lifetime_binders` is incomplete and may not be safe to use and/or cause compiler crashes
 --> src/main.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[E0107]: associated type takes 1 generic argument but 0 generic arguments were supplied
  --> src/main.rs:10:27
   |
10 |     T1: for<T> Foo<usize, Bar< > = T>,
   |                           ^^^ expected 1 generic argument
   |
note: associated type defined here, with 1 generic parameter: `K`
  --> src/main.rs:3:10
   |
3  |     type Bar<K: ?Sized>: ?Sized;
   |          ^^^ -
help: add missing generic argument
   |
10 |     T1: for<T> Foo<usize, Bar<K > = T>,
   |                               +

error: internal compiler error: compiler/rustc_trait_selection/src/traits/mod.rs:237:13: inference variables in normalized parameter environment: unconstrained type
  --> src/main.rs:8:1
   |
8  | / pub fn f<T1, T2>(a: T1, b: T2)
9  | | where
10 | |     T1: for<T> Foo<usize, Bar< > = T>,
11 | |     T2: for<T> Foo<usize, Bar<T> = <T1 as Foo<usize>>::Bar<T>>,
   | |_______________________________________________________________^

thread 'rustc' panicked at compiler/rustc_trait_selection/src/traits/mod.rs:237:13:
Box<dyn Any>
Backtrace

stack backtrace:
   0:     0x7fdfbec3ba75 - std::backtrace_rs::backtrace::libunwind::trace::h3178471d9f78e3cb
                               at /rustc/e3181b091e88321f5ea149afed6db0edf0a4f37b/library/std/src/../../backtrace/src/backtrace/libunwind.rs:105:5
   1:     0x7fdfbec3ba75 - std::backtrace_rs::backtrace::trace_unsynchronized::hbdc1834532c09e2a
                               at /rustc/e3181b091e88321f5ea149afed6db0edf0a4f37b/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7fdfbec3ba75 - std::sys_common::backtrace::_print_fmt::he0effe2168984738
                               at /rustc/e3181b091e88321f5ea149afed6db0edf0a4f37b/library/std/src/sys_common/backtrace.rs:68:5
   3:     0x7fdfbec3ba75 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h2a6106103c1910ba
                               at /rustc/e3181b091e88321f5ea149afed6db0edf0a4f37b/library/std/src/sys_common/backtrace.rs:44:22
   4:     0x7fdfbec8aceb - core::fmt::rt::Argument::fmt::h2639f1ab76ff1f58
                               at /rustc/e3181b091e88321f5ea149afed6db0edf0a4f37b/library/core/src/fmt/rt.rs:165:63
   5:     0x7fdfbec8aceb - core::fmt::write::h6eeb5f66a1bca2fc
                               at /rustc/e3181b091e88321f5ea149afed6db0edf0a4f37b/library/core/src/fmt/mod.rs:1157:21
   6:     0x7fdfbec305ff - std::io::Write::write_fmt::h2d109f420f32f292
                               at /rustc/e3181b091e88321f5ea149afed6db0edf0a4f37b/library/std/src/io/mod.rs:1832:15
   7:     0x7fdfbec3b84e - std::sys_common::backtrace::_print::h5eae48fb2e24a524
                               at /rustc/e3181b091e88321f5ea149afed6db0edf0a4f37b/library/std/src/sys_common/backtrace.rs:47:5
   8:     0x7fdfbec3b84e - std::sys_common::backtrace::print::h82c60fdc4d53f603
                               at /rustc/e3181b091e88321f5ea149afed6db0edf0a4f37b/library/std/src/sys_common/backtrace.rs:34:9
   9:     0x7fdfbec3e1b9 - std::panicking::default_hook::{{closure}}::hb1af461c15feab08
  10:     0x7fdfbec3defd - std::panicking::default_hook::h7844e690451631db
                               at /rustc/e3181b091e88321f5ea149afed6db0edf0a4f37b/library/std/src/panicking.rs:291:9
  11:     0x7fdfc1ccd62c - std[470e2cc56b39f005]::panicking::update_hook::<alloc[d6b86ee176900255]::boxed::Box<rustc_driver_impl[49d04bc720e6c988]::install_ice_hook::{closure#0}>>::{closure#0}
  12:     0x7fdfbec3e8b6 - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::h1970eb6751de199d
                               at /rustc/e3181b091e88321f5ea149afed6db0edf0a4f37b/library/alloc/src/boxed.rs:2036:9
  13:     0x7fdfbec3e8b6 - std::panicking::rust_panic_with_hook::hbe7168eb035bc8b8
                               at /rustc/e3181b091e88321f5ea149afed6db0edf0a4f37b/library/std/src/panicking.rs:792:13
  14:     0x7fdfc1cfd774 - std[470e2cc56b39f005]::panicking::begin_panic::<rustc_errors[8cb7adb7aedc754]::ExplicitBug>::{closure#0}
  15:     0x7fdfc1cfa2d6 - std[470e2cc56b39f005]::sys_common::backtrace::__rust_end_short_backtrace::<std[470e2cc56b39f005]::panicking::begin_panic<rustc_errors[8cb7adb7aedc754]::ExplicitBug>::{closure#0}, !>
  16:     0x7fdfc1cf58d6 - std[470e2cc56b39f005]::panicking::begin_panic::<rustc_errors[8cb7adb7aedc754]::ExplicitBug>
  17:     0x7fdfc1d06851 - <rustc_errors[8cb7adb7aedc754]::diagnostic::BugAbort as rustc_errors[8cb7adb7aedc754]::diagnostic::EmissionGuarantee>::emit_producing_guarantee
  18:     0x7fdfc274f508 - <rustc_errors[8cb7adb7aedc754]::DiagCtxt>::span_bug::<rustc_span[e4641a2caa7e40e]::span_encoding::Span, alloc[d6b86ee176900255]::string::String>
  19:     0x7fdfc279c5ad - rustc_middle[30aac62dc32be234]::util::bug::opt_span_bug_fmt::<rustc_span[e4641a2caa7e40e]::span_encoding::Span>::{closure#0}
  20:     0x7fdfc279c72a - rustc_middle[30aac62dc32be234]::ty::context::tls::with_opt::<rustc_middle[30aac62dc32be234]::util::bug::opt_span_bug_fmt<rustc_span[e4641a2caa7e40e]::span_encoding::Span>::{closure#0}, !>::{closure#0}
  21:     0x7fdfc27718db - rustc_middle[30aac62dc32be234]::ty::context::tls::with_context_opt::<rustc_middle[30aac62dc32be234]::ty::context::tls::with_opt<rustc_middle[30aac62dc32be234]::util::bug::opt_span_bug_fmt<rustc_span[e4641a2caa7e40e]::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
  22:     0x7fdfc276cc27 - rustc_middle[30aac62dc32be234]::util::bug::span_bug_fmt::<rustc_span[e4641a2caa7e40e]::span_encoding::Span>
  23:     0x7fdfc33aac85 - rustc_trait_selection[d3cae4c2355d46cb]::traits::do_normalize_predicates
  24:     0x7fdfc06dd107 - rustc_trait_selection[d3cae4c2355d46cb]::traits::normalize_param_env_or_error
  25:     0x7fdfc316bee9 - rustc_ty_utils[eb36414ede0e90ea]::ty::param_env
  26:     0x7fdfc316bb3d - rustc_query_impl[c4c415242faa3e03]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[c4c415242faa3e03]::query_impl::param_env::dynamic_query::{closure#2}::{closure#0}, rustc_middle[30aac62dc32be234]::query::erase::Erased<[u8; 8usize]>>
  27:     0x7fdfc3166861 - rustc_query_system[63c18adbd871b367]::query::plumbing::try_execute_query::<rustc_query_impl[c4c415242faa3e03]::DynamicConfig<rustc_query_system[63c18adbd871b367]::query::caches::DefIdCache<rustc_middle[30aac62dc32be234]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[c4c415242faa3e03]::plumbing::QueryCtxt, false>
  28:     0x7fdfc316629b - rustc_query_impl[c4c415242faa3e03]::query_impl::param_env::get_query_non_incr::__rust_end_short_backtrace
  29:     0x7fdfc378613e - rustc_middle[30aac62dc32be234]::query::plumbing::query_get_at::<rustc_query_system[63c18adbd871b367]::query::caches::DefIdCache<rustc_middle[30aac62dc32be234]::query::erase::Erased<[u8; 8usize]>>>
  30:     0x7fdfc377e5fc - rustc_hir_analysis[2c1107505d93ebda]::check::wfcheck::check_item_fn
  31:     0x7fdfc39e512d - rustc_hir_analysis[2c1107505d93ebda]::check::wfcheck::check_well_formed
  32:     0x7fdfc39e39d7 - rustc_query_impl[c4c415242faa3e03]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[c4c415242faa3e03]::query_impl::check_well_formed::dynamic_query::{closure#2}::{closure#0}, rustc_middle[30aac62dc32be234]::query::erase::Erased<[u8; 1usize]>>
  33:     0x7fdfc39e316a - rustc_query_system[63c18adbd871b367]::query::plumbing::try_execute_query::<rustc_query_impl[c4c415242faa3e03]::DynamicConfig<rustc_query_system[63c18adbd871b367]::query::caches::VecCache<rustc_hir[ffef4c4dbed7ea26]::hir_id::OwnerId, rustc_middle[30aac62dc32be234]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[c4c415242faa3e03]::plumbing::QueryCtxt, false>
  34:     0x7fdfc39e2ed3 - rustc_query_impl[c4c415242faa3e03]::query_impl::check_well_formed::get_query_non_incr::__rust_end_short_backtrace
  35:     0x7fdfc39e0e41 - rustc_hir_analysis[2c1107505d93ebda]::check::wfcheck::check_mod_type_wf
  36:     0x7fdfc39e0c89 - rustc_query_impl[c4c415242faa3e03]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[c4c415242faa3e03]::query_impl::check_mod_type_wf::dynamic_query::{closure#2}::{closure#0}, rustc_middle[30aac62dc32be234]::query::erase::Erased<[u8; 1usize]>>
  37:     0x7fdfc3b8ae46 - rustc_query_system[63c18adbd871b367]::query::plumbing::try_execute_query::<rustc_query_impl[c4c415242faa3e03]::DynamicConfig<rustc_query_system[63c18adbd871b367]::query::caches::DefaultCache<rustc_span[e4641a2caa7e40e]::def_id::LocalModDefId, rustc_middle[30aac62dc32be234]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[c4c415242faa3e03]::plumbing::QueryCtxt, false>
  38:     0x7fdfc3b8abff - rustc_query_impl[c4c415242faa3e03]::query_impl::check_mod_type_wf::get_query_non_incr::__rust_end_short_backtrace
  39:     0x7fdfc329cb07 - rustc_hir_analysis[2c1107505d93ebda]::check_crate
  40:     0x7fdfc363953a - rustc_interface[53da3a61844c65b8]::passes::analysis
  41:     0x7fdfc3639095 - rustc_query_impl[c4c415242faa3e03]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[c4c415242faa3e03]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[30aac62dc32be234]::query::erase::Erased<[u8; 1usize]>>
  42:     0x7fdfc3e4b2a5 - rustc_query_system[63c18adbd871b367]::query::plumbing::try_execute_query::<rustc_query_impl[c4c415242faa3e03]::DynamicConfig<rustc_query_system[63c18adbd871b367]::query::caches::SingleCache<rustc_middle[30aac62dc32be234]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[c4c415242faa3e03]::plumbing::QueryCtxt, false>
  43:     0x7fdfc3e4b009 - rustc_query_impl[c4c415242faa3e03]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
  44:     0x7fdfc3cdd399 - rustc_interface[53da3a61844c65b8]::interface::run_compiler::<core[face5b6acd610675]::result::Result<(), rustc_span[e4641a2caa7e40e]::ErrorGuaranteed>, rustc_driver_impl[49d04bc720e6c988]::run_compiler::{closure#0}>::{closure#1}
  45:     0x7fdfc3cc68e7 - std[470e2cc56b39f005]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[53da3a61844c65b8]::util::run_in_thread_with_globals<rustc_interface[53da3a61844c65b8]::util::run_in_thread_pool_with_globals<rustc_interface[53da3a61844c65b8]::interface::run_compiler<core[face5b6acd610675]::result::Result<(), rustc_span[e4641a2caa7e40e]::ErrorGuaranteed>, rustc_driver_impl[49d04bc720e6c988]::run_compiler::{closure#0}>::{closure#1}, core[face5b6acd610675]::result::Result<(), rustc_span[e4641a2caa7e40e]::ErrorGuaranteed>>::{closure#0}, core[face5b6acd610675]::result::Result<(), rustc_span[e4641a2caa7e40e]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[face5b6acd610675]::result::Result<(), rustc_span[e4641a2caa7e40e]::ErrorGuaranteed>>
  46:     0x7fdfc3cc66aa - <<std[470e2cc56b39f005]::thread::Builder>::spawn_unchecked_<rustc_interface[53da3a61844c65b8]::util::run_in_thread_with_globals<rustc_interface[53da3a61844c65b8]::util::run_in_thread_pool_with_globals<rustc_interface[53da3a61844c65b8]::interface::run_compiler<core[face5b6acd610675]::result::Result<(), rustc_span[e4641a2caa7e40e]::ErrorGuaranteed>, rustc_driver_impl[49d04bc720e6c988]::run_compiler::{closure#0}>::{closure#1}, core[face5b6acd610675]::result::Result<(), rustc_span[e4641a2caa7e40e]::ErrorGuaranteed>>::{closure#0}, core[face5b6acd610675]::result::Result<(), rustc_span[e4641a2caa7e40e]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[face5b6acd610675]::result::Result<(), rustc_span[e4641a2caa7e40e]::ErrorGuaranteed>>::{closure#2} as core[face5b6acd610675]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  47:     0x7fdfbec4878b - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::hf6035c437e16c4de
                               at /rustc/e3181b091e88321f5ea149afed6db0edf0a4f37b/library/alloc/src/boxed.rs:2022:9
  48:     0x7fdfbec4878b - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h2661e9a43deb34c7
                               at /rustc/e3181b091e88321f5ea149afed6db0edf0a4f37b/library/alloc/src/boxed.rs:2022:9
  49:     0x7fdfbec4878b - std::sys::pal::unix::thread::Thread::new::thread_start::h748d17afc5d2b125
                               at /rustc/e3181b091e88321f5ea149afed6db0edf0a4f37b/library/std/src/sys/pal/unix/thread.rs:108:17
  50:     0x7fdfbeb55609 - start_thread
  51:     0x7fdfbea78353 - clone
  52:                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: please attach the file at `/playground/rustc-ice-2024-04-19T17_43_48-23.txt` to your bug report

note: compiler flags: --crate-type bin -C embed-bitcode=no -C codegen-units=1 -C debuginfo=2

note: some of the compiler flags provided by cargo are hidden

query stack during panic:
#0 [param_env] computing normalized predicates of `f`
#1 [check_well_formed] checking that `f` is well-formed
#2 [check_mod_type_wf] checking that types are well-formed in top-level module
#3 [analysis] running analysis passes on this crate
end of query stack
For more information about this error, try `rustc --explain E0107`.

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️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