summaryrefslogtreecommitdiffstats
path: root/tests/ui/moves/needs-clone-through-deref.rs
diff options
context:
space:
mode:
Diffstat (limited to 'tests/ui/moves/needs-clone-through-deref.rs')
-rw-r--r--tests/ui/moves/needs-clone-through-deref.rs18
1 files changed, 18 insertions, 0 deletions
diff --git a/tests/ui/moves/needs-clone-through-deref.rs b/tests/ui/moves/needs-clone-through-deref.rs
new file mode 100644
index 000000000..8116008ff
--- /dev/null
+++ b/tests/ui/moves/needs-clone-through-deref.rs
@@ -0,0 +1,18 @@
+// run-rustfix
+#![allow(dead_code, noop_method_call)]
+use std::ops::Deref;
+struct S(Vec<usize>);
+impl Deref for S {
+ type Target = Vec<usize>;
+ fn deref(&self) -> &Self::Target {
+ &self.0
+ }
+}
+
+impl S {
+ fn foo(&self) {
+ // `self.clone()` returns `&S`, not `Vec`
+ for _ in self.clone().into_iter() {} //~ ERROR cannot move out of dereference of `S`
+ }
+}
+fn main() {}