Skip to content

ICE when trying to use &impl in a binding #54840

Closed
@smarnach

Description

@smarnach

This code results in an ICE on the playground:

#![feature(impl_trait_in_bindings)]

use std::ops::Add;

fn main() {
    let i: i32 = 0;
    let j: &impl Add = &i;
}

This may be a duplicate of #54600, but I can't really tell. Error message:

   Compiling playground v0.0.1 (/playground)
warning: unused variable: `j`
 --> src/main.rs:7:9
  |
7 |     let j: &impl Add = &i;
  |         ^ help: consider using `_j` instead
  |
  = note: #[warn(unused_variables)] on by default

error: internal compiler error: broken MIR in DefId(0/0:4 ~ playground[bf48]::main[0]) (_2 = &(*_3)): bad assignment (&impl std::ops::Add = &i32): NoSolution
 --> src/main.rs:7:24
  |
7 |     let j: &impl Add = &i;
  |                        ^^

thread 'main' panicked at 'no errors encountered even though `delay_span_bug` issued', librustc_errors/lib.rs:334:17
note: Run with `RUST_BACKTRACE=1` for 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/blob/master/CONTRIBUTING.md#bug-reports

note: rustc 1.31.0-nightly (8c4ad4e9e 2018-10-04) running on x86_64-unknown-linux-gnu

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

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

error: Could not compile `playground`.

To learn more, run the command again with --verbose.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-impl-traitArea: `impl Trait`. Universally / existentially quantified anonymous types with static dispatch.C-bugCategory: This is a bug.F-impl_trait_in_bindings`#![feature(impl_trait_in_bindings)]`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