Skip to content

ICE: issue-74614.rs with debug asserstions, mir-opt-level=3 and polymorphizations #90192

Closed
@matthiaskrgr

Description

@matthiaskrgr
Member

Code

Note that in order to reproduce this, you need a rustc build with debug assertions enabled!

code from ./src/test/ui/polymorphization/issue-74614.rs

// build-pass

fn test<T>() {
    std::mem::size_of::<T>();
}

pub fn foo<T>(_: T) -> &'static fn() {
    &(test::<T> as fn())
}

fn outer<T>() {
    foo(|| ());
}

fn main() {
    outer::<u8>();
}

Meta

rustc --version --verbose:

rustc 1.58.0-dev
binary: rustc
commit-hash: unknown
commit-date: unknown
host: x86_64-unknown-linux-gnu
release: 1.58.0-dev
LLVM version: 13.0.0

rustc @ 0119879

Error output

rustc ./src/test/ui/polymorphization/issue-74614.rs -Zmir-opt-level=3 -Zpolymorphize=on

thread 'rustc' panicked at 'assertion failed: matches!(ty.kind(), ty :: Param(_))', compiler/rustc_const_eval/src/interpret/util.rs:55:37
Backtrace

thread 'rustc' panicked at 'assertion failed: matches!(ty.kind(), ty :: Param(_))', compiler/rustc_const_eval/src/interpret/util.rs:55:37
stack backtrace:
   0:     0x7fac33bcc2ac - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::hb9742b8546a91052
   1:     0x7fac33c77d8c - core::fmt::write::h3fddcb644eebfde3
   2:     0x7fac33c10fd5 - std::io::Write::write_fmt::h1a1f2abcba70e3b1
   3:     0x7fac33bcc0cb - std::sys_common::backtrace::print::hc4410d3dd534974f
   4:     0x7fac33c197e0 - std::panicking::default_hook::{{closure}}::heb097f17356ef40d
   5:     0x7fac33c193ce - std::panicking::default_hook::h3a96289c47c5d257
   6:     0x7fac34f26215 - rustc_driver::DEFAULT_HOOK::{{closure}}::{{closure}}::h225178fa6d985d8b
   7:     0x7fac33c19fe0 - std::panicking::rust_panic_with_hook::h47efdb331119e29d
   8:     0x7fac33bce4f2 - std::panicking::begin_panic_handler::{{closure}}::h5049f125401e6ca6
   9:     0x7fac33bcc3c4 - std::sys_common::backtrace::__rust_end_short_backtrace::h05af6e9294f0df69
  10:     0x7fac33c19932 - rust_begin_unwind
  11:     0x7fac33c764e1 - core::panicking::panic_fmt::hbe77619298865d03
  12:     0x7fac33c763bd - core::panicking::panic::h46baf3c669af5f94
  13:     0x7fac3619888e - <rustc_const_eval::interpret::util::ensure_monomorphic_enough::UsedParamsNeedSubstVisitor as rustc_middle::ty::fold::TypeVisitor>::visit_ty::hfe14ca9ed1e7905f
  14:     0x7fac3619818a - rustc_const_eval::interpret::util::ensure_monomorphic_enough::h6c45688b36013c2b
  15:     0x7fac3624784b - rustc_const_eval::interpret::step::<impl rustc_const_eval::interpret::eval_context::InterpCx<M>>::eval_rvalue_into_place::h7cbada67c71e97f2
  16:     0x7fac3624258b - rustc_const_eval::interpret::step::<impl rustc_const_eval::interpret::eval_context::InterpCx<M>>::run::hd36462915a88e6bd
  17:     0x7fac36221320 - rustc_const_eval::const_eval::eval_queries::eval_to_allocation_raw_provider::hcb6d40b820eac213
  18:     0x7fac367765ec - rustc_query_system::query::plumbing::get_query::hf078d05283963f86
  19:     0x7fac36bb7ad6 - <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::eval_to_allocation_raw::hadf6f0dabc541b11
  20:     0x7fac3621f82f - rustc_const_eval::const_eval::eval_queries::eval_to_const_value_raw_provider::he61c2e0a7118f1b4
  21:     0x7fac36703b3c - rustc_query_system::query::plumbing::get_query::h02e8c9cd08509d7e
  22:     0x7fac36bb7b36 - <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::eval_to_const_value_raw::ha35a1cab1e854f95
  23:     0x7fac3621f46d - rustc_const_eval::const_eval::eval_queries::eval_to_const_value_raw_provider::he61c2e0a7118f1b4
  24:     0x7fac36703b3c - rustc_query_system::query::plumbing::get_query::h02e8c9cd08509d7e
  25:     0x7fac36bb7b36 - <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::eval_to_const_value_raw::ha35a1cab1e854f95
  26:     0x7fac37836ec7 - rustc_middle::mir::interpret::queries::<impl rustc_middle::ty::context::TyCtxt>::const_eval_global_id::h8f0768069952119a
  27:     0x7fac378f21bf - rustc_middle::mir::interpret::queries::<impl rustc_middle::ty::context::TyCtxt>::const_eval_resolve::h179c117b4c59655b
  28:     0x7fac37508662 - <rustc_trait_selection::traits::query::normalize::QueryNormalizer as rustc_middle::ty::fold::TypeFolder>::fold_const::hb245c99910ef171f
  29:     0x7fac37508801 - <rustc_trait_selection::traits::query::normalize::QueryNormalizer as rustc_middle::ty::fold::TypeFolder>::fold_mir_const::h3329ed552d54afb8
  30:     0x7fac36337d90 - <rustc_infer::infer::at::At as rustc_trait_selection::traits::query::normalize::AtExt>::normalize::h96d663739f7b49c2
  31:     0x7fac364232cb - rustc_infer::infer::InferCtxtBuilder::enter::h1134294ab10eec48
  32:     0x7fac36348491 - core::ops::function::FnOnce::call_once::h5b98c61ddb99d90e
  33:     0x7fac3675e6c8 - rustc_query_system::query::plumbing::get_query::hba56dd2bea792c90
  34:     0x7fac36bb8862 - <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::normalize_mir_const_after_erasing_regions::h274465631431d4bf
  35:     0x7fac3535f477 - rustc_middle::ty::fold::TypeFoldable::fold_with::hc8e38b3ac42451cb
  36:     0x7fac3536003a - rustc_middle::ty::fold::TypeFoldable::fold_with::hddffd8cd534f7614
  37:     0x7fac3535ea94 - rustc_middle::ty::fold::TypeFoldable::fold_with::hc2af2687f52562db
  38:     0x7fac35359d02 - rustc_middle::ty::fold::TypeFoldable::fold_with::h455d350994463488
  39:     0x7fac3535a6fc - rustc_middle::ty::fold::TypeFoldable::fold_with::h51026ce53c1af3fc
  40:     0x7fac35404f90 - rustc_middle::ty::normalize_erasing_regions::<impl rustc_middle::ty::context::TyCtxt>::normalize_erasing_regions::h82c5a1d5bce4869f
  41:     0x7fac35406d6a - rustc_middle::ty::normalize_erasing_regions::<impl rustc_middle::ty::context::TyCtxt>::subst_and_normalize_erasing_regions::he8f5f16d2a9bb3af
  42:     0x7fac353dc6b7 - rustc_mir_transform::inline::Inliner::try_inlining::hb8e29314c9b76d1a
  43:     0x7fac353d8e3d - rustc_mir_transform::inline::Inliner::process_blocks::hb2fc9a2e5cbc055e
  44:     0x7fac353d829e - <rustc_mir_transform::inline::Inline as rustc_middle::mir::MirPass>::run_pass::hf6a4eb8173b89807
  45:     0x7fac35541a58 - rustc_mir_transform::run_passes::h7dc5f990a06d68a5
  46:     0x7fac35547593 - rustc_mir_transform::optimized_mir::hf2ae489364a60b98
  47:     0x7fac3660155a - rustc_query_system::query::plumbing::try_execute_query::h2d0c9f581c548f89
  48:     0x7fac367582ef - rustc_query_system::query::plumbing::get_query::hb052f6ea106723af
  49:     0x7fac378ef416 - rustc_middle::ty::<impl rustc_middle::ty::context::TyCtxt>::instance_mir::h6924934e59e88960
  50:     0x7fac353d9dba - rustc_mir_transform::inline::Inliner::try_inlining::hb8e29314c9b76d1a
  51:     0x7fac353d8e3d - rustc_mir_transform::inline::Inliner::process_blocks::hb2fc9a2e5cbc055e
  52:     0x7fac353d829e - <rustc_mir_transform::inline::Inline as rustc_middle::mir::MirPass>::run_pass::hf6a4eb8173b89807
  53:     0x7fac35541a58 - rustc_mir_transform::run_passes::h7dc5f990a06d68a5
  54:     0x7fac35547593 - rustc_mir_transform::optimized_mir::hf2ae489364a60b98
  55:     0x7fac3660155a - rustc_query_system::query::plumbing::try_execute_query::h2d0c9f581c548f89
  56:     0x7fac367582ef - rustc_query_system::query::plumbing::get_query::hb052f6ea106723af
  57:     0x7fac378ef416 - rustc_middle::ty::<impl rustc_middle::ty::context::TyCtxt>::instance_mir::h6924934e59e88960
  58:     0x7fac352dc401 - rustc_monomorphize::collector::collect_neighbours::h536654654527a903
  59:     0x7fac352d1b84 - rustc_monomorphize::collector::collect_items_rec::h9918e4106a823ad2
  60:     0x7fac3529adc2 - rustc_session::utils::<impl rustc_session::session::Session>::time::h46f5b2cc16c744ea
  61:     0x7fac352d0569 - rustc_monomorphize::collector::collect_crate_mono_items::hd6b8da447f3d69d4
  62:     0x7fac352f2470 - rustc_monomorphize::partitioning::collect_and_partition_mono_items::hf3e18df16c46a331
  63:     0x7fac3661babc - rustc_query_system::query::plumbing::try_execute_query::h61043c045b9b17be
  64:     0x7fac367502ed - rustc_query_system::query::plumbing::get_query::ha55955bfbd52bc65
  65:     0x7fac36bb870e - <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::collect_and_partition_mono_items::hc3f40c33cf3fdcc4
  66:     0x7fac351c494e - rustc_codegen_ssa::base::codegen_crate::h152261da58a2bcb6
  67:     0x7fac350f5e0b - <rustc_codegen_llvm::LlvmCodegenBackend as rustc_codegen_ssa::traits::backend::CodegenBackend>::codegen_crate::hc019a98ce10262d7
  68:     0x7fac3508fb9f - rustc_interface::queries::Queries::ongoing_codegen::h67423ffa6421921b
  69:     0x7fac34dd09de - std::sys_common::backtrace::__rust_begin_short_backtrace::hc801dc55c4fb9438
  70:     0x7fac34eed450 - core::ops::function::FnOnce::call_once{{vtable.shim}}::h334b669fc5472cf7
  71:     0x7fac33c1d943 - std::sys::unix::thread::Thread::new::thread_start::h5b3c5f92bbe007fe
  72:     0x7fac30207259 - start_thread
  73:     0x7fac339f55e3 - __GI___clone
  74:                0x0 - <unknown>

error: internal compiler error: unexpected panic

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.58.0-dev running on x86_64-unknown-linux-gnu

note: compiler flags: -Z mir-opt-level=3 -Z polymorphize=on

query stack during panic:
#0 [eval_to_allocation_raw] const-evaluating + checking `foo::promoted[0]`
#1 [eval_to_const_value_raw] simplifying constant for the type system `foo::promoted[0]`
#2 [eval_to_const_value_raw] simplifying constant for the type system `foo::promoted[0]`
#3 [normalize_mir_const_after_erasing_regions] normalizing `foo::<[closure@./src/test/ui/polymorphization/issue-74614.rs:13:9: 13:14]>::promoted[0]`
#4 [optimized_mir] optimizing MIR for `outer`
#5 [optimized_mir] optimizing MIR for `main`
#6 [collect_and_partition_mono_items] collect_and_partition_mono_items
end of query stack

Activity

added
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.
on Oct 23, 2021
added
requires-debug-assertionsThis issue requires a build of rustc or tooling with debug-assertions in some way
on Jun 4, 2022
matthiaskrgr

matthiaskrgr commented on Nov 6, 2022

@matthiaskrgr
MemberAuthor

Seems to be fixed in nightly

added
E-needs-testCall for participation: An issue has been fixed and does not reproduce, but no test has been added.
on Nov 6, 2022
added a commit that references this issue on Mar 22, 2024
added 2 commits that reference this issue on Mar 24, 2024

Rollup merge of rust-lang#122886 - matthiaskrgr:issue90192, r=fee1-dead

ed3e660
added a commit that references this issue on Mar 24, 2024

Auto merge of rust-lang#123000 - matthiaskrgr:rollup-pa6cygu, r=matth…

added a commit that references this issue on Mar 24, 2024

Rollup merge of rust-lang#122886 - matthiaskrgr:issue90192, r=fee1-dead

702261d
added a commit that references this issue on Mar 24, 2024

Auto merge of rust-lang#123004 - matthiaskrgr:rollup-s3v4p50, r=matth…

added a commit that references this issue on Mar 24, 2024
added 2 commits that reference this issue on Mar 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.E-needs-testCall for participation: An issue has been fixed and does not reproduce, but no test has been 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.requires-debug-assertionsThis issue requires a build of rustc or tooling with debug-assertions in some way

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      Participants

      @matthiaskrgr

      Issue actions

        ICE: issue-74614.rs with debug asserstions, mir-opt-level=3 and polymorphizations · Issue #90192 · rust-lang/rust