diff options
| author | Nick Cameron <ncameron@mozilla.com> | 2014-07-08 14:26:02 +1200 |
|---|---|---|
| committer | Nick Cameron <ncameron@mozilla.com> | 2014-07-08 22:44:31 +1200 |
| commit | a0cfda53c4b7367f6494e3d746b35cea644ee50d (patch) | |
| tree | a9a65cb86769ae39e01562cda9eda0dfdb860245 /src/test/compile-fail | |
| parent | 6959931498820b2b784168164b53a79dceafc4da (diff) | |
| download | rust-a0cfda53c4b7367f6494e3d746b35cea644ee50d.tar.gz rust-a0cfda53c4b7367f6494e3d746b35cea644ee50d.zip | |
Change DST syntax: type -> Sized?
closes #13367
[breaking-change] Use `Sized?` to indicate a dynamically sized type parameter or trait (used to be `type`). E.g.,
```
trait Tr for Sized? {}
fn foo<Sized? X: Share>(x: X) {}
```
Diffstat (limited to 'src/test/compile-fail')
| -rw-r--r-- | src/test/compile-fail/unsized-bare-typaram.rs | 2 | ||||
| -rw-r--r-- | src/test/compile-fail/unsized-enum.rs | 2 | ||||
| -rw-r--r-- | src/test/compile-fail/unsized-struct.rs | 2 | ||||
| -rw-r--r-- | src/test/compile-fail/unsized3.rs | 28 | ||||
| -rw-r--r-- | src/test/compile-fail/unsized4.rs | 2 | ||||
| -rw-r--r-- | src/test/compile-fail/unsized5.rs | 8 | ||||
| -rw-r--r-- | src/test/compile-fail/unsized6.rs | 16 |
7 files changed, 30 insertions, 30 deletions
diff --git a/src/test/compile-fail/unsized-bare-typaram.rs b/src/test/compile-fail/unsized-bare-typaram.rs index fd09d78a4fa..6fd749b1298 100644 --- a/src/test/compile-fail/unsized-bare-typaram.rs +++ b/src/test/compile-fail/unsized-bare-typaram.rs @@ -10,5 +10,5 @@ // error-pattern: instantiating a type parameter with an incompatible type fn bar<T: Sized>() { } -fn foo<type T>() { bar::<T>() } +fn foo<Sized? T>() { bar::<T>() } fn main() { } diff --git a/src/test/compile-fail/unsized-enum.rs b/src/test/compile-fail/unsized-enum.rs index f586fbb576b..651eb26cadc 100644 --- a/src/test/compile-fail/unsized-enum.rs +++ b/src/test/compile-fail/unsized-enum.rs @@ -10,5 +10,5 @@ // error-pattern: instantiating a type parameter with an incompatible type fn bar<T: Sized>() { } -fn foo<type T>() { bar::<Option<T>>() } +fn foo<Sized? T>() { bar::<Option<T>>() } fn main() { } diff --git a/src/test/compile-fail/unsized-struct.rs b/src/test/compile-fail/unsized-struct.rs index 9fab3accbb9..ec6aafb43f4 100644 --- a/src/test/compile-fail/unsized-struct.rs +++ b/src/test/compile-fail/unsized-struct.rs @@ -13,5 +13,5 @@ struct Foo<T> { data: T } fn bar<T: Sized>() { } -fn foo<type T>() { bar::<Foo<T>>() } +fn foo<Sized? T>() { bar::<Foo<T>>() } fn main() { } diff --git a/src/test/compile-fail/unsized3.rs b/src/test/compile-fail/unsized3.rs index c5cc7e8f716..c07dcf93683 100644 --- a/src/test/compile-fail/unsized3.rs +++ b/src/test/compile-fail/unsized3.rs @@ -12,45 +12,45 @@ // Unbounded. -fn f1<type X>(x: &X) { +fn f1<Sized? X>(x: &X) { f2::<X>(x); //~ ERROR instantiating a type parameter with an incompatible type `X`, which does n } fn f2<X>(x: &X) { } // Bounded. -trait T for type {} -fn f3<type X: T>(x: &X) { +trait T for Sized? {} +fn f3<Sized? X: T>(x: &X) { f4::<X>(x); //~ ERROR instantiating a type parameter with an incompatible type `X`, which does n } fn f4<X: T>(x: &X) { } // Test with unsized enum. -enum E<type X> { +enum E<Sized? X> { V(X), } fn f5<Y>(x: &Y) {} -fn f6<type X>(x: &X) {} -fn f7<type X>(x1: &E<X>, x2: &E<X>) { +fn f6<Sized? X>(x: &X) {} +fn f7<Sized? X>(x1: &E<X>, x2: &E<X>) { f5(x1); //~ERROR instantiating a type parameter with an incompatible type `E<X>`, which does not f6(x2); // ok } // Test with unsized struct. -struct S<type X> { +struct S<Sized? X> { x: X, } -fn f8<type X>(x1: &S<X>, x2: &S<X>) { +fn f8<Sized? X>(x1: &S<X>, x2: &S<X>) { f5(x1); //~ERROR instantiating a type parameter with an incompatible type `S<X>`, which does not f6(x2); // ok } // Test some tuples. -fn f9<type X>(x1: Box<S<X>>, x2: Box<E<X>>) { +fn f9<Sized? X>(x1: Box<S<X>>, x2: Box<E<X>>) { f5(&(*x1, 34i)); //~ERROR instantiating a type parameter with an incompatible type `(S<X>,int)`, f5(&(32i, *x2)); //~ERROR instantiating a type parameter with an incompatible type `(int,E<X>)`, } @@ -60,20 +60,20 @@ fn f9<type X>(x1: Box<S<X>>, x2: Box<E<X>>) { // impl - bounded trait T1<Z: T> { } -struct S3<type Y>; -impl<type X: T> T1<X> for S3<X> { //ERROR instantiating a type parameter with an incompatible type +struct S3<Sized? Y>; +impl<Sized? X: T> T1<X> for S3<X> { //ERROR instantiating a type parameter with an incompatible type } // impl - unbounded trait T2<Z> { } -impl<type X> T2<X> for S3<X> { //ERROR instantiating a type parameter with an incompatible type `X` +impl<Sized? X> T2<X> for S3<X> { //ERROR instantiating a type parameter with an incompatible type `X // impl - struct -trait T3<type Z> { +trait T3<Sized? Z> { } struct S4<Y>; -impl<type X> T3<X> for S4<X> { //ERROR instantiating a type parameter with an incompatible type `X` +impl<Sized? X> T3<X> for S4<X> { //ERROR instantiating a type parameter with an incompatible type `X } */ diff --git a/src/test/compile-fail/unsized4.rs b/src/test/compile-fail/unsized4.rs index 968716320fd..e377c9d5f41 100644 --- a/src/test/compile-fail/unsized4.rs +++ b/src/test/compile-fail/unsized4.rs @@ -11,7 +11,7 @@ // Test that bounds are sized-compatible. trait T {} -fn f<type Y: T>() { +fn f<Sized? Y: T>() { //~^ERROR incompatible bounds on type parameter Y, bound T does not allow unsized type } diff --git a/src/test/compile-fail/unsized5.rs b/src/test/compile-fail/unsized5.rs index 614b8e3a5ab..7028f7e798b 100644 --- a/src/test/compile-fail/unsized5.rs +++ b/src/test/compile-fail/unsized5.rs @@ -9,19 +9,19 @@ // except according to those terms. #![feature(struct_variant)] -// Test `type` types not allowed in fields. +// Test `Sized?` types not allowed in fields. -struct S1<type X> { +struct S1<Sized? X> { f1: X, //~ ERROR type `f1` is dynamically sized. dynamically sized types may only appear as the f2: int, } -struct S2<type X> { +struct S2<Sized? X> { f: int, g: X, //~ ERROR type `g` is dynamically sized. dynamically sized types may only appear as the ty h: int, } -enum E<type X> { +enum E<Sized? X> { V1(X, int), //~ERROR type `X` is dynamically sized. dynamically sized types may only appear as t V2{f1: X, f: int}, //~ERROR type `f1` is dynamically sized. dynamically sized types may only app } diff --git a/src/test/compile-fail/unsized6.rs b/src/test/compile-fail/unsized6.rs index 061b003b5e3..def1146526b 100644 --- a/src/test/compile-fail/unsized6.rs +++ b/src/test/compile-fail/unsized6.rs @@ -8,37 +8,37 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// Test `type` local variables. +// Test `Sized?` local variables. -trait T for type {} +trait T for Sized? {} -fn f1<type X>(x: &X) { +fn f1<Sized? X>(x: &X) { let _: X; //~ERROR variable `_` has dynamically sized type `X` let _: (int, (X, int)); //~ERROR variable `_` has dynamically sized type `(int,(X,int))` let y: X; //~ERROR variable `y` has dynamically sized type `X` let y: (int, (X, int)); //~ERROR variable `y` has dynamically sized type `(int,(X,int))` } -fn f2<type X: T>(x: &X) { +fn f2<Sized? X: T>(x: &X) { let _: X; //~ERROR variable `_` has dynamically sized type `X` let _: (int, (X, int)); //~ERROR variable `_` has dynamically sized type `(int,(X,int))` let y: X; //~ERROR variable `y` has dynamically sized type `X` let y: (int, (X, int)); //~ERROR variable `y` has dynamically sized type `(int,(X,int))` } -fn f3<type X>(x1: Box<X>, x2: Box<X>, x3: Box<X>) { +fn f3<Sized? X>(x1: Box<X>, x2: Box<X>, x3: Box<X>) { let y: X = *x1; //~ERROR variable `y` has dynamically sized type `X` let y = *x2; //~ERROR variable `y` has dynamically sized type `X` let (y, z) = (*x3, 4i); //~ERROR variable `y` has dynamically sized type `X` } -fn f4<type X: T>(x1: Box<X>, x2: Box<X>, x3: Box<X>) { +fn f4<Sized? X: T>(x1: Box<X>, x2: Box<X>, x3: Box<X>) { let y: X = *x1; //~ERROR variable `y` has dynamically sized type `X` let y = *x2; //~ERROR variable `y` has dynamically sized type `X` let (y, z) = (*x3, 4i); //~ERROR variable `y` has dynamically sized type `X` } -fn g1<type X>(x: X) {} //~ERROR variable `x` has dynamically sized type `X` -fn g2<type X: T>(x: X) {} //~ERROR variable `x` has dynamically sized type `X` +fn g1<Sized? X>(x: X) {} //~ERROR variable `x` has dynamically sized type `X` +fn g2<Sized? X: T>(x: X) {} //~ERROR variable `x` has dynamically sized type `X` pub fn main() { } |
