Skip to content

ICE: broken mir: Cannot compare unequal types fn(&str) and for<'r> fn(&'r str) with -Zvalidate-mir #95978

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Closed
matthiaskrgr opened this issue Apr 12, 2022 · 3 comments · Fixed by #96004
Labels
C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@matthiaskrgr
Copy link
Member

Code

code from glacier / fixed/91636.rs

fn foo(_a: &str) {}

fn main() {
    let x = foo as fn(&'static str);

    let _ = x == foo;
}

Meta

rustc --version --verbose:

rustc 1.62.0-nightly (2a83fbc42 2022-04-12)
binary: rustc
commit-hash: 2a83fbc42a9bb6bfdb8d3fb4ecce83fb410d7642
commit-date: 2022-04-12
host: x86_64-unknown-linux-gnu
release: 1.62.0-nightly
LLVM version: 14.0.0

rustc ./91636.rs -Zvalidate-mir

Backtrace

error: internal compiler error: no errors encountered even though `delay_span_bug` issued

error: internal compiler error: broken MIR in Item(WithOptConstParam { did: DefId(0:4 ~ 91636[c00a]::main), const_param_did: None }) (start of phase transition from Built) at bb0[12]:
                                Cannot compare unequal types fn(&str) and for<'r> fn(&'r str)
 --> ./91636.rs:6:13
  |
6 |     let _ = x == foo;
  |             ^^^^^^^^
  |
  = note: delayed at compiler/rustc_const_eval/src/transform/validate.rs:126:36

error: internal compiler error: broken MIR in Item(WithOptConstParam { did: DefId(0:4 ~ 91636[c00a]::main), const_param_did: None }) (after pass CheckPackedRef) at bb0[12]:
                                Cannot compare unequal types fn(&str) and for<'r> fn(&'r str)
 --> ./91636.rs:6:13
  |
6 |     let _ = x == foo;
  |             ^^^^^^^^
  |
  = note: delayed at compiler/rustc_const_eval/src/transform/validate.rs:126:36

error: internal compiler error: broken MIR in Item(WithOptConstParam { did: DefId(0:4 ~ 91636[c00a]::main), const_param_did: None }) (after pass CheckConstItemMutation) at bb0[12]:
                                Cannot compare unequal types fn(&str) and for<'r> fn(&'r str)
 --> ./91636.rs:6:13
  |
6 |     let _ = x == foo;
  |             ^^^^^^^^
  |
  = note: delayed at compiler/rustc_const_eval/src/transform/validate.rs:126:36

error: internal compiler error: broken MIR in Item(WithOptConstParam { did: DefId(0:4 ~ 91636[c00a]::main), const_param_did: None }) (after pass FunctionItemReferences) at bb0[12]:
                                Cannot compare unequal types fn(&str) and for<'r> fn(&'r str)
 --> ./91636.rs:6:13
  |
6 |     let _ = x == foo;
  |             ^^^^^^^^
  |
  = note: delayed at compiler/rustc_const_eval/src/transform/validate.rs:126:36

error: internal compiler error: broken MIR in Item(WithOptConstParam { did: DefId(0:4 ~ 91636[c00a]::main), const_param_did: None }) (after pass SimplifyCfg-initial) at bb0[12]:
                                Cannot compare unequal types fn(&str) and for<'r> fn(&'r str)
 --> ./91636.rs:6:13
  |
6 |     let _ = x == foo;
  |             ^^^^^^^^
  |
  = note: delayed at compiler/rustc_const_eval/src/transform/validate.rs:126:36

error: internal compiler error: broken MIR in Item(WithOptConstParam { did: DefId(0:4 ~ 91636[c00a]::main), const_param_did: None }) (after pass SanityCheck) at bb0[12]:
                                Cannot compare unequal types fn(&str) and for<'r> fn(&'r str)
 --> ./91636.rs:6:13
  |
6 |     let _ = x == foo;
  |             ^^^^^^^^
  |
  = note: delayed at compiler/rustc_const_eval/src/transform/validate.rs:126:36

error: internal compiler error: broken MIR in Item(WithOptConstParam { did: DefId(0:4 ~ 91636[c00a]::main), const_param_did: None }) (after pass PhaseChange-Const) at bb0[12]:
                                Cannot compare unequal types fn(&str) and for<'r> fn(&'r str)
 --> ./91636.rs:6:13
  |
6 |     let _ = x == foo;
  |             ^^^^^^^^
  |
  = note: delayed at compiler/rustc_const_eval/src/transform/validate.rs:126:36

error: internal compiler error: broken MIR in Item(WithOptConstParam { did: DefId(0:4 ~ 91636[c00a]::main), const_param_did: None }) (end of phase transition to Const) at bb0[12]:
                                Cannot compare unequal types fn(&str) and for<'r> fn(&'r str)
 --> ./91636.rs:6:13
  |
6 |     let _ = x == foo;
  |             ^^^^^^^^
  |
  = note: delayed at compiler/rustc_const_eval/src/transform/validate.rs:126:36

error: internal compiler error: broken MIR in Item(WithOptConstParam { did: DefId(0:4 ~ 91636[c00a]::main), const_param_did: None }) (start of phase transition from Const) at bb0[12]:
                                Cannot compare unequal types fn(&str) and for<'r> fn(&'r str)
 --> ./91636.rs:6:13
  |
6 |     let _ = x == foo;
  |             ^^^^^^^^
  |
  = note: delayed at compiler/rustc_const_eval/src/transform/validate.rs:126:36

error: internal compiler error: broken MIR in Item(WithOptConstParam { did: DefId(0:4 ~ 91636[c00a]::main), const_param_did: None }) (after pass PromoteTemps) at bb0[12]:
                                Cannot compare unequal types fn(&str) and for<'r> fn(&'r str)
 --> ./91636.rs:6:13
  |
6 |     let _ = x == foo;
  |             ^^^^^^^^
  |
  = note: delayed at compiler/rustc_const_eval/src/transform/validate.rs:126:36

error: internal compiler error: broken MIR in Item(WithOptConstParam { did: DefId(0:4 ~ 91636[c00a]::main), const_param_did: None }) (after pass SimplifyCfg-promote-consts) at bb0[12]:
                                Cannot compare unequal types fn(&str) and for<'r> fn(&'r str)
 --> ./91636.rs:6:13
  |
6 |     let _ = x == foo;
  |             ^^^^^^^^
  |
  = note: delayed at compiler/rustc_const_eval/src/transform/validate.rs:126:36

error: internal compiler error: broken MIR in Item(WithOptConstParam { did: DefId(0:4 ~ 91636[c00a]::main), const_param_did: None }) (end of phase transition to ConstsPromoted) at bb0[12]:
                                Cannot compare unequal types fn(&str) and for<'r> fn(&'r str)
 --> ./91636.rs:6:13
  |
6 |     let _ = x == foo;
  |             ^^^^^^^^
  |
  = note: delayed at compiler/rustc_const_eval/src/transform/validate.rs:126:36

error: internal compiler error: broken MIR in Item(WithOptConstParam { did: DefId(0:4 ~ 91636[c00a]::main), const_param_did: None }) (start of phase transition from ConstsPromoted) at bb0[12]:
                                Cannot compare unequal types fn(&str) and for<'r> fn(&'r str)
 --> ./91636.rs:6:13
  |
6 |     let _ = x == foo;
  |             ^^^^^^^^
  |
  = note: delayed at compiler/rustc_const_eval/src/transform/validate.rs:126:36

error: internal compiler error: broken MIR in Item(WithOptConstParam { did: DefId(0:4 ~ 91636[c00a]::main), const_param_did: None }) (after pass RemoveFalseEdges) at bb0[12]:
                                Cannot compare unequal types fn(&str) and for<'r> fn(&'r str)
 --> ./91636.rs:6:13
  |
6 |     let _ = x == foo;
  |             ^^^^^^^^
  |
  = note: delayed at compiler/rustc_const_eval/src/transform/validate.rs:126:36

error: internal compiler error: broken MIR in Item(WithOptConstParam { did: DefId(0:4 ~ 91636[c00a]::main), const_param_did: None }) (after pass SimplifyConstCondition-initial) at bb0[12]:
                                Cannot compare unequal types fn(&str) and for<'r> fn(&'r str)
 --> ./91636.rs:6:13
  |
6 |     let _ = x == foo;
  |             ^^^^^^^^
  |
  = note: delayed at compiler/rustc_const_eval/src/transform/validate.rs:126:36

error: internal compiler error: broken MIR in Item(WithOptConstParam { did: DefId(0:4 ~ 91636[c00a]::main), const_param_did: None }) (after pass RemoveNoopLandingPads) at bb0[12]:
                                Cannot compare unequal types fn(&str) and for<'r> fn(&'r str)
 --> ./91636.rs:6:13
  |
6 |     let _ = x == foo;
  |             ^^^^^^^^
  |
  = note: delayed at compiler/rustc_const_eval/src/transform/validate.rs:126:36

error: internal compiler error: broken MIR in Item(WithOptConstParam { did: DefId(0:4 ~ 91636[c00a]::main), const_param_did: None }) (after pass CleanupNonCodegenStatements) at bb0[12]:
                                Cannot compare unequal types fn(&str) and for<'r> fn(&'r str)
 --> ./91636.rs:6:13
  |
6 |     let _ = x == foo;
  |             ^^^^^^^^
  |
  = note: delayed at compiler/rustc_const_eval/src/transform/validate.rs:126:36

error: internal compiler error: broken MIR in Item(WithOptConstParam { did: DefId(0:4 ~ 91636[c00a]::main), const_param_did: None }) (after pass SimplifyCfg-early-opt) at bb0[10]:
                                Cannot compare unequal types fn(&str) and for<'r> fn(&'r str)
 --> ./91636.rs:6:13
  |
6 |     let _ = x == foo;
  |             ^^^^^^^^
  |
  = note: delayed at compiler/rustc_const_eval/src/transform/validate.rs:126:36

error: internal compiler error: broken MIR in Item(WithOptConstParam { did: DefId(0:4 ~ 91636[c00a]::main), const_param_did: None }) (after pass AddCallGuards) at bb0[10]:
                                Cannot compare unequal types fn(&str) and for<'r> fn(&'r str)
 --> ./91636.rs:6:13
  |
6 |     let _ = x == foo;
  |             ^^^^^^^^
  |
  = note: delayed at compiler/rustc_const_eval/src/transform/validate.rs:126:36

error: internal compiler error: broken MIR in Item(WithOptConstParam { did: DefId(0:4 ~ 91636[c00a]::main), const_param_did: None }) (after pass ElaborateDrops) at bb0[10]:
                                Cannot compare unequal types fn(&str) and for<'r> fn(&'r str)
 --> ./91636.rs:6:13
  |
6 |     let _ = x == foo;
  |             ^^^^^^^^
  |
  = note: delayed at compiler/rustc_const_eval/src/transform/validate.rs:126:36

error: internal compiler error: broken MIR in Item(WithOptConstParam { did: DefId(0:4 ~ 91636[c00a]::main), const_param_did: None }) (after pass AbortUnwindingCalls) at bb0[10]:
                                Cannot compare unequal types fn(&str) and for<'r> fn(&'r str)
 --> ./91636.rs:6:13
  |
6 |     let _ = x == foo;
  |             ^^^^^^^^
  |
  = note: delayed at compiler/rustc_const_eval/src/transform/validate.rs:126:36

error: internal compiler error: broken MIR in Item(WithOptConstParam { did: DefId(0:4 ~ 91636[c00a]::main), const_param_did: None }) (after pass AddMovesForPackedDrops) at bb0[10]:
                                Cannot compare unequal types fn(&str) and for<'r> fn(&'r str)
 --> ./91636.rs:6:13
  |
6 |     let _ = x == foo;
  |             ^^^^^^^^
  |
  = note: delayed at compiler/rustc_const_eval/src/transform/validate.rs:126:36

error: internal compiler error: broken MIR in Item(WithOptConstParam { did: DefId(0:4 ~ 91636[c00a]::main), const_param_did: None }) (after pass LowerIntrinsics) at bb0[10]:
                                Cannot compare unequal types fn(&str) and for<'r> fn(&'r str)
 --> ./91636.rs:6:13
  |
6 |     let _ = x == foo;
  |             ^^^^^^^^
  |
  = note: delayed at compiler/rustc_const_eval/src/transform/validate.rs:126:36

error: internal compiler error: broken MIR in Item(WithOptConstParam { did: DefId(0:4 ~ 91636[c00a]::main), const_param_did: None }) (after pass SimplifyCfg-elaborate-drops) at bb0[10]:
                                Cannot compare unequal types fn(&str) and for<'r> fn(&'r str)
 --> ./91636.rs:6:13
  |
6 |     let _ = x == foo;
  |             ^^^^^^^^
  |
  = note: delayed at compiler/rustc_const_eval/src/transform/validate.rs:126:36

error: internal compiler error: broken MIR in Item(WithOptConstParam { did: DefId(0:4 ~ 91636[c00a]::main), const_param_did: None }) (after pass Deaggregator) at bb0[10]:
                                Cannot compare unequal types fn(&str) and for<'r> fn(&'r str)
 --> ./91636.rs:6:13
  |
6 |     let _ = x == foo;
  |             ^^^^^^^^
  |
  = note: delayed at compiler/rustc_const_eval/src/transform/validate.rs:126:36

error: internal compiler error: broken MIR in Item(WithOptConstParam { did: DefId(0:4 ~ 91636[c00a]::main), const_param_did: None }) (after pass Derefer) at bb0[10]:
                                Cannot compare unequal types fn(&str) and for<'r> fn(&'r str)
 --> ./91636.rs:6:13
  |
6 |     let _ = x == foo;
  |             ^^^^^^^^
  |
  = note: delayed at compiler/rustc_const_eval/src/transform/validate.rs:126:36

error: internal compiler error: broken MIR in Item(WithOptConstParam { did: DefId(0:4 ~ 91636[c00a]::main), const_param_did: None }) (after pass ConstProp) at bb0[10]:
                                Cannot compare unequal types fn(&str) and for<'r> fn(&'r str)
 --> ./91636.rs:6:13
  |
6 |     let _ = x == foo;
  |             ^^^^^^^^
  |
  = note: delayed at compiler/rustc_const_eval/src/transform/validate.rs:126:36

error: internal compiler error: broken MIR in Item(WithOptConstParam { did: DefId(0:4 ~ 91636[c00a]::main), const_param_did: None }) (end of phase transition to Deaggregated) at bb0[10]:
                                Cannot compare unequal types fn(&str) and for<'r> fn(&'r str)
 --> ./91636.rs:6:13
  |
6 |     let _ = x == foo;
  |             ^^^^^^^^
  |
  = note: delayed at compiler/rustc_const_eval/src/transform/validate.rs:126:36

error: internal compiler error: broken MIR in Item(WithOptConstParam { did: DefId(0:4 ~ 91636[c00a]::main), const_param_did: None }) (start of phase transition from Deaggregated) at bb0[10]:
                                Cannot compare unequal types fn(&str) and for<'r> fn(&'r str)
 --> ./91636.rs:6:13
  |
6 |     let _ = x == foo;
  |             ^^^^^^^^
  |
  = note: delayed at compiler/rustc_const_eval/src/transform/validate.rs:126:36

error: internal compiler error: broken MIR in Item(WithOptConstParam { did: DefId(0:4 ~ 91636[c00a]::main), const_param_did: None }) (after pass LowerSliceLenCalls) at bb0[10]:
                                Cannot compare unequal types fn(&str) and for<'r> fn(&'r str)
 --> ./91636.rs:6:13
  |
6 |     let _ = x == foo;
  |             ^^^^^^^^
  |
  = note: delayed at compiler/rustc_const_eval/src/transform/validate.rs:126:36

error: internal compiler error: broken MIR in Item(WithOptConstParam { did: DefId(0:4 ~ 91636[c00a]::main), const_param_did: None }) (after pass UninhabitedEnumBranching) at bb0[10]:
                                Cannot compare unequal types fn(&str) and for<'r> fn(&'r str)
 --> ./91636.rs:6:13
  |
6 |     let _ = x == foo;
  |             ^^^^^^^^
  |
  = note: delayed at compiler/rustc_const_eval/src/transform/validate.rs:126:36

error: internal compiler error: broken MIR in Item(WithOptConstParam { did: DefId(0:4 ~ 91636[c00a]::main), const_param_did: None }) (after pass SimplifyCfg-after-uninhabited-enum-branching) at bb0[10]:
                                Cannot compare unequal types fn(&str) and for<'r> fn(&'r str)
 --> ./91636.rs:6:13
  |
6 |     let _ = x == foo;
  |             ^^^^^^^^
  |
  = note: delayed at compiler/rustc_const_eval/src/transform/validate.rs:126:36

error: internal compiler error: broken MIR in Item(WithOptConstParam { did: DefId(0:4 ~ 91636[c00a]::main), const_param_did: None }) (after pass StateTransform) at bb0[10]:
                                Cannot compare unequal types fn(&str) and for<'r> fn(&'r str)
 --> ./91636.rs:6:13
  |
6 |     let _ = x == foo;
  |             ^^^^^^^^
  |
  = note: delayed at compiler/rustc_const_eval/src/transform/validate.rs:126:36

error: internal compiler error: broken MIR in Item(WithOptConstParam { did: DefId(0:4 ~ 91636[c00a]::main), const_param_did: None }) (end of phase transition to GeneratorsLowered) at bb0[10]:
                                Cannot compare unequal types fn(&str) and for<'r> fn(&'r str)
 --> ./91636.rs:6:13
  |
6 |     let _ = x == foo;
  |             ^^^^^^^^
  |
  = note: delayed at compiler/rustc_const_eval/src/transform/validate.rs:126:36

