Skip to content

Compiler Panic on specific macro expansion #103222

Closed
@blaine-dodson

Description

@blaine-dodson

Code

macro_rules! inst {
    ($name:ident ( $exe:expr;)) => {
        Instruction {
            execute: $exe,
        }
    };
}

struct Instruction {
    execute: fn(),
}

fn main() {
    let _i = inst!(
        INST ( || { Err(()) }; )
    );
}

Meta

rustc --version --verbose:

rustc 1.63.0 (4b91a6ea7 2022-08-08)
binary: rustc
commit-hash: 4b91a6ea7258a947e59c6522cd5898e7c0a6a88f
commit-date: 2022-08-08
host: x86_64-pc-windows-msvc
release: 1.63.0
LLVM version: 14.0.5

Error output

> rustc .\src\main.rs
...

error: internal compiler error: compiler\rustc_codegen_llvm\src\context.rs:975:13: failed to get layout for `[type error]`: the type `[type error]` has an unknown layout
  --> .\src\main.rs:14:1
   |
14 | fn main() {
   | ^^^^^^^^^

thread 'rustc' panicked at 'Box<dyn Any>', /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f\compiler\rustc_errors\src\lib.rs:1331:9

... backtrace here ...

note: the compiler unexpectedly panicked. this is a bug.
Backtrace

stack backtrace:
   0:     0x7ffaf4379eff - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::he6ddce8c3451a57e
   1:     0x7ffaf43b50ea - core::fmt::write::h365ccbbdf4748102
   2:     0x7ffaf436c2c9 - <std::io::IoSliceMut as core::fmt::Debug>::fmt::h29d49dd5c0747aeb
   3:     0x7ffaf437d7eb - std::panicking::default_hook::hb4271f543ae89c34
   4:     0x7ffaf437d46b - std::panicking::default_hook::hb4271f543ae89c34
   5:     0x7ffae33d7b76 - rustc_driver[183ba813ad9b9dae]::pretty::print_after_hir_lowering
   6:     0x7ffaf437df92 - std::panicking::rust_panic_with_hook::he1475943c7445074
   7:     0x7ffae3543835 - <rustc_codegen_llvm[1e06b400de6132fd]::llvm_::archive_ro::ArchiveRO as core[e6ecc7be13daddac]::ops::drop::Drop>::drop
   8:     0x7ffae3542e29 - <rustc_codegen_llvm[1e06b400de6132fd]::llvm_::archive_ro::ArchiveRO as core[e6ecc7be13daddac]::ops::drop::Drop>::drop
   9:     0x7ffae7e2d079 - _rust_realloc
  10:     0x7ffae358ca09 - <rustc_codegen_llvm[1e06b400de6132fd]::llvm_::ffi::coverageinfo::CounterMappingRegion as core[e6ecc7be13daddac]::fmt::Debug>::fmt
  11:     0x7ffae358c9a1 - <rustc_codegen_llvm[1e06b400de6132fd]::llvm_::ffi::coverageinfo::CounterMappingRegion as core[e6ecc7be13daddac]::fmt::Debug>::fmt
  12:     0x7ffae358c362 - <rustc_codegen_llvm[1e06b400de6132fd]::llvm_::ffi::coverageinfo::CounterMappingRegion as core[e6ecc7be13daddac]::fmt::Debug>::fmt
  13:     0x7ffae35e859c - <rustc_target[a8fc8fc8f2adb8e6]::abi::TyAndLayout<rustc_middle[859f69f7102253e7]::ty::Ty> as rustc_codegen_llvm[1e06b400de6132fd]::type_of::LayoutLlvmExt>::pointee_info_at
  14:     0x7ffae35e83bc - <rustc_target[a8fc8fc8f2adb8e6]::abi::TyAndLayout<rustc_middle[859f69f7102253e7]::ty::Ty> as rustc_codegen_llvm[1e06b400de6132fd]::type_of::LayoutLlvmExt>::pointee_info_at
  15:     0x7ffae7e2d10a - _rust_realloc
  16:     0x7ffae3602505 - <rustc_codegen_llvm[1e06b400de6132fd]::builder::Builder as rustc_codegen_ssa[c26d335c855d8e25]::traits::builder::BuilderMethods>::va_arg
  17:     0x7ffae35ee7de - <rustc_target[a8fc8fc8f2adb8e6]::abi::TyAndLayout<rustc_middle[859f69f7102253e7]::ty::Ty> as rustc_codegen_llvm[1e06b400de6132fd]::type_of::LayoutLlvmExt>::pointee_info_at
  18:     0x7ffae35f9756 - <rustc_target[a8fc8fc8f2adb8e6]::abi::TyAndLayout<rustc_middle[859f69f7102253e7]::ty::Ty> as rustc_codegen_llvm[1e06b400de6132fd]::type_of::LayoutLlvmExt>::pointee_info_at
  19:     0x7ffae35ebe85 - <rustc_target[a8fc8fc8f2adb8e6]::abi::TyAndLayout<rustc_middle[859f69f7102253e7]::ty::Ty> as rustc_codegen_llvm[1e06b400de6132fd]::type_of::LayoutLlvmExt>::pointee_info_at
  20:     0x7ffae362e633 - <rustc_codegen_llvm[1e06b400de6132fd]::back::write::DiagnosticHandlers as core[e6ecc7be13daddac]::ops::drop::Drop>::drop
  21:     0x7ffae3661a46 - <rustc_codegen_llvm[1e06b400de6132fd]::debuginfo::utils::FatPtrKind as core[e6ecc7be13daddac]::fmt::Debug>::fmt
  22:     0x7ffae353ae32 - rustc_interface[fd4bce9b80171ecf]::passes::analysis
  23:     0x7ffae35902c5 - <rustc_codegen_llvm[1e06b400de6132fd]::llvm_::ffi::coverageinfo::CounterMappingRegion as core[e6ecc7be13daddac]::fmt::Debug>::fmt
  24:     0x7ffae3619481 - <rustc_codegen_llvm[1e06b400de6132fd]::base::ValueIter as core[e6ecc7be13daddac]::iter::traits::iterator::Iterator>::next
  25:     0x7ffae35b4ac1 - rustc_codegen_llvm[1e06b400de6132fd]::llvm_util::target_features
  26:     0x7ffae3618e68 - <rustc_codegen_llvm[1e06b400de6132fd]::base::ValueIter as core[e6ecc7be13daddac]::iter::traits::iterator::Iterator>::next
  27:     0x7ffae356d63d - <rustc_codegen_llvm[1e06b400de6132fd]::LlvmCodegenBackend as rustc_codegen_ssa[c26d335c855d8e25]::traits::backend::CodegenBackend>::codegen_crate
  28:     0x7ffae34d6262 - rustc_interface[fd4bce9b80171ecf]::passes::analysis
  29:     0x7ffae34d4440 - <rustc_interface[fd4bce9b80171ecf]::passes::LintStoreExpandImpl as rustc_expand[e217e340a00cf420]::base::LintStoreExpand>::pre_expansion_lint
  30:     0x7ffae349e900 - <rustc_interface[fd4bce9b80171ecf]::queries::Queries>::ongoing_codegen
  31:     0x7ffae3364edb - <rustc_ast_passes[79adae6e0e894ada]::node_count::NodeCounter as rustc_ast[a6530cc9c718edce]::visit::Visitor>::visit_ident
  32:     0x7ffae33e6425 - <rustc_driver[183ba813ad9b9dae]::Compilation as core[e6ecc7be13daddac]::fmt::Debug>::fmt
  33:     0x7ffae33660ed - <rustc_ast_passes[79adae6e0e894ada]::node_count::NodeCounter as rustc_ast[a6530cc9c718edce]::visit::Visitor>::visit_ident
  34:     0x7ffae33ce416 - <rustc_metadata[96069ccbf5a419d0]::rmeta::encoder::EncodeContext as rustc_serialize[2ae8dcffef6f4bd]::serialize::Encoder>::emit_raw_bytes
  35:     0x7ffae33901d8 - <rustc_driver[183ba813ad9b9dae]::args::Error as core[e6ecc7be13daddac]::fmt::Debug>::fmt
  36:     0x7ffaf438f2bc - std::sys::windows::thread::Thread::new::h91dd265f074e3962
  37:     0x7ffb46107034 - BaseThreadInitThunk
  38:     0x7ffb479826a1 - RtlUserThreadStart

Metadata

Metadata

Assignees

No one assigned

    Labels

    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.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions