Closed
Description
Messing around with a Haskell-like implementation of fix
, I encountered two presumably similar ICEs
(would think they're the same, but the error messages are obviously different). The other one is here.
I'm pretty sure this should be an error, based on the reasoning that fix
returns an opaque type, so, while the output of fix
might be G
, it also might not (and in this case, isn't), and since f
only accepts G
s, f(fix(anything))
should be an error.
Code
fn main() {
let f = fix(|_: &dyn Fn()| {});
f();
}
fn fix<F: Fn(G), G: Fn()>(f: F) -> impl Fn() {
move || f(fix(&f))
}
Meta
rustc --version --verbose
:
rustc 1.62.0 (a8314ef7d 2022-06-27)
binary: rustc
commit-hash: a8314ef7d0ec7b75c336af2c9857bfaf43002bfc
commit-date: 2022-06-27
host: x86_64-pc-windows-msvc
release: 1.62.0
LLVM version: 14.0.5
Same ICE on nightly:
rustc 1.64.0-nightly (7425fb293 2022-06-30)
binary: rustc
commit-hash: 7425fb293f510a6f138e82a963a3bc599a5b9e1c
commit-date: 2022-06-30
host: x86_64-pc-windows-msvc
release: 1.64.0-nightly
LLVM version: 14.0.6
Error output
error: internal compiler error: /rustc/a8314ef7d0ec7b75c336af2c9857bfaf43002bfc\compiler\rustc_codegen_ssa\src\mir\block.rs:1156:22: codegen_argument: OperandRef(Immediate((i8*: %7 = load i8*, i8** %2, align 8, !nonnull !2, !align !3, !noundef !2)) @ TyAndLayout { ty: [closure@ICE.rs:7:3: 7:21], layout: Layout { fields: Arbitrary { offsets: [Size(0 bytes)], memory_index: [0] }, variants: Single { index: 0 }, abi: Scalar(Initialized { value: Pointer, valid_range: 1..=18446744073709551615 }), largest_niche: Some(Niche { offset: Size(0 bytes), value: Pointer, valid_range: 1..=18446744073709551615 }), align: AbiAndPrefAlign { abi: Align(8 bytes), pref: Align(8 bytes) }, size: Size(8 bytes) } }) invalid for pair argument
thread 'rustc' panicked at 'Box<dyn Any>', /rustc/a8314ef7d0ec7b75c336af2c9857bfaf43002bfc\compiler\rustc_errors\src\lib.rs:1335:9
stack backtrace:
0: 0x7ff8a09a994f - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::hacdb30195c80e0b1
1: 0x7ff8a09e484a - core::fmt::write::h933e103661a87ff3
2: 0x7ff8a099bf79 - <std::io::IoSlice as core::fmt::Debug>::fmt::hea673ff643a18274
3: 0x7ff8a09ad1fb - std::panicking::default_hook::h663c37f307fa2cce
4: 0x7ff8a09acdee - std::panicking::default_hook::h663c37f307fa2cce
5: 0x7ff861bbefb9 - <rustc_middle[fc52725189803489]::ty::SymbolName as core[eeb9ad4fed407cd7]::fmt::Debug>::fmt
6: 0x7ff8a09adada - std::panicking::rust_panic_with_hook::ha00d018f7a00c749
7: 0x7ff866010955 - <rustc_middle[fc52725189803489]::ty::adt::AdtKind as core[eeb9ad4fed407cd7]::fmt::Debug>::fmt
8: 0x7ff866010689 - <rustc_middle[fc52725189803489]::ty::adt::AdtKind as core[eeb9ad4fed407cd7]::fmt::Debug>::fmt
9: 0x7ff866640d49 - <rustc_query_impl[dc8a99b54703bf7d]::on_disk_cache::OnDiskCache>::store_side_effects_for_anon_node
10: 0x7ff86611b369 - <rustc_middle[fc52725189803489]::ty::subst::UserSubsts as rustc_middle[fc52725189803489]::ty::context::Lift>::lift_to_tcx
11: 0x7ff86611b153 - <rustc_middle[fc52725189803489]::ty::subst::UserSubsts as rustc_middle[fc52725189803489]::ty::context::Lift>::lift_to_tcx
12: 0x7ff86611a872 - <rustc_middle[fc52725189803489]::ty::subst::UserSubsts as rustc_middle[fc52725189803489]::ty::context::Lift>::lift_to_tcx
13: 0x7ff86609b159 - <rustc_middle[fc52725189803489]::ty::consts::valtree::ValTree>::zst
14: 0x7ff86609b1dc - <rustc_middle[fc52725189803489]::ty::consts::valtree::ValTree>::zst
15: 0x7ff8666414e8 - rustc_middle[fc52725189803489]::util::bug::bug_fmt
16: 0x7ff861ee4804 - <rustc_codegen_llvm[a47d8e5dccee9039]::back::write::DiagnosticHandlers as core[eeb9ad4fed407cd7]::ops::drop::Drop>::drop
17: 0x7ff861ee8678 - <rustc_codegen_llvm[a47d8e5dccee9039]::back::write::DiagnosticHandlers as core[eeb9ad4fed407cd7]::ops::drop::Drop>::drop
18: 0x7ff861ed6e91 - <rustc_codegen_llvm[a47d8e5dccee9039]::back::write::DiagnosticHandlers as core[eeb9ad4fed407cd7]::ops::drop::Drop>::drop
19: 0x7ff861e96942 - <rustc_codegen_llvm[a47d8e5dccee9039]::back::write::DiagnosticHandlers as core[eeb9ad4fed407cd7]::ops::drop::Drop>::drop
20: 0x7ff861e4e1c5 - <rustc_codegen_llvm[a47d8e5dccee9039]::context::CodegenCx as rustc_codegen_ssa[c1f88a47c86a60f2]::traits::type_::LayoutTypeMethods>::reg_backend_type
21: 0x7ff861e140b1 - <rustc_codegen_llvm[a47d8e5dccee9039]::base::ValueIter as core[eeb9ad4fed407cd7]::iter::traits::iterator::Iterator>::next
22: 0x7ff861e90531 - <rustc_codegen_llvm[a47d8e5dccee9039]::back::write::DiagnosticHandlers as core[eeb9ad4fed407cd7]::ops::drop::Drop>::drop
23: 0x7ff861e13a88 - <rustc_codegen_llvm[a47d8e5dccee9039]::base::ValueIter as core[eeb9ad4fed407cd7]::iter::traits::iterator::Iterator>::next
24: 0x7ff861e95539 - <rustc_codegen_llvm[a47d8e5dccee9039]::back::write::DiagnosticHandlers as core[eeb9ad4fed407cd7]::ops::drop::Drop>::drop
25: 0x7ff861d8fae5 - <rustc_codegen_llvm[a47d8e5dccee9039]::LlvmCodegenBackend as rustc_codegen_ssa[c1f88a47c86a60f2]::traits::backend::CodegenBackend>::codegen_crate
26: 0x7ff861d1c072 - rustc_interface[8b243e6e96a34b94]::passes::analysis
27: 0x7ff861cdd4f0 - <rustc_interface[8b243e6e96a34b94]::passes::LintStoreExpandImpl as rustc_expand[5fb5fc673353c3e9]::base::LintStoreExpand>::pre_expansion_lint
28: 0x7ff861cbaee0 - <rustc_interface[8b243e6e96a34b94]::queries::Queries>::ongoing_codegen
29: 0x7ff861b4e244 - <rustc_privacy[9daebf6d6dd1f9f8]::NamePrivacyVisitor as rustc_hir[ef6dd62a99d46082]::intravisit::Visitor>::visit_mod
30: 0x7ff861bd19e5 - rustc_driver[87b9ba788b0782fb]::pretty::print_after_hir_lowering
31: 0x7ff861b50a30 - <rustc_privacy[9daebf6d6dd1f9f8]::NamePrivacyVisitor as rustc_hir[ef6dd62a99d46082]::intravisit::Visitor>::visit_mod
32: 0x7ff861b72d37 - <rustc_privacy[9daebf6d6dd1f9f8]::NamePrivacyVisitor as rustc_hir[ef6dd62a99d46082]::intravisit::Visitor>::visit_mod
33: 0x7ff861b7cd56 - <rustc_driver[87b9ba788b0782fb]::args::Error as core[eeb9ad4fed407cd7]::fmt::Debug>::fmt
34: 0x7ff861b7de78 - <rustc_driver[87b9ba788b0782fb]::args::Error as core[eeb9ad4fed407cd7]::fmt::Debug>::fmt
35: 0x7ff8a09beccc - std::sys::windows::thread::Thread::new::hc027ed84984f61da
36: 0x7ff8d65f7034 - BaseThreadInitThunk
37: 0x7ff8d7242651 - RtlUserThreadStart
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.62.0 (a8314ef7d 2022-06-27) running on x86_64-pc-windows-msvc
query stack during panic:
end of query stack
Backtrace
0: 0x7ff8a09a994f - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::hacdb30195c80e0b1
1: 0x7ff8a09e484a - core::fmt::write::h933e103661a87ff3
2: 0x7ff8a099bf79 - <std::io::IoSlice as core::fmt::Debug>::fmt::hea673ff643a18274
3: 0x7ff8a09ad1fb - std::panicking::default_hook::h663c37f307fa2cce
4: 0x7ff8a09acdee - std::panicking::default_hook::h663c37f307fa2cce
5: 0x7ff861bbefb9 - <rustc_middle[fc52725189803489]::ty::SymbolName as core[eeb9ad4fed407cd7]::fmt::Debug>::fmt
6: 0x7ff8a09adada - std::panicking::rust_panic_with_hook::ha00d018f7a00c749
7: 0x7ff866010955 - <rustc_middle[fc52725189803489]::ty::adt::AdtKind as core[eeb9ad4fed407cd7]::fmt::Debug>::fmt
8: 0x7ff866010689 - <rustc_middle[fc52725189803489]::ty::adt::AdtKind as core[eeb9ad4fed407cd7]::fmt::Debug>::fmt
9: 0x7ff866640d49 - <rustc_query_impl[dc8a99b54703bf7d]::on_disk_cache::OnDiskCache>::store_side_effects_for_anon_node
10: 0x7ff86611b369 - <rustc_middle[fc52725189803489]::ty::subst::UserSubsts as rustc_middle[fc52725189803489]::ty::context::Lift>::lift_to_tcx
11: 0x7ff86611b153 - <rustc_middle[fc52725189803489]::ty::subst::UserSubsts as rustc_middle[fc52725189803489]::ty::context::Lift>::lift_to_tcx
12: 0x7ff86611a872 - <rustc_middle[fc52725189803489]::ty::subst::UserSubsts as rustc_middle[fc52725189803489]::ty::context::Lift>::lift_to_tcx
13: 0x7ff86609b159 - <rustc_middle[fc52725189803489]::ty::consts::valtree::ValTree>::zst
14: 0x7ff86609b1dc - <rustc_middle[fc52725189803489]::ty::consts::valtree::ValTree>::zst
15: 0x7ff8666414e8 - rustc_middle[fc52725189803489]::util::bug::bug_fmt
16: 0x7ff861ee4804 - <rustc_codegen_llvm[a47d8e5dccee9039]::back::write::DiagnosticHandlers as core[eeb9ad4fed407cd7]::ops::drop::Drop>::drop
17: 0x7ff861ee8678 - <rustc_codegen_llvm[a47d8e5dccee9039]::back::write::DiagnosticHandlers as core[eeb9ad4fed407cd7]::ops::drop::Drop>::drop
18: 0x7ff861ed6e91 - <rustc_codegen_llvm[a47d8e5dccee9039]::back::write::DiagnosticHandlers as core[eeb9ad4fed407cd7]::ops::drop::Drop>::drop
19: 0x7ff861e96942 - <rustc_codegen_llvm[a47d8e5dccee9039]::back::write::DiagnosticHandlers as core[eeb9ad4fed407cd7]::ops::drop::Drop>::drop
20: 0x7ff861e4e1c5 - <rustc_codegen_llvm[a47d8e5dccee9039]::context::CodegenCx as rustc_codegen_ssa[c1f88a47c86a60f2]::traits::type_::LayoutTypeMethods>::reg_backend_type
21: 0x7ff861e140b1 - <rustc_codegen_llvm[a47d8e5dccee9039]::base::ValueIter as core[eeb9ad4fed407cd7]::iter::traits::iterator::Iterator>::next
22: 0x7ff861e90531 - <rustc_codegen_llvm[a47d8e5dccee9039]::back::write::DiagnosticHandlers as core[eeb9ad4fed407cd7]::ops::drop::Drop>::drop
23: 0x7ff861e13a88 - <rustc_codegen_llvm[a47d8e5dccee9039]::base::ValueIter as core[eeb9ad4fed407cd7]::iter::traits::iterator::Iterator>::next
24: 0x7ff861e95539 - <rustc_codegen_llvm[a47d8e5dccee9039]::back::write::DiagnosticHandlers as core[eeb9ad4fed407cd7]::ops::drop::Drop>::drop
25: 0x7ff861d8fae5 - <rustc_codegen_llvm[a47d8e5dccee9039]::LlvmCodegenBackend as rustc_codegen_ssa[c1f88a47c86a60f2]::traits::backend::CodegenBackend>::codegen_crate
26: 0x7ff861d1c072 - rustc_interface[8b243e6e96a34b94]::passes::analysis
27: 0x7ff861cdd4f0 - <rustc_interface[8b243e6e96a34b94]::passes::LintStoreExpandImpl as rustc_expand[5fb5fc673353c3e9]::base::LintStoreExpand>::pre_expansion_lint
28: 0x7ff861cbaee0 - <rustc_interface[8b243e6e96a34b94]::queries::Queries>::ongoing_codegen
29: 0x7ff861b4e244 - <rustc_privacy[9daebf6d6dd1f9f8]::NamePrivacyVisitor as rustc_hir[ef6dd62a99d46082]::intravisit::Visitor>::visit_mod
30: 0x7ff861bd19e5 - rustc_driver[87b9ba788b0782fb]::pretty::print_after_hir_lowering
31: 0x7ff861b50a30 - <rustc_privacy[9daebf6d6dd1f9f8]::NamePrivacyVisitor as rustc_hir[ef6dd62a99d46082]::intravisit::Visitor>::visit_mod
32: 0x7ff861b72d37 - <rustc_privacy[9daebf6d6dd1f9f8]::NamePrivacyVisitor as rustc_hir[ef6dd62a99d46082]::intravisit::Visitor>::visit_mod
33: 0x7ff861b7cd56 - <rustc_driver[87b9ba788b0782fb]::args::Error as core[eeb9ad4fed407cd7]::fmt::Debug>::fmt
34: 0x7ff861b7de78 - <rustc_driver[87b9ba788b0782fb]::args::Error as core[eeb9ad4fed407cd7]::fmt::Debug>::fmt
35: 0x7ff8a09beccc - std::sys::windows::thread::Thread::new::hc027ed84984f61da
36: 0x7ff8d65f7034 - BaseThreadInitThunk
37: 0x7ff8d7242651 - RtlUserThreadStart