error: internal compiler error: broken MIR in Item(WithOptConstParam { did: DefId(0:4 ~ 91636[c00a]::main), const_param_did: None }) (start of phase transition from GeneratorsLowered) at bb0[10]:
                                Cannot compare unequal types fn(&str) and for<'r> fn(&'r str)
 --> ./91636.rs:6:13
  |
6 |     let _ = x == foo;
  |             ^^^^^^^^
  |
  = note: delayed at compiler/rustc_const_eval/src/transform/validate.rs:126:36

error: internal compiler error: broken MIR in Item(WithOptConstParam { did: DefId(0:4 ~ 91636[c00a]::main), const_param_did: None }) (after pass RemoveStorageMarkers) at bb0[4]:
                                Cannot compare unequal types fn(&str) and for<'r> fn(&'r str)
 --> ./91636.rs:6:13
  |
6 |     let _ = x == foo;
  |             ^^^^^^^^
  |
  = note: delayed at compiler/rustc_const_eval/src/transform/validate.rs:126:36

error: internal compiler error: broken MIR in Item(WithOptConstParam { did: DefId(0:4 ~ 91636[c00a]::main), const_param_did: None }) (after pass RemoveZsts) at bb0[4]:
                                Cannot compare unequal types fn(&str) and for<'r> fn(&'r str)
 --> ./91636.rs:6:13
  |
6 |     let _ = x == foo;
  |             ^^^^^^^^
  |
  = note: delayed at compiler/rustc_const_eval/src/transform/validate.rs:126:36

error: internal compiler error: broken MIR in Item(WithOptConstParam { did: DefId(0:4 ~ 91636[c00a]::main), const_param_did: None }) (after pass RemoveUnneededDrops) at bb0[4]:
                                Cannot compare unequal types fn(&str) and for<'r> fn(&'r str)
 --> ./91636.rs:6:13
  |
6 |     let _ = x == foo;
  |             ^^^^^^^^
  |
  = note: delayed at compiler/rustc_const_eval/src/transform/validate.rs:126:36

error: internal compiler error: broken MIR in Item(WithOptConstParam { did: DefId(0:4 ~ 91636[c00a]::main), const_param_did: None }) (after pass InstCombine) at bb0[4]:
                                Cannot compare unequal types fn(&str) and for<'r> fn(&'r str)
 --> ./91636.rs:6:13
  |
6 |     let _ = x == foo;
  |             ^^^^^^^^
  |
  = note: delayed at compiler/rustc_const_eval/src/transform/validate.rs:126:36

error: internal compiler error: broken MIR in Item(WithOptConstParam { did: DefId(0:4 ~ 91636[c00a]::main), const_param_did: None }) (after pass ConstProp) at bb0[4]:
                                Cannot compare unequal types fn(&str) and for<'r> fn(&'r str)
 --> ./91636.rs:6:13
  |
6 |     let _ = x == foo;
  |             ^^^^^^^^
  |
  = note: delayed at compiler/rustc_const_eval/src/transform/validate.rs:126:36

error: internal compiler error: broken MIR in Item(WithOptConstParam { did: DefId(0:4 ~ 91636[c00a]::main), const_param_did: None }) (after pass SimplifyConstCondition-after-const-prop) at bb0[4]:
                                Cannot compare unequal types fn(&str) and for<'r> fn(&'r str)
 --> ./91636.rs:6:13
  |
6 |     let _ = x == foo;
  |             ^^^^^^^^
  |
  = note: delayed at compiler/rustc_const_eval/src/transform/validate.rs:126:36

error: internal compiler error: broken MIR in Item(WithOptConstParam { did: DefId(0:4 ~ 91636[c00a]::main), const_param_did: None }) (after pass SimplifyComparisonIntegral) at bb0[4]:
                                Cannot compare unequal types fn(&str) and for<'r> fn(&'r str)
 --> ./91636.rs:6:13
  |
6 |     let _ = x == foo;
  |             ^^^^^^^^
  |
  = note: delayed at compiler/rustc_const_eval/src/transform/validate.rs:126:36

error: internal compiler error: broken MIR in Item(WithOptConstParam { did: DefId(0:4 ~ 91636[c00a]::main), const_param_did: None }) (after pass SimplifyArmIdentity) at bb0[4]:
                                Cannot compare unequal types fn(&str) and for<'r> fn(&'r str)
 --> ./91636.rs:6:13
  |
6 |     let _ = x == foo;
  |             ^^^^^^^^
  |
  = note: delayed at compiler/rustc_const_eval/src/transform/validate.rs:126:36

error: internal compiler error: broken MIR in Item(WithOptConstParam { did: DefId(0:4 ~ 91636[c00a]::main), const_param_did: None }) (after pass SimplifyBranchSame) at bb0[4]:
                                Cannot compare unequal types fn(&str) and for<'r> fn(&'r str)
 --> ./91636.rs:6:13
  |
6 |     let _ = x == foo;
  |             ^^^^^^^^
  |
  = note: delayed at compiler/rustc_const_eval/src/transform/validate.rs:126:36

error: internal compiler error: broken MIR in Item(WithOptConstParam { did: DefId(0:4 ~ 91636[c00a]::main), const_param_did: None }) (after pass SimplifyConstCondition-final) at bb0[4]:
                                Cannot compare unequal types fn(&str) and for<'r> fn(&'r str)
 --> ./91636.rs:6:13
  |
6 |     let _ = x == foo;
  |             ^^^^^^^^
  |
  = note: delayed at compiler/rustc_const_eval/src/transform/validate.rs:126:36

error: internal compiler error: broken MIR in Item(WithOptConstParam { did: DefId(0:4 ~ 91636[c00a]::main), const_param_did: None }) (after pass RemoveNoopLandingPads) at bb0[4]:
                                Cannot compare unequal types fn(&str) and for<'r> fn(&'r str)
 --> ./91636.rs:6:13
  |
6 |     let _ = x == foo;
  |             ^^^^^^^^
  |
  = note: delayed at compiler/rustc_const_eval/src/transform/validate.rs:126:36

error: internal compiler error: broken MIR in Item(WithOptConstParam { did: DefId(0:4 ~ 91636[c00a]::main), const_param_did: None }) (after pass SimplifyCfg-final) at bb0[4]:
                                Cannot compare unequal types fn(&str) and for<'r> fn(&'r str)
 --> ./91636.rs:6:13
  |
6 |     let _ = x == foo;
  |             ^^^^^^^^
  |
  = note: delayed at compiler/rustc_const_eval/src/transform/validate.rs:126:36

error: internal compiler error: broken MIR in Item(WithOptConstParam { did: DefId(0:4 ~ 91636[c00a]::main), const_param_did: None }) (after pass RenameReturnPlace) at bb0[4]:
                                Cannot compare unequal types fn(&str) and for<'r> fn(&'r str)
 --> ./91636.rs:6:13
  |
6 |     let _ = x == foo;
  |             ^^^^^^^^
  |
  = note: delayed at compiler/rustc_const_eval/src/transform/validate.rs:126:36

