Skip to content

ice: unexpected non-type generic_const_exprs #102768

Closed

Description

@matthiaskrgr

Code

#![feature(generic_associated_types)]

trait X {
    type Y<'a>;
}

const _: () = {
  fn f2<'a>(arg : Box<dyn X<Y<1> = &'a ()>>) {}
      //~^ ERROR this associated type takes 1 lifetime argument but 0 lifetime arguments
      //~| ERROR this associated type takes 0 generic arguments but 1 generic argument
};

fn main() {}

Meta

rustc --version --verbose:

rustc 1.66.0-nightly (0ca356586 2022-10-06)
binary: rustc
commit-hash: 0ca356586fed56002b10920fd21ddf6fb12de797
commit-date: 2022-10-06
host: x86_64-unknown-linux-gnu
release: 1.66.0-nightly
LLVM version: 15.0.2

Error output

rustc <file> "-Zcrate-attr=feature(generic_const_exprs)"

<output>
Backtrace

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

warning: the feature `generic_associated_types` has been stable since 1.65.0 and no longer requires an attribute to enable
 --> ./4846af96d32ac6d91958f8be05cd7e0107845232.rs:1:12
  |
1 | #![feature(generic_associated_types)]
  |            ^^^^^^^^^^^^^^^^^^^^^^^^
  |
  = note: `#[warn(stable_features)]` on by default

error: internal compiler error: compiler/rustc_hir_analysis/src/collect/type_of.rs:523:18: unexpected non-type Node::GenericParam: Lifetime { kind: Explicit }

thread 'rustc' panicked at 'Box<dyn Any>', /rustc/0ca356586fed56002b10920fd21ddf6fb12de797/compiler/rustc_errors/src/lib.rs:1503:9
stack backtrace:
   0:     0x7f5db4210450 - std::backtrace_rs::backtrace::libunwind::trace::hcf69096e68cbc96c
                               at /rustc/0ca356586fed56002b10920fd21ddf6fb12de797/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   1:     0x7f5db4210450 - std::backtrace_rs::backtrace::trace_unsynchronized::hc388a2eb8060d628
                               at /rustc/0ca356586fed56002b10920fd21ddf6fb12de797/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7f5db4210450 - std::sys_common::backtrace::_print_fmt::h4c04c7375802901c
                               at /rustc/0ca356586fed56002b10920fd21ddf6fb12de797/library/std/src/sys_common/backtrace.rs:66:5
   3:     0x7f5db4210450 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h0437a8b14d91b76c
                               at /rustc/0ca356586fed56002b10920fd21ddf6fb12de797/library/std/src/sys_common/backtrace.rs:45:22
   4:     0x7f5db426b21e - core::fmt::write::h3b1165d45b8cb3f7
                               at /rustc/0ca356586fed56002b10920fd21ddf6fb12de797/library/core/src/fmt/mod.rs:1209:17
   5:     0x7f5db4200fd5 - std::io::Write::write_fmt::h108967c06574ddc1
                               at /rustc/0ca356586fed56002b10920fd21ddf6fb12de797/library/std/src/io/mod.rs:1679:15
   6:     0x7f5db42131f3 - std::sys_common::backtrace::_print::haaa35276780afaf9
                               at /rustc/0ca356586fed56002b10920fd21ddf6fb12de797/library/std/src/sys_common/backtrace.rs:48:5
   7:     0x7f5db42131f3 - std::sys_common::backtrace::print::hbb2439e50cf7a680
                               at /rustc/0ca356586fed56002b10920fd21ddf6fb12de797/library/std/src/sys_common/backtrace.rs:35:9
   8:     0x7f5db42131f3 - std::panicking::default_hook::{{closure}}::h255e62e45345406e
                               at /rustc/0ca356586fed56002b10920fd21ddf6fb12de797/library/std/src/panicking.rs:267:22
   9:     0x7f5db4212eca - std::panicking::default_hook::h3a9c05016eae076b
                               at /rustc/0ca356586fed56002b10920fd21ddf6fb12de797/library/std/src/panicking.rs:286:9
  10:     0x7f5db6b36cd1 - <rustc_driver[f8d5eb37f9652177]::DEFAULT_HOOK::{closure#0}::{closure#0} as core[341adad06997dc31]::ops::function::FnOnce<(&core[341adad06997dc31]::panic::panic_info::PanicInfo,)>>::call_once::{shim:vtable#0}
  11:     0x7f5db4213a2b - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::h96fcb5350a0ce4d2
                               at /rustc/0ca356586fed56002b10920fd21ddf6fb12de797/library/alloc/src/boxed.rs:1952:9
  12:     0x7f5db4213a2b - std::panicking::rust_panic_with_hook::h1e087acdfd3a88b4
                               at /rustc/0ca356586fed56002b10920fd21ddf6fb12de797/library/std/src/panicking.rs:673:13
  13:     0x7f5db7b309e1 - std[ec613a431564c17a]::panicking::begin_panic::<rustc_errors[827f592ed624eae5]::ExplicitBug>::{closure#0}
  14:     0x7f5db7b2c836 - std[ec613a431564c17a]::sys_common::backtrace::__rust_end_short_backtrace::<std[ec613a431564c17a]::panicking::begin_panic<rustc_errors[827f592ed624eae5]::ExplicitBug>::{closure#0}, !>
  15:     0x7f5db7b2c7d6 - std[ec613a431564c17a]::panicking::begin_panic::<rustc_errors[827f592ed624eae5]::ExplicitBug>
  16:     0x7f5db7b2c7c6 - std[ec613a431564c17a]::panic::panic_any::<rustc_errors[827f592ed624eae5]::ExplicitBug>
  17:     0x7f5db7b280af - <rustc_errors[827f592ed624eae5]::HandlerInner>::bug::<&alloc[574e8598a5f01642]::string::String>
  18:     0x7f5db7b27be0 - <rustc_errors[827f592ed624eae5]::Handler>::bug::<&alloc[574e8598a5f01642]::string::String>
  19:     0x7f5db7b6d5ad - rustc_middle[8fec32cc1d722bdc]::ty::context::tls::with_context_opt::<rustc_middle[8fec32cc1d722bdc]::ty::context::tls::with_opt<rustc_middle[8fec32cc1d722bdc]::util::bug::opt_span_bug_fmt<rustc_span[97dc9a00dee87296]::span_encoding::Span>::{closure#0}, ()>::{closure#0}, ()>
  20:     0x7f5db7b6e416 - rustc_middle[8fec32cc1d722bdc]::util::bug::opt_span_bug_fmt::<rustc_span[97dc9a00dee87296]::span_encoding::Span>
  21:     0x7f5db55295a3 - rustc_middle[8fec32cc1d722bdc]::util::bug::bug_fmt
  22:     0x7f5db679754a - rustc_hir_analysis[23b58cca7863dc36]::collect::type_of::type_of
  23:     0x7f5db5fe894c - rustc_query_system[8eac85d8325cc65c]::query::plumbing::get_query::<rustc_query_impl[8927692615c9b81a]::queries::type_of, rustc_query_impl[8927692615c9b81a]::plumbing::QueryCtxt>
  24:     0x7f5db6798dcb - rustc_hir_analysis[23b58cca7863dc36]::collect::type_of::type_of
  25:     0x7f5db5fe894c - rustc_query_system[8eac85d8325cc65c]::query::plumbing::get_query::<rustc_query_impl[8927692615c9b81a]::queries::type_of, rustc_query_impl[8927692615c9b81a]::plumbing::QueryCtxt>
  26:     0x7f5db5caff89 - <rustc_middle[8fec32cc1d722bdc]::ty::consts::Const>::from_opt_const_arg_anon_const
  27:     0x7f5db5c9ecdb - <rustc_middle[8fec32cc1d722bdc]::ty::consts::Const>::from_anon_const
  28:     0x7f5db6da16e0 - <rustc_hir_analysis[23b58cca7863dc36]::collect::predicates_of::const_evaluatable_predicates_of::ConstCollector as rustc_hir[b64f9c04a004c0d9]::intravisit::Visitor>::visit_anon_const
  29:     0x7f5db6df28ae - rustc_hir[b64f9c04a004c0d9]::intravisit::walk_generic_args::<rustc_hir_analysis[23b58cca7863dc36]::collect::predicates_of::const_evaluatable_predicates_of::ConstCollector>
  30:     0x7f5db6df4363 - rustc_hir[b64f9c04a004c0d9]::intravisit::walk_assoc_type_binding::<rustc_hir_analysis[23b58cca7863dc36]::collect::predicates_of::const_evaluatable_predicates_of::ConstCollector>
  31:     0x7f5db6df28d4 - rustc_hir[b64f9c04a004c0d9]::intravisit::walk_generic_args::<rustc_hir_analysis[23b58cca7863dc36]::collect::predicates_of::const_evaluatable_predicates_of::ConstCollector>
  32:     0x7f5db6df9d0d - rustc_hir[b64f9c04a004c0d9]::intravisit::walk_path::<rustc_hir_analysis[23b58cca7863dc36]::collect::predicates_of::const_evaluatable_predicates_of::ConstCollector>
  33:     0x7f5db6df53dc - rustc_hir[b64f9c04a004c0d9]::intravisit::walk_ty::<rustc_hir_analysis[23b58cca7863dc36]::collect::predicates_of::const_evaluatable_predicates_of::ConstCollector>
  34:     0x7f5db6df28ae - rustc_hir[b64f9c04a004c0d9]::intravisit::walk_generic_args::<rustc_hir_analysis[23b58cca7863dc36]::collect::predicates_of::const_evaluatable_predicates_of::ConstCollector>
  35:     0x7f5db6df9d0d - rustc_hir[b64f9c04a004c0d9]::intravisit::walk_path::<rustc_hir_analysis[23b58cca7863dc36]::collect::predicates_of::const_evaluatable_predicates_of::ConstCollector>
  36:     0x7f5db6df037e - rustc_hir[b64f9c04a004c0d9]::intravisit::walk_fn_decl::<rustc_hir_analysis[23b58cca7863dc36]::collect::predicates_of::const_evaluatable_predicates_of::ConstCollector>
  37:     0x7f5db6323d94 - rustc_hir_analysis[23b58cca7863dc36]::collect::predicates_of::gather_explicit_predicates_of
  38:     0x7f5db6321321 - rustc_hir_analysis[23b58cca7863dc36]::collect::predicates_of::explicit_predicates_of
  39:     0x7f5db63107b8 - rustc_query_system[8eac85d8325cc65c]::query::plumbing::get_query::<rustc_query_impl[8927692615c9b81a]::queries::explicit_predicates_of, rustc_query_impl[8927692615c9b81a]::plumbing::QueryCtxt>
  40:     0x7f5db63103e3 - <rustc_query_impl[8927692615c9b81a]::Queries as rustc_middle[8fec32cc1d722bdc]::ty::query::QueryEngine>::explicit_predicates_of
  41:     0x7f5db676e2e1 - rustc_hir_analysis[23b58cca7863dc36]::collect::predicates_defined_on
  42:     0x7f5db61f5f57 - rustc_query_system[8eac85d8325cc65c]::query::plumbing::get_query::<rustc_query_impl[8927692615c9b81a]::queries::predicates_defined_on, rustc_query_impl[8927692615c9b81a]::plumbing::QueryCtxt>
  43:     0x7f5db61f5b93 - <rustc_query_impl[8927692615c9b81a]::Queries as rustc_middle[8fec32cc1d722bdc]::ty::query::QueryEngine>::predicates_defined_on
  44:     0x7f5db59ae96b - rustc_hir_analysis[23b58cca7863dc36]::collect::predicates_of::predicates_of
  45:     0x7f5db5cec496 - rustc_query_system[8eac85d8325cc65c]::query::plumbing::get_query::<rustc_query_impl[8927692615c9b81a]::queries::predicates_of, rustc_query_impl[8927692615c9b81a]::plumbing::QueryCtxt>
  46:     0x7f5db5cec0c3 - <rustc_query_impl[8927692615c9b81a]::Queries as rustc_middle[8fec32cc1d722bdc]::ty::query::QueryEngine>::predicates_of
  47:     0x7f5db5c6b5d1 - <rustc_hir_analysis[23b58cca7863dc36]::collect::CollectItemTypesVisitor as rustc_hir[b64f9c04a004c0d9]::intravisit::Visitor>::visit_item
  48:     0x7f5db5c68bf4 - <rustc_middle[8fec32cc1d722bdc]::hir::map::Map>::visit_item_likes_in_module::<rustc_hir_analysis[23b58cca7863dc36]::collect::CollectItemTypesVisitor>
  49:     0x7f5db5c68abc - rustc_hir_analysis[23b58cca7863dc36]::collect::collect_mod_item_types
  50:     0x7f5db61c7618 - rustc_query_system[8eac85d8325cc65c]::query::plumbing::try_execute_query::<rustc_query_impl[8927692615c9b81a]::plumbing::QueryCtxt, rustc_query_system[8eac85d8325cc65c]::query::caches::DefaultCache<rustc_span[97dc9a00dee87296]::def_id::LocalDefId, ()>>
  51:     0x7f5db6555f69 - rustc_query_system[8eac85d8325cc65c]::query::plumbing::get_query::<rustc_query_impl[8927692615c9b81a]::queries::collect_mod_item_types, rustc_query_impl[8927692615c9b81a]::plumbing::QueryCtxt>
  52:     0x7f5db5e7357c - <rustc_middle[8fec32cc1d722bdc]::hir::map::Map>::for_each_module::<rustc_hir_analysis[23b58cca7863dc36]::check_crate::{closure#0}::{closure#0}::{closure#0}>
  53:     0x7f5db5e71bf8 - <rustc_session[5f8ba50a91a4fb10]::session::Session>::track_errors::<rustc_hir_analysis[23b58cca7863dc36]::check_crate::{closure#0}, ()>
  54:     0x7f5db5e71932 - rustc_hir_analysis[23b58cca7863dc36]::check_crate
  55:     0x7f5db5e716d7 - rustc_interface[ef326ff72e9f2695]::passes::analysis
  56:     0x7f5db68a79b4 - rustc_query_system[8eac85d8325cc65c]::query::plumbing::try_execute_query::<rustc_query_impl[8927692615c9b81a]::plumbing::QueryCtxt, rustc_query_system[8eac85d8325cc65c]::query::caches::DefaultCache<(), core[341adad06997dc31]::result::Result<(), rustc_errors[827f592ed624eae5]::ErrorGuaranteed>>>
  57:     0x7f5db68a76e7 - rustc_query_system[8eac85d8325cc65c]::query::plumbing::get_query::<rustc_query_impl[8927692615c9b81a]::queries::analysis, rustc_query_impl[8927692615c9b81a]::plumbing::QueryCtxt>
  58:     0x7f5db5809484 - <rustc_interface[ef326ff72e9f2695]::passes::QueryContext>::enter::<rustc_driver[f8d5eb37f9652177]::run_compiler::{closure#1}::{closure#2}::{closure#3}, core[341adad06997dc31]::result::Result<(), rustc_errors[827f592ed624eae5]::ErrorGuaranteed>>
  59:     0x7f5db5804019 - rustc_interface[ef326ff72e9f2695]::interface::create_compiler_and_run::<core[341adad06997dc31]::result::Result<(), rustc_errors[827f592ed624eae5]::ErrorGuaranteed>, rustc_driver[f8d5eb37f9652177]::run_compiler::{closure#1}>
  60:     0x7f5db5802922 - <scoped_tls[fa3665dae4c012d7]::ScopedKey<rustc_span[97dc9a00dee87296]::SessionGlobals>>::set::<rustc_interface[ef326ff72e9f2695]::interface::run_compiler<core[341adad06997dc31]::result::Result<(), rustc_errors[827f592ed624eae5]::ErrorGuaranteed>, rustc_driver[f8d5eb37f9652177]::run_compiler::{closure#1}>::{closure#0}, core[341adad06997dc31]::result::Result<(), rustc_errors[827f592ed624eae5]::ErrorGuaranteed>>
  61:     0x7f5db580260f - std[ec613a431564c17a]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[ef326ff72e9f2695]::util::run_in_thread_pool_with_globals<rustc_interface[ef326ff72e9f2695]::interface::run_compiler<core[341adad06997dc31]::result::Result<(), rustc_errors[827f592ed624eae5]::ErrorGuaranteed>, rustc_driver[f8d5eb37f9652177]::run_compiler::{closure#1}>::{closure#0}, core[341adad06997dc31]::result::Result<(), rustc_errors[827f592ed624eae5]::ErrorGuaranteed>>::{closure#0}, core[341adad06997dc31]::result::Result<(), rustc_errors[827f592ed624eae5]::ErrorGuaranteed>>
  62:     0x7f5db694d530 - <<std[ec613a431564c17a]::thread::Builder>::spawn_unchecked_<rustc_interface[ef326ff72e9f2695]::util::run_in_thread_pool_with_globals<rustc_interface[ef326ff72e9f2695]::interface::run_compiler<core[341adad06997dc31]::result::Result<(), rustc_errors[827f592ed624eae5]::ErrorGuaranteed>, rustc_driver[f8d5eb37f9652177]::run_compiler::{closure#1}>::{closure#0}, core[341adad06997dc31]::result::Result<(), rustc_errors[827f592ed624eae5]::ErrorGuaranteed>>::{closure#0}, core[341adad06997dc31]::result::Result<(), rustc_errors[827f592ed624eae5]::ErrorGuaranteed>>::{closure#1} as core[341adad06997dc31]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  63:     0x7f5db421d503 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h716e33e5062fa80e
                               at /rustc/0ca356586fed56002b10920fd21ddf6fb12de797/library/alloc/src/boxed.rs:1938:9
  64:     0x7f5db421d503 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::hda2b1d1f461e1c20
                               at /rustc/0ca356586fed56002b10920fd21ddf6fb12de797/library/alloc/src/boxed.rs:1938:9
  65:     0x7f5db421d503 - std::sys::unix::thread::Thread::new::thread_start::hcbf78f667b73439d
                               at /rustc/0ca356586fed56002b10920fd21ddf6fb12de797/library/std/src/sys/unix/thread.rs:108:17
  66:     0x7f5db3f7574d - <unknown>
  67:     0x7f5db3ff7700 - <unknown>
  68:                0x0 - <unknown>

note: 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: rustc 1.66.0-nightly (0ca356586 2022-10-06) running on x86_64-unknown-linux-gnu

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

query stack during panic:
#0 [type_of] computing type of `X::Y::'a`
#1 [type_of] computing type of `_::f2::{constant#0}`
#2 [explicit_predicates_of] computing explicit predicates of `_::f2`
#3 [predicates_defined_on] computing predicates of `_::f2`
#4 [predicates_of] computing predicates of `_::f2`
#5 [collect_mod_item_types] collecting item types in top-level module
#6 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to previous error; 2 warnings emitted

Activity

  1. added
    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.
    C-bugCategory: This is a bug.
    S-has-mcveStatus: A Minimal Complete and Verifiable Example has been found for this issue
    on Oct 7, 2022
  2. self-assigned this
    on Oct 7, 2022
  3. TaKO8Ki commented on Oct 7, 2022

    @TaKO8Ki
    Member

    Rgression in #102336

  4. added a commit that references this issue on Oct 7, 2022
    d70e56a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

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-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

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions