Move compile-fail/unsized-locals under ui as per #44844.
This commit is contained in:
parent
e568e98063
commit
b3dce87a86
7 changed files with 61 additions and 0 deletions
30
src/test/ui/unsized-locals/by-value-trait-object-safety.rs
Normal file
30
src/test/ui/unsized-locals/by-value-trait-object-safety.rs
Normal file
|
|
@ -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 <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_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<dyn Foo>);
|
||||
x.foo();
|
||||
//~^ERROR the `foo` method cannot be invoked on a trait object
|
||||
}
|
||||
|
|
@ -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
|
||||
|
||||
36
src/test/ui/unsized-locals/unsized-exprs.rs
Normal file
36
src/test/ui/unsized-locals/unsized-exprs.rs
Normal file
|
|
@ -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
|
||||
}
|
||||
25
src/test/ui/unsized-locals/unsized-exprs.stderr
Normal file
25
src/test/ui/unsized-locals/unsized-exprs.stderr
Normal file
|
|
@ -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 <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 `({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<[u8]>>(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 <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 `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`.
|
||||
19
src/test/ui/unsized-locals/unsized-exprs2.nll.stderr
Normal file
19
src/test/ui/unsized-locals/unsized-exprs2.nll.stderr
Normal file
|
|
@ -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`.
|
||||
36
src/test/ui/unsized-locals/unsized-exprs2.rs
Normal file
36
src/test/ui/unsized-locals/unsized-exprs2.rs
Normal file
|
|
@ -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()));
|
||||
}
|
||||
9
src/test/ui/unsized-locals/unsized-exprs2.stderr
Normal file
9
src/test/ui/unsized-locals/unsized-exprs2.stderr
Normal file
|
|
@ -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`.
|
||||
Loading…
Add table
Add a link
Reference in a new issue