thread 'rustc' panicked at 'Box<dyn Any>', compiler/rustc_errors/src/lib.rs:1383:13
stack backtrace:
   0:     0x7fdc2329e51d - std::backtrace_rs::backtrace::libunwind::trace::ha83d3c29ca45171c
                               at /rustc/2a83fbc42a9bb6bfdb8d3fb4ecce83fb410d7642/library/std/src/../../backtrace/src/backtrace/libunwind.rs:93:5
   1:     0x7fdc2329e51d - std::backtrace_rs::backtrace::trace_unsynchronized::h26b9ccedbf051c48
                               at /rustc/2a83fbc42a9bb6bfdb8d3fb4ecce83fb410d7642/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7fdc2329e51d - std::sys_common::backtrace::_print_fmt::h5e457999760b88f5
                               at /rustc/2a83fbc42a9bb6bfdb8d3fb4ecce83fb410d7642/library/std/src/sys_common/backtrace.rs:66:5
   3:     0x7fdc2329e51d - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::hbe8346f709709d41
                               at /rustc/2a83fbc42a9bb6bfdb8d3fb4ecce83fb410d7642/library/std/src/sys_common/backtrace.rs:45:22
   4:     0x7fdc232f8ccc - core::fmt::write::hd118a99f3ff6458d
                               at /rustc/2a83fbc42a9bb6bfdb8d3fb4ecce83fb410d7642/library/core/src/fmt/mod.rs:1194:17
   5:     0x7fdc2328fcf1 - std::io::Write::write_fmt::h1319ce9d06dc33b9
                               at /rustc/2a83fbc42a9bb6bfdb8d3fb4ecce83fb410d7642/library/std/src/io/mod.rs:1655:15
   6:     0x7fdc232a1235 - std::sys_common::backtrace::_print::h6d19793f62f802da
                               at /rustc/2a83fbc42a9bb6bfdb8d3fb4ecce83fb410d7642/library/std/src/sys_common/backtrace.rs:48:5
   7:     0x7fdc232a1235 - std::sys_common::backtrace::print::h11f51cb1e8e1849d
                               at /rustc/2a83fbc42a9bb6bfdb8d3fb4ecce83fb410d7642/library/std/src/sys_common/backtrace.rs:35:9
   8:     0x7fdc232a1235 - std::panicking::default_hook::{{closure}}::h03447e80aba783b4
                               at /rustc/2a83fbc42a9bb6bfdb8d3fb4ecce83fb410d7642/library/std/src/panicking.rs:295:22
   9:     0x7fdc232a0ea9 - std::panicking::default_hook::h1c76be3b96c985fb
                               at /rustc/2a83fbc42a9bb6bfdb8d3fb4ecce83fb410d7642/library/std/src/panicking.rs:314:9
  10:     0x7fdc23acfc21 - rustc_driver[71f879f59330bb6b]::DEFAULT_HOOK::{closure#0}::{closure#0}
  11:     0x7fdc232a1a06 - std::panicking::rust_panic_with_hook::hb9bd69f80399060c
                               at /rustc/2a83fbc42a9bb6bfdb8d3fb4ecce83fb410d7642/library/std/src/panicking.rs:702:17
  12:     0x7fdc24c17d91 - std[58cab7405c17b2df]::panicking::begin_panic::<rustc_errors[5914e37740eaeab3]::ExplicitBug>::{closure#0}
  13:     0x7fdc24c17816 - std[58cab7405c17b2df]::sys_common::backtrace::__rust_end_short_backtrace::<std[58cab7405c17b2df]::panicking::begin_panic<rustc_errors[5914e37740eaeab3]::ExplicitBug>::{closure#0}, !>
  14:     0x7fdc24c1dc1f - std[58cab7405c17b2df]::panicking::begin_panic::<rustc_errors[5914e37740eaeab3]::ExplicitBug>
  15:     0x7fdc24c1b006 - std[58cab7405c17b2df]::panic::panic_any::<rustc_errors[5914e37740eaeab3]::ExplicitBug>
  16:     0x7fdc263c1a57 - <rustc_errors[5914e37740eaeab3]::HandlerInner as core[679d8fb27ead3507]::ops::drop::Drop>::drop
  17:     0x7fdc25adc258 - core[679d8fb27ead3507]::ptr::drop_in_place::<rustc_session[85ecf831e9c88e1e]::parse::ParseSess>
  18:     0x7fdc25adefd3 - <alloc[159f59a03ffd3b7b]::rc::Rc<rustc_session[85ecf831e9c88e1e]::session::Session> as core[679d8fb27ead3507]::ops::drop::Drop>::drop
  19:     0x7fdc25b091ad - core[679d8fb27ead3507]::ptr::drop_in_place::<rustc_interface[ebfb7a8f3d97ff2]::interface::Compiler>
  20:     0x7fdc25b08944 - rustc_span[714eccce3bad819e]::with_source_map::<core[679d8fb27ead3507]::result::Result<(), rustc_errors[5914e37740eaeab3]::ErrorGuaranteed>, rustc_interface[ebfb7a8f3d97ff2]::interface::create_compiler_and_run<core[679d8fb27ead3507]::result::Result<(), rustc_errors[5914e37740eaeab3]::ErrorGuaranteed>, rustc_driver[71f879f59330bb6b]::run_compiler::{closure#1}>::{closure#1}>
  21:     0x7fdc25ae03e7 - <scoped_tls[f03ae5544dd9ca96]::ScopedKey<rustc_span[714eccce3bad819e]::SessionGlobals>>::set::<rustc_interface[ebfb7a8f3d97ff2]::interface::run_compiler<core[679d8fb27ead3507]::result::Result<(), rustc_errors[5914e37740eaeab3]::ErrorGuaranteed>, rustc_driver[71f879f59330bb6b]::run_compiler::{closure#1}>::{closure#0}, core[679d8fb27ead3507]::result::Result<(), rustc_errors[5914e37740eaeab3]::ErrorGuaranteed>>
  22:     0x7fdc25af57ff - std[58cab7405c17b2df]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[ebfb7a8f3d97ff2]::util::run_in_thread_pool_with_globals<rustc_interface[ebfb7a8f3d97ff2]::interface::run_compiler<core[679d8fb27ead3507]::result::Result<(), rustc_errors[5914e37740eaeab3]::ErrorGuaranteed>, rustc_driver[71f879f59330bb6b]::run_compiler::{closure#1}>::{closure#0}, core[679d8fb27ead3507]::result::Result<(), rustc_errors[5914e37740eaeab3]::ErrorGuaranteed>>::{closure#0}, core[679d8fb27ead3507]::result::Result<(), rustc_errors[5914e37740eaeab3]::ErrorGuaranteed>>
  23:     0x7fdc25af5939 - <<std[58cab7405c17b2df]::thread::Builder>::spawn_unchecked_<rustc_interface[ebfb7a8f3d97ff2]::util::run_in_thread_pool_with_globals<rustc_interface[ebfb7a8f3d97ff2]::interface::run_compiler<core[679d8fb27ead3507]::result::Result<(), rustc_errors[5914e37740eaeab3]::ErrorGuaranteed>, rustc_driver[71f879f59330bb6b]::run_compiler::{closure#1}>::{closure#0}, core[679d8fb27ead3507]::result::Result<(), rustc_errors[5914e37740eaeab3]::ErrorGuaranteed>>::{closure#0}, core[679d8fb27ead3507]::result::Result<(), rustc_errors[5914e37740eaeab3]::ErrorGuaranteed>>::{closure#1} as core[679d8fb27ead3507]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  24:     0x7fdc232abbe3 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::hbff38f4d7cc5f33b
                               at /rustc/2a83fbc42a9bb6bfdb8d3fb4ecce83fb410d7642/library/alloc/src/boxed.rs:1858:9
  25:     0x7fdc232abbe3 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::hef44c24dd7faac8d
                               at /rustc/2a83fbc42a9bb6bfdb8d3fb4ecce83fb410d7642/library/alloc/src/boxed.rs:1858:9
  26:     0x7fdc232abbe3 - std::sys::unix::thread::Thread::new::thread_start::hded193f89a16724c
                               at /rustc/2a83fbc42a9bb6bfdb8d3fb4ecce83fb410d7642/library/std/src/sys/unix/thread.rs:108:17
  27:     0x7fdc230835c2 - start_thread
  28:     0x7fdc23108584 - __clone
  29:                0x0 - <unknown>

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-nightly (2a83fbc42 2022-04-12) running on x86_64-unknown-linux-gnu

note: compiler flags: -Z validate-mir

query stack during panic:
end of query stack

@matthiaskrgr matthiaskrgr added I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. C-bug Category: This is a bug. labels Apr 12, 2022
@matthiaskrgr
Copy link
Member Author

another case
src/tools/miri/tests/run-pass/issue-91636.rs

type BuiltIn = for<'a> fn(&str);

struct Function {
    inner: BuiltIn,
}

impl Function {
    fn new(subr: BuiltIn) -> Self {
        Self { inner: subr }
    }
}

fn dummy(_: &str) {}

fn main() {
    let func1 = Function::new(dummy);
    let func2 = Function::new(dummy);
    let inner: fn(&'static _) -> _ = func1.inner;
    assert!(inner == func2.inner);
}
error: internal compiler error: no errors encountered even though `delay_span_bug` issued

error: internal compiler error: broken MIR in Item(WithOptConstParam { did: DefId(0:10 ~ issue_91636[2737]::main), const_param_did: None }) (end of phase transition to Optimized) at bb2[3]:
                                Cannot compare unequal types fn(&str) and for<'r> fn(&'r str)
  --> src/tools/miri/tests/run-pass/issue-91636.rs:19:13
   |
19 |     assert!(inner == func2.inner);
   |             ^^^^^^^^^^^^^^^^^^^^
   |
   = note: delayed at compiler/rustc_const_eval/src/transform/validate.rs:126:36

@matthiaskrgr
Copy link
Member Author

Probably caused by #95320 cc @JakobDegen

@JakobDegen
Copy link
Contributor

Oops. That's my b, I'll have a PR up in 10 minutes

Dylan-DPC added a commit to Dylan-DPC/rust that referenced this issue Apr 14, 2022
…rochenkov

Consider lifetimes when comparing types for equality in MIR validator

Closes rust-lang#95978 .
Dylan-DPC added a commit to Dylan-DPC/rust that referenced this issue Apr 15, 2022
…rochenkov

Consider lifetimes when comparing types for equality in MIR validator

Closes rust-lang#95978 .
Dylan-DPC added a commit to Dylan-DPC/rust that referenced this issue Apr 15, 2022
…rochenkov

Consider lifetimes when comparing types for equality in MIR validator

Closes rust-lang#95978 .
Dylan-DPC added a commit to Dylan-DPC/rust that referenced this issue Apr 16, 2022
…rochenkov

Consider lifetimes when comparing types for equality in MIR validator

Closes rust-lang#95978 .
@bors bors closed this as completed in fd7a1f1 Apr 16, 2022
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants