Skip to content

Broken MIR ICE with box yield #85635

Closed
@PatchMixolydic

Description

@PatchMixolydic

May be related to #58504.

Code

#![feature(generators)]
#![feature(box_syntax)]

fn main() {
    || box yield;
}

Meta

rustc --version --verbose:

rustc 1.54.0-nightly (79e50bf77 2021-05-10)
binary: rustc
commit-hash: 79e50bf77928f374921a6bcafee3fcff1915f062
commit-date: 2021-05-10
host: x86_64-unknown-linux-gnu
release: 1.54.0-nightly
LLVM version: 12.0.1

Also reproduced on the Playground using 1.54.0-nightly (2021-05-23 f64503eb555475d65ae5).

Error output

warning: unused generator that must be used
 --> src/main.rs:5:5
  |
5 |     || box yield;
  |     ^^^^^^^^^^^^^
  |
  = note: `#[warn(unused_must_use)]` on by default
  = note: generators are lazy and do nothing unless resumed

warning: 1 warning emitted

error: internal compiler error: broken MIR in Item(WithOptConstParam { did: DefId(0:4 ~ playground[d309]::main::{closure#0}), const_param_did: None }) (end of phase Optimization) at bb2[0]:
encountered `Assign(((((*(_1.0: &mut [generator@src/main.rs:5:5: 5:17 {()}])) as variant#3).0: std::boxed::Box<()>), move _2))` with incompatible types:
left-hand side has type: Box<()>
right-hand side has type: ()
 --> src/main.rs:5:5
  |
5 |     || box yield;
  |     ^^^^^^^^^^^^
  |
  = note: delayed at compiler/rustc_mir/src/transform/validate.rs:120:36

thread 'rustc' panicked at 'no errors encountered even though `delay_span_bug` issued', compiler/rustc_errors/src/lib.rs:1021:13
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

error: internal compiler error: unexpected panic

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.54.0-nightly (f64503eb5 2021-05-23) running on x86_64-unknown-linux-gnu

note: compiler flags: -C embed-bitcode=no -C codegen-units=1 -C debuginfo=2 --crate-type bin

note: some of the compiler flags provided by cargo are hidden

query stack during panic:
end of query stack
Backtrace

warning: unused generator that must be used
 --> src/main.rs:5:5
  |
5 |     || box yield;
  |     ^^^^^^^^^^^^^
  |
  = note: `#[warn(unused_must_use)]` on by default
  = note: generators are lazy and do nothing unless resumed

warning: 1 warning emitted

error: internal compiler error: broken MIR in Item(WithOptConstParam { did: DefId(0:4 ~ playground[d309]::main::{closure#0}), const_param_did: None }) (end of phase Optimization) at bb2[0]:
encountered `Assign(((((*(_1.0: &mut [generator@src/main.rs:5:5: 5:17 {()}])) as variant#3).0: std::boxed::Box<()>), move _2))` with incompatible types:
left-hand side has type: Box<()>
right-hand side has type: ()
 --> src/main.rs:5:5
  |
5 |     || box yield;
  |     ^^^^^^^^^^^^
  |
  = note: delayed at compiler/rustc_mir/src/transform/validate.rs:120:36

thread 'rustc' panicked at 'no errors encountered even though `delay_span_bug` issued', compiler/rustc_errors/src/lib.rs:1021:13
stack backtrace:
   0: rust_begin_unwind
             at /rustc/f64503eb555475d65ae5503ef22439ca5dd394fd/library/std/src/panicking.rs:515:5
   1: std::panicking::begin_panic_fmt
             at /rustc/f64503eb555475d65ae5503ef22439ca5dd394fd/library/std/src/panicking.rs:457:5
   2: rustc_errors::HandlerInner::flush_delayed
   3: <rustc_errors::HandlerInner as core::ops::drop::Drop>::drop
   4: core::ptr::drop_in_place<rustc_session::parse::ParseSess>
   5: <alloc::rc::Rc<T> as core::ops::drop::Drop>::drop
   6: core::ptr::drop_in_place<rustc_interface::interface::Compiler>
   7: rustc_span::with_source_map
   8: scoped_tls::ScopedKey<T>::set
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

error: internal compiler error: unexpected panic

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.54.0-nightly (f64503eb5 2021-05-23) running on x86_64-unknown-linux-gnu

note: compiler flags: -C embed-bitcode=no -C codegen-units=1 -C debuginfo=2 --crate-type bin

note: some of the compiler flags provided by cargo are hidden

query stack during panic:
end of query stack

@rustbot modify labels +A-generators

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-coroutinesArea: CoroutinesC-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