From 1474face6fe8081c29c79179460e1b3e53f51a6e Mon Sep 17 00:00:00 2001 From: Wesley Wiser Date: Fri, 24 Apr 2020 20:27:17 -0400 Subject: [PATCH] Add regression test for #26376 --- .../unsized/return-unsized-from-trait-method.rs | 16 ++++++++++++++++ .../return-unsized-from-trait-method.stderr | 9 +++++++++ 2 files changed, 25 insertions(+) create mode 100644 src/test/ui/unsized/return-unsized-from-trait-method.rs create mode 100644 src/test/ui/unsized/return-unsized-from-trait-method.stderr diff --git a/src/test/ui/unsized/return-unsized-from-trait-method.rs b/src/test/ui/unsized/return-unsized-from-trait-method.rs new file mode 100644 index 0000000000000..2d265d5db5c14 --- /dev/null +++ b/src/test/ui/unsized/return-unsized-from-trait-method.rs @@ -0,0 +1,16 @@ +// ignore-tidy-linelength + +// regression test for #26376 + +trait Foo { + fn foo(&self) -> [u8]; +} + +fn foo(f: Option<&dyn Foo>) { + if let Some(f) = f { + let _ = f.foo(); + //~^ ERROR cannot move a value of type [u8]: the size of [u8] cannot be statically determined + } +} + +fn main() { foo(None) } diff --git a/src/test/ui/unsized/return-unsized-from-trait-method.stderr b/src/test/ui/unsized/return-unsized-from-trait-method.stderr new file mode 100644 index 0000000000000..7ecdd28616674 --- /dev/null +++ b/src/test/ui/unsized/return-unsized-from-trait-method.stderr @@ -0,0 +1,9 @@ +error[E0161]: cannot move a value of type [u8]: the size of [u8] cannot be statically determined + --> $DIR/return-unsized-from-trait-method.rs:11:17 + | +LL | let _ = f.foo(); + | ^^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0161`.