summaryrefslogtreecommitdiffstats
path: root/tests/ui/borrowck/borrowck-storage-dead.rs
diff options
context:
space:
mode:
Diffstat (limited to 'tests/ui/borrowck/borrowck-storage-dead.rs')
-rw-r--r--tests/ui/borrowck/borrowck-storage-dead.rs24
1 files changed, 24 insertions, 0 deletions
diff --git a/tests/ui/borrowck/borrowck-storage-dead.rs b/tests/ui/borrowck/borrowck-storage-dead.rs
new file mode 100644
index 000000000..fe9844610
--- /dev/null
+++ b/tests/ui/borrowck/borrowck-storage-dead.rs
@@ -0,0 +1,24 @@
+fn ok() {
+ loop {
+ let _x = 1;
+ }
+}
+
+fn also_ok() {
+ loop {
+ let _x = String::new();
+ }
+}
+
+fn fail() {
+ loop {
+ let x: i32;
+ let _ = x + 1; //~ERROR [E0381]
+ }
+}
+
+fn main() {
+ ok();
+ also_ok();
+ fail();
+}