Skip to content

ICE: failed to normalize with -Zmir-opt-level=3 --emit-mir  #97728

Closed
@matthiaskrgr

Description

@matthiaskrgr

Code

src/test/ui/associated-types/issue-67684.rs

// check-pass

#![allow(dead_code)]

trait ParseError {
    type StreamError;
}

impl<T> ParseError for T {
    type StreamError = ();
}

trait Stream {
    type Item;
    type Error: ParseError;
}

trait Parser
where
    <Self as Parser>::PartialState: Default,
{
    type PartialState;
    fn parse_mode(_: &Self, _: Self::PartialState) {
        loop {}
    }
}

impl Stream for () {
    type Item = ();
    type Error = ();
}

impl Parser for () {
    type PartialState = ();
}

struct AndThen<A, B>(core::marker::PhantomData<(A, B)>);

impl<A, B> Parser for AndThen<A, B>
where
    A: Stream,
    B: Into<<A::Error as ParseError>::StreamError>,
{
    type PartialState = ();
}

fn expr<A>() -> impl Parser
where
    A: Stream<Error = <A as Stream>::Item>,
{
    AndThen::<A, ()>(core::marker::PhantomData)
}

fn parse_mode_impl<A>()
where
    <A as Stream>::Error: ParseError,
    A: Stream<Error = <A as Stream>::Item>,
{
    Parser::parse_mode(&expr::<A>(), Default::default())
}

fn main() {}

Meta

rustc --version --verbose:

rustc 1.63.0-nightly (cb0584f86 2022-06-04)
binary: rustc
commit-hash: cb0584f86b8cfa952dffad55f7d83bd90765120f
commit-date: 2022-06-04
host: x86_64-unknown-linux-gnu
release: 1.63.0-nightly
LLVM version: 14.0.4

Error output

rustc -Zmir-opt-level=3 --emit=mir ./issue-67684.rs

<output>
Backtrace

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

error: internal compiler error: failed to normalize <impl Parser as Parser>::PartialState
  --> ./issue-67684.rs:59:24
   |
59 |     Parser::parse_mode(&expr::<A>(), Default::default())
   |                        ^^^^^^^^^^^^
   |
   = note: delayed at /rustc/cb0584f86b8cfa952dffad55f7d83bd90765120f/compiler/rustc_const_eval/src/interpret/eval_context.rs:524:31

