Closed
Description
I was attempting to figure out the feature landscape for #27941, and I found this ICE when playing with it and specialization:
Code
#![feature(specialization)]
#![feature(unsize, coerce_unsized)]
use std::ops::CoerceUnsized;
use std::marker::Unsize;
pub struct SmartassPtr<A: Smartass+?Sized>(A::Data);
pub trait Smartass {
type Data;
type Data2: CoerceUnsized<*const [u8]>;
}
pub trait MaybeObjectSafe {
// fn not_object_safe(self: SmartassPtr<Self>);
}
impl MaybeObjectSafe for () {}
impl<T> Smartass for T {
type Data = <Self as Smartass>::Data2;
default type Data2 = ();
}
impl Smartass for () {
type Data2 = *const [u8; 1];
}
impl Smartass for MaybeObjectSafe {
type Data = *const [u8];
type Data2 = *const [u8; 0];
}
impl<U: Smartass+?Sized, T: Smartass+?Sized> CoerceUnsized<SmartassPtr<T>> for SmartassPtr<U>
where <U as Smartass>::Data: std::ops::CoerceUnsized<<T as Smartass>::Data>
{}
pub fn conv(s: SmartassPtr<()>) -> SmartassPtr<MaybeObjectSafe> {
s
}
fn main() {
}
ICE:
error: internal compiler error: /checkout/src/librustc_trans/collector.rs:820: find_vtable_types_for_unsizing: invalid coercion <() as Smartass>::Data -> <MaybeObjectSafe as Smartass>::Data
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.22.0-nightly (6c476ce46 2017-09-25) running on x86_64-unknown-linux-gnu
thread 'rustc' panicked at 'Box<Any>', /checkout/src/librustc_errors/lib.rs:492:8
note: Run with `RUST_BACKTRACE=1` for a backtrace
Metadata
Metadata
Assignees
Labels
Area: Trait impl specializationCategory: This is a bug.Call for participation: An issue has been fixed and does not reproduce, but no test has been added.The `CoerceUnsized` trait`#![feature(specialization)]`Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ICE tracked in rust-lang/glacier.This issue requires a nightly compiler in some way.