Skip to content

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

Open
@matthiaskrgr

Description

@matthiaskrgr

snippet:

#![feature(non_lifetime_binders)]

pub trait Foo<T: ?Sized> {
    type Bar<K: ?Sized>;
}

pub struct Bar<T: ?AutoTrait> {}

pub fn f<T1, T2>()
where
    T1: for<T> Foo<usize, Bar = Bar<T>>,
    T2: for<L, T> Foo<usize, Bar<T> = T1::Bar<T>>,
{
}

Version information

rustc 1.77.0-nightly (e64f8495e 2024-01-16)
binary: rustc
commit-hash: e64f8495e73fbc3653b4bcb73268c58b9c4a0a0d
commit-date: 2024-01-16
host: x86_64-unknown-linux-gnu
release: 1.77.0-nightly
LLVM version: 17.0.6

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

Program output

error[E0405]: cannot find trait `AutoTrait` in this scope
 --> /tmp/icemaker_global_tempdir.sRdilPN7rXO6/rustc_testrunner_tmpdir_reporting.ngEGvTdeSLNZ/mvce.rs:7:20
  |
7 | pub struct Bar<T: ?AutoTrait> {}
  |                    ^^^^^^^^^ not found in this scope

warning: the feature `non_lifetime_binders` is incomplete and may not be safe to use and/or cause compiler crashes
 --> /tmp/icemaker_global_tempdir.sRdilPN7rXO6/rustc_testrunner_tmpdir_reporting.ngEGvTdeSLNZ/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.sRdilPN7rXO6/rustc_testrunner_tmpdir_reporting.ngEGvTdeSLNZ/mvce.rs:14:2
   |
14 | }
   |  ^ consider adding a `main` function to `/tmp/icemaker_global_tempdir.sRdilPN7rXO6/rustc_testrunner_tmpdir_reporting.ngEGvTdeSLNZ/mvce.rs`

warning: relaxing a default bound only does something for `?Sized`; all other traits are not bound by default
 --> /tmp/icemaker_global_tempdir.sRdilPN7rXO6/rustc_testrunner_tmpdir_reporting.ngEGvTdeSLNZ/mvce.rs:7:19
  |
7 | pub struct Bar<T: ?AutoTrait> {}
  |                   ^^^^^^^^^^

error[E0107]: missing generics for associated type `Foo::Bar`
  --> /tmp/icemaker_global_tempdir.sRdilPN7rXO6/rustc_testrunner_tmpdir_reporting.ngEGvTdeSLNZ/mvce.rs:11:27
   |
11 |     T1: for<T> Foo<usize, Bar = Bar<T>>,
   |                           ^^^ expected 1 generic argument
   |
note: associated type defined here, with 1 generic parameter: `K`
  --> /tmp/icemaker_global_tempdir.sRdilPN7rXO6/rustc_testrunner_tmpdir_reporting.ngEGvTdeSLNZ/mvce.rs:4:10
   |
4  |     type Bar<K: ?Sized>;
   |          ^^^ -
help: add missing generic argument
   |
11 |     T1: for<T> Foo<usize, Bar<K> = Bar<T>>,
   |                              +++

error[E0392]: parameter `T` is never used
 --> /tmp/icemaker_global_tempdir.sRdilPN7rXO6/rustc_testrunner_tmpdir_reporting.ngEGvTdeSLNZ/mvce.rs:7:16
  |
7 | pub struct Bar<T: ?AutoTrait> {}
  |                ^ unused parameter
  |
  = help: consider removing `T`, referring to it in a field, or using a marker such as `PhantomData`

error: internal compiler error: compiler/rustc_trait_selection/src/traits/mod.rs:236:13: inference variables in normalized parameter environment: unconstrained type
  --> /tmp/icemaker_global_tempdir.sRdilPN7rXO6/rustc_testrunner_tmpdir_reporting.ngEGvTdeSLNZ/mvce.rs:9:1
   |
9  | / pub fn f<T1, T2>()
10 | | where
11 | |     T1: for<T> Foo<usize, Bar = Bar<T>>,
12 | |     T2: for<L, T> Foo<usize, Bar<T> = T1::Bar<T>>,
   | |__________________________________________________^

