From ba83b39d4e53f412339f1af8c4f7cbe80eb1ee6e Mon Sep 17 00:00:00 2001 From: Anton Golov Date: Fri, 20 Aug 2021 15:59:42 +0200 Subject: [PATCH] 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). --- .../src/error_codes/E0161.md | 26 +++++++++++++++---- src/test/ui/error-codes/E0161.edition.stderr | 8 +++--- .../ui/error-codes/E0161.editionul.stderr | 9 ------- src/test/ui/error-codes/E0161.migrate.stderr | 8 +++--- .../ui/error-codes/E0161.migrateul.stderr | 9 ------- src/test/ui/error-codes/E0161.nll.stderr | 8 +++--- src/test/ui/error-codes/E0161.nllul.stderr | 9 ------- src/test/ui/error-codes/E0161.rs | 14 +++++++--- src/test/ui/error-codes/E0161.zflags.stderr | 8 +++--- src/test/ui/error-codes/E0161.zflagsul.stderr | 9 ------- 10 files changed, 47 insertions(+), 61 deletions(-) delete mode 100644 src/test/ui/error-codes/E0161.editionul.stderr delete mode 100644 src/test/ui/error-codes/E0161.migrateul.stderr delete mode 100644 src/test/ui/error-codes/E0161.nllul.stderr delete mode 100644 src/test/ui/error-codes/E0161.zflagsul.stderr diff --git a/compiler/rustc_error_codes/src/error_codes/E0161.md b/compiler/rustc_error_codes/src/error_codes/E0161.md index c2e2f0240f4..ebd2c97698b 100644 --- a/compiler/rustc_error_codes/src/error_codes/E0161.md +++ b/compiler/rustc_error_codes/src/error_codes/E0161.md @@ -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 = 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 = box (0 as i32); + b.f(); + // ok! } ``` diff --git a/src/test/ui/error-codes/E0161.edition.stderr b/src/test/ui/error-codes/E0161.edition.stderr index 536a81a4bc6..6beb29c57d5 100644 --- a/src/test/ui/error-codes/E0161.edition.stderr +++ b/src/test/ui/error-codes/E0161.edition.stderr @@ -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 diff --git a/src/test/ui/error-codes/E0161.editionul.stderr b/src/test/ui/error-codes/E0161.editionul.stderr deleted file mode 100644 index 2baba998f12..00000000000 --- a/src/test/ui/error-codes/E0161.editionul.stderr +++ /dev/null @@ -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`. diff --git a/src/test/ui/error-codes/E0161.migrate.stderr b/src/test/ui/error-codes/E0161.migrate.stderr index 536a81a4bc6..6beb29c57d5 100644 --- a/src/test/ui/error-codes/E0161.migrate.stderr +++ b/src/test/ui/error-codes/E0161.migrate.stderr @@ -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 diff --git a/src/test/ui/error-codes/E0161.migrateul.stderr b/src/test/ui/error-codes/E0161.migrateul.stderr deleted file mode 100644 index 2baba998f12..00000000000 --- a/src/test/ui/error-codes/E0161.migrateul.stderr +++ /dev/null @@ -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`. diff --git a/src/test/ui/error-codes/E0161.nll.stderr b/src/test/ui/error-codes/E0161.nll.stderr index 536a81a4bc6..6beb29c57d5 100644 --- a/src/test/ui/error-codes/E0161.nll.stderr +++ b/src/test/ui/error-codes/E0161.nll.stderr @@ -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 diff --git a/src/test/ui/error-codes/E0161.nllul.stderr b/src/test/ui/error-codes/E0161.nllul.stderr deleted file mode 100644 index 2baba998f12..00000000000 --- a/src/test/ui/error-codes/E0161.nllul.stderr +++ /dev/null @@ -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`. diff --git a/src/test/ui/error-codes/E0161.rs b/src/test/ui/error-codes/E0161.rs index e0f5776424e..ba74529e4b6 100644 --- a/src/test/ui/error-codes/E0161.rs +++ b/src/test/ui/error-codes/E0161.rs @@ -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) { + x.f(); //[migrate,nll,zflags,edition]~^ ERROR E0161 - //[migrateul,nllul,zflagsul,editionul]~^^ ERROR E0161 } fn main() {} diff --git a/src/test/ui/error-codes/E0161.zflags.stderr b/src/test/ui/error-codes/E0161.zflags.stderr index 536a81a4bc6..6beb29c57d5 100644 --- a/src/test/ui/error-codes/E0161.zflags.stderr +++ b/src/test/ui/error-codes/E0161.zflags.stderr @@ -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 diff --git a/src/test/ui/error-codes/E0161.zflagsul.stderr b/src/test/ui/error-codes/E0161.zflagsul.stderr deleted file mode 100644 index 2baba998f12..00000000000 --- a/src/test/ui/error-codes/E0161.zflagsul.stderr +++ /dev/null @@ -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`.