Skip to content

Commit 75504ee

Browse files
committed
update error messages -- in some cases maybe we should investigate
1 parent e79656c commit 75504ee

File tree

4 files changed

+45
-36
lines changed

4 files changed

+45
-36
lines changed

src/test/ui/borrowck/promote-ref-mut-in-let-issue-46557.nll.stderr

+14-20
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,24 @@
11
error[E0597]: borrowed value does not live long enough
22
--> $DIR/promote-ref-mut-in-let-issue-46557.rs:15:21
33
|
4-
LL | fn gimme_static_mut_let() -> &'static mut u32 {
5-
| _______________________________________________-
6-
LL | | let ref mut x = 1234543; //~ ERROR
7-
| | ^^^^^^^ temporary value does not live long enough
8-
LL | | x
9-
LL | | }
10-
| | -
11-
| | |
12-
| |_temporary value only lives until here
13-
| borrow later used here
4+
LL | let ref mut x = 1234543; //~ ERROR
5+
| ^^^^^^^ temporary value does not live long enough
6+
LL | x
7+
LL | }
8+
| - temporary value only lives until here
9+
|
10+
= note: borrowed value must be valid for the static lifetime...
1411

1512
error[E0597]: borrowed value does not live long enough
1613
--> $DIR/promote-ref-mut-in-let-issue-46557.rs:20:25
1714
|
18-
LL | fn gimme_static_mut_let_nested() -> &'static mut u32 {
19-
| ______________________________________________________-
20-
LL | | let (ref mut x, ) = (1234543, ); //~ ERROR
21-
| | ^^^^^^^^^^^ temporary value does not live long enough
22-
LL | | x
23-
LL | | }
24-
| | -
25-
| | |
26-
| |_temporary value only lives until here
27-
| borrow later used here
15+
LL | let (ref mut x, ) = (1234543, ); //~ ERROR
16+
| ^^^^^^^^^^^ temporary value does not live long enough
17+
LL | x
18+
LL | }
19+
| - temporary value only lives until here
20+
|
21+
= note: borrowed value must be valid for the static lifetime...
2822

2923
error[E0597]: borrowed value does not live long enough
3024
--> $DIR/promote-ref-mut-in-let-issue-46557.rs:25:11

src/test/ui/nll/get_default.nll.stderr

+12-3
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,18 @@ LL | match map.get() {
6363
LL | Some(v) => {
6464
LL | map.set(String::new()); // Both AST and MIR error here
6565
| ^^^^^^^^^^^^^^^^^^^^^^ mutable borrow occurs here
66-
...
67-
LL | return v;
68-
| - borrow later used here
66+
|
67+
note: borrowed value must be valid for the anonymous lifetime #1 defined on the function body at 41:1...
68+
--> $DIR/get_default.rs:41:1
69+
|
70+
LL | / fn err(map: &mut Map) -> &String {
71+
LL | | loop {
72+
LL | | match map.get() {
73+
LL | | Some(v) => {
74+
... |
75+
LL | | }
76+
LL | | }
77+
| |_^
6978

7079
error[E0502]: cannot borrow `*map` as mutable because it is also borrowed as immutable (Mir)
7180
--> $DIR/get_default.rs:51:17

src/test/ui/nll/get_default.stderr

+12-3
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,18 @@ LL | match map.get() {
6363
LL | Some(v) => {
6464
LL | map.set(String::new()); // Both AST and MIR error here
6565
| ^^^ mutable borrow occurs here
66-
...
67-
LL | return v;
68-
| - borrow later used here
66+
|
67+
note: borrowed value must be valid for the anonymous lifetime #1 defined on the function body at 41:1...
68+
--> $DIR/get_default.rs:41:1
69+
|
70+
LL | / fn err(map: &mut Map) -> &String {
71+
LL | | loop {
72+
LL | | match map.get() {
73+
LL | | Some(v) => {
74+
... |
75+
LL | | }
76+
LL | | }
77+
| |_^
6978

7079
error[E0502]: cannot borrow `*map` as mutable because it is also borrowed as immutable (Mir)
7180
--> $DIR/get_default.rs:51:17

src/test/ui/nll/return-ref-mut-issue-46557.stderr

+7-10
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,13 @@
11
error[E0597]: borrowed value does not live long enough
22
--> $DIR/return-ref-mut-issue-46557.rs:17:21
33
|
4-
LL | fn gimme_static_mut() -> &'static mut u32 {
5-
| ___________________________________________-
6-
LL | | let ref mut x = 1234543; //~ ERROR borrowed value does not live long enough [E0597]
7-
| | ^^^^^^^ temporary value does not live long enough
8-
LL | | x
9-
LL | | }
10-
| | -
11-
| | |
12-
| |_temporary value only lives until here
13-
| borrow later used here
4+
LL | let ref mut x = 1234543; //~ ERROR borrowed value does not live long enough [E0597]
5+
| ^^^^^^^ temporary value does not live long enough
6+
LL | x
7+
LL | }
8+
| - temporary value only lives until here
9+
|
10+
= note: borrowed value must be valid for the static lifetime...
1411

1512
error: aborting due to previous error
1613

0 commit comments

Comments
 (0)