thread 'rustc' panicked at /rustc/e64f8495e73fbc3653b4bcb73268c58b9c4a0a0d/compiler/rustc_errors/src/lib.rs:854:41:
Box<dyn Any>
stack backtrace:
   0:     0x7f0cd5817806 - std::backtrace_rs::backtrace::libunwind::trace::h4b22376ba0492652
                               at /rustc/e64f8495e73fbc3653b4bcb73268c58b9c4a0a0d/library/std/src/../../backtrace/src/backtrace/libunwind.rs:104:5
   1:     0x7f0cd5817806 - std::backtrace_rs::backtrace::trace_unsynchronized::h0e3835b8afb2038f
                               at /rustc/e64f8495e73fbc3653b4bcb73268c58b9c4a0a0d/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7f0cd5817806 - std::sys_common::backtrace::_print_fmt::h01e8ef90ace289e3
                               at /rustc/e64f8495e73fbc3653b4bcb73268c58b9c4a0a0d/library/std/src/sys_common/backtrace.rs:68:5
   3:     0x7f0cd5817806 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::hf9dd6cae74685c81
                               at /rustc/e64f8495e73fbc3653b4bcb73268c58b9c4a0a0d/library/std/src/sys_common/backtrace.rs:44:22
   4:     0x7f0cd5869e00 - core::fmt::rt::Argument::fmt::h8ea94010f89e6634
                               at /rustc/e64f8495e73fbc3653b4bcb73268c58b9c4a0a0d/library/core/src/fmt/rt.rs:142:9
   5:     0x7f0cd5869e00 - core::fmt::write::h72cc333598639a69
                               at /rustc/e64f8495e73fbc3653b4bcb73268c58b9c4a0a0d/library/core/src/fmt/mod.rs:1120:17
   6:     0x7f0cd580b1cf - std::io::Write::write_fmt::h4b8808e44803d04e
                               at /rustc/e64f8495e73fbc3653b4bcb73268c58b9c4a0a0d/library/std/src/io/mod.rs:1810:15
   7:     0x7f0cd58175e4 - std::sys_common::backtrace::_print::hb2c185826855226e
                               at /rustc/e64f8495e73fbc3653b4bcb73268c58b9c4a0a0d/library/std/src/sys_common/backtrace.rs:47:5
   8:     0x7f0cd58175e4 - std::sys_common::backtrace::print::hf0402097dc954189
                               at /rustc/e64f8495e73fbc3653b4bcb73268c58b9c4a0a0d/library/std/src/sys_common/backtrace.rs:34:9
   9:     0x7f0cd581a377 - std::panicking::default_hook::{{closure}}::h2879d7f688c03513
  10:     0x7f0cd581a0d9 - std::panicking::default_hook::h6b4d39921063eece
                               at /rustc/e64f8495e73fbc3653b4bcb73268c58b9c4a0a0d/library/std/src/panicking.rs:292:9
  11:     0x7f0cd2567b4c - std[45f158bc17f9e196]::panicking::update_hook::<alloc[f6bf7dd499ada734]::boxed::Box<rustc_driver_impl[856b55f1ad5b32fc]::install_ice_hook::{closure#0}>>::{closure#0}
  12:     0x7f0cd581aac6 - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::hbefca42bded875fc
                               at /rustc/e64f8495e73fbc3653b4bcb73268c58b9c4a0a0d/library/alloc/src/boxed.rs:2030:9
  13:     0x7f0cd581aac6 - std::panicking::rust_panic_with_hook::h861adc023e7cc0c9
                               at /rustc/e64f8495e73fbc3653b4bcb73268c58b9c4a0a0d/library/std/src/panicking.rs:785:13
  14:     0x7f0cd2599ab4 - std[45f158bc17f9e196]::panicking::begin_panic::<rustc_errors[9a83f08cfa696d6d]::ExplicitBug>::{closure#0}
  15:     0x7f0cd2596076 - std[45f158bc17f9e196]::sys_common::backtrace::__rust_end_short_backtrace::<std[45f158bc17f9e196]::panicking::begin_panic<rustc_errors[9a83f08cfa696d6d]::ExplicitBug>::{closure#0}, !>
  16:     0x7f0cd2591136 - std[45f158bc17f9e196]::panicking::begin_panic::<rustc_errors[9a83f08cfa696d6d]::ExplicitBug>
  17:     0x7f0cd25a4c51 - <rustc_errors[9a83f08cfa696d6d]::diagnostic_builder::BugAbort as rustc_errors[9a83f08cfa696d6d]::diagnostic_builder::EmissionGuarantee>::emit_producing_guarantee
  18:     0x7f0cd2fbbb8d - rustc_middle[eb670d4eb5009434]::util::bug::opt_span_bug_fmt::<rustc_span[1828e6de90cfe8a6]::span_encoding::Span>::{closure#0}
  19:     0x7f0cd2fbbbba - rustc_middle[eb670d4eb5009434]::ty::context::tls::with_opt::<rustc_middle[eb670d4eb5009434]::util::bug::opt_span_bug_fmt<rustc_span[1828e6de90cfe8a6]::span_encoding::Span>::{closure#0}, !>::{closure#0}
  20:     0x7f0cd2f8f0e8 - rustc_middle[eb670d4eb5009434]::ty::context::tls::with_context_opt::<rustc_middle[eb670d4eb5009434]::ty::context::tls::with_opt<rustc_middle[eb670d4eb5009434]::util::bug::opt_span_bug_fmt<rustc_span[1828e6de90cfe8a6]::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
  21:     0x7f0cd2f8c1f4 - rustc_middle[eb670d4eb5009434]::util::bug::span_bug_fmt::<rustc_span[1828e6de90cfe8a6]::span_encoding::Span>
  22:     0x7f0cd4199627 - rustc_trait_selection[bc7c8cde1afc0761]::traits::do_normalize_predicates
  23:     0x7f0cd3f786da - rustc_trait_selection[bc7c8cde1afc0761]::traits::normalize_param_env_or_error
  24:     0x7f0cd3ac9eb4 - rustc_ty_utils[a1af397cf76d45e7]::ty::param_env
  25:     0x7f0cd3ac9a59 - rustc_query_impl[a4ba8400aa2b99d0]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[a4ba8400aa2b99d0]::query_impl::param_env::dynamic_query::{closure#2}::{closure#0}, rustc_middle[eb670d4eb5009434]::query::erase::Erased<[u8; 8usize]>>
  26:     0x7f0cd389cfd4 - rustc_query_system[1dd2241d09e5cc4c]::query::plumbing::try_execute_query::<rustc_query_impl[a4ba8400aa2b99d0]::DynamicConfig<rustc_query_system[1dd2241d09e5cc4c]::query::caches::DefaultCache<rustc_span[1828e6de90cfe8a6]::def_id::DefId, rustc_middle[eb670d4eb5009434]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[a4ba8400aa2b99d0]::plumbing::QueryCtxt, false>
  27:     0x7f0cd389cae1 - rustc_query_impl[a4ba8400aa2b99d0]::query_impl::param_env::get_query_non_incr::__rust_end_short_backtrace
  28:     0x7f0cd3c275a8 - rustc_middle[eb670d4eb5009434]::query::plumbing::query_get_at::<rustc_query_system[1dd2241d09e5cc4c]::query::caches::DefaultCache<rustc_span[1828e6de90cfe8a6]::def_id::DefId, rustc_middle[eb670d4eb5009434]::query::erase::Erased<[u8; 8usize]>>>
  29:     0x7f0cd3c3740e - rustc_hir_analysis[9d00e3e5b40bb3cf]::check::wfcheck::check_item_fn
  30:     0x7f0cd3c34e2d - rustc_hir_analysis[9d00e3e5b40bb3cf]::check::wfcheck::check_well_formed
  31:     0x7f0cd3c33b2f - rustc_query_impl[a4ba8400aa2b99d0]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[a4ba8400aa2b99d0]::query_impl::check_well_formed::dynamic_query::{closure#2}::{closure#0}, rustc_middle[eb670d4eb5009434]::query::erase::Erased<[u8; 1usize]>>
  32:     0x7f0cd3c3320b - rustc_query_system[1dd2241d09e5cc4c]::query::plumbing::try_execute_query::<rustc_query_impl[a4ba8400aa2b99d0]::DynamicConfig<rustc_query_system[1dd2241d09e5cc4c]::query::caches::VecCache<rustc_hir[5d84c8f70b537736]::hir_id::OwnerId, rustc_middle[eb670d4eb5009434]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[a4ba8400aa2b99d0]::plumbing::QueryCtxt, false>
  33:     0x7f0cd3c32f83 - rustc_query_impl[a4ba8400aa2b99d0]::query_impl::check_well_formed::get_query_non_incr::__rust_end_short_backtrace
  34:     0x7f0cd3c309b7 - rustc_hir_analysis[9d00e3e5b40bb3cf]::check::wfcheck::check_mod_type_wf
  35:     0x7f0cd3c308fb - rustc_query_impl[a4ba8400aa2b99d0]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[a4ba8400aa2b99d0]::query_impl::check_mod_type_wf::dynamic_query::{closure#2}::{closure#0}, rustc_middle[eb670d4eb5009434]::query::erase::Erased<[u8; 1usize]>>
  36:     0x7f0cd3c2fa95 - rustc_query_system[1dd2241d09e5cc4c]::query::plumbing::try_execute_query::<rustc_query_impl[a4ba8400aa2b99d0]::DynamicConfig<rustc_query_system[1dd2241d09e5cc4c]::query::caches::DefaultCache<rustc_span[1828e6de90cfe8a6]::def_id::LocalModDefId, rustc_middle[eb670d4eb5009434]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[a4ba8400aa2b99d0]::plumbing::QueryCtxt, false>
  37:     0x7f0cd3c2f843 - rustc_query_impl[a4ba8400aa2b99d0]::query_impl::check_mod_type_wf::get_query_non_incr::__rust_end_short_backtrace
  38:     0x7f0cd3e982b0 - <rustc_middle[eb670d4eb5009434]::hir::map::Map>::try_par_for_each_module::<rustc_hir_analysis[9d00e3e5b40bb3cf]::check_crate::{closure#4}::{closure#0}>::{closure#0}
  39:     0x7f0cd3e96611 - rustc_hir_analysis[9d00e3e5b40bb3cf]::check_crate
  40:     0x7f0cd427e819 - rustc_interface[13fabbb621f7a7a7]::passes::analysis
  41:     0x7f0cd427e45f - rustc_query_impl[a4ba8400aa2b99d0]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[a4ba8400aa2b99d0]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[eb670d4eb5009434]::query::erase::Erased<[u8; 1usize]>>
  42:     0x7f0cd47a65a4 - rustc_query_system[1dd2241d09e5cc4c]::query::plumbing::try_execute_query::<rustc_query_impl[a4ba8400aa2b99d0]::DynamicConfig<rustc_query_system[1dd2241d09e5cc4c]::query::caches::SingleCache<rustc_middle[eb670d4eb5009434]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[a4ba8400aa2b99d0]::plumbing::QueryCtxt, false>
  43:     0x7f0cd47a6395 - rustc_query_impl[a4ba8400aa2b99d0]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
  44:     0x7f0cd45463ad - rustc_interface[13fabbb621f7a7a7]::interface::run_compiler::<core[5977124cf3f69ab]::result::Result<(), rustc_span[1828e6de90cfe8a6]::ErrorGuaranteed>, rustc_driver_impl[856b55f1ad5b32fc]::run_compiler::{closure#0}>::{closure#0}
  45:     0x7f0cd4808e46 - std[45f158bc17f9e196]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[13fabbb621f7a7a7]::util::run_in_thread_with_globals<rustc_interface[13fabbb621f7a7a7]::util::run_in_thread_pool_with_globals<rustc_interface[13fabbb621f7a7a7]::interface::run_compiler<core[5977124cf3f69ab]::result::Result<(), rustc_span[1828e6de90cfe8a6]::ErrorGuaranteed>, rustc_driver_impl[856b55f1ad5b32fc]::run_compiler::{closure#0}>::{closure#0}, core[5977124cf3f69ab]::result::Result<(), rustc_span[1828e6de90cfe8a6]::ErrorGuaranteed>>::{closure#0}, core[5977124cf3f69ab]::result::Result<(), rustc_span[1828e6de90cfe8a6]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[5977124cf3f69ab]::result::Result<(), rustc_span[1828e6de90cfe8a6]::ErrorGuaranteed>>
  46:     0x7f0cd4808c73 - <<std[45f158bc17f9e196]::thread::Builder>::spawn_unchecked_<rustc_interface[13fabbb621f7a7a7]::util::run_in_thread_with_globals<rustc_interface[13fabbb621f7a7a7]::util::run_in_thread_pool_with_globals<rustc_interface[13fabbb621f7a7a7]::interface::run_compiler<core[5977124cf3f69ab]::result::Result<(), rustc_span[1828e6de90cfe8a6]::ErrorGuaranteed>, rustc_driver_impl[856b55f1ad5b32fc]::run_compiler::{closure#0}>::{closure#0}, core[5977124cf3f69ab]::result::Result<(), rustc_span[1828e6de90cfe8a6]::ErrorGuaranteed>>::{closure#0}, core[5977124cf3f69ab]::result::Result<(), rustc_span[1828e6de90cfe8a6]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[5977124cf3f69ab]::result::Result<(), rustc_span[1828e6de90cfe8a6]::ErrorGuaranteed>>::{closure#1} as core[5977124cf3f69ab]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  47:     0x7f0cd58243b5 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h5d9d7f54a2e59c6d
                               at /rustc/e64f8495e73fbc3653b4bcb73268c58b9c4a0a0d/library/alloc/src/boxed.rs:2016:9
  48:     0x7f0cd58243b5 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h48bf4b2427be9cd8
                               at /rustc/e64f8495e73fbc3653b4bcb73268c58b9c4a0a0d/library/alloc/src/boxed.rs:2016:9
  49:     0x7f0cd58243b5 - std::sys::pal::unix::thread::Thread::new::thread_start::hbf0f1ac511c22d9d
                               at /rustc/e64f8495e73fbc3653b4bcb73268c58b9c4a0a0d/library/std/src/sys/pal/unix/thread.rs:108:17
  50:     0x7f0ccf6aa9eb - <unknown>
  51:     0x7f0ccf72e7cc - <unknown>
  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: rustc 1.77.0-nightly (e64f8495e 2024-01-16) running on x86_64-unknown-linux-gnu

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
error: aborting due to 5 previous errors; 2 warnings emitted

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.F-non_lifetime_binders`#![feature(non_lifetime_binders)]`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

    Status

    Todo

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions