Closed
Description
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.)
Metadata
Metadata
Assignees
Labels
Area: Trait systemCategory: This is a bug.Call for participation: An issue has been fixed and does not reproduce, but no test has been added.Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️Relevant to the compiler team, which will review and decide on the PR/issue.ICE tracked in rust-lang/glacier.