Skip to content

ICE with probably recursive opaque types and closures #99073

@Aegrithas

Description

@Aegrithas

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 Gs, f(fix(anything)) should be an error.

Code

fn main() {
  let _ = fix(|_: &dyn Fn()| {});
}

fn fix<F: Fn(G), G: Fn()>(f: F) -> impl Fn() {
  move || f(fix(&f))
}

Note that this fix implementation throws the ICE even without the main method, but I'm leaving it there for contrast to the other ICE.

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: no errors encountered even though `delay_span_bug` issued

error: internal compiler error: opaque type with non-universal region substs
 --> ICE.rs:6:11
  |
6 |   move || f(fix(&f))
  |           ^^^^^^^^^^
  |
  = note: delayed at compiler\rustc_borrowck\src\region_infer\opaque_types.rs:81:40

thread 'rustc' panicked at 'Box<dyn Any>', compiler\rustc_errors\src\lib.rs:1369:13
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:     0x7ff866310515 - <rustc_errors[7c23d5e4cf22f7a2]::diagnostic_builder::DiagnosticBuilderInner as core[eeb9ad4fed407cd7]::ops::drop::Drop>::drop
   8:     0x7ff8663104c9 - <rustc_errors[7c23d5e4cf22f7a2]::diagnostic_builder::DiagnosticBuilderInner as core[eeb9ad4fed407cd7]::ops::drop::Drop>::drop
   9:     0x7ff8666546d9 - rustc_query_system[58927a9c078e4f74]::query::plumbing::incremental_verify_ich_cold
  10:     0x7ff8663025f9 - <rustc_feature[3e4da95902b85434]::builtin_attrs::AttributeType as core[eeb9ad4fed407cd7]::fmt::Debug>::fmt
  11:     0x7ff866306828 - <rustc_errors[7c23d5e4cf22f7a2]::HandlerInner as core[eeb9ad4fed407cd7]::ops::drop::Drop>::drop
  12:     0x7ff861bde5a4 - rustc_driver[87b9ba788b0782fb]::pretty::print_after_hir_lowering
  13:     0x7ff861be781a - rustc_driver[87b9ba788b0782fb]::pretty::print_after_hir_lowering
  14:     0x7ff861bd48dd - rustc_driver[87b9ba788b0782fb]::pretty::print_after_hir_lowering
  15:     0x7ff861bd1ae9 - rustc_driver[87b9ba788b0782fb]::pretty::print_after_hir_lowering
  16:     0x7ff861b50a30 - <rustc_privacy[9daebf6d6dd1f9f8]::NamePrivacyVisitor as rustc_hir[ef6dd62a99d46082]::intravisit::Visitor>::visit_mod
  17:     0x7ff861b72d37 - <rustc_privacy[9daebf6d6dd1f9f8]::NamePrivacyVisitor as rustc_hir[ef6dd62a99d46082]::intravisit::Visitor>::visit_mod
  18:     0x7ff861b7cd56 - <rustc_driver[87b9ba788b0782fb]::args::Error as core[eeb9ad4fed407cd7]::fmt::Debug>::fmt
  19:     0x7ff861b7de78 - <rustc_driver[87b9ba788b0782fb]::args::Error as core[eeb9ad4fed407cd7]::fmt::Debug>::fmt
  20:     0x7ff8a09beccc - std::sys::windows::thread::Thread::new::hc027ed84984f61da
  21:     0x7ff8d65f7034 - BaseThreadInitThunk
  22:     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:     0x7ff8a022994f - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::hacdb30195c80e0b1
   1:     0x7ff8a026484a - core::fmt::write::h933e103661a87ff3
   2:     0x7ff8a021bf79 - <std::io::IoSlice as core::fmt::Debug>::fmt::hea673ff643a18274
   3:     0x7ff8a022d1fb - std::panicking::default_hook::h663c37f307fa2cce
   4:     0x7ff8a022cdee - std::panicking::default_hook::h663c37f307fa2cce
   5:     0x7ff861bbefb9 - <rustc_middle[fc52725189803489]::ty::SymbolName as core[eeb9ad4fed407cd7]::fmt::Debug>::fmt
   6:     0x7ff8a022dada - std::panicking::rust_panic_with_hook::ha00d018f7a00c749
   7:     0x7ff866310515 - <rustc_errors[7c23d5e4cf22f7a2]::diagnostic_builder::DiagnosticBuilderInner as core[eeb9ad4fed407cd7]::ops::drop::Drop>::drop
   8:     0x7ff8663104c9 - <rustc_errors[7c23d5e4cf22f7a2]::diagnostic_builder::DiagnosticBuilderInner as core[eeb9ad4fed407cd7]::ops::drop::Drop>::drop
   9:     0x7ff8666546d9 - rustc_query_system[58927a9c078e4f74]::query::plumbing::incremental_verify_ich_cold
  10:     0x7ff8663025f9 - <rustc_feature[3e4da95902b85434]::builtin_attrs::AttributeType as core[eeb9ad4fed407cd7]::fmt::Debug>::fmt
  11:     0x7ff866306828 - <rustc_errors[7c23d5e4cf22f7a2]::HandlerInner as core[eeb9ad4fed407cd7]::ops::drop::Drop>::drop
  12:     0x7ff861bde5a4 - rustc_driver[87b9ba788b0782fb]::pretty::print_after_hir_lowering
  13:     0x7ff861be781a - rustc_driver[87b9ba788b0782fb]::pretty::print_after_hir_lowering
  14:     0x7ff861bd48dd - rustc_driver[87b9ba788b0782fb]::pretty::print_after_hir_lowering
  15:     0x7ff861bd1ae9 - rustc_driver[87b9ba788b0782fb]::pretty::print_after_hir_lowering
  16:     0x7ff861b50a30 - <rustc_privacy[9daebf6d6dd1f9f8]::NamePrivacyVisitor as rustc_hir[ef6dd62a99d46082]::intravisit::Visitor>::visit_mod
  17:     0x7ff861b72d37 - <rustc_privacy[9daebf6d6dd1f9f8]::NamePrivacyVisitor as rustc_hir[ef6dd62a99d46082]::intravisit::Visitor>::visit_mod
  18:     0x7ff861b7cd56 - <rustc_driver[87b9ba788b0782fb]::args::Error as core[eeb9ad4fed407cd7]::fmt::Debug>::fmt
  19:     0x7ff861b7de78 - <rustc_driver[87b9ba788b0782fb]::args::Error as core[eeb9ad4fed407cd7]::fmt::Debug>::fmt
  20:     0x7ff8a023eccc - std::sys::windows::thread::Thread::new::hc027ed84984f61da
  21:     0x7ff8d65f7034 - BaseThreadInitThunk
  22:     0x7ff8d7242651 - RtlUserThreadStart

Metadata

Metadata

Labels

C-bugCategory: This is a bug.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️I-unsoundIssue: A soundness hole (worst kind of bug), see: https://en.wikipedia.org/wiki/SoundnessP-criticalCritical priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.T-typesRelevant to the types team, which will review and decide on the PR/issue.glacierICE tracked in rust-lang/glacier.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions