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: unexpected infer type #123140

Open
matthiaskrgr opened this issue Mar 27, 2024 · 4 comments
Open

ICE: unexpected infer type #123140

matthiaskrgr opened this issue Mar 27, 2024 · 4 comments
Assignees
Labels
A-trait-objects Area: trait objects, vtable layout C-bug Category: This is a bug. F-associated_const_equality `#![feature(associated_const_equality)]` 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

auto-reduced (treereduce-rust):

trait Project {
    const SELF: Self;
}

fn take1(_: Project<SELF = { loop {} }>) {}
original code

original:

// Regression test for issue #108271.
// Detect and reject generic params in the type of assoc consts used in an equality bound.
#![feature(associated_const_equality)]

trait Trait<'a, T: 'a, const N: usize> {
    //~^ NOTE the lifetime parameter `'r` is defined here
    //~| NOTE the lifetime parameter `'r` is defined here
    type Assoc<const Q: usize>: Trait<'r, Self, Q, K = { loop {} }>
    //~^ ERROR the type of the associated constant `K` must not depend on generic parameters
    //~| ERROR the type of the associated constant `K` must not depend on generic parameters
    //~| NOTE its type must not depend on the lifetime parameter `'r`
    //~| NOTE `K` has type `&'r [Self; Q]`
    //~| ERROR the type of the associated constant `K` must not depend on `Self`
    //~| NOTE its type must not depend on `Self`
    //~| NOTE `K` has type `&'r [Self; Q]`
    //~| ERROR the type of the associated constant `K` must not depend on generic parameters
    //~| NOTE its type must not depend on the const parameter `Q`
    //~| NOTE the const parameter `Q` is defined here
    //~| NOTE `K` has type `&'r [Self; Q]`
    //~| NOTE its type must not depend on the lifetime parameter `'r`
    //~| NOTE `K` has type `&'r [Self; Q]`
    //~| ERROR the type of the associated constant `K` must not depend on `Self`
    //~| NOTE its type must not depend on `Self`
    //~| NOTE `K` has type `&'r [Self; Q]`
    //~| ERROR the type of the associated constant `K` must not depend on generic parameters
    //~| NOTE its type must not depend on the const parameter `Q`
    //~| NOTE the const parameter `Q` is defined here
    //~| NOTE `K` has type `&'r [Self; Q]`
    //~| NOTE duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
    //~| NOTE duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
    //~| NOTE duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
    where
        Self: Sized + 'r;
}

fn take0<'r, A: Project<SELF = {}>, const Q: usize>(_: impl Trait<'r, A, Q, K = { loop {} }>) {}
//~^ ERROR the type of the associated constant `K` must not depend on generic parameters
//~| NOTE its type must not depend on the lifetime parameter `'r`
//~| NOTE the lifetime parameter `'r` is defined here
//~^ ERROR the type of the associated constant `K` must not depend on generic parameters
//~| ERROR the type of the associated constant `K` must not depend on generic parameters
//~| NOTE its type must not depend on the type parameter `A`
//~| NOTE the type parameter `A` is defined here
//~| NOTE `K` has type `&'r [A; Q]`
//~| ERROR the type of the associated constant `K` must not depend on generic parameters
//~| NOTE its type must not depend on the const parameter `Q`
//~| NOTE the const parameter `Q` is defined here
//~| NOTE `K` has type `&'r [A; Q]`

trait Project {
    const SELF: Self;
}

fn take1(_:  Project<SELF = { loop {} }>) {}
//~^ ERROR the type of the associated constant `SELF` must not depend on `impl Trait`
//~| NOTE its type must not depend on `impl Trait`
//~| NOTE the `impl Trait` is specified here

fn take2<P: Project<SELF = {}>>(_: P) {}
//~^ ERROR the type of the associated constant `SELF` must not depend on generic parameters
//~| NOTE its type must not depend on the type parameter `P`
//~| NOTE the type parameter `P` is defined here
//~| NOTE `SELF` has type `P`

trait Iface<'r> {
    //~^ NOTE the lifetime parameter `'r` is defined here
    //~| NOTE the lifetime parameter `'r` is defined here
    type Assoc<const Q: usize>: Trait<'r, Self, Q, K = { loop {} }>
    //~^ ERROR the type of the associated constant `K` must not depend on generic parameters
    //~| ERROR the type of the associated constant `K` must not depend on generic parameters
    //~| NOTE its type must not depend on the lifetime parameter `'r`
    //~| NOTE `K` has type `&'r [Self; Q]`
    //~| ERROR the type of the associated constant `K` must not depend on `Self`
    //~| NOTE its type must not depend on `Self`
    //~| NOTE `K` has type `&'r [Self; Q]`
    //~| ERROR the type of the associated constant `K` must not depend on generic parameters
    //~| NOTE its type must not depend on the const parameter `Q`
    //~| NOTE the const parameter `Q` is defined here
    //~| NOTE `K` has type `&'r [Self; Q]`
    //~| NOTE its type must not depend on the lifetime parameter `'r`
    //~| NOTE `K` has type `&'r [Self; Q]`
    //~| ERROR the type of the associated constant `K` must not depend on `Self`
    //~| NOTE its type must not depend on `Self`
    //~| NOTE `K` has type `&'r [A; Q]`
    //~| ERROR the type of the associated constant `K` must not depend on generic parameters
    //~| NOTE its type must not depend on the const parameter `Q`
    //~| NOTE the const parameter `Q` is defined here
    //~| NOTE `K` has type `&'r [Self; Q]`
    //~| NOTE duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
    //~^ ERROR the type of the associated constant `SELF` must not depend on generic parameters
    //~| NOTE its type must not depend on `Self`
    SELF =;
}

