Skip to content

normalization ICE during codegen of trait objects with supertraits #56229

Description

@nikomatsakis

The following example ICEs

impl Mirror for Even {
    type Other = Odd;
}

impl Mirror for Odd {
    type Other = Even;
}

trait Dyn<T: Mirror>: AsRef<<T as Mirror>::Other> { }

impl Dyn<Odd> for Even { }

impl AsRef<Even> for Even {
    fn as_ref(&self) -> &Even {
        self
    }
}

fn code<T: Mirror>(d: &dyn Dyn<T>) -> &T::Other {
    d.as_ref()
}

fn main() {
    println!("{:?}", code(&Even(22)));
}

yields

athena. rustc +nightly ~/tmp/as-ref-bug.rs
error: internal compiler error: src/librustc/traits/codegen/mod.rs:68: Encountered error `Unimplemented` selecting `Binder(<dyn Dyn<Odd> as std::convert::AsRef<Even>>)` during codegen

thread 'main' panicked at 'Box<Any>', src/librustc_errors/lib.rs:600:9
note: Run with `RUST_BACKTRACE=1` for a backtrace.
error: aborting due to previous error


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.32.0-nightly (6acbb5b65 2018-11-25) running on x86_64-unknown-linux-gnu

(Same is true on stable.)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-trait-systemArea: Trait systemC-bugCategory: This is a bug.E-needs-testCall for participation: An issue has been fixed and does not reproduce, but no test has been added.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