diff options
| author | Masaki Hara <ackie.h.gmai@gmail.com> | 2018-05-29 00:11:34 +0900 |
|---|---|---|
| committer | Masaki Hara <ackie.h.gmai@gmail.com> | 2018-08-19 08:07:33 +0900 |
| commit | e2b95cb70e2142aab82a40115d11ff54a975335e (patch) | |
| tree | c8e4c91ad14abd3a6b82ec3a51be94167cf14a4f /src/test | |
| parent | 7f05304068bf6a3b84b328ad6911f6645a0dbf40 (diff) | |
| download | rust-e2b95cb70e2142aab82a40115d11ff54a975335e.tar.gz rust-e2b95cb70e2142aab82a40115d11ff54a975335e.zip | |
Lift some Sized checks.
Diffstat (limited to 'src/test')
| -rw-r--r-- | src/test/compile-fail/unsized-locals/unsized-exprs.rs | 36 | ||||
| -rw-r--r-- | src/test/compile-fail/unsized-locals/unsized-exprs2.rs | 36 | ||||
| -rw-r--r-- | src/test/ui/associated-types/associated-types-unsized.stderr | 1 | ||||
| -rw-r--r-- | src/test/ui/error-codes/E0277.stderr | 1 | ||||
| -rw-r--r-- | src/test/ui/feature-gate-unsized_locals.stderr | 1 | ||||
| -rw-r--r-- | src/test/ui/issues/issue-15756.stderr | 1 | ||||
| -rw-r--r-- | src/test/ui/issues/issue-27078.stderr | 1 | ||||
| -rw-r--r-- | src/test/ui/issues/issue-38954.stderr | 1 | ||||
| -rw-r--r-- | src/test/ui/issues/issue-41229-ref-str.stderr | 1 | ||||
| -rw-r--r-- | src/test/ui/issues/issue-42312.stderr | 2 | ||||
| -rw-r--r-- | src/test/ui/issues/issue-5883.stderr | 1 | ||||
| -rw-r--r-- | src/test/ui/resolve/issue-5035-2.stderr | 1 | ||||
| -rw-r--r-- | src/test/ui/str/str-array-assignment.stderr | 1 | ||||
| -rw-r--r-- | src/test/ui/traits/trait-bounds-not-on-bare-trait.stderr | 1 | ||||
| -rw-r--r-- | src/test/ui/unsized6.stderr | 10 |
15 files changed, 95 insertions, 0 deletions
diff --git a/src/test/compile-fail/unsized-locals/unsized-exprs.rs b/src/test/compile-fail/unsized-locals/unsized-exprs.rs new file mode 100644 index 00000000000..a09ccbb407e --- /dev/null +++ b/src/test/compile-fail/unsized-locals/unsized-exprs.rs @@ -0,0 +1,36 @@ +// Copyright 2018 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. + +#![feature(unsized_tuple_coercion, unsized_locals)] + +struct A<X: ?Sized>(X); + +fn udrop<T: ?Sized>(_x: T) {} +fn foo() -> Box<[u8]> { + Box::new(*b"foo") +} +fn tfoo() -> Box<(i32, [u8])> { + Box::new((42, *b"foo")) +} +fn afoo() -> Box<A<[u8]>> { + Box::new(A(*b"foo")) +} + +impl std::ops::Add<i32> for A<[u8]> { + type Output = (); + fn add(self, _rhs: i32) -> Self::Output {} +} + +fn main() { + udrop::<(i32, [u8])>((42, *foo())); + //~^ERROR E0277 + udrop::<A<[u8]>>(A { 0: *foo() }); + //~^ERROR E0277 +} diff --git a/src/test/compile-fail/unsized-locals/unsized-exprs2.rs b/src/test/compile-fail/unsized-locals/unsized-exprs2.rs new file mode 100644 index 00000000000..40d6e54bd89 --- /dev/null +++ b/src/test/compile-fail/unsized-locals/unsized-exprs2.rs @@ -0,0 +1,36 @@ +// Copyright 2018 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. + +#![feature(unsized_tuple_coercion, unsized_locals)] + +struct A<X: ?Sized>(X); + +fn udrop<T: ?Sized>(_x: T) {} +fn foo() -> Box<[u8]> { + Box::new(*b"foo") +} +fn tfoo() -> Box<(i32, [u8])> { + Box::new((42, *b"foo")) +} +fn afoo() -> Box<A<[u8]>> { + Box::new(A(*b"foo")) +} + +impl std::ops::Add<i32> for A<[u8]> { + type Output = (); + fn add(self, _rhs: i32) -> Self::Output {} +} + +fn main() { + udrop::<[u8]>(foo()[..]); + //~^ERROR cannot move out of indexed content + // FIXME: should be error + udrop::<A<[u8]>>(A(*foo())); +} diff --git a/src/test/ui/associated-types/associated-types-unsized.stderr b/src/test/ui/associated-types/associated-types-unsized.stderr index 0b338c9ad45..09e3cb8c126 100644 --- a/src/test/ui/associated-types/associated-types-unsized.stderr +++ b/src/test/ui/associated-types/associated-types-unsized.stderr @@ -8,6 +8,7 @@ LL | let x = t.get(); //~ ERROR the size for values of type = note: to learn more, visit <https://doc.rust-lang.org/book/second-edition/ch19-04-advanced-types.html#dynamically-sized-types-and-the-sized-trait> = help: consider adding a `where <T as Get>::Value: std::marker::Sized` bound = note: all local variables must have a statically known size + = help: unsized locals are gated as an unstable feature error: aborting due to previous error diff --git a/src/test/ui/error-codes/E0277.stderr b/src/test/ui/error-codes/E0277.stderr index e4c2f102267..ab9020222ea 100644 --- a/src/test/ui/error-codes/E0277.stderr +++ b/src/test/ui/error-codes/E0277.stderr @@ -8,6 +8,7 @@ LL | fn f(p: Path) { } = note: to learn more, visit <https://doc.rust-lang.org/book/second-edition/ch19-04-advanced-types.html#dynamically-sized-types-and-the-sized-trait> = note: required because it appears within the type `std::path::Path` = note: all local variables must have a statically known size + = help: unsized locals are gated as an unstable feature error[E0277]: the trait bound `i32: Foo` is not satisfied --> $DIR/E0277.rs:27:5 diff --git a/src/test/ui/feature-gate-unsized_locals.stderr b/src/test/ui/feature-gate-unsized_locals.stderr index 3cb0aa3b3ec..a0440a373d2 100644 --- a/src/test/ui/feature-gate-unsized_locals.stderr +++ b/src/test/ui/feature-gate-unsized_locals.stderr @@ -7,6 +7,7 @@ LL | fn f(f: FnOnce()) {} = help: the trait `std::marker::Sized` is not implemented for `(dyn std::ops::FnOnce() + 'static)` = note: to learn more, visit <https://doc.rust-lang.org/book/second-edition/ch19-04-advanced-types.html#dynamically-sized-types-and-the-sized-trait> = note: all local variables must have a statically known size + = help: unsized locals are gated as an unstable feature error: aborting due to previous error diff --git a/src/test/ui/issues/issue-15756.stderr b/src/test/ui/issues/issue-15756.stderr index e142a504eb6..877e0eaedf1 100644 --- a/src/test/ui/issues/issue-15756.stderr +++ b/src/test/ui/issues/issue-15756.stderr @@ -7,6 +7,7 @@ LL | &mut something = help: the trait `std::marker::Sized` is not implemented for `[T]` = note: to learn more, visit <https://doc.rust-lang.org/book/second-edition/ch19-04-advanced-types.html#dynamically-sized-types-and-the-sized-trait> = note: all local variables must have a statically known size + = help: unsized locals are gated as an unstable feature error: aborting due to previous error diff --git a/src/test/ui/issues/issue-27078.stderr b/src/test/ui/issues/issue-27078.stderr index 65b66997ee8..269a69dde33 100644 --- a/src/test/ui/issues/issue-27078.stderr +++ b/src/test/ui/issues/issue-27078.stderr @@ -8,6 +8,7 @@ LL | fn foo(self) -> &'static i32 { = note: to learn more, visit <https://doc.rust-lang.org/book/second-edition/ch19-04-advanced-types.html#dynamically-sized-types-and-the-sized-trait> = help: consider adding a `where Self: std::marker::Sized` bound = note: all local variables must have a statically known size + = help: unsized locals are gated as an unstable feature error: aborting due to previous error diff --git a/src/test/ui/issues/issue-38954.stderr b/src/test/ui/issues/issue-38954.stderr index 9ecae90ff3a..9bc937b97c9 100644 --- a/src/test/ui/issues/issue-38954.stderr +++ b/src/test/ui/issues/issue-38954.stderr @@ -7,6 +7,7 @@ LL | fn _test(ref _p: str) {} = help: the trait `std::marker::Sized` is not implemented for `str` = note: to learn more, visit <https://doc.rust-lang.org/book/second-edition/ch19-04-advanced-types.html#dynamically-sized-types-and-the-sized-trait> = note: all function arguments must have a statically known size + = help: unsized locals are gated as an unstable feature error: aborting due to previous error diff --git a/src/test/ui/issues/issue-41229-ref-str.stderr b/src/test/ui/issues/issue-41229-ref-str.stderr index 75f43be7728..e4a34fdaf48 100644 --- a/src/test/ui/issues/issue-41229-ref-str.stderr +++ b/src/test/ui/issues/issue-41229-ref-str.stderr @@ -7,6 +7,7 @@ LL | pub fn example(ref s: str) {} = help: the trait `std::marker::Sized` is not implemented for `str` = note: to learn more, visit <https://doc.rust-lang.org/book/second-edition/ch19-04-advanced-types.html#dynamically-sized-types-and-the-sized-trait> = note: all function arguments must have a statically known size + = help: unsized locals are gated as an unstable feature error: aborting due to previous error diff --git a/src/test/ui/issues/issue-42312.stderr b/src/test/ui/issues/issue-42312.stderr index 0f383fe40a5..912d791b6bc 100644 --- a/src/test/ui/issues/issue-42312.stderr +++ b/src/test/ui/issues/issue-42312.stderr @@ -8,6 +8,7 @@ LL | fn baz(_: Self::Target) where Self: Deref {} = note: to learn more, visit <https://doc.rust-lang.org/book/second-edition/ch19-04-advanced-types.html#dynamically-sized-types-and-the-sized-trait> = help: consider adding a `where <Self as std::ops::Deref>::Target: std::marker::Sized` bound = note: all function arguments must have a statically known size + = help: unsized locals are gated as an unstable feature error[E0277]: the size for values of type `(dyn std::string::ToString + 'static)` cannot be known at compilation time --> $DIR/issue-42312.rs:18:23 @@ -18,6 +19,7 @@ LL | pub fn f(_: ToString) {} = help: the trait `std::marker::Sized` is not implemented for `(dyn std::string::ToString + 'static)` = note: to learn more, visit <https://doc.rust-lang.org/book/second-edition/ch19-04-advanced-types.html#dynamically-sized-types-and-the-sized-trait> = note: all function arguments must have a statically known size + = help: unsized locals are gated as an unstable feature error: aborting due to 2 previous errors diff --git a/src/test/ui/issues/issue-5883.stderr b/src/test/ui/issues/issue-5883.stderr index 6a321abeaed..63dabd86ca8 100644 --- a/src/test/ui/issues/issue-5883.stderr +++ b/src/test/ui/issues/issue-5883.stderr @@ -7,6 +7,7 @@ LL | fn new_struct(r: A+'static) = help: the trait `std::marker::Sized` is not implemented for `(dyn A + 'static)` = note: to learn more, visit <https://doc.rust-lang.org/book/second-edition/ch19-04-advanced-types.html#dynamically-sized-types-and-the-sized-trait> = note: all local variables must have a statically known size + = help: unsized locals are gated as an unstable feature error[E0277]: the size for values of type `(dyn A + 'static)` cannot be known at compilation time --> $DIR/issue-5883.rs:18:8 diff --git a/src/test/ui/resolve/issue-5035-2.stderr b/src/test/ui/resolve/issue-5035-2.stderr index 10d7a52297f..9e7fca0508e 100644 --- a/src/test/ui/resolve/issue-5035-2.stderr +++ b/src/test/ui/resolve/issue-5035-2.stderr @@ -7,6 +7,7 @@ LL | fn foo(_x: K) {} = help: the trait `std::marker::Sized` is not implemented for `(dyn I + 'static)` = note: to learn more, visit <https://doc.rust-lang.org/book/second-edition/ch19-04-advanced-types.html#dynamically-sized-types-and-the-sized-trait> = note: all local variables must have a statically known size + = help: unsized locals are gated as an unstable feature error: aborting due to previous error diff --git a/src/test/ui/str/str-array-assignment.stderr b/src/test/ui/str/str-array-assignment.stderr index 59521bd2e2f..57eff3fb137 100644 --- a/src/test/ui/str/str-array-assignment.stderr +++ b/src/test/ui/str/str-array-assignment.stderr @@ -30,6 +30,7 @@ LL | let v = s[..2]; = help: the trait `std::marker::Sized` is not implemented for `str` = note: to learn more, visit <https://doc.rust-lang.org/book/second-edition/ch19-04-advanced-types.html#dynamically-sized-types-and-the-sized-trait> = note: all local variables must have a statically known size + = help: unsized locals are gated as an unstable feature error[E0308]: mismatched types --> $DIR/str-array-assignment.rs:19:17 diff --git a/src/test/ui/traits/trait-bounds-not-on-bare-trait.stderr b/src/test/ui/traits/trait-bounds-not-on-bare-trait.stderr index b0c1c284f5a..ecabf9af27b 100644 --- a/src/test/ui/traits/trait-bounds-not-on-bare-trait.stderr +++ b/src/test/ui/traits/trait-bounds-not-on-bare-trait.stderr @@ -7,6 +7,7 @@ LL | fn foo(_x: Foo + Send) { = help: the trait `std::marker::Sized` is not implemented for `(dyn Foo + std::marker::Send + 'static)` = note: to learn more, visit <https://doc.rust-lang.org/book/second-edition/ch19-04-advanced-types.html#dynamically-sized-types-and-the-sized-trait> = note: all local variables must have a statically known size + = help: unsized locals are gated as an unstable feature error: aborting due to previous error diff --git a/src/test/ui/unsized6.stderr b/src/test/ui/unsized6.stderr index 5dc12a344ad..5a095332692 100644 --- a/src/test/ui/unsized6.stderr +++ b/src/test/ui/unsized6.stderr @@ -8,6 +8,7 @@ LL | let y: Y; = note: to learn more, visit <https://doc.rust-lang.org/book/second-edition/ch19-04-advanced-types.html#dynamically-sized-types-and-the-sized-trait> = help: consider adding a `where Y: std::marker::Sized` bound = note: all local variables must have a statically known size + = help: unsized locals are gated as an unstable feature error[E0277]: the size for values of type `X` cannot be known at compilation time --> $DIR/unsized6.rs:17:12 @@ -41,6 +42,7 @@ LL | let y: X; = note: to learn more, visit <https://doc.rust-lang.org/book/second-edition/ch19-04-advanced-types.html#dynamically-sized-types-and-the-sized-trait> = help: consider adding a `where X: std::marker::Sized` bound = note: all local variables must have a statically known size + = help: unsized locals are gated as an unstable feature error[E0277]: the size for values of type `Y` cannot be known at compilation time --> $DIR/unsized6.rs:27:12 @@ -63,6 +65,7 @@ LL | let y: X = *x1; = note: to learn more, visit <https://doc.rust-lang.org/book/second-edition/ch19-04-advanced-types.html#dynamically-sized-types-and-the-sized-trait> = help: consider adding a `where X: std::marker::Sized` bound = note: all local variables must have a statically known size + = help: unsized locals are gated as an unstable feature error[E0277]: the size for values of type `X` cannot be known at compilation time --> $DIR/unsized6.rs:34:9 @@ -74,6 +77,7 @@ LL | let y = *x2; = note: to learn more, visit <https://doc.rust-lang.org/book/second-edition/ch19-04-advanced-types.html#dynamically-sized-types-and-the-sized-trait> = help: consider adding a `where X: std::marker::Sized` bound = note: all local variables must have a statically known size + = help: unsized locals are gated as an unstable feature error[E0277]: the size for values of type `X` cannot be known at compilation time --> $DIR/unsized6.rs:36:10 @@ -85,6 +89,7 @@ LL | let (y, z) = (*x3, 4); = note: to learn more, visit <https://doc.rust-lang.org/book/second-edition/ch19-04-advanced-types.html#dynamically-sized-types-and-the-sized-trait> = help: consider adding a `where X: std::marker::Sized` bound = note: all local variables must have a statically known size + = help: unsized locals are gated as an unstable feature error[E0277]: the size for values of type `X` cannot be known at compilation time --> $DIR/unsized6.rs:40:9 @@ -96,6 +101,7 @@ LL | let y: X = *x1; = note: to learn more, visit <https://doc.rust-lang.org/book/second-edition/ch19-04-advanced-types.html#dynamically-sized-types-and-the-sized-trait> = help: consider adding a `where X: std::marker::Sized` bound = note: all local variables must have a statically known size + = help: unsized locals are gated as an unstable feature error[E0277]: the size for values of type `X` cannot be known at compilation time --> $DIR/unsized6.rs:42:9 @@ -107,6 +113,7 @@ LL | let y = *x2; = note: to learn more, visit <https://doc.rust-lang.org/book/second-edition/ch19-04-advanced-types.html#dynamically-sized-types-and-the-sized-trait> = help: consider adding a `where X: std::marker::Sized` bound = note: all local variables must have a statically known size + = help: unsized locals are gated as an unstable feature error[E0277]: the size for values of type `X` cannot be known at compilation time --> $DIR/unsized6.rs:44:10 @@ -118,6 +125,7 @@ LL | let (y, z) = (*x3, 4); = note: to learn more, visit <https://doc.rust-lang.org/book/second-edition/ch19-04-advanced-types.html#dynamically-sized-types-and-the-sized-trait> = help: consider adding a `where X: std::marker::Sized` bound = note: all local variables must have a statically known size + = help: unsized locals are gated as an unstable feature error[E0277]: the size for values of type `X` cannot be known at compilation time --> $DIR/unsized6.rs:48:18 @@ -129,6 +137,7 @@ LL | fn g1<X: ?Sized>(x: X) {} = note: to learn more, visit <https://doc.rust-lang.org/book/second-edition/ch19-04-advanced-types.html#dynamically-sized-types-and-the-sized-trait> = help: consider adding a `where X: std::marker::Sized` bound = note: all local variables must have a statically known size + = help: unsized locals are gated as an unstable feature error[E0277]: the size for values of type `X` cannot be known at compilation time --> $DIR/unsized6.rs:50:22 @@ -140,6 +149,7 @@ LL | fn g2<X: ?Sized + T>(x: X) {} = note: to learn more, visit <https://doc.rust-lang.org/book/second-edition/ch19-04-advanced-types.html#dynamically-sized-types-and-the-sized-trait> = help: consider adding a `where X: std::marker::Sized` bound = note: all local variables must have a statically known size + = help: unsized locals are gated as an unstable feature error: aborting due to 13 previous errors |