fn main() { loop {} }

Version information

rustc 1.79.0-nightly (d5db7fb53 2024-03-27)
binary: rustc
commit-hash: d5db7fb537c0352eec3855aa0331c271c48ac4f6
commit-date: 2024-03-27
host: x86_64-unknown-linux-gnu
release: 1.79.0-nightly
LLVM version: 18.1.2

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

Program output

error[E0658]: associated const equality is incomplete
 --> /tmp/icemaker_global_tempdir.iaTnhD6gpiUs/rustc_testrunner_tmpdir_reporting.j6t1MTYnJCzk/mvce.rs:5:21
  |
5 | fn take1(_: Project<SELF = { loop {} }>) {}
  |                     ^^^^^^^^^^^^^^^^^^
  |
  = note: see issue #92827 <https://github.com/rust-lang/rust/issues/92827> for more information
  = help: add `#![feature(associated_const_equality)]` to the crate attributes to enable
  = note: this compiler was built on 2024-03-27; consider upgrading it if it is out of date

error[E0601]: `main` function not found in crate `mvce`
 --> /tmp/icemaker_global_tempdir.iaTnhD6gpiUs/rustc_testrunner_tmpdir_reporting.j6t1MTYnJCzk/mvce.rs:5:44
  |
5 | fn take1(_: Project<SELF = { loop {} }>) {}
  |                                            ^ consider adding a `main` function to `/tmp/icemaker_global_tempdir.iaTnhD6gpiUs/rustc_testrunner_tmpdir_reporting.j6t1MTYnJCzk/mvce.rs`

warning: trait objects without an explicit `dyn` are deprecated
 --> /tmp/icemaker_global_tempdir.iaTnhD6gpiUs/rustc_testrunner_tmpdir_reporting.j6t1MTYnJCzk/mvce.rs:5:13
  |
5 | fn take1(_: Project<SELF = { loop {} }>) {}
  |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  |
  = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021!
  = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/warnings-promoted-to-error.html>
  = note: `#[warn(bare_trait_objects)]` on by default
help: if this is an object-safe trait, use `dyn`
  |
5 | fn take1(_: dyn Project<SELF = { loop {} }>) {}
  |             +++

error: internal compiler error: compiler/rustc_infer/src/infer/relate/generalize.rs:458:17: unexpected infer type: FreshTy(0)

