Skip to content

Commit 6a5abea

Browse files
committed
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.
1 parent b2a02c8 commit 6a5abea

File tree

1 file changed

+9
-15
lines changed

1 file changed

+9
-15
lines changed

src/librustc_mir/diagnostics.rs

+9-15
Original file line numberDiff line numberDiff line change
@@ -1551,11 +1551,9 @@ fn eat(val: Value) {}
15511551
15521552
fn main() {
15531553
let x = Value{};
1554-
{
1555-
let _ref_to_val: &Value = &x;
1556-
eat(x);
1557-
borrow(_ref_to_val);
1558-
}
1554+
let _ref_to_val: &Value = &x;
1555+
eat(x);
1556+
borrow(_ref_to_val);
15591557
}
15601558
```
15611559
@@ -1579,11 +1577,9 @@ fn eat(val: &Value) {}
15791577
15801578
fn main() {
15811579
let x = Value{};
1582-
{
1583-
let _ref_to_val: &Value = &x;
1584-
eat(&x); // pass by reference, if it's possible
1585-
borrow(_ref_to_val);
1586-
}
1580+
let _ref_to_val: &Value = &x;
1581+
eat(&x); // pass by reference, if it's possible
1582+
borrow(_ref_to_val);
15871583
}
15881584
```
15891585
@@ -1618,11 +1614,9 @@ fn eat(val: Value) {}
16181614
16191615
fn main() {
16201616
let x = Value{};
1621-
{
1622-
let _ref_to_val: &Value = &x;
1623-
eat(x); // it will be copied here.
1624-
borrow(_ref_to_val);
1625-
}
1617+
let _ref_to_val: &Value = &x;
1618+
eat(x); // it will be copied here.
1619+
borrow(_ref_to_val);
16261620
}
16271621
```
16281622

0 commit comments

Comments
 (0)