summaryrefslogtreecommitdiffstats
path: root/tests/ui/moves
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--tests/ui/moves/issue-22536-copy-mustnt-zero.rs (renamed from tests/ui/issues/issue-22536-copy-mustnt-zero.rs)0
-rw-r--r--tests/ui/moves/move-fn-self-receiver.stderr2
-rw-r--r--tests/ui/moves/pin-mut-reborrow-infer-var-issue-107419.fixed11
-rw-r--r--tests/ui/moves/pin-mut-reborrow-infer-var-issue-107419.rs11
-rw-r--r--tests/ui/moves/pin-mut-reborrow-infer-var-issue-107419.stderr20
5 files changed, 44 insertions, 0 deletions
diff --git a/tests/ui/issues/issue-22536-copy-mustnt-zero.rs b/tests/ui/moves/issue-22536-copy-mustnt-zero.rs
index 017f36484..017f36484 100644
--- a/tests/ui/issues/issue-22536-copy-mustnt-zero.rs
+++ b/tests/ui/moves/issue-22536-copy-mustnt-zero.rs
diff --git a/tests/ui/moves/move-fn-self-receiver.stderr b/tests/ui/moves/move-fn-self-receiver.stderr
index 7f69e5dcf..91d237b1d 100644
--- a/tests/ui/moves/move-fn-self-receiver.stderr
+++ b/tests/ui/moves/move-fn-self-receiver.stderr
@@ -75,6 +75,8 @@ LL | fn use_pin_box_self(self: Pin<Box<Self>>) {}
error[E0505]: cannot move out of `mut_foo` because it is borrowed
--> $DIR/move-fn-self-receiver.rs:50:5
|
+LL | let mut mut_foo = Foo;
+ | ----------- binding `mut_foo` declared here
LL | let ret = mut_foo.use_mut_self();
| ---------------------- borrow of `mut_foo` occurs here
LL | mut_foo;
diff --git a/tests/ui/moves/pin-mut-reborrow-infer-var-issue-107419.fixed b/tests/ui/moves/pin-mut-reborrow-infer-var-issue-107419.fixed
new file mode 100644
index 000000000..0b9a3bae9
--- /dev/null
+++ b/tests/ui/moves/pin-mut-reborrow-infer-var-issue-107419.fixed
@@ -0,0 +1,11 @@
+// run-rustfix
+use std::pin::Pin;
+
+fn foo(_: &mut ()) {}
+
+fn main() {
+ let mut uwu = ();
+ let mut r = Pin::new(&mut uwu);
+ foo(r.as_mut().get_mut());
+ foo(r.get_mut()); //~ ERROR use of moved value
+}
diff --git a/tests/ui/moves/pin-mut-reborrow-infer-var-issue-107419.rs b/tests/ui/moves/pin-mut-reborrow-infer-var-issue-107419.rs
new file mode 100644
index 000000000..0e952b06e
--- /dev/null
+++ b/tests/ui/moves/pin-mut-reborrow-infer-var-issue-107419.rs
@@ -0,0 +1,11 @@
+// run-rustfix
+use std::pin::Pin;
+
+fn foo(_: &mut ()) {}
+
+fn main() {
+ let mut uwu = ();
+ let mut r = Pin::new(&mut uwu);
+ foo(r.get_mut());
+ foo(r.get_mut()); //~ ERROR use of moved value
+}
diff --git a/tests/ui/moves/pin-mut-reborrow-infer-var-issue-107419.stderr b/tests/ui/moves/pin-mut-reborrow-infer-var-issue-107419.stderr
new file mode 100644
index 000000000..7e513b73c
--- /dev/null
+++ b/tests/ui/moves/pin-mut-reborrow-infer-var-issue-107419.stderr
@@ -0,0 +1,20 @@
+error[E0382]: use of moved value: `r`
+ --> $DIR/pin-mut-reborrow-infer-var-issue-107419.rs:10:9
+ |
+LL | let mut r = Pin::new(&mut uwu);
+ | ----- move occurs because `r` has type `Pin<&mut ()>`, which does not implement the `Copy` trait
+LL | foo(r.get_mut());
+ | --------- `r` moved due to this method call
+LL | foo(r.get_mut());
+ | ^ value used here after move
+ |
+note: `Pin::<&'a mut T>::get_mut` takes ownership of the receiver `self`, which moves `r`
+ --> $SRC_DIR/core/src/pin.rs:LL:COL
+help: consider reborrowing the `Pin` instead of moving it
+ |
+LL | foo(r.as_mut().get_mut());
+ | +++++++++
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0382`.