about summary refs log tree commit diff
diff options
context:
space:
mode:
authorAlex Gurganus <gurgalex@iastate.edu>2019-02-20 16:12:28 -0600
committerAlex Gurganus <gurgalex@iastate.edu>2019-02-20 16:12:28 -0600
commit6a5abea7092cf7ede5bb6b3489db94eb701cd04e (patch)
treeb69ae5c10923e807b8455d0c973c1127eb831117
parentb2a02c8d4aeb74fd6adc23e5eec935fc064e153a (diff)
downloadrust-6a5abea7092cf7ede5bb6b3489db94eb701cd04e.tar.gz
rust-6a5abea7092cf7ede5bb6b3489db94eb701cd04e.zip
Remove braces from most E0505 examples
The solution which uses braces to release the borrow
before it is moved is only required to satisfy the 2015
edition borrow checker.

All other examples give the expected results for both
2015 and 2018 editions.
-rw-r--r--src/librustc_mir/diagnostics.rs24
1 files changed, 9 insertions, 15 deletions
diff --git a/src/librustc_mir/diagnostics.rs b/src/librustc_mir/diagnostics.rs
index 1aac78d8adc..f369324157a 100644
--- a/src/librustc_mir/diagnostics.rs
+++ b/src/librustc_mir/diagnostics.rs
@@ -1551,11 +1551,9 @@ fn eat(val: Value) {}
 
 fn main() {
     let x = Value{};
-    {
-        let _ref_to_val: &Value = &x;
-        eat(x);
-        borrow(_ref_to_val);
-    }
+    let _ref_to_val: &Value = &x;
+    eat(x);
+    borrow(_ref_to_val);
 }
 ```
 
@@ -1579,11 +1577,9 @@ fn eat(val: &Value) {}
 
 fn main() {
     let x = Value{};
-    {
-        let _ref_to_val: &Value = &x;
-        eat(&x); // pass by reference, if it's possible
-        borrow(_ref_to_val);
-    }
+    let _ref_to_val: &Value = &x;
+    eat(&x); // pass by reference, if it's possible
+    borrow(_ref_to_val);
 }
 ```
 
@@ -1618,11 +1614,9 @@ fn eat(val: Value) {}
 
 fn main() {
     let x = Value{};
-    {
-        let _ref_to_val: &Value = &x;
-        eat(x); // it will be copied here.
-        borrow(_ref_to_val);
-    }
+    let _ref_to_val: &Value = &x;
+    eat(x); // it will be copied here.
+    borrow(_ref_to_val);
 }
 ```