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 | |
| 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')
| -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 | ||||
| -rw-r--r-- | src/test/run-pass/unsized.rs | 26 | ||||
| -rw-r--r-- | src/test/run-pass/unsized2.rs | 24 |
9 files changed, 55 insertions, 55 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() { } diff --git a/src/test/run-pass/unsized.rs b/src/test/run-pass/unsized.rs index db0cc83d786..f49e8f46e78 100644 --- a/src/test/run-pass/unsized.rs +++ b/src/test/run-pass/unsized.rs @@ -8,20 +8,20 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// Test syntax checks for `type` keyword. +// Test syntax checks for `Sized?` syntax. -trait T1 for type {} -pub trait T2 for type {} -trait T3<X: T1> for type: T2 {} -trait T4<type X> {} -trait T5<type X, Y> {} -trait T6<Y, type X> {} -trait T7<type X, type Y> {} -trait T8<type X: T2> {} -struct S1<type X>; -enum E<type X> {} -impl <type X> T1 for S1<X> {} -fn f<type X>() {} +trait T1 for Sized? {} +pub trait T2 for Sized? {} +trait T3<X: T1> for Sized?: T2 {} +trait T4<Sized? X> {} +trait T5<Sized? X, Y> {} +trait T6<Y, Sized? X> {} +trait T7<Sized? X, Sized? Y> {} +trait T8<Sized? X: T2> {} +struct S1<Sized? X>; +enum E<Sized? X> {} +impl <Sized? X> T1 for S1<X> {} +fn f<Sized? X>() {} pub fn main() { } diff --git a/src/test/run-pass/unsized2.rs b/src/test/run-pass/unsized2.rs index 53db7f37e8d..9703b55cda7 100644 --- a/src/test/run-pass/unsized2.rs +++ b/src/test/run-pass/unsized2.rs @@ -13,7 +13,7 @@ // Test sized-ness checking in substitution. // Unbounded. -fn f1<type X>(x: &X) { +fn f1<Sized? X>(x: &X) { f1::<X>(x); } fn f2<X>(x: &X) { @@ -22,8 +22,8 @@ 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) { f3::<X>(x); } fn f4<X: T>(x: &X) { @@ -32,7 +32,7 @@ fn f4<X: T>(x: &X) { } // Self type. -trait T2 for type { +trait T2 for Sized? { fn f() -> Box<Self>; } struct S; @@ -41,14 +41,14 @@ impl T2 for S { box S } } -fn f5<type X: T2>(x: &X) { +fn f5<Sized? X: T2>(x: &X) { let _: Box<X> = T2::f(); } fn f6<X: T2>(x: &X) { let _: Box<X> = T2::f(); } -trait T3 for type { +trait T3 for Sized? { fn f() -> Box<Self>; } impl T3 for S { @@ -56,7 +56,7 @@ impl T3 for S { box S } } -fn f7<type X: T3>(x: &X) { +fn f7<Sized? X: T3>(x: &X) { // This is valid, but the unsized bound on X is irrelevant because any type // which implements T3 must have statically known size. let _: Box<X> = T3::f(); @@ -66,7 +66,7 @@ trait T4<X> { fn m1(x: &T4<X>); fn m2(x: &T5<X>); } -trait T5<type X> { +trait T5<Sized? X> { // not an error (for now) fn m1(x: &T4<X>); fn m2(x: &T5<X>); @@ -76,21 +76,21 @@ trait T6<X: T> { fn m1(x: &T4<X>); fn m2(x: &T5<X>); } -trait T7<type X: T> { +trait T7<Sized? X: T> { // not an error (for now) fn m1(x: &T4<X>); fn m2(x: &T5<X>); } // The last field in a struct or variant may be unsized -struct S2<type X> { +struct S2<Sized? X> { f: X, } -struct S3<type X> { +struct S3<Sized? X> { f1: int, f2: X, } -enum E<type X> { +enum E<Sized? X> { V1(X), V2{x: X}, V3(int, X), |
