about summary refs log tree commit diff
path: root/compiler/rustc_error_codes
diff options
context:
space:
mode:
authorAnton Golov <jesyspa@gmail.com>2021-08-20 15:59:42 +0200
committerAnton Golov <jesyspa@gmail.com>2021-08-20 15:59:42 +0200
commitba83b39d4e53f412339f1af8c4f7cbe80eb1ee6e (patch)
treec11a2fb9f402635539bcce590aa8e19932e0ee63 /compiler/rustc_error_codes
parent521734787ecf80ff12df7ca5998f7ec0b3b7b2c9 (diff)
downloadrust-ba83b39d4e53f412339f1af8c4f7cbe80eb1ee6e.tar.gz
rust-ba83b39d4e53f412339f1af8c4f7cbe80eb1ee6e.zip
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).
Diffstat (limited to 'compiler/rustc_error_codes')
-rw-r--r--compiler/rustc_error_codes/src/error_codes/E0161.md26
1 files changed, 21 insertions, 5 deletions
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<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!
 }
 ```