Skip to content

Commit 29585f0

Browse files
committed
Add tests for super let.
1 parent 6c3417d commit 29585f0

File tree

2 files changed

+460
-0
lines changed

2 files changed

+460
-0
lines changed

tests/ui/super-let.borrowck.stderr

+174
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,174 @@
1+
error[E0506]: cannot assign to `x` because it is borrowed
2+
--> $DIR/super-let.rs:31:28
3+
|
4+
LL | super let b = DropMe(&mut x);
5+
| ------ `x` is borrowed here
6+
...
7+
LL | #[cfg(borrowck)] { x = true; }
8+
| ^^^^^^^^ `x` is assigned to here but it was already borrowed
9+
...
10+
LL | }
11+
| - borrow might be used here, when `b` is dropped and runs the `Drop` code for type `DropMe`
12+
13+
error[E0506]: cannot assign to `x` because it is borrowed
14+
--> $DIR/super-let.rs:47:28
15+
|
16+
LL | super let b = &DropMe(&mut x);
17+
| --------------
18+
| | |
19+
| | `x` is borrowed here
20+
| a temporary with access to the borrow is created here ...
21+
...
22+
LL | #[cfg(borrowck)] { x = true; }
23+
| ^^^^^^^^ `x` is assigned to here but it was already borrowed
24+
...
25+
LL | }
26+
| - ... and the borrow might be used here, when that temporary is dropped and runs the `Drop` code for type `DropMe`
27+
28+
error[E0506]: cannot assign to `x` because it is borrowed
29+
--> $DIR/super-let.rs:65:32
30+
|
31+
LL | super let b = identity(&DropMe(&mut x));
32+
| --------------
33+
| | |
34+
| | `x` is borrowed here
35+
| a temporary with access to the borrow is created here ...
36+
LL | #[cfg(borrowck)] { x = true; }
37+
| ^^^^^^^^ `x` is assigned to here but it was already borrowed
38+
...
39+
LL | };
40+
| - ... and the borrow might be used here, when that temporary is dropped and runs the `Drop` code for type `DropMe`
41+
42+
error[E0506]: cannot assign to `x` because it is borrowed
43+
--> $DIR/super-let.rs:88:36
44+
|
45+
LL | super let b = identity(&DropMe(&mut x));
46+
| --------------
47+
| | |
48+
| | `x` is borrowed here
49+
| a temporary with access to the borrow is created here ...
50+
...
51+
LL | #[cfg(borrowck)] { x = true; }
52+
| ^^^^^^^^ `x` is assigned to here but it was already borrowed
53+
...
54+
LL | ));
55+
| - ... and the borrow might be used here, when that temporary is dropped and runs the `Drop` code for type `DropMe`
56+
57+
error[E0506]: cannot assign to `x` because it is borrowed
58+
--> $DIR/super-let.rs:108:28
59+
|
60+
LL | super let b = DropMe(&mut x);
61+
| ------ `x` is borrowed here
62+
...
63+
LL | #[cfg(borrowck)] { x = true; }
64+
| ^^^^^^^^ `x` is assigned to here but it was already borrowed
65+
...
66+
LL | }
67+
| - borrow might be used here, when `b` is dropped and runs the `Drop` code for type `DropMe`
68+
69+
error[E0506]: cannot assign to `x` because it is borrowed
70+
--> $DIR/super-let.rs:126:28
71+
|
72+
LL | super let b = DropMe(&mut x);
73+
| ------ `x` is borrowed here
74+
...
75+
LL | #[cfg(borrowck)] { x = true; }
76+
| ^^^^^^^^ `x` is assigned to here but it was already borrowed
77+
...
78+
LL | }
79+
| - borrow might be used here, when `b` is dropped and runs the `Drop` code for type `DropMe`
80+
81+
error[E0506]: cannot assign to `x` because it is borrowed
82+
--> $DIR/super-let.rs:144:28
83+
|
84+
LL | super let b = DropMe(&mut x);
85+
| ------ `x` is borrowed here
86+
...
87+
LL | #[cfg(borrowck)] { x = true; }
88+
| ^^^^^^^^ `x` is assigned to here but it was already borrowed
89+
...
90+
LL | }
91+
| - borrow might be used here, when `b` is dropped and runs the `Drop` code for type `DropMe`
92+
93+
error[E0506]: cannot assign to `x` because it is borrowed
94+
--> $DIR/super-let.rs:160:28
95+
|
96+
LL | b = DropMe(&mut x);
97+
| ------ `x` is borrowed here
98+
...
99+
LL | #[cfg(borrowck)] { x = true; }
100+
| ^^^^^^^^ `x` is assigned to here but it was already borrowed
101+
LL | drop(a);
102+
| - borrow later used here
103+
104+
error[E0716]: temporary value dropped while borrowed
105+
--> $DIR/super-let.rs:173:33
106+
|
107+
LL | #[cfg(borrowck)] { a = &String::from("asdf"); };
108+
| ^^^^^^^^^^^^^^^^^^^^- temporary value is freed at the end of this statement
109+
| |
110+
| creates a temporary value which is freed while still in use
111+
...
112+
LL | let _ = a;
113+
| - borrow later used here
114+
|
115+
= note: consider using a `let` binding to create a longer lived value
116+
117+
error[E0506]: cannot assign to `x` because it is borrowed
118+
--> $DIR/super-let.rs:207:28
119+
|
120+
LL | super let d = &DropMe(&mut x);
121+
| --------------
122+
| | |
123+
| | `x` is borrowed here
124+
| a temporary with access to the borrow is created here ...
125+
...
126+
LL | #[cfg(borrowck)] { x = true; }
127+
| ^^^^^^^^ `x` is assigned to here but it was already borrowed
128+
...
129+
LL | }
130+
| - ... and the borrow might be used here, when that temporary is dropped and runs the `Drop` code for type `DropMe`
131+
132+
error[E0506]: cannot assign to `x` because it is borrowed
133+
--> $DIR/super-let.rs:228:32
134+
|
135+
LL | super let d = identity(&DropMe(&mut x));
136+
| --------------
137+
| | |
138+
| | `x` is borrowed here
139+
| a temporary with access to the borrow is created here ...
140+
...
141+
LL | #[cfg(borrowck)] { x = true; }
142+
| ^^^^^^^^ `x` is assigned to here but it was already borrowed
143+
...
144+
LL | };
145+
| - ... and the borrow might be used here, when that temporary is dropped and runs the `Drop` code for type `DropMe`
146+
147+
error[E0506]: cannot assign to `x` because it is borrowed
148+
--> $DIR/super-let.rs:247:28
149+
|
150+
LL | super let b = DropMe(&mut x);
151+
| ------ `x` is borrowed here
152+
...
153+
LL | #[cfg(borrowck)] { x = true; }
154+
| ^^^^^^^^ `x` is assigned to here but it was already borrowed
155+
...
156+
LL | }
157+
| - borrow might be used here, when `b` is dropped and runs the `Drop` code for type `DropMe`
158+
159+
error[E0506]: cannot assign to `x` because it is borrowed
160+
--> $DIR/super-let.rs:264:28
161+
|
162+
LL | let dropme = Some(DropMe(&mut x));
163+
| ------ `x` is borrowed here
164+
...
165+
LL | #[cfg(borrowck)] { x = true; }
166+
| ^^^^^^^^ `x` is assigned to here but it was already borrowed
167+
...
168+
LL | }
169+
| - borrow might be used here, when `x` is dropped and runs the `Drop` code for type `DropMe`
170+
171+
error: aborting due to 13 previous errors
172+
173+
Some errors have detailed explanations: E0506, E0716.
174+
For more information about an error, try `rustc --explain E0506`.

0 commit comments

Comments
 (0)