thread 'rustc' panicked at 'Box<dyn Any>', compiler/rustc_errors/src/lib.rs:1369:13
stack backtrace:
   0:     0x7f124649e25d - std::backtrace_rs::backtrace::libunwind::trace::hfffba49f58b42846
                               at /rustc/cb0584f86b8cfa952dffad55f7d83bd90765120f/library/std/src/../../backtrace/src/backtrace/libunwind.rs:93:5
   1:     0x7f124649e25d - std::backtrace_rs::backtrace::trace_unsynchronized::h4ff0c2095022a3ae
                               at /rustc/cb0584f86b8cfa952dffad55f7d83bd90765120f/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7f124649e25d - std::sys_common::backtrace::_print_fmt::h368acf2bc7c52809
                               at /rustc/cb0584f86b8cfa952dffad55f7d83bd90765120f/library/std/src/sys_common/backtrace.rs:66:5
   3:     0x7f124649e25d - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h49e74caf07a5a0ec
                               at /rustc/cb0584f86b8cfa952dffad55f7d83bd90765120f/library/std/src/sys_common/backtrace.rs:45:22
   4:     0x7f12464f9ffc - core::fmt::write::h6fe216e3357fd66d
                               at /rustc/cb0584f86b8cfa952dffad55f7d83bd90765120f/library/core/src/fmt/mod.rs:1196:17
   5:     0x7f124648f951 - std::io::Write::write_fmt::h31215d80db6fc0f2
                               at /rustc/cb0584f86b8cfa952dffad55f7d83bd90765120f/library/std/src/io/mod.rs:1654:15
   6:     0x7f12464a0f45 - std::sys_common::backtrace::_print::h470bdb28bea3fdc9
                               at /rustc/cb0584f86b8cfa952dffad55f7d83bd90765120f/library/std/src/sys_common/backtrace.rs:48:5
   7:     0x7f12464a0f45 - std::sys_common::backtrace::print::h59ffa1af45c7a016
                               at /rustc/cb0584f86b8cfa952dffad55f7d83bd90765120f/library/std/src/sys_common/backtrace.rs:35:9
   8:     0x7f12464a0f45 - std::panicking::default_hook::{{closure}}::ha1d0d1db32e3e907
                               at /rustc/cb0584f86b8cfa952dffad55f7d83bd90765120f/library/std/src/panicking.rs:295:22
   9:     0x7f12464a0c66 - std::panicking::default_hook::h538f986254060a89
                               at /rustc/cb0584f86b8cfa952dffad55f7d83bd90765120f/library/std/src/panicking.rs:314:9
  10:     0x7f1246cfa081 - rustc_driver[bf03ee4c7109303e]::DEFAULT_HOOK::{closure#0}::{closure#0}
  11:     0x7f12464a161a - std::panicking::rust_panic_with_hook::h8b012130e7d34dc2
                               at /rustc/cb0584f86b8cfa952dffad55f7d83bd90765120f/library/std/src/panicking.rs:702:17
  12:     0x7f1247e615a1 - std[1d0ca0320202746c]::panicking::begin_panic::<rustc_errors[e788818e6484a2a6]::ExplicitBug>::{closure#0}
  13:     0x7f1247e5f1f6 - std[1d0ca0320202746c]::sys_common::backtrace::__rust_end_short_backtrace::<std[1d0ca0320202746c]::panicking::begin_panic<rustc_errors[e788818e6484a2a6]::ExplicitBug>::{closure#0}, !>
  14:     0x7f1247e7b3d6 - std[1d0ca0320202746c]::panicking::begin_panic::<rustc_errors[e788818e6484a2a6]::ExplicitBug>
  15:     0x7f1247e77f76 - std[1d0ca0320202746c]::panic::panic_any::<rustc_errors[e788818e6484a2a6]::ExplicitBug>
  16:     0x7f1249751801 - <rustc_errors[e788818e6484a2a6]::HandlerInner as core[d492d6ee2ab5e18c]::ops::drop::Drop>::drop
  17:     0x7f1248e94f08 - core[d492d6ee2ab5e18c]::ptr::drop_in_place::<rustc_session[3d6fc94e96156abd]::parse::ParseSess>
  18:     0x7f1248e97713 - <alloc[45891ddd3b5b27e4]::rc::Rc<rustc_session[3d6fc94e96156abd]::session::Session> as core[d492d6ee2ab5e18c]::ops::drop::Drop>::drop
  19:     0x7f1248ec303d - core[d492d6ee2ab5e18c]::ptr::drop_in_place::<rustc_interface[31b3ce34e407c1c5]::interface::Compiler>
  20:     0x7f1248ec2a74 - rustc_span[d519d88b4b18fc73]::with_source_map::<core[d492d6ee2ab5e18c]::result::Result<(), rustc_errors[e788818e6484a2a6]::ErrorGuaranteed>, rustc_interface[31b3ce34e407c1c5]::interface::create_compiler_and_run<core[d492d6ee2ab5e18c]::result::Result<(), rustc_errors[e788818e6484a2a6]::ErrorGuaranteed>, rustc_driver[bf03ee4c7109303e]::run_compiler::{closure#1}>::{closure#1}>
  21:     0x7f1248e99dc2 - <scoped_tls[f5963f8680a07e14]::ScopedKey<rustc_span[d519d88b4b18fc73]::SessionGlobals>>::set::<rustc_interface[31b3ce34e407c1c5]::interface::run_compiler<core[d492d6ee2ab5e18c]::result::Result<(), rustc_errors[e788818e6484a2a6]::ErrorGuaranteed>, rustc_driver[bf03ee4c7109303e]::run_compiler::{closure#1}>::{closure#0}, core[d492d6ee2ab5e18c]::result::Result<(), rustc_errors[e788818e6484a2a6]::ErrorGuaranteed>>
  22:     0x7f1248eaf4ff - std[1d0ca0320202746c]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[31b3ce34e407c1c5]::util::run_in_thread_pool_with_globals<rustc_interface[31b3ce34e407c1c5]::interface::run_compiler<core[d492d6ee2ab5e18c]::result::Result<(), rustc_errors[e788818e6484a2a6]::ErrorGuaranteed>, rustc_driver[bf03ee4c7109303e]::run_compiler::{closure#1}>::{closure#0}, core[d492d6ee2ab5e18c]::result::Result<(), rustc_errors[e788818e6484a2a6]::ErrorGuaranteed>>::{closure#0}, core[d492d6ee2ab5e18c]::result::Result<(), rustc_errors[e788818e6484a2a6]::ErrorGuaranteed>>
  23:     0x7f1248eaf669 - <<std[1d0ca0320202746c]::thread::Builder>::spawn_unchecked_<rustc_interface[31b3ce34e407c1c5]::util::run_in_thread_pool_with_globals<rustc_interface[31b3ce34e407c1c5]::interface::run_compiler<core[d492d6ee2ab5e18c]::result::Result<(), rustc_errors[e788818e6484a2a6]::ErrorGuaranteed>, rustc_driver[bf03ee4c7109303e]::run_compiler::{closure#1}>::{closure#0}, core[d492d6ee2ab5e18c]::result::Result<(), rustc_errors[e788818e6484a2a6]::ErrorGuaranteed>>::{closure#0}, core[d492d6ee2ab5e18c]::result::Result<(), rustc_errors[e788818e6484a2a6]::ErrorGuaranteed>>::{closure#1} as core[d492d6ee2ab5e18c]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  24:     0x7f12464ab543 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::he67347ae150d3c25
                               at /rustc/cb0584f86b8cfa952dffad55f7d83bd90765120f/library/alloc/src/boxed.rs:1951:9
  25:     0x7f12464ab543 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h88d067c9f9535f57
                               at /rustc/cb0584f86b8cfa952dffad55f7d83bd90765120f/library/alloc/src/boxed.rs:1951:9
  26:     0x7f12464ab543 - std::sys::unix::thread::Thread::new::thread_start::hc424c020edfa2794
                               at /rustc/cb0584f86b8cfa952dffad55f7d83bd90765120f/library/std/src/sys/unix/thread.rs:108:17
  27:     0x7f124627f54d - <unknown>
  28:     0x7f1246304b14 - 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.63.0-nightly (cb0584f86 2022-06-04) running on x86_64-unknown-linux-gnu

note: compiler flags: -Z mir-opt-level=3

query stack during panic:
end of query stack

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.glacierICE tracked in rust-lang/glacier.requires-nightlyThis issue requires a nightly compiler in some way.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions