diff options
| author | Dylan DPC <dylan.dpc@gmail.com> | 2020-04-26 01:00:19 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-04-26 01:00:19 +0200 |
| commit | fde472792f2c05455f37ab770545579705f437e5 (patch) | |
| tree | e02a86f46912464b1187e70d351f75a12b026171 | |
| parent | 98a43caf9b776516f2afd3ca9b59cbe4ccf11a49 (diff) | |
| parent | 1474face6fe8081c29c79179460e1b3e53f51a6e (diff) | |
| download | rust-fde472792f2c05455f37ab770545579705f437e5.tar.gz rust-fde472792f2c05455f37ab770545579705f437e5.zip | |
Rollup merge of #71541 - wesleywiser:issue_26376, r=Dylan-DPC
Add regression test for #26376 Closes #26376
| -rw-r--r-- | src/test/ui/unsized/return-unsized-from-trait-method.rs | 16 | ||||
| -rw-r--r-- | src/test/ui/unsized/return-unsized-from-trait-method.stderr | 9 |
2 files changed, 25 insertions, 0 deletions
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 00000000000..2d265d5db5c --- /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 00000000000..7ecdd286166 --- /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`. |
