Skip to content

"escaping late-bound region during canonicalization" ICE when returning DST #91803

Closed
@5225225

Description

@5225225

Code

https://play.rust-lang.org/?version=nightly&mode=debug&edition=2021&gist=681b7aa5ba07fe30593b61e77e3d3b03

trait Foo<'a> {}

fn or<'a>(first: &'static dyn Foo<'a>) -> dyn Foo<'a> {
    return Box::new(panic!());
}

Happens on stable, beta, and nightly.

Error output

   Compiling playground v0.0.1 (/playground)
warning: unreachable call
 --> src/lib.rs:4:12
  |
4 |     return Box::new(panic!());
  |            ^^^^^^^^ -------- any code following this expression is unreachable
  |            |
  |            unreachable call
  |
  = note: `#[warn(unreachable_code)]` on by default

error: internal compiler error: compiler/rustc_infer/src/infer/canonical/canonicalizer.rs:295:21: escaping late-bound region during canonicalization

thread 'rustc' panicked at 'Box<dyn Any>', compiler/rustc_errors/src/lib.rs:1170:9
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

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.59.0-nightly (0b42deacc 2021-12-09) running on x86_64-unknown-linux-gnu

note: compiler flags: -C opt-level=3 -C embed-bitcode=no -C codegen-units=1 --crate-type lib

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

query stack during panic:
#0 [typeck] type-checking `or`
#1 [typeck_item_bodies] type-checking all item bodies
end of query stack
warning: `playground` (lib) generated 1 warning
error: could not compile `playground`; 1 warning emitted

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.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions