about summary refs log tree commit diff
path: root/tests/ui/issues/issue-11681.rs
diff options
context:
space:
mode:
Diffstat (limited to 'tests/ui/issues/issue-11681.rs')
-rw-r--r--tests/ui/issues/issue-11681.rs19
1 files changed, 19 insertions, 0 deletions
diff --git a/tests/ui/issues/issue-11681.rs b/tests/ui/issues/issue-11681.rs
new file mode 100644
index 00000000000..6d8810d8052
--- /dev/null
+++ b/tests/ui/issues/issue-11681.rs
@@ -0,0 +1,19 @@
+// This tests verifies that unary structs and enum variants
+// are treated as rvalues and their lifetime is not bounded to
+// the static scope.
+
+struct Test;
+
+impl Drop for Test {
+    fn drop (&mut self) {}
+}
+
+fn createTest<'a>() -> &'a Test {
+  let testValue = &Test;
+  return testValue; //~ ERROR cannot return value referencing temporary value
+}
+
+
+pub fn main() {
+    createTest();
+}