Skip to content

ICE: effects: Unexpected parameter Type(()) when instantiating in region 'x (index=1) #121957

Closed

Description

auto-reduced (treereduce-rust):

#![feature(const_trait_impl, effects)]

#[const_trait]
trait Main {
    fn compute<T: ~const Aux>() -> u32;
}

impl const Main for () {
    fn compute<'x, 'y, 'z: 'x>() -> u32 {}
}

#[const_trait]
trait Aux {}

impl const Aux for () {}

fn main() {
    const _: u32 = <()>::compute::<()>();
}

original:

// Regression test for issue #119700.
//@ check-pass

#![feature(const_trait_impl, effects)]

#[const_trait]
trait Main {
    fn compute<T: ~const Aux>() -> u32;
}

impl const Main for () {
    fn compute<'x, 'y, 'z: 'x>() -> u32 {
        T::generate()
    }
}

#[const_trait]
trait Aux {
    fn generate() -> u32;
}

impl const Aux for () {
    fn generate() -> u32 { 1024 }
}

fn main() {
    const _: u32 = <()>::compute::<()>();
    let _ = <()>::compute::<()>();
}

Version information

rustc 1.78.0-nightly (10902058a 2024-03-03)
binary: rustc
commit-hash: 10902058a979aaea1fcb3576d84b93ba97e3b977
commit-date: 2024-03-03
host: x86_64-unknown-linux-gnu
release: 1.78.0-nightly
LLVM version: 18.1.0

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

Program output

error[E0049]: method `compute` has 0 type parameters but its trait declaration has 1 type parameter
 --> /tmp/icemaker_global_tempdir.RyaLtQEMp4T5/rustc_testrunner_tmpdir_reporting.FcJxB8wB8kpw/mvce.rs:9:16
  |
5 |     fn compute<T: ~const Aux>() -> u32;
  |                - expected 1 type parameter
...
9 |     fn compute<'x, 'y, 'z: 'x>() -> u32 {}
  |                ^^  ^^  ^^
  |                |
  |                found 0 type parameters

error: internal compiler error: compiler/rustc_middle/src/ty/generic_args.rs:846:13: Unexpected parameter Type(()) when instantiating in region 'x (index=1)

thread 'rustc' panicked at compiler/rustc_middle/src/util/bug.rs:35:44:
Box<dyn Any>
stack backtrace:
   0:     0x7f791a58cca6 - std::backtrace_rs::backtrace::libunwind::trace::h8590c0cdc9c2288b
                               at /rustc/10902058a979aaea1fcb3576d84b93ba97e3b977/library/std/src/../../backtrace/src/backtrace/libunwind.rs:104:5
   1:     0x7f791a58cca6 - std::backtrace_rs::backtrace::trace_unsynchronized::h2438b43884092300
                               at /rustc/10902058a979aaea1fcb3576d84b93ba97e3b977/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7f791a58cca6 - std::sys_common::backtrace::_print_fmt::h5d85ac8eae23de24
                               at /rustc/10902058a979aaea1fcb3576d84b93ba97e3b977/library/std/src/sys_common/backtrace.rs:68:5
   3:     0x7f791a58cca6 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h4f3424d75a01565f
                               at /rustc/10902058a979aaea1fcb3576d84b93ba97e3b977/library/std/src/sys_common/backtrace.rs:44:22
   4:     0x7f791a5ddb6c - core::fmt::rt::Argument::fmt::h9be1862b17a5cb37
                               at /rustc/10902058a979aaea1fcb3576d84b93ba97e3b977/library/core/src/fmt/rt.rs:142:9
   5:     0x7f791a5ddb6c - core::fmt::write::hb52ab9d2640f684b
                               at /rustc/10902058a979aaea1fcb3576d84b93ba97e3b977/library/core/src/fmt/mod.rs:1120:17
   6:     0x7f791a58154f - std::io::Write::write_fmt::he0bd898c1ac59b41
                               at /rustc/10902058a979aaea1fcb3576d84b93ba97e3b977/library/std/src/io/mod.rs:1846:15
   7:     0x7f791a58ca54 - std::sys_common::backtrace::_print::h95dd43befba84d57
                               at /rustc/10902058a979aaea1fcb3576d84b93ba97e3b977/library/std/src/sys_common/backtrace.rs:47:5
   8:     0x7f791a58ca54 - std::sys_common::backtrace::print::hf37ce03c87b06d3a
                               at /rustc/10902058a979aaea1fcb3576d84b93ba97e3b977/library/std/src/sys_common/backtrace.rs:34:9
   9:     0x7f791a58f79b - std::panicking::default_hook::{{closure}}::h343b3dabcbe411ad
  10:     0x7f791a58f4f7 - std::panicking::default_hook::h44d66419e02187fe
                               at /rustc/10902058a979aaea1fcb3576d84b93ba97e3b977/library/std/src/panicking.rs:292:9
  11:     0x7f791d49514c - std[f8d5c81aaff4de76]::panicking::update_hook::<alloc[2d3c73c7ba185632]::boxed::Box<rustc_driver_impl[f27e31f8ff148ccd]::install_ice_hook::{closure#0}>>::{closure#0}
  12:     0x7f791a58ff00 - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::h766766601bb8fbcb
                               at /rustc/10902058a979aaea1fcb3576d84b93ba97e3b977/library/alloc/src/boxed.rs:2030:9
  13:     0x7f791a58ff00 - std::panicking::rust_panic_with_hook::h0fe2c4b2a983a2f9
                               at /rustc/10902058a979aaea1fcb3576d84b93ba97e3b977/library/std/src/panicking.rs:783:13
  14:     0x7f791d4c1924 - std[f8d5c81aaff4de76]::panicking::begin_panic::<rustc_errors[10aca52f4cd8801e]::ExplicitBug>::{closure#0}
  15:     0x7f791d4be846 - std[f8d5c81aaff4de76]::sys_common::backtrace::__rust_end_short_backtrace::<std[f8d5c81aaff4de76]::panicking::begin_panic<rustc_errors[10aca52f4cd8801e]::ExplicitBug>::{closure#0}, !>
  16:     0x7f791d4be526 - std[f8d5c81aaff4de76]::panicking::begin_panic::<rustc_errors[10aca52f4cd8801e]::ExplicitBug>
  17:     0x7f791d4caf21 - <rustc_errors[10aca52f4cd8801e]::diagnostic::BugAbort as rustc_errors[10aca52f4cd8801e]::diagnostic::EmissionGuarantee>::emit_producing_guarantee
  18:     0x7f791d8a54bc - <rustc_errors[10aca52f4cd8801e]::DiagCtxt>::bug::<alloc[2d3c73c7ba185632]::string::String>
  19:     0x7f791d949fdb - rustc_middle[31e5eb56d6ce1ef8]::util::bug::opt_span_bug_fmt::<rustc_span[5102bb35249f7207]::span_encoding::Span>::{closure#0}
  20:     0x7f791d92d1aa - rustc_middle[31e5eb56d6ce1ef8]::ty::context::tls::with_opt::<rustc_middle[31e5eb56d6ce1ef8]::util::bug::opt_span_bug_fmt<rustc_span[5102bb35249f7207]::span_encoding::Span>::{closure#0}, !>::{closure#0}
  21:     0x7f791d92d028 - rustc_middle[31e5eb56d6ce1ef8]::ty::context::tls::with_context_opt::<rustc_middle[31e5eb56d6ce1ef8]::ty::context::tls::with_opt<rustc_middle[31e5eb56d6ce1ef8]::util::bug::opt_span_bug_fmt<rustc_span[5102bb35249f7207]::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
  22:     0x7f791be90cd0 - rustc_middle[31e5eb56d6ce1ef8]::util::bug::bug_fmt
  23:     0x7f791d93d3a1 - <rustc_middle[31e5eb56d6ce1ef8]::ty::generic_args::ArgFolder as rustc_type_ir[cd9c1553d4a5ed1c]::fold::TypeFolder<rustc_middle[31e5eb56d6ce1ef8]::ty::context::TyCtxt>>::fold_region::region_param_invalid
  24:     0x7f791e8087a7 - <rustc_middle[31e5eb56d6ce1ef8]::ty::generic_args::ArgFolder as rustc_type_ir[cd9c1553d4a5ed1c]::fold::TypeFolder<rustc_middle[31e5eb56d6ce1ef8]::ty::context::TyCtxt>>::fold_ty
  25:     0x7f791ef827ab - rustc_ty_utils[824d172e0a760ed5]::abi::fn_abi_of_instance
  26:     0x7f791ef825b3 - rustc_query_impl[cb51db93cbf9f55c]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[cb51db93cbf9f55c]::query_impl::fn_abi_of_instance::dynamic_query::{closure#2}::{closure#0}, rustc_middle[31e5eb56d6ce1ef8]::query::erase::Erased<[u8; 16usize]>>
  27:     0x7f791ef81410 - rustc_query_system[f0ce38311c874f6d]::query::plumbing::try_execute_query::<rustc_query_impl[cb51db93cbf9f55c]::DynamicConfig<rustc_query_system[f0ce38311c874f6d]::query::caches::DefaultCache<rustc_middle[31e5eb56d6ce1ef8]::ty::ParamEnvAnd<(rustc_middle[31e5eb56d6ce1ef8]::ty::instance::Instance, &rustc_middle[31e5eb56d6ce1ef8]::ty::list::List<rustc_middle[31e5eb56d6ce1ef8]::ty::Ty>)>, rustc_middle[31e5eb56d6ce1ef8]::query::erase::Erased<[u8; 16usize]>>, false, false, false>, rustc_query_impl[cb51db93cbf9f55c]::plumbing::QueryCtxt, false>
  28:     0x7f791ef8106d - rustc_query_impl[cb51db93cbf9f55c]::query_impl::fn_abi_of_instance::get_query_non_incr::__rust_end_short_backtrace
  29:     0x7f791f6f1799 - rustc_const_eval[f007e0324f55074e]::const_eval::eval_queries::eval_body_using_ecx::{closure#0}
  30:     0x7f791f6b66a3 - rustc_const_eval[f007e0324f55074e]::const_eval::eval_queries::eval_in_interpreter
  31:     0x7f791ec1eb74 - rustc_const_eval[f007e0324f55074e]::const_eval::eval_queries::eval_to_allocation_raw_provider
  32:     0x7f791ec1e942 - rustc_query_impl[cb51db93cbf9f55c]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[cb51db93cbf9f55c]::query_impl::eval_to_allocation_raw::dynamic_query::{closure#2}::{closure#0}, rustc_middle[31e5eb56d6ce1ef8]::query::erase::Erased<[u8; 24usize]>>
  33:     0x7f791f214791 - rustc_query_system[f0ce38311c874f6d]::query::plumbing::try_execute_query::<rustc_query_impl[cb51db93cbf9f55c]::DynamicConfig<rustc_query_system[f0ce38311c874f6d]::query::caches::DefaultCache<rustc_middle[31e5eb56d6ce1ef8]::ty::ParamEnvAnd<rustc_middle[31e5eb56d6ce1ef8]::mir::interpret::GlobalId>, rustc_middle[31e5eb56d6ce1ef8]::query::erase::Erased<[u8; 24usize]>>, false, false, false>, rustc_query_impl[cb51db93cbf9f55c]::plumbing::QueryCtxt, false>
  34:     0x7f791f21436c - rustc_query_impl[cb51db93cbf9f55c]::query_impl::eval_to_allocation_raw::get_query_non_incr::__rust_end_short_backtrace
  35:     0x7f791ec1f88d - rustc_const_eval[f007e0324f55074e]::const_eval::eval_queries::eval_to_const_value_raw_provider
  36:     0x7f791ec1f68c - rustc_query_impl[cb51db93cbf9f55c]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[cb51db93cbf9f55c]::query_impl::eval_to_const_value_raw::dynamic_query::{closure#2}::{closure#0}, rustc_middle[31e5eb56d6ce1ef8]::query::erase::Erased<[u8; 24usize]>>
  37:     0x7f791f214754 - rustc_query_system[f0ce38311c874f6d]::query::plumbing::try_execute_query::<rustc_query_impl[cb51db93cbf9f55c]::DynamicConfig<rustc_query_system[f0ce38311c874f6d]::query::caches::DefaultCache<rustc_middle[31e5eb56d6ce1ef8]::ty::ParamEnvAnd<rustc_middle[31e5eb56d6ce1ef8]::mir::interpret::GlobalId>, rustc_middle[31e5eb56d6ce1ef8]::query::erase::Erased<[u8; 24usize]>>, false, false, false>, rustc_query_impl[cb51db93cbf9f55c]::plumbing::QueryCtxt, false>
  38:     0x7f791f21426c - rustc_query_impl[cb51db93cbf9f55c]::query_impl::eval_to_const_value_raw::get_query_non_incr::__rust_end_short_backtrace
  39:     0x7f791f0b10eb - <rustc_middle[31e5eb56d6ce1ef8]::query::plumbing::TyCtxtEnsure>::const_eval_poly
  40:     0x7f791f0aee53 - rustc_hir_analysis[7bc76459f4203458]::check_crate
  41:     0x7f791f50136f - rustc_interface[a0a5e08285f36d55]::passes::analysis
  42:     0x7f791f500fd9 - rustc_query_impl[cb51db93cbf9f55c]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[cb51db93cbf9f55c]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[31e5eb56d6ce1ef8]::query::erase::Erased<[u8; 1usize]>>
  43:     0x7f791f5ccf65 - rustc_query_system[f0ce38311c874f6d]::query::plumbing::try_execute_query::<rustc_query_impl[cb51db93cbf9f55c]::DynamicConfig<rustc_query_system[f0ce38311c874f6d]::query::caches::SingleCache<rustc_middle[31e5eb56d6ce1ef8]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[cb51db93cbf9f55c]::plumbing::QueryCtxt, false>
  44:     0x7f791f5cccc9 - rustc_query_impl[cb51db93cbf9f55c]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
  45:     0x7f791f578236 - rustc_interface[a0a5e08285f36d55]::interface::run_compiler::<core[7e464b15e70308f6]::result::Result<(), rustc_span[5102bb35249f7207]::ErrorGuaranteed>, rustc_driver_impl[f27e31f8ff148ccd]::run_compiler::{closure#0}>::{closure#0}
  46:     0x7f791f7edde4 - std[f8d5c81aaff4de76]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[a0a5e08285f36d55]::util::run_in_thread_with_globals<rustc_interface[a0a5e08285f36d55]::util::run_in_thread_pool_with_globals<rustc_interface[a0a5e08285f36d55]::interface::run_compiler<core[7e464b15e70308f6]::result::Result<(), rustc_span[5102bb35249f7207]::ErrorGuaranteed>, rustc_driver_impl[f27e31f8ff148ccd]::run_compiler::{closure#0}>::{closure#0}, core[7e464b15e70308f6]::result::Result<(), rustc_span[5102bb35249f7207]::ErrorGuaranteed>>::{closure#0}, core[7e464b15e70308f6]::result::Result<(), rustc_span[5102bb35249f7207]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[7e464b15e70308f6]::result::Result<(), rustc_span[5102bb35249f7207]::ErrorGuaranteed>>
  47:     0x7f791f7edc10 - <<std[f8d5c81aaff4de76]::thread::Builder>::spawn_unchecked_<rustc_interface[a0a5e08285f36d55]::util::run_in_thread_with_globals<rustc_interface[a0a5e08285f36d55]::util::run_in_thread_pool_with_globals<rustc_interface[a0a5e08285f36d55]::interface::run_compiler<core[7e464b15e70308f6]::result::Result<(), rustc_span[5102bb35249f7207]::ErrorGuaranteed>, rustc_driver_impl[f27e31f8ff148ccd]::run_compiler::{closure#0}>::{closure#0}, core[7e464b15e70308f6]::result::Result<(), rustc_span[5102bb35249f7207]::ErrorGuaranteed>>::{closure#0}, core[7e464b15e70308f6]::result::Result<(), rustc_span[5102bb35249f7207]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[7e464b15e70308f6]::result::Result<(), rustc_span[5102bb35249f7207]::ErrorGuaranteed>>::{closure#1} as core[7e464b15e70308f6]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  48:     0x7f791a599705 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::hd2148634af555f73
                               at /rustc/10902058a979aaea1fcb3576d84b93ba97e3b977/library/alloc/src/boxed.rs:2016:9
  49:     0x7f791a599705 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h32103ee56b6eec9a
                               at /rustc/10902058a979aaea1fcb3576d84b93ba97e3b977/library/alloc/src/boxed.rs:2016:9
  50:     0x7f791a599705 - std::sys::pal::unix::thread::Thread::new::thread_start::hdda6f1b90fb85bed
                               at /rustc/10902058a979aaea1fcb3576d84b93ba97e3b977/library/std/src/sys/pal/unix/thread.rs:108:17
  51:     0x7f791a38155a - <unknown>
  52:     0x7f791a3fea3c - <unknown>
  53:                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.78.0-nightly (10902058a 2024-03-03) running on x86_64-unknown-linux-gnu

query stack during panic:
#0 [fn_abi_of_instance] computing call ABI of `<impl at /tmp/icemaker_global_tempdir.RyaLtQEMp4T5/rustc_testrunner_tmpdir_reporting.FcJxB8wB8kpw/mvce.rs:8:1: 8:23>::compute`
#1 [eval_to_allocation_raw] const-evaluating + checking `main::_`
#2 [eval_to_const_value_raw] simplifying constant for the type system `main::_`
#3 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to 2 previous errors

For more information about this error, try `rustc --explain E0049`.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.F-const_trait_impl`#![feature(const_trait_impl)]`F-effects`#![feature(effects)]`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.S-has-mcveStatus: A Minimal Complete and Verifiable Example has been found for this issueT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    • Status

      Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions