diff options
| author | Michael Goulet <michael@errs.io> | 2022-03-06 17:21:39 -0800 |
|---|---|---|
| committer | Michael Goulet <michael@errs.io> | 2022-03-06 17:21:39 -0800 |
| commit | 5ddaa2d5e53344ff8b88d98e61e3dd36edb803e9 (patch) | |
| tree | 34314a21df5a01d6941cf82a9184708fac2a1433 /src | |
| parent | 38a0b81b1c32764d6a583a5efb6f306b8c44c503 (diff) | |
Erase regions when checking for missing Copy predicates
Diffstat (limited to 'src')
| -rw-r--r-- | src/test/ui/borrowck/copy-suggestion-region-vid.rs | 17 | ||||
| -rw-r--r-- | src/test/ui/borrowck/copy-suggestion-region-vid.stderr | 14 |
2 files changed, 31 insertions, 0 deletions
diff --git a/src/test/ui/borrowck/copy-suggestion-region-vid.rs b/src/test/ui/borrowck/copy-suggestion-region-vid.rs new file mode 100644 index 00000000000..dff95283459 --- /dev/null +++ b/src/test/ui/borrowck/copy-suggestion-region-vid.rs @@ -0,0 +1,17 @@ +pub struct DataStruct(); + +pub struct HelperStruct<'n> { + pub helpers: [Vec<&'n i64>; 2], + pub is_empty: bool, +} + +impl DataStruct { + pub fn f(&self) -> HelperStruct { + let helpers = [vec![], vec![]]; + + HelperStruct { helpers, is_empty: helpers[0].is_empty() } + //~^ ERROR borrow of moved value + } +} + +fn main() {} diff --git a/src/test/ui/borrowck/copy-suggestion-region-vid.stderr b/src/test/ui/borrowck/copy-suggestion-region-vid.stderr new file mode 100644 index 00000000000..f03cdd84d75 --- /dev/null +++ b/src/test/ui/borrowck/copy-suggestion-region-vid.stderr @@ -0,0 +1,14 @@ +error[E0382]: borrow of moved value: `helpers` + --> $DIR/copy-suggestion-region-vid.rs:12:43 + | +LL | let helpers = [vec![], vec![]]; + | ------- move occurs because `helpers` has type `[Vec<&i64>; 2]`, which does not implement the `Copy` trait +LL | +LL | HelperStruct { helpers, is_empty: helpers[0].is_empty() } + | ------- ^^^^^^^^^^^^^^^^^^^^^ value borrowed here after move + | | + | value moved here + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0382`. |