thread 'rustc' panicked at compiler/rustc_infer/src/infer/relate/generalize.rs:458:17:
Box<dyn Any>
stack backtrace:
   0:     0x7a1979cc4235 - std::backtrace_rs::backtrace::libunwind::trace::h35c05b60de86c082
                               at /rustc/d5db7fb537c0352eec3855aa0331c271c48ac4f6/library/std/src/../../backtrace/src/backtrace/libunwind.rs:105:5
   1:     0x7a1979cc4235 - std::backtrace_rs::backtrace::trace_unsynchronized::h716cc93b6616466b
                               at /rustc/d5db7fb537c0352eec3855aa0331c271c48ac4f6/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7a1979cc4235 - std::sys_common::backtrace::_print_fmt::h2eafab78e5405086
                               at /rustc/d5db7fb537c0352eec3855aa0331c271c48ac4f6/library/std/src/sys_common/backtrace.rs:68:5
   3:     0x7a1979cc4235 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h782eb93aef6bbfdc
                               at /rustc/d5db7fb537c0352eec3855aa0331c271c48ac4f6/library/std/src/sys_common/backtrace.rs:44:22
   4:     0x7a1979d153fb - core::fmt::rt::Argument::fmt::h423c1825313972bd
                               at /rustc/d5db7fb537c0352eec3855aa0331c271c48ac4f6/library/core/src/fmt/rt.rs:142:9
   5:     0x7a1979d153fb - core::fmt::write::h8bf0eb0713660507
                               at /rustc/d5db7fb537c0352eec3855aa0331c271c48ac4f6/library/core/src/fmt/mod.rs:1153:17
   6:     0x7a1979cb8e4f - std::io::Write::write_fmt::h1869b88304121496
                               at /rustc/d5db7fb537c0352eec3855aa0331c271c48ac4f6/library/std/src/io/mod.rs:1843:15
   7:     0x7a1979cc400e - std::sys_common::backtrace::_print::h3f71a60e8eec22db
                               at /rustc/d5db7fb537c0352eec3855aa0331c271c48ac4f6/library/std/src/sys_common/backtrace.rs:47:5
   8:     0x7a1979cc400e - std::sys_common::backtrace::print::hbc0f4a4435261b96
                               at /rustc/d5db7fb537c0352eec3855aa0331c271c48ac4f6/library/std/src/sys_common/backtrace.rs:34:9
   9:     0x7a1979cc6c89 - std::panicking::default_hook::{{closure}}::hcb90344a23466037
  10:     0x7a1979cc69f3 - std::panicking::default_hook::h4e7402b852825f26
                               at /rustc/d5db7fb537c0352eec3855aa0331c271c48ac4f6/library/std/src/panicking.rs:292:9
  11:     0x7a19765f7eee - std[ee38f4c3e7db4cb4]::panicking::update_hook::<alloc[5f51a9fa993ddee8]::boxed::Box<rustc_driver_impl[b62da54691605f75]::install_ice_hook::{closure#0}>>::{closure#0}
  12:     0x7a1979cc738c - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::h41b4c40829d8b80c
                               at /rustc/d5db7fb537c0352eec3855aa0331c271c48ac4f6/library/alloc/src/boxed.rs:2032:9
  13:     0x7a1979cc738c - std::panicking::rust_panic_with_hook::h34319b28877d2524
                               at /rustc/d5db7fb537c0352eec3855aa0331c271c48ac4f6/library/std/src/panicking.rs:793:13
  14:     0x7a1976627d64 - std[ee38f4c3e7db4cb4]::panicking::begin_panic::<rustc_errors[82d4239d9c7af4ff]::ExplicitBug>::{closure#0}
  15:     0x7a1976624c86 - std[ee38f4c3e7db4cb4]::sys_common::backtrace::__rust_end_short_backtrace::<std[ee38f4c3e7db4cb4]::panicking::begin_panic<rustc_errors[82d4239d9c7af4ff]::ExplicitBug>::{closure#0}, !>
  16:     0x7a1976624966 - std[ee38f4c3e7db4cb4]::panicking::begin_panic::<rustc_errors[82d4239d9c7af4ff]::ExplicitBug>
  17:     0x7a19766311f1 - <rustc_errors[82d4239d9c7af4ff]::diagnostic::BugAbort as rustc_errors[82d4239d9c7af4ff]::diagnostic::EmissionGuarantee>::emit_producing_guarantee
  18:     0x7a1976ac17bc - rustc_middle[edfcb02b6a244f2]::util::bug::opt_span_bug_fmt::<rustc_span[b9a3f8dff5ad8c72]::span_encoding::Span>::{closure#0}
  19:     0x7a1976aa52ba - rustc_middle[edfcb02b6a244f2]::ty::context::tls::with_opt::<rustc_middle[edfcb02b6a244f2]::util::bug::opt_span_bug_fmt<rustc_span[b9a3f8dff5ad8c72]::span_encoding::Span>::{closure#0}, !>::{closure#0}
  20:     0x7a1976aa515b - rustc_middle[edfcb02b6a244f2]::ty::context::tls::with_context_opt::<rustc_middle[edfcb02b6a244f2]::ty::context::tls::with_opt<rustc_middle[edfcb02b6a244f2]::util::bug::opt_span_bug_fmt<rustc_span[b9a3f8dff5ad8c72]::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
  21:     0x7a1974703930 - rustc_middle[edfcb02b6a244f2]::util::bug::bug_fmt
  22:     0x7a1977aa5b28 - <rustc_infer[db4fc5bbfe73a864]::infer::relate::generalize::Generalizer as rustc_middle[edfcb02b6a244f2]::ty::relate::TypeRelation>::tys
  23:     0x7a1977a9116a - <rustc_infer[db4fc5bbfe73a864]::infer::relate::type_relating::TypeRelating as rustc_middle[edfcb02b6a244f2]::ty::relate::TypeRelation>::tys
  24:     0x7a1977a836c3 - <rustc_hir_typeck[d5655f81daec17bc]::fn_ctxt::FnCtxt>::coerce
  25:     0x7a1977a721ab - <rustc_hir_typeck[d5655f81daec17bc]::fn_ctxt::FnCtxt>::demand_coerce
  26:     0x7a1977bf594d - rustc_hir_typeck[d5655f81daec17bc]::typeck
  27:     0x7a1977bf3a57 - rustc_query_impl[2d2f12ae863522a2]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[2d2f12ae863522a2]::query_impl::typeck::dynamic_query::{closure#2}::{closure#0}, rustc_middle[edfcb02b6a244f2]::query::erase::Erased<[u8; 8usize]>>
  28:     0x7a1977be0971 - rustc_query_system[1181c72fefabd0ae]::query::plumbing::try_execute_query::<rustc_query_impl[2d2f12ae863522a2]::DynamicConfig<rustc_query_system[1181c72fefabd0ae]::query::caches::VecCache<rustc_span[b9a3f8dff5ad8c72]::def_id::LocalDefId, rustc_middle[edfcb02b6a244f2]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[2d2f12ae863522a2]::plumbing::QueryCtxt, false>
  29:     0x7a1977bdcdcc - rustc_query_impl[2d2f12ae863522a2]::query_impl::typeck::get_query_non_incr::__rust_end_short_backtrace
  30:     0x7a1977dcb79c - rustc_mir_build[1b46b2c93e920ce6]::thir::pattern::check_match::check_match
  31:     0x7a1977dca93b - rustc_query_impl[2d2f12ae863522a2]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[2d2f12ae863522a2]::query_impl::check_match::dynamic_query::{closure#2}::{closure#0}, rustc_middle[edfcb02b6a244f2]::query::erase::Erased<[u8; 1usize]>>
  32:     0x7a197813bd7c - rustc_query_system[1181c72fefabd0ae]::query::plumbing::try_execute_query::<rustc_query_impl[2d2f12ae863522a2]::DynamicConfig<rustc_query_system[1181c72fefabd0ae]::query::caches::VecCache<rustc_span[b9a3f8dff5ad8c72]::def_id::LocalDefId, rustc_middle[edfcb02b6a244f2]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[2d2f12ae863522a2]::plumbing::QueryCtxt, false>
  33:     0x7a197813b9ff - rustc_query_impl[2d2f12ae863522a2]::query_impl::check_match::get_query_non_incr::__rust_end_short_backtrace
  34:     0x7a1977dba5f3 - rustc_mir_build[1b46b2c93e920ce6]::build::mir_build
  35:     0x7a1977db9aa8 - rustc_query_impl[2d2f12ae863522a2]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[2d2f12ae863522a2]::query_impl::mir_built::dynamic_query::{closure#2}::{closure#0}, rustc_middle[edfcb02b6a244f2]::query::erase::Erased<[u8; 8usize]>>
  36:     0x7a1977be0971 - rustc_query_system[1181c72fefabd0ae]::query::plumbing::try_execute_query::<rustc_query_impl[2d2f12ae863522a2]::DynamicConfig<rustc_query_system[1181c72fefabd0ae]::query::caches::VecCache<rustc_span[b9a3f8dff5ad8c72]::def_id::LocalDefId, rustc_middle[edfcb02b6a244f2]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[2d2f12ae863522a2]::plumbing::QueryCtxt, false>
  37:     0x7a1977be054c - rustc_query_impl[2d2f12ae863522a2]::query_impl::mir_built::get_query_non_incr::__rust_end_short_backtrace
  38:     0x7a1977be024b - rustc_middle[edfcb02b6a244f2]::query::plumbing::query_get_at::<rustc_query_system[1181c72fefabd0ae]::query::caches::VecCache<rustc_span[b9a3f8dff5ad8c72]::def_id::LocalDefId, rustc_middle[edfcb02b6a244f2]::query::erase::Erased<[u8; 8usize]>>>
  39:     0x7a197812f701 - rustc_mir_transform[953c3acd5e2981a0]::mir_const_qualif
  40:     0x7a197812f6b5 - rustc_query_impl[2d2f12ae863522a2]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[2d2f12ae863522a2]::query_impl::mir_const_qualif::dynamic_query::{closure#2}::{closure#0}, rustc_middle[edfcb02b6a244f2]::query::erase::Erased<[u8; 4usize]>>
  41:     0x7a197812f18b - rustc_query_system[1181c72fefabd0ae]::query::plumbing::try_execute_query::<rustc_query_impl[2d2f12ae863522a2]::DynamicConfig<rustc_query_system[1181c72fefabd0ae]::query::caches::DefIdCache<rustc_middle[edfcb02b6a244f2]::query::erase::Erased<[u8; 4usize]>>, false, false, false>, rustc_query_impl[2d2f12ae863522a2]::plumbing::QueryCtxt, false>
  42:     0x7a197812ef09 - rustc_query_impl[2d2f12ae863522a2]::query_impl::mir_const_qualif::get_query_non_incr::__rust_end_short_backtrace
  43:     0x7a197812ed36 - rustc_middle[edfcb02b6a244f2]::query::plumbing::query_get_at::<rustc_query_system[1181c72fefabd0ae]::query::caches::DefIdCache<rustc_middle[edfcb02b6a244f2]::query::erase::Erased<[u8; 4usize]>>>
  44:     0x7a1974f714b6 - rustc_mir_transform[953c3acd5e2981a0]::mir_promoted
  45:     0x7a1977d0341c - rustc_query_impl[2d2f12ae863522a2]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[2d2f12ae863522a2]::query_impl::mir_promoted::dynamic_query::{closure#2}::{closure#0}, rustc_middle[edfcb02b6a244f2]::query::erase::Erased<[u8; 16usize]>>
  46:     0x7a1977d036ed - rustc_query_system[1181c72fefabd0ae]::query::plumbing::try_execute_query::<rustc_query_impl[2d2f12ae863522a2]::DynamicConfig<rustc_query_system[1181c72fefabd0ae]::query::caches::VecCache<rustc_span[b9a3f8dff5ad8c72]::def_id::LocalDefId, rustc_middle[edfcb02b6a244f2]::query::erase::Erased<[u8; 16usize]>>, false, false, false>, rustc_query_impl[2d2f12ae863522a2]::plumbing::QueryCtxt, false>
  47:     0x7a1977d03325 - rustc_query_impl[2d2f12ae863522a2]::query_impl::mir_promoted::get_query_non_incr::__rust_end_short_backtrace
  48:     0x7a1977bdead0 - rustc_borrowck[87c1aa11a50066c]::mir_borrowck
  49:     0x7a1977bdea17 - rustc_query_impl[2d2f12ae863522a2]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[2d2f12ae863522a2]::query_impl::mir_borrowck::dynamic_query::{closure#2}::{closure#0}, rustc_middle[edfcb02b6a244f2]::query::erase::Erased<[u8; 8usize]>>
  50:     0x7a1977be0971 - rustc_query_system[1181c72fefabd0ae]::query::plumbing::try_execute_query::<rustc_query_impl[2d2f12ae863522a2]::DynamicConfig<rustc_query_system[1181c72fefabd0ae]::query::caches::VecCache<rustc_span[b9a3f8dff5ad8c72]::def_id::LocalDefId, rustc_middle[edfcb02b6a244f2]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[2d2f12ae863522a2]::plumbing::QueryCtxt, false>
  51:     0x7a1977be048c - rustc_query_impl[2d2f12ae863522a2]::query_impl::mir_borrowck::get_query_non_incr::__rust_end_short_backtrace
  52:     0x7a1978136aab - rustc_mir_transform[953c3acd5e2981a0]::mir_drops_elaborated_and_const_checked
  53:     0x7a19781361a5 - rustc_query_impl[2d2f12ae863522a2]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[2d2f12ae863522a2]::query_impl::mir_drops_elaborated_and_const_checked::dynamic_query::{closure#2}::{closure#0}, rustc_middle[edfcb02b6a244f2]::query::erase::Erased<[u8; 8usize]>>
  54:     0x7a1977be0971 - rustc_query_system[1181c72fefabd0ae]::query::plumbing::try_execute_query::<rustc_query_impl[2d2f12ae863522a2]::DynamicConfig<rustc_query_system[1181c72fefabd0ae]::query::caches::VecCache<rustc_span[b9a3f8dff5ad8c72]::def_id::LocalDefId, rustc_middle[edfcb02b6a244f2]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[2d2f12ae863522a2]::plumbing::QueryCtxt, false>
  55:     0x7a1977be030c - rustc_query_impl[2d2f12ae863522a2]::query_impl::mir_drops_elaborated_and_const_checked::get_query_non_incr::__rust_end_short_backtrace
  56:     0x7a1977be024b - rustc_middle[edfcb02b6a244f2]::query::plumbing::query_get_at::<rustc_query_system[1181c72fefabd0ae]::query::caches::VecCache<rustc_span[b9a3f8dff5ad8c72]::def_id::LocalDefId, rustc_middle[edfcb02b6a244f2]::query::erase::Erased<[u8; 8usize]>>>
  57:     0x7a1978134f6c - rustc_mir_transform[953c3acd5e2981a0]::mir_for_ctfe
  58:     0x7a1978134edb - rustc_query_impl[2d2f12ae863522a2]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[2d2f12ae863522a2]::query_impl::mir_for_ctfe::dynamic_query::{closure#2}::{closure#0}, rustc_middle[edfcb02b6a244f2]::query::erase::Erased<[u8; 8usize]>>
  59:     0x7a1977bc6f9c - rustc_query_system[1181c72fefabd0ae]::query::plumbing::try_execute_query::<rustc_query_impl[2d2f12ae863522a2]::DynamicConfig<rustc_query_system[1181c72fefabd0ae]::query::caches::DefIdCache<rustc_middle[edfcb02b6a244f2]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[2d2f12ae863522a2]::plumbing::QueryCtxt, false>
  60:     0x7a19785b049e - rustc_query_impl[2d2f12ae863522a2]::query_impl::mir_for_ctfe::get_query_non_incr::__rust_end_short_backtrace
  61:     0x7a19785b07ca - <rustc_const_eval[176732e30479c26b]::interpret::eval_context::InterpCx<rustc_const_eval[176732e30479c26b]::const_eval::machine::CompileTimeInterpreter>>::load_mir
  62:     0x7a19785b25df - rustc_const_eval[176732e30479c26b]::const_eval::eval_queries::eval_to_allocation_raw_provider
  63:     0x7a19785b2340 - rustc_query_impl[2d2f12ae863522a2]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[2d2f12ae863522a2]::query_impl::eval_to_allocation_raw::dynamic_query::{closure#2}::{closure#0}, rustc_middle[edfcb02b6a244f2]::query::erase::Erased<[u8; 24usize]>>
  64:     0x7a19785af396 - rustc_query_system[1181c72fefabd0ae]::query::plumbing::try_execute_query::<rustc_query_impl[2d2f12ae863522a2]::DynamicConfig<rustc_query_system[1181c72fefabd0ae]::query::caches::DefaultCache<rustc_middle[edfcb02b6a244f2]::ty::ParamEnvAnd<rustc_middle[edfcb02b6a244f2]::mir::interpret::GlobalId>, rustc_middle[edfcb02b6a244f2]::query::erase::Erased<[u8; 24usize]>>, false, false, false>, rustc_query_impl[2d2f12ae863522a2]::plumbing::QueryCtxt, false>
  65:     0x7a19785aef6c - rustc_query_impl[2d2f12ae863522a2]::query_impl::eval_to_allocation_raw::get_query_non_incr::__rust_end_short_backtrace
  66:     0x7a19785aeb0a - rustc_middle[edfcb02b6a244f2]::query::plumbing::query_get_at::<rustc_query_system[1181c72fefabd0ae]::query::caches::DefaultCache<rustc_middle[edfcb02b6a244f2]::ty::ParamEnvAnd<rustc_middle[edfcb02b6a244f2]::mir::interpret::GlobalId>, rustc_middle[edfcb02b6a244f2]::query::erase::Erased<[u8; 24usize]>>>
  67:     0x7a197858c421 - rustc_const_eval[176732e30479c26b]::const_eval::valtrees::eval_to_valtree
  68:     0x7a197858c3a2 - <rustc_const_eval[176732e30479c26b]::provide::{closure#0} as core[852c89a24d64efc7]::ops::function::FnOnce<(rustc_middle[edfcb02b6a244f2]::ty::context::TyCtxt, rustc_middle[edfcb02b6a244f2]::ty::ParamEnvAnd<rustc_middle[edfcb02b6a244f2]::mir::interpret::GlobalId>)>>::call_once
  69:     0x7a197858c376 - rustc_query_impl[2d2f12ae863522a2]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[2d2f12ae863522a2]::query_impl::eval_to_valtree::dynamic_query::{closure#2}::{closure#0}, rustc_middle[edfcb02b6a244f2]::query::erase::Erased<[u8; 24usize]>>
  70:     0x7a197858c32f - <rustc_query_impl[2d2f12ae863522a2]::query_impl::eval_to_valtree::dynamic_query::{closure#2} as core[852c89a24d64efc7]::ops::function::FnOnce<(rustc_middle[edfcb02b6a244f2]::ty::context::TyCtxt, rustc_middle[edfcb02b6a244f2]::ty::ParamEnvAnd<rustc_middle[edfcb02b6a244f2]::mir::interpret::GlobalId>)>>::call_once
  71:     0x7a19785af471 - rustc_query_system[1181c72fefabd0ae]::query::plumbing::try_execute_query::<rustc_query_impl[2d2f12ae863522a2]::DynamicConfig<rustc_query_system[1181c72fefabd0ae]::query::caches::DefaultCache<rustc_middle[edfcb02b6a244f2]::ty::ParamEnvAnd<rustc_middle[edfcb02b6a244f2]::mir::interpret::GlobalId>, rustc_middle[edfcb02b6a244f2]::query::erase::Erased<[u8; 24usize]>>, false, false, false>, rustc_query_impl[2d2f12ae863522a2]::plumbing::QueryCtxt, false>
  72:     0x7a19785999ac - rustc_query_impl[2d2f12ae863522a2]::query_impl::eval_to_valtree::get_query_non_incr::__rust_end_short_backtrace
  73:     0x7a1977d3e847 - rustc_middle[edfcb02b6a244f2]::query::plumbing::query_get_at::<rustc_query_system[1181c72fefabd0ae]::query::caches::DefaultCache<rustc_middle[edfcb02b6a244f2]::ty::ParamEnvAnd<rustc_middle[edfcb02b6a244f2]::mir::interpret::GlobalId>, rustc_middle[edfcb02b6a244f2]::query::erase::Erased<[u8; 24usize]>>>
  74:     0x7a19782b791c - <rustc_middle[edfcb02b6a244f2]::ty::context::TyCtxt>::const_eval_global_id_for_typeck
  75:     0x7a19782b70a1 - <rustc_middle[edfcb02b6a244f2]::ty::context::TyCtxt>::const_eval_resolve_for_typeck
  76:     0x7a19782b6e56 - <rustc_middle[edfcb02b6a244f2]::ty::consts::Const>::eval
  77:     0x7a1977bf07c1 - <rustc_trait_selection[44f63119e1d12199]::traits::normalize::AssocTypeNormalizer as rustc_type_ir[4b4d295dba5e89f3]::fold::TypeFolder<rustc_middle[edfcb02b6a244f2]::ty::context::TyCtxt>>::fold_const
  78:     0x7a19770f6dcd - <rustc_trait_selection[44f63119e1d12199]::traits::normalize::AssocTypeNormalizer as rustc_type_ir[4b4d295dba5e89f3]::fold::TypeFolder<rustc_middle[edfcb02b6a244f2]::ty::context::TyCtxt>>::fold_binder::<rustc_middle[edfcb02b6a244f2]::ty::predicate::ExistentialPredicate>
  79:     0x7a19781fb427 - <rustc_middle[edfcb02b6a244f2]::ty::Ty as rustc_type_ir[4b4d295dba5e89f3]::fold::TypeSuperFoldable<rustc_middle[edfcb02b6a244f2]::ty::context::TyCtxt>>::try_super_fold_with::<rustc_trait_selection[44f63119e1d12199]::traits::normalize::AssocTypeNormalizer>
  80:     0x7a19780605ec - <rustc_hir_analysis[9a86bb4861b99e0a]::check::wfcheck::WfCheckingCtxt>::normalize::<rustc_middle[edfcb02b6a244f2]::ty::Ty>
  81:     0x7a197806140b - rustc_hir_analysis[9a86bb4861b99e0a]::check::wfcheck::check_fn_or_method
  82:     0x7a197805f28f - rustc_hir_analysis[9a86bb4861b99e0a]::check::wfcheck::check_item_fn
  83:     0x7a197806fec5 - rustc_hir_analysis[9a86bb4861b99e0a]::check::wfcheck::check_well_formed
  84:     0x7a197806e787 - rustc_query_impl[2d2f12ae863522a2]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[2d2f12ae863522a2]::query_impl::check_well_formed::dynamic_query::{closure#2}::{closure#0}, rustc_middle[edfcb02b6a244f2]::query::erase::Erased<[u8; 1usize]>>
  85:     0x7a197806df00 - rustc_query_system[1181c72fefabd0ae]::query::plumbing::try_execute_query::<rustc_query_impl[2d2f12ae863522a2]::DynamicConfig<rustc_query_system[1181c72fefabd0ae]::query::caches::VecCache<rustc_hir[7cb6db536684f817]::hir_id::OwnerId, rustc_middle[edfcb02b6a244f2]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[2d2f12ae863522a2]::plumbing::QueryCtxt, false>
  86:     0x7a197806dc7f - rustc_query_impl[2d2f12ae863522a2]::query_impl::check_well_formed::get_query_non_incr::__rust_end_short_backtrace
  87:     0x7a197806bbc6 - rustc_hir_analysis[9a86bb4861b99e0a]::check::wfcheck::check_mod_type_wf
  88:     0x7a197806ba09 - rustc_query_impl[2d2f12ae863522a2]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[2d2f12ae863522a2]::query_impl::check_mod_type_wf::dynamic_query::{closure#2}::{closure#0}, rustc_middle[edfcb02b6a244f2]::query::erase::Erased<[u8; 1usize]>>
  89:     0x7a197849e830 - rustc_query_system[1181c72fefabd0ae]::query::plumbing::try_execute_query::<rustc_query_impl[2d2f12ae863522a2]::DynamicConfig<rustc_query_system[1181c72fefabd0ae]::query::caches::DefaultCache<rustc_span[b9a3f8dff5ad8c72]::def_id::LocalModDefId, rustc_middle[edfcb02b6a244f2]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[2d2f12ae863522a2]::plumbing::QueryCtxt, false>
  90:     0x7a197849e5db - rustc_query_impl[2d2f12ae863522a2]::query_impl::check_mod_type_wf::get_query_non_incr::__rust_end_short_backtrace
  91:     0x7a1977bdb07b - rustc_hir_analysis[9a86bb4861b99e0a]::check_crate
  92:     0x7a1977f4aaea - rustc_interface[8a3ca12de370bc6d]::passes::analysis
  93:     0x7a1977f4a659 - rustc_query_impl[2d2f12ae863522a2]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[2d2f12ae863522a2]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[edfcb02b6a244f2]::query::erase::Erased<[u8; 1usize]>>
  94:     0x7a1978794da5 - rustc_query_system[1181c72fefabd0ae]::query::plumbing::try_execute_query::<rustc_query_impl[2d2f12ae863522a2]::DynamicConfig<rustc_query_system[1181c72fefabd0ae]::query::caches::SingleCache<rustc_middle[edfcb02b6a244f2]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[2d2f12ae863522a2]::plumbing::QueryCtxt, false>
  95:     0x7a1978794b09 - rustc_query_impl[2d2f12ae863522a2]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
  96:     0x7a1978687299 - rustc_interface[8a3ca12de370bc6d]::interface::run_compiler::<core[852c89a24d64efc7]::result::Result<(), rustc_span[b9a3f8dff5ad8c72]::ErrorGuaranteed>, rustc_driver_impl[b62da54691605f75]::run_compiler::{closure#0}>::{closure#0}
  97:     0x7a19787665e3 - std[ee38f4c3e7db4cb4]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[8a3ca12de370bc6d]::util::run_in_thread_with_globals<rustc_interface[8a3ca12de370bc6d]::util::run_in_thread_pool_with_globals<rustc_interface[8a3ca12de370bc6d]::interface::run_compiler<core[852c89a24d64efc7]::result::Result<(), rustc_span[b9a3f8dff5ad8c72]::ErrorGuaranteed>, rustc_driver_impl[b62da54691605f75]::run_compiler::{closure#0}>::{closure#0}, core[852c89a24d64efc7]::result::Result<(), rustc_span[b9a3f8dff5ad8c72]::ErrorGuaranteed>>::{closure#0}, core[852c89a24d64efc7]::result::Result<(), rustc_span[b9a3f8dff5ad8c72]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[852c89a24d64efc7]::result::Result<(), rustc_span[b9a3f8dff5ad8c72]::ErrorGuaranteed>>
  98:     0x7a1978766410 - <<std[ee38f4c3e7db4cb4]::thread::Builder>::spawn_unchecked_<rustc_interface[8a3ca12de370bc6d]::util::run_in_thread_with_globals<rustc_interface[8a3ca12de370bc6d]::util::run_in_thread_pool_with_globals<rustc_interface[8a3ca12de370bc6d]::interface::run_compiler<core[852c89a24d64efc7]::result::Result<(), rustc_span[b9a3f8dff5ad8c72]::ErrorGuaranteed>, rustc_driver_impl[b62da54691605f75]::run_compiler::{closure#0}>::{closure#0}, core[852c89a24d64efc7]::result::Result<(), rustc_span[b9a3f8dff5ad8c72]::ErrorGuaranteed>>::{closure#0}, core[852c89a24d64efc7]::result::Result<(), rustc_span[b9a3f8dff5ad8c72]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[852c89a24d64efc7]::result::Result<(), rustc_span[b9a3f8dff5ad8c72]::ErrorGuaranteed>>::{closure#1} as core[852c89a24d64efc7]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  99:     0x7a1979cd0ca9 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::hc7f4be48b61584a0
                               at /rustc/d5db7fb537c0352eec3855aa0331c271c48ac4f6/library/alloc/src/boxed.rs:2018:9
 100:     0x7a1979cd0ca9 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h98f2eb6153ee7231
                               at /rustc/d5db7fb537c0352eec3855aa0331c271c48ac4f6/library/alloc/src/boxed.rs:2018:9
 101:     0x7a1979cd0ca9 - std::sys::pal::unix::thread::Thread::new::thread_start::h5b05a8117b189654
                               at /rustc/d5db7fb537c0352eec3855aa0331c271c48ac4f6/library/std/src/sys/pal/unix/thread.rs:108:17
 102:     0x7a19734a955a - <unknown>
 103:     0x7a1973526a3c - <unknown>
 104:                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.79.0-nightly (d5db7fb53 2024-03-27) running on x86_64-unknown-linux-gnu

query stack during panic:
#0 [typeck] type-checking `take1::{constant#0}`
#1 [check_match] match-checking `take1::{constant#0}`
#2 [mir_built] building MIR for `take1::{constant#0}`
#3 [mir_const_qualif] const checking `take1::{constant#0}`
#4 [mir_promoted] promoting constants in MIR for `take1::{constant#0}`
#5 [mir_borrowck] borrow-checking `take1::{constant#0}`
#6 [mir_drops_elaborated_and_const_checked] elaborating drops for `take1::{constant#0}`
#7 [mir_for_ctfe] caching mir of `take1::{constant#0}` for CTFE
#8 [eval_to_allocation_raw] const-evaluating + checking `take1::{constant#0}`
#9 [eval_to_valtree] evaluating type-level constant
#10 [check_well_formed] checking that `take1` is well-formed
#11 [check_mod_type_wf] checking that types are well-formed in top-level module
#12 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to 3 previous errors; 1 warning emitted

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

@matthiaskrgr matthiaskrgr added 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. C-bug Category: This is a bug. labels Mar 27, 2024
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Mar 27, 2024
@matthiaskrgr
Copy link
Member Author

Regression in nightly-2023-02-18

looking for regression commit between 2023-02-17 and 2023-02-18
fetching (via remote github) commits from max(9a7cc6c, 2023-02-15) to 9aa5c24
ending github query because we found starting sha: 9a7cc6c
get_commits_between returning commits, len: 8
commit[0] 2023-02-16: Auto merge of #108127 - matthiaskrgr:rollup-kpzfc6j, r=matthiaskrgr
commit[1] 2023-02-16: Auto merge of #107833 - Zoxc:arena-query-clean, r=cjgillot
commit[2] 2023-02-17: Auto merge of #108145 - matthiaskrgr:rollup-bgadak1, r=matthiaskrgr
commit[3] 2023-02-17: Auto merge of #107753 - kylematsuda:type-of, r=BoxyUwU
commit[4] 2023-02-17: Auto merge of #108058 - Zoxc:query-ctxtx-byval, r=cjgillot
commit[5] 2023-02-17: Auto merge of #107965 - BoxyUwU:add_const_arg_has_type_predicate, r=compiler-errors
commit[6] 2023-02-17: Auto merge of #108159 - matthiaskrgr:rollup-5k2j7cx, r=matthiaskrgr
commit[7] 2023-02-17: Auto merge of #108075 - WaffleLapkin:de-arena-allocates-you-OwO, r=Nilstrieb
ERROR: no CI builds available between 9a7cc6c and 9aa5c24 within last 167 days

@fmease fmease added F-associated_const_equality `#![feature(associated_const_equality)]` and removed needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels Mar 29, 2024
@fmease fmease self-assigned this Mar 29, 2024
@fmease
Copy link
Member

fmease commented Mar 29, 2024

Oh, I see. I forgot about tcx.types.trait_object_dummy_self (FreshTy(0)) in #121258. Ofc, my PR doesn't regress anything here but still I forgot about this case. Very likely we need to reject trait_object_dummy_self manually and can't rely on registering a <Ty as core::marker::ConstParamTy> obligation1 (which I plan to do to fix #119783 but the location is still unclear to me2) because we just shouldn't be feeding the fake FreshTy(0) to type_of as can be seen by the ICE, the trait solver & the inference engine obviously can't handle such malformed obligations.

Footnotes

  1. Trait object types never impl ConstParamTy.

  2. HIR wf-checking isn't an option because we lack too much information at this stage, during normalization isn't an option since we shouldn't rely on normalization for ensuring well-formedness, leaving us with constructing an ObligationCtxt ad hoc during HIR ty lowering which isn't super great.

@fmease fmease added the A-trait-objects Area: trait objects, vtable layout label Mar 29, 2024
@fmease
Copy link
Member

fmease commented Mar 29, 2024

Wait, I don't think we should deny trait_object_dummy_self in the code path that rejects early-bound and escaping late-bound vars, that's not the right thing to do. They are semi-legitimate types that get discarded by helpers like ExistentialTraitRef::erase_self_ty and ExistentialProjection::erase_self_ty, e.g. inside lower_trait_object_ty (which also introduces these dummy_self types).

Oh, okay, so inside lower_trait_object_ty we discard const projections if their args contain a dummy self type but in our case, the projected type (the type_of(proj)) contains a dummy self type.

As the comment over there says such a (const) projection would expand to an infinitely-long type. We also need to check the projected type for dummy self types and drop the existential const projection in case we find any. Edit: Tho, no I'm confused since the projection_ty and the term.ct().ty() should be same in this case due to the anon const feeding, so why isn't it detecting anything? 🤔 Update: We don't even reach the aforementioned branch inside lower_trait_object_ty for some reason. Update: Oh, that's not the code path we're interested in, that's only for super trait elab.

@fmease
Copy link
Member

fmease commented Mar 29, 2024

Stopping my investigations for now but overwriting the args (incl. the self type subst) of such projections with {type error} as well turning the const projection term into {const error} if the args or the type of the projected const contains trait_object_dummy_self didn't help. Note that lower_trait_object_ty does parts of this already.

I haven't dug deeper yet but the cause of this might be the anon const query feeding in lower_assoc_item_binding: We may feed trait_object_dummy_self to type_of(AnonConst) which can't be undone.

@matthiaskrgr matthiaskrgr added the S-bug-has-test Status: This bug is tracked inside the repo by a `known-bug` test. label Apr 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-trait-objects Area: trait objects, vtable layout C-bug Category: This is a bug. F-associated_const_equality `#![feature(associated_const_equality)]` 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

No branches or pull requests

3 participants