Skip to content

[ICE] Static items with an fn type which uses a wildcard results in an ICE #74086

Closed

Description

Code

static BUG: fn(_) -> u8 = |_| 8;

https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=534f07f9eb0e8b5f12f6fd99b5b98f24
The actual cause seems to be the fn(_), return type does not affect it

Meta

rustc --version --verbose:

rustc 1.44.0-nightly (6dee5f112 2020-04-06)
binary: rustc
commit-hash: 6dee5f1126dfd5c9314ee5ae9d9eb010e35ef257
commit-date: 2020-04-06
host: x86_64-pc-windows-msvc
release: 1.44.0-nightly
LLVM version: 9.0

The bug seems to appear in both stable and nightly

Error output

error: internal compiler error: src/librustc_codegen_llvm/context.rs:849: failed to get layout for `[type error]`: the type `[type error]` has an unknown layout
Backtrace

   0: <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt
   1: core::fmt::write
   2: <std::io::IoSlice as core::fmt::Debug>::fmt
   3: std::panicking::take_hook
   4: std::panicking::take_hook
   5: rustc_driver::report_ice
   6: std::panicking::rust_panic_with_hook
   7: rustc_errors::diagnostic_builder::DiagnosticBuilder::code
   8: rustc_errors::HandlerInner::treat_err_as_bug
   9: rustc_errors::Handler::bug
  10: rustc_middle::util::bug::bug_fmt
  11: rustc_middle::ty::walk::walk_shallow
  12: rustc_middle::ty::walk::walk_shallow
  13: rustc_middle::util::bug::bug_fmt
  14: rustc_middle::util::bug::bug_fmt
  15: <rustc_codegen_llvm::context::CodegenCx as rustc_target::abi::LayoutOf>::spanned_layout_of
  16: <rustc_codegen_llvm::context::CodegenCx as rustc_target::abi::LayoutOf>::layout_of
  17: <rustc_codegen_llvm::llvm_::OperandBundleDef as core::ops::drop::Drop>::drop
  18: <rustc_codegen_llvm::llvm_::OperandBundleDef as core::ops::drop::Drop>::drop
  19: <rustc_codegen_llvm::builder::Builder as rustc_codegen_ssa::traits::builder::BuilderMethods>::unchecked_umul
  20: <rustc_codegen_llvm::llvm_::ffi::debuginfo::DISPFlags as core::fmt::Debug>::fmt
  21: <rustc_target::abi::TyAndLayout<&rustc_middle::ty::TyS> as rustc_codegen_llvm::type_of::LayoutLlvmExt>::llvm_type
  22: rustc_codegen_llvm::mono_item::<impl rustc_codegen_ssa::traits::declare::PreDefineMethods for rustc_codegen_llvm::context::CodegenCx>::predefine_static
  23: <rustc_codegen_llvm::base::ValueIter as core::iter::traits::iterator::Iterator>::next
  24: <rustc_codegen_llvm::llvm_::ffi::PassKind as core::fmt::Debug>::fmt
  25: <rustc_target::abi::TyAndLayout<&rustc_middle::ty::TyS> as rustc_codegen_llvm::type_of::LayoutLlvmExt>::pointee_info_at
  26: <rustc_codegen_llvm::base::ValueIter as core::iter::traits::iterator::Iterator>::next
  27: <rustc_codegen_llvm::back::lto::ThinLTOImports as core::fmt::Debug>::fmt
  28: <rustc_codegen_llvm::LlvmCodegenBackend as rustc_codegen_ssa::traits::backend::CodegenBackend>::codegen_crate
  29: rustc_interface::passes::QueryContext::print_stats
  30: <rustc_interface::util::ReplaceBodyWithLoop as rustc_ast::mut_visit::MutVisitor>::visit_mac
  31: rustc_interface::queries::Queries::ongoing_codegen
  32: rustc_driver::pretty::print_after_hir_lowering
  33: <rustc_span::symbol::SymbolStr as core::fmt::Display>::fmt
  34: <rustc_span::symbol::SymbolStr as core::fmt::Display>::fmt
  35: <(&rustc_middle::ty::sty::Const, rustc_middle::mir::Field) as rustc_middle::ty::query::keys::Key>::query_crate
  36: rustc_driver::pretty::print_after_hir_lowering
  37: ZN244_$LT$std..error..$LT$impl$u20$core..convert..From$LT$alloc..string..String$GT$$u20$for$u20$alloc..boxed..Box$LT$dyn$u20$std..error..Error$u2b$core..marker..Sync$u2b$core..marker..Send$GT$$GT$..from..StringError$u20$as$u20$core..fmt..Display$GT$3fmt17
  38: std::sys::windows::thread::Thread::new
  39: BaseThreadInitThunk
  40: RtlUserThreadStart

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

Metadata

Assignees

Labels

C-bugCategory: This is a bug.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️P-mediumMedium priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.regression-from-stable-to-stablePerformance or correctness regression from one stable version to another.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions