mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-25 08:13:41 +00:00
Change example and tests for E0161.
The code will not emit this warning once box expressions require a sized type (since that error is emitted earlier in the flow).
This commit is contained in:
parent
521734787e
commit
ba83b39d4e
@ -4,11 +4,18 @@ Erroneous code example:
|
||||
|
||||
```compile_fail,E0161
|
||||
#![feature(box_syntax)]
|
||||
trait Bar {
|
||||
fn f(self);
|
||||
}
|
||||
|
||||
impl Bar for i32 {
|
||||
fn f(self) {}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let array: &[isize] = &[1, 2, 3];
|
||||
let _x: Box<[isize]> = box *array;
|
||||
// error: cannot move a value of type [isize]: the size of [isize] cannot
|
||||
let b: Box<dyn Bar> = box (0 as i32);
|
||||
b.f();
|
||||
// error: cannot move a value of type dyn Bar: the size of dyn Bar cannot
|
||||
// be statically determined
|
||||
}
|
||||
```
|
||||
@ -22,8 +29,17 @@ it around as usual. Example:
|
||||
```
|
||||
#![feature(box_syntax)]
|
||||
|
||||
trait Bar {
|
||||
fn f(&self);
|
||||
}
|
||||
|
||||
impl Bar for i32 {
|
||||
fn f(&self) {}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let array: &[isize] = &[1, 2, 3];
|
||||
let _x: Box<&[isize]> = box array; // ok!
|
||||
let b: Box<dyn Bar> = box (0 as i32);
|
||||
b.f();
|
||||
// ok!
|
||||
}
|
||||
```
|
||||
|
@ -1,8 +1,8 @@
|
||||
error[E0161]: cannot move a value of type [i32]: the size of [i32] cannot be statically determined
|
||||
--> $DIR/E0161.rs:22:9
|
||||
error[E0161]: cannot move a value of type dyn Bar: the size of dyn Bar cannot be statically determined
|
||||
--> $DIR/E0161.rs:29:5
|
||||
|
|
||||
LL | box *x;
|
||||
| ^^
|
||||
LL | x.f();
|
||||
| ^
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
@ -1,9 +0,0 @@
|
||||
error[E0161]: cannot move a value of type [i32]: the size of [i32] cannot be statically determined
|
||||
--> $DIR/E0161.rs:22:5
|
||||
|
|
||||
LL | box *x;
|
||||
| ^^^^^^
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0161`.
|
@ -1,8 +1,8 @@
|
||||
error[E0161]: cannot move a value of type [i32]: the size of [i32] cannot be statically determined
|
||||
--> $DIR/E0161.rs:22:9
|
||||
error[E0161]: cannot move a value of type dyn Bar: the size of dyn Bar cannot be statically determined
|
||||
--> $DIR/E0161.rs:29:5
|
||||
|
|
||||
LL | box *x;
|
||||
| ^^
|
||||
LL | x.f();
|
||||
| ^
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
@ -1,9 +0,0 @@
|
||||
error[E0161]: cannot move a value of type [i32]: the size of [i32] cannot be statically determined
|
||||
--> $DIR/E0161.rs:22:5
|
||||
|
|
||||
LL | box *x;
|
||||
| ^^^^^^
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0161`.
|
@ -1,8 +1,8 @@
|
||||
error[E0161]: cannot move a value of type [i32]: the size of [i32] cannot be statically determined
|
||||
--> $DIR/E0161.rs:22:9
|
||||
error[E0161]: cannot move a value of type dyn Bar: the size of dyn Bar cannot be statically determined
|
||||
--> $DIR/E0161.rs:29:5
|
||||
|
|
||||
LL | box *x;
|
||||
| ^^
|
||||
LL | x.f();
|
||||
| ^
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
@ -1,9 +0,0 @@
|
||||
error[E0161]: cannot move a value of type [i32]: the size of [i32] cannot be statically determined
|
||||
--> $DIR/E0161.rs:22:5
|
||||
|
|
||||
LL | box *x;
|
||||
| ^^^^^^
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0161`.
|
@ -8,6 +8,10 @@
|
||||
//[edition]edition:2018
|
||||
//[zflagsul]compile-flags: -Z borrowck=migrate
|
||||
//[editionul]edition:2018
|
||||
//[migrateul] check-pass
|
||||
//[nllul] check-pass
|
||||
//[zflagsul] check-pass
|
||||
//[editionul] check-pass
|
||||
|
||||
#![allow(incomplete_features)]
|
||||
#![cfg_attr(nll, feature(nll))]
|
||||
@ -16,12 +20,14 @@
|
||||
#![cfg_attr(zflagsul, feature(unsized_locals))]
|
||||
#![cfg_attr(nllul, feature(unsized_locals))]
|
||||
#![cfg_attr(editionul, feature(unsized_locals))]
|
||||
#![feature(box_syntax)]
|
||||
|
||||
fn foo(x: Box<[i32]>) {
|
||||
box *x;
|
||||
trait Bar {
|
||||
fn f(self);
|
||||
}
|
||||
|
||||
fn foo(x: Box<dyn Bar>) {
|
||||
x.f();
|
||||
//[migrate,nll,zflags,edition]~^ ERROR E0161
|
||||
//[migrateul,nllul,zflagsul,editionul]~^^ ERROR E0161
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
@ -1,8 +1,8 @@
|
||||
error[E0161]: cannot move a value of type [i32]: the size of [i32] cannot be statically determined
|
||||
--> $DIR/E0161.rs:22:9
|
||||
error[E0161]: cannot move a value of type dyn Bar: the size of dyn Bar cannot be statically determined
|
||||
--> $DIR/E0161.rs:29:5
|
||||
|
|
||||
LL | box *x;
|
||||
| ^^
|
||||
LL | x.f();
|
||||
| ^
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
@ -1,9 +0,0 @@
|
||||
error[E0161]: cannot move a value of type [i32]: the size of [i32] cannot be statically determined
|
||||
--> $DIR/E0161.rs:22:5
|
||||
|
|
||||
LL | box *x;
|
||||
| ^^^^^^
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0161`.
|
Loading…
Reference in New Issue
Block a user