rust/tests/ui/unsized/unsized-struct.rs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

19 lines
493 B
Rust
Raw Normal View History

fn is_sized<T:Sized>() { }
2015-01-05 21:16:49 +00:00
fn not_sized<T: ?Sized>() { }
2013-05-31 01:40:55 +00:00
struct Foo<T> { data: T }
fn foo1<T>() { not_sized::<Foo<T>>() } // Hunky dory.
2015-01-05 21:16:49 +00:00
fn foo2<T: ?Sized>() { not_sized::<Foo<T>>() }
2018-07-10 21:10:13 +00:00
//~^ ERROR the size for values of type
//
// Not OK: `T` is not sized.
2013-05-31 01:40:55 +00:00
2015-01-05 21:16:49 +00:00
struct Bar<T: ?Sized> { data: T }
fn bar1<T: ?Sized>() { not_sized::<Bar<T>>() }
fn bar2<T: ?Sized>() { is_sized::<Bar<T>>() }
2018-07-10 21:10:13 +00:00
//~^ ERROR the size for values of type
//
// Not OK: `Bar<T>` is not sized, but it should be.
2013-05-31 01:40:55 +00:00
fn main() { }