about summary refs log tree commit diff
path: root/tests/ui/disallowed-deconstructing/disallowed-deconstructing-destructing-struct-let.fixed
diff options
context:
space:
mode:
Diffstat (limited to 'tests/ui/disallowed-deconstructing/disallowed-deconstructing-destructing-struct-let.fixed')
-rw-r--r--tests/ui/disallowed-deconstructing/disallowed-deconstructing-destructing-struct-let.fixed21
1 files changed, 21 insertions, 0 deletions
diff --git a/tests/ui/disallowed-deconstructing/disallowed-deconstructing-destructing-struct-let.fixed b/tests/ui/disallowed-deconstructing/disallowed-deconstructing-destructing-struct-let.fixed
new file mode 100644
index 00000000000..ae0a84eea4d
--- /dev/null
+++ b/tests/ui/disallowed-deconstructing/disallowed-deconstructing-destructing-struct-let.fixed
@@ -0,0 +1,21 @@
+// run-rustfix
+struct X {
+    x: String,
+}
+
+impl Drop for X {
+    fn drop(&mut self) {
+        println!("value: {}", self.x);
+    }
+}
+
+fn unwrap(x: X) -> String {
+    let X { x: ref y } = x; //~ ERROR cannot move out of type
+    y.to_string()
+}
+
+fn main() {
+    let x = X { x: "hello".to_string() };
+    let y = unwrap(x);
+    println!("contents: {}", y);
+}