From b3dce87a8694381e4e96fd4a7183487ffa100e22 Mon Sep 17 00:00:00 2001 From: Masaki Hara Date: Wed, 24 Oct 2018 22:10:17 +0900 Subject: Move compile-fail/unsized-locals under ui as per #44844. --- .../unsized-locals/by-value-trait-object-safety.rs | 30 ------------------ .../compile-fail/unsized-locals/unsized-exprs.rs | 36 ---------------------- .../compile-fail/unsized-locals/unsized-exprs2.rs | 36 ---------------------- .../unsized-locals/by-value-trait-object-safety.rs | 30 ++++++++++++++++++ .../by-value-trait-object-safety.stderr | 8 +++++ src/test/ui/unsized-locals/unsized-exprs.rs | 36 ++++++++++++++++++++++ src/test/ui/unsized-locals/unsized-exprs.stderr | 25 +++++++++++++++ .../ui/unsized-locals/unsized-exprs2.nll.stderr | 19 ++++++++++++ src/test/ui/unsized-locals/unsized-exprs2.rs | 36 ++++++++++++++++++++++ src/test/ui/unsized-locals/unsized-exprs2.stderr | 9 ++++++ 10 files changed, 163 insertions(+), 102 deletions(-) delete mode 100644 src/test/compile-fail/unsized-locals/by-value-trait-object-safety.rs delete mode 100644 src/test/compile-fail/unsized-locals/unsized-exprs.rs delete mode 100644 src/test/compile-fail/unsized-locals/unsized-exprs2.rs create mode 100644 src/test/ui/unsized-locals/by-value-trait-object-safety.rs create mode 100644 src/test/ui/unsized-locals/by-value-trait-object-safety.stderr create mode 100644 src/test/ui/unsized-locals/unsized-exprs.rs create mode 100644 src/test/ui/unsized-locals/unsized-exprs.stderr create mode 100644 src/test/ui/unsized-locals/unsized-exprs2.nll.stderr create mode 100644 src/test/ui/unsized-locals/unsized-exprs2.rs create mode 100644 src/test/ui/unsized-locals/unsized-exprs2.stderr (limited to 'src') diff --git a/src/test/compile-fail/unsized-locals/by-value-trait-object-safety.rs b/src/test/compile-fail/unsized-locals/by-value-trait-object-safety.rs deleted file mode 100644 index 9ac67da2443..00000000000 --- a/src/test/compile-fail/unsized-locals/by-value-trait-object-safety.rs +++ /dev/null @@ -1,30 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(unsized_locals)] - -pub trait Foo { - fn foo(self) -> String where Self: Sized; -} - -struct A; - -impl Foo for A { - fn foo(self) -> String { - format!("hello") - } -} - - -fn main() { - let x = *(Box::new(A) as Box); - x.foo(); - //~^ERROR the `foo` method cannot be invoked on a trait object -} diff --git a/src/test/compile-fail/unsized-locals/unsized-exprs.rs b/src/test/compile-fail/unsized-locals/unsized-exprs.rs deleted file mode 100644 index a09ccbb407e..00000000000 --- a/src/test/compile-fail/unsized-locals/unsized-exprs.rs +++ /dev/null @@ -1,36 +0,0 @@ -// 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 or the MIT license -// , 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); - -fn udrop(_x: T) {} -fn foo() -> Box<[u8]> { - Box::new(*b"foo") -} -fn tfoo() -> Box<(i32, [u8])> { - Box::new((42, *b"foo")) -} -fn afoo() -> Box> { - Box::new(A(*b"foo")) -} - -impl std::ops::Add for A<[u8]> { - type Output = (); - fn add(self, _rhs: i32) -> Self::Output {} -} - -fn main() { - udrop::<(i32, [u8])>((42, *foo())); - //~^ERROR E0277 - udrop::>(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 deleted file mode 100644 index 40d6e54bd89..00000000000 --- a/src/test/compile-fail/unsized-locals/unsized-exprs2.rs +++ /dev/null @@ -1,36 +0,0 @@ -// 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 or the MIT license -// , 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); - -fn udrop(_x: T) {} -fn foo() -> Box<[u8]> { - Box::new(*b"foo") -} -fn tfoo() -> Box<(i32, [u8])> { - Box::new((42, *b"foo")) -} -fn afoo() -> Box> { - Box::new(A(*b"foo")) -} - -impl std::ops::Add 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(*foo())); -} diff --git a/src/test/ui/unsized-locals/by-value-trait-object-safety.rs b/src/test/ui/unsized-locals/by-value-trait-object-safety.rs new file mode 100644 index 00000000000..9ac67da2443 --- /dev/null +++ b/src/test/ui/unsized-locals/by-value-trait-object-safety.rs @@ -0,0 +1,30 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(unsized_locals)] + +pub trait Foo { + fn foo(self) -> String where Self: Sized; +} + +struct A; + +impl Foo for A { + fn foo(self) -> String { + format!("hello") + } +} + + +fn main() { + let x = *(Box::new(A) as Box); + x.foo(); + //~^ERROR the `foo` method cannot be invoked on a trait object +} diff --git a/src/test/ui/unsized-locals/by-value-trait-object-safety.stderr b/src/test/ui/unsized-locals/by-value-trait-object-safety.stderr new file mode 100644 index 00000000000..885944b2019 --- /dev/null +++ b/src/test/ui/unsized-locals/by-value-trait-object-safety.stderr @@ -0,0 +1,8 @@ +error: the `foo` method cannot be invoked on a trait object + --> $DIR/by-value-trait-object-safety.rs:28:7 + | +LL | x.foo(); + | ^^^ + +error: aborting due to previous error + diff --git a/src/test/ui/unsized-locals/unsized-exprs.rs b/src/test/ui/unsized-locals/unsized-exprs.rs new file mode 100644 index 00000000000..a09ccbb407e --- /dev/null +++ b/src/test/ui/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 or the MIT license +// , 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); + +fn udrop(_x: T) {} +fn foo() -> Box<[u8]> { + Box::new(*b"foo") +} +fn tfoo() -> Box<(i32, [u8])> { + Box::new((42, *b"foo")) +} +fn afoo() -> Box> { + Box::new(A(*b"foo")) +} + +impl std::ops::Add for A<[u8]> { + type Output = (); + fn add(self, _rhs: i32) -> Self::Output {} +} + +fn main() { + udrop::<(i32, [u8])>((42, *foo())); + //~^ERROR E0277 + udrop::>(A { 0: *foo() }); + //~^ERROR E0277 +} diff --git a/src/test/ui/unsized-locals/unsized-exprs.stderr b/src/test/ui/unsized-locals/unsized-exprs.stderr new file mode 100644 index 00000000000..42a9d622e0d --- /dev/null +++ b/src/test/ui/unsized-locals/unsized-exprs.stderr @@ -0,0 +1,25 @@ +error[E0277]: the size for values of type `[u8]` cannot be known at compilation time + --> $DIR/unsized-exprs.rs:32:26 + | +LL | udrop::<(i32, [u8])>((42, *foo())); + | ^^^^^^^^^^^^ doesn't have a size known at compile-time + | + = help: within `({integer}, [u8])`, the trait `std::marker::Sized` is not implemented for `[u8]` + = note: to learn more, visit + = note: required because it appears within the type `({integer}, [u8])` + = note: tuples must have a statically known size to be initialized + +error[E0277]: the size for values of type `[u8]` cannot be known at compilation time + --> $DIR/unsized-exprs.rs:34:22 + | +LL | udrop::>(A { 0: *foo() }); + | ^^^^^^^^^^^^^^^ doesn't have a size known at compile-time + | + = help: within `A<[u8]>`, the trait `std::marker::Sized` is not implemented for `[u8]` + = note: to learn more, visit + = note: required because it appears within the type `A<[u8]>` + = note: structs must have a statically known size to be initialized + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/unsized-locals/unsized-exprs2.nll.stderr b/src/test/ui/unsized-locals/unsized-exprs2.nll.stderr new file mode 100644 index 00000000000..21541fb8b87 --- /dev/null +++ b/src/test/ui/unsized-locals/unsized-exprs2.nll.stderr @@ -0,0 +1,19 @@ +error[E0508]: cannot move out of type `[u8]`, a non-copy slice + --> $DIR/unsized-exprs2.rs:32:19 + | +LL | udrop::<[u8]>(foo()[..]); + | ^^^^^^^^^ cannot move out of here + +error[E0507]: cannot move out of data in a `&` reference + --> $DIR/unsized-exprs2.rs:32:19 + | +LL | udrop::<[u8]>(foo()[..]); + | ^^^^^^^^^ + | | + | cannot move out of data in a `&` reference + | cannot move + +error: aborting due to 2 previous errors + +Some errors occurred: E0507, E0508. +For more information about an error, try `rustc --explain E0507`. diff --git a/src/test/ui/unsized-locals/unsized-exprs2.rs b/src/test/ui/unsized-locals/unsized-exprs2.rs new file mode 100644 index 00000000000..40d6e54bd89 --- /dev/null +++ b/src/test/ui/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 or the MIT license +// , 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); + +fn udrop(_x: T) {} +fn foo() -> Box<[u8]> { + Box::new(*b"foo") +} +fn tfoo() -> Box<(i32, [u8])> { + Box::new((42, *b"foo")) +} +fn afoo() -> Box> { + Box::new(A(*b"foo")) +} + +impl std::ops::Add 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(*foo())); +} diff --git a/src/test/ui/unsized-locals/unsized-exprs2.stderr b/src/test/ui/unsized-locals/unsized-exprs2.stderr new file mode 100644 index 00000000000..30a6d5473df --- /dev/null +++ b/src/test/ui/unsized-locals/unsized-exprs2.stderr @@ -0,0 +1,9 @@ +error[E0507]: cannot move out of indexed content + --> $DIR/unsized-exprs2.rs:32:19 + | +LL | udrop::<[u8]>(foo()[..]); + | ^^^^^^^^^ cannot move out of indexed content + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0507`. -- cgit 1.4.1-3-g733a5