Change:
Backtrace: This seems to occur when using a non-struct type that contains an unsized type. This is probably because  only handles and the base unsized types. This should be extended to handle enums and tuples as well.
This is still happening. Does this mean we should avoid using DSTs for complex custom types for now?
Visiting for triage This is still an issue:
ICE also happens with a tupled trait object:
I've seen this too with: Reproducer: Version: Backtrace:
No longer reproduces but the other tests do.
cc
Is this the same as or related to ?
leads to . As mentioned inline, using the correct type works (). I'm using the Ubuntu PPA "rust-nightly", version ~~vivid.
Does not compile for other reasons that the ICE anymore. I've adjusted to the following and could not reproduce it anymore.
Another example hitting this same ICE:
Bugs similar to this one have been reported numerous times (most of the references to this issue are duplicates). Although it would be nice for reporters to search for similar issues before filing a new one, it's hard to blame them, since the ICE message from rustc tells people to file an issue. This issue itself was opened over two years ago. Separate from fixing the underlying problem, we should at least investigate displaying a real error instead of an ICE.

Discussion:
trait_name)); } ObligationCauseCode::FieldSized => { <del> err.note("only the last field of a struct or enum variant  may have a dynamically sized type"); </del> <ins> err.note("only the last field of a struct may have a dynamically sized type"); </ins> } ObligationCauseCode::ConstSized => { err.note("constant expressions must have a statically known size");

self.check_variances_for_type_defn(item, ast_generics); } hir::ItemEnum(ref enum_def, ref ast_generics) => { <del> self.check_type_defn(item, false, |fcx| { </del> <ins> self.check_type_defn(item, true, |fcx| { </ins> fcx.enum_variants(enum_def) });

// option. This file may not be copied, modified, or distributed // except according to those terms. <ins> // ignore-test the unsized enum no longer compiles </ins> enum A { B(char), C([Box<A>]),

Struct { r: r } } <del> trait Curve {} enum E {X(Curve+'static)} </del> fn main() {}

// // Not OK: `T` is not sized. <del> enum Bar<U: ?Sized> { BarSome(U), BarNone } fn bar1<T: ?Sized>() { not_sized::<Bar<T>>() } fn bar2<T: ?Sized>() { is_sized::<Bar<T>>() } //~^ ERROR `T: std::marker::Sized` is not satisfied // // Not OK: `Bar<T>` is not sized, but it should be. </del> fn main() { }

<ins> // Copyright 206 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your // option. This file may not be copied, modified, or distributed // except according to those terms. use std::ops::Deref; // Due to aggressive error message deduplication, we require 20 *different* // unsized types (even Path and [u8] are considered the "same"). trait Foo {} trait Bar {} trait FooBar {} trait BarFoo {} trait PathHelper1 {} trait PathHelper2 {} trait PathHelper3 {} trait PathHelper4 {} struct Path1(PathHelper1); struct Path2(PathHelper2); struct Path3(PathHelper3); struct Path4(PathHelper4); enum E<W: ?Sized, X: ?Sized, Y: ?Sized, Z: ?Sized> { // parameter VA(W), //~ ERROR `W: std::marker::Sized` is not satisfied VB{x: X}, //~ ERROR `X: std::marker::Sized` is not satisfied VC(isize, Y), //~ ERROR `Y: std::marker::Sized` is not satisfied VD{u: isize, x: Z}, //~ ERROR `Z: std::marker::Sized` is not satisfied // slice / str VE([u8]), //~ ERROR `[u8]: std::marker::Sized` is not satisfied VF{x: str}, //~ ERROR `str: std::marker::Sized` is not satisfied VG(isize, [f32]), //~ ERROR `[f32]: std::marker::Sized` is not satisfied VH{u: isize, x: [u32]}, //~ ERROR `[u32]: std::marker::Sized` is not satisfied // unsized struct VI(Path1), //~ ERROR `PathHelper1 + 'static: std::marker::Sized` is not satisfied VJ{x: Path2}, //~ ERROR `PathHelper2 + 'static: std::marker::Sized` is not satisfied VK(isize, Path3), //~ ERROR `PathHelper3 + 'static: std::marker::Sized` is not satisfied VL{u: isize, x: Path4}, //~ ERROR `PathHelper4 + 'static: std::marker::Sized` is not satisfied // plain trait VM(Foo),  //~ ERROR `Foo + 'static: std::marker::Sized` is not satisfied VN{x: Bar}, //~ ERROR `Bar + 'static: std::marker::Sized` is not satisfied VO(isize, FooBar), //~ ERROR `FooBar + 'static: std::marker::Sized` is not satisfied VP{u: isize, x: BarFoo}, //~ ERROR `BarFoo + 'static: std::marker::Sized` is not satisfied // projected VQ(<&'static [i8] as Deref>::Target), //~ ERROR `[i8]: std::marker::Sized` is not satisfied VR{x: <&'static [char] as Deref>::Target}, //~^ ERROR `[char]: std::marker::Sized` is not satisfied VS(isize, <&'static [f64] as Deref>::Target), //~^ ERROR `[f64]: std::marker::Sized` is not satisfied VT{u: isize, x: <&'static [i32] as Deref>::Target}, //~^ ERROR `[i32]: std::marker::Sized` is not satisfied } fn main() { } </ins>

fn f4<X: T>(x: &X) { } <del> // Test with unsized enum. enum E<X: ?Sized> { V(X), } </del> fn f5<Y>(x: &Y) {} fn f6<X: ?Sized>(x: &X) {} <del> fn f7<X: ?Sized>(x1: &E<X>, x2: &E<X>) { f5(x1); //~^ ERROR `X: std::marker::Sized` is not satisfied f6(x2); // ok } </del> // Test with unsized struct. struct S<X: ?Sized> {

} // Test some tuples. <del> fn f9<X: ?Sized>(x1: Box<S<X>>, x2: Box<E<X>>) { </del> <ins> fn f9<X: ?Sized>(x1: Box<S<X>>) { </ins> f5(&(*x1, 34)); //~^ ERROR `X: std::marker::Sized` is not satisfied } <del> fn f10<X: ?Sized>(x1: Box<S<X>>, x2: Box<E<X>>) { f5(&(32, *x2)); </del> <ins> fn f10<X: ?Sized>(x1: Box<S<X>>) { f5(&(32, *x1)); </ins> //~^ ERROR `X: std::marker::Sized` is not satisfied }

fn m2(&self, x: &T5<X>); } <del> // The last field in a struct or variant may be unsized </del> <ins> // The last field in a struct may be unsized </ins> struct S2<X: ?Sized> { f: X, }

f1: isize, f2: X, } <del> enum E<X: ?Sized> { V1(X), V2{x: X}, V3(isize, X), V4{u: isize, x: X}, } </del> pub fn main() { }