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
10 changed files with 47 additions and 61 deletions
|
@ -4,11 +4,18 @@ Erroneous code example:
|
||||||
|
|
||||||
```compile_fail,E0161
|
```compile_fail,E0161
|
||||||
#![feature(box_syntax)]
|
#![feature(box_syntax)]
|
||||||
|
trait Bar {
|
||||||
|
fn f(self);
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Bar for i32 {
|
||||||
|
fn f(self) {}
|
||||||
|
}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let array: &[isize] = &[1, 2, 3];
|
let b: Box<dyn Bar> = box (0 as i32);
|
||||||
let _x: Box<[isize]> = box *array;
|
b.f();
|
||||||
// error: cannot move a value of type [isize]: the size of [isize] cannot
|
// error: cannot move a value of type dyn Bar: the size of dyn Bar cannot
|
||||||
// be statically determined
|
// be statically determined
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
@ -22,8 +29,17 @@ it around as usual. Example:
|
||||||
```
|
```
|
||||||
#![feature(box_syntax)]
|
#![feature(box_syntax)]
|
||||||
|
|
||||||
|
trait Bar {
|
||||||
|
fn f(&self);
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Bar for i32 {
|
||||||
|
fn f(&self) {}
|
||||||
|
}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let array: &[isize] = &[1, 2, 3];
|
let b: Box<dyn Bar> = box (0 as i32);
|
||||||
let _x: Box<&[isize]> = box array; // ok!
|
b.f();
|
||||||
|
// ok!
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
error[E0161]: cannot move a value of type [i32]: the size of [i32] cannot be statically determined
|
error[E0161]: cannot move a value of type dyn Bar: the size of dyn Bar cannot be statically determined
|
||||||
--> $DIR/E0161.rs:22:9
|
--> $DIR/E0161.rs:29:5
|
||||||
|
|
|
|
||||||
LL | box *x;
|
LL | x.f();
|
||||||
| ^^
|
| ^
|
||||||
|
|
||||||
error: aborting due to previous error
|
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
|
error[E0161]: cannot move a value of type dyn Bar: the size of dyn Bar cannot be statically determined
|
||||||
--> $DIR/E0161.rs:22:9
|
--> $DIR/E0161.rs:29:5
|
||||||
|
|
|
|
||||||
LL | box *x;
|
LL | x.f();
|
||||||
| ^^
|
| ^
|
||||||
|
|
||||||
error: aborting due to previous error
|
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
|
error[E0161]: cannot move a value of type dyn Bar: the size of dyn Bar cannot be statically determined
|
||||||
--> $DIR/E0161.rs:22:9
|
--> $DIR/E0161.rs:29:5
|
||||||
|
|
|
|
||||||
LL | box *x;
|
LL | x.f();
|
||||||
| ^^
|
| ^
|
||||||
|
|
||||||
error: aborting due to previous error
|
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
|
//[edition]edition:2018
|
||||||
//[zflagsul]compile-flags: -Z borrowck=migrate
|
//[zflagsul]compile-flags: -Z borrowck=migrate
|
||||||
//[editionul]edition:2018
|
//[editionul]edition:2018
|
||||||
|
//[migrateul] check-pass
|
||||||
|
//[nllul] check-pass
|
||||||
|
//[zflagsul] check-pass
|
||||||
|
//[editionul] check-pass
|
||||||
|
|
||||||
#![allow(incomplete_features)]
|
#![allow(incomplete_features)]
|
||||||
#![cfg_attr(nll, feature(nll))]
|
#![cfg_attr(nll, feature(nll))]
|
||||||
|
@ -16,12 +20,14 @@
|
||||||
#![cfg_attr(zflagsul, feature(unsized_locals))]
|
#![cfg_attr(zflagsul, feature(unsized_locals))]
|
||||||
#![cfg_attr(nllul, feature(unsized_locals))]
|
#![cfg_attr(nllul, feature(unsized_locals))]
|
||||||
#![cfg_attr(editionul, feature(unsized_locals))]
|
#![cfg_attr(editionul, feature(unsized_locals))]
|
||||||
#![feature(box_syntax)]
|
|
||||||
|
|
||||||
fn foo(x: Box<[i32]>) {
|
trait Bar {
|
||||||
box *x;
|
fn f(self);
|
||||||
|
}
|
||||||
|
|
||||||
|
fn foo(x: Box<dyn Bar>) {
|
||||||
|
x.f();
|
||||||
//[migrate,nll,zflags,edition]~^ ERROR E0161
|
//[migrate,nll,zflags,edition]~^ ERROR E0161
|
||||||
//[migrateul,nllul,zflagsul,editionul]~^^ ERROR E0161
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() {}
|
fn main() {}
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
error[E0161]: cannot move a value of type [i32]: the size of [i32] cannot be statically determined
|
error[E0161]: cannot move a value of type dyn Bar: the size of dyn Bar cannot be statically determined
|
||||||
--> $DIR/E0161.rs:22:9
|
--> $DIR/E0161.rs:29:5
|
||||||
|
|
|
|
||||||
LL | box *x;
|
LL | x.f();
|
||||||
| ^^
|
| ^
|
||||||
|
|
||||||
error: aborting due to previous error
|
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…
Add table
Add a link
Reference in a new issue