promote-not: add test that distinguishes promotion from outer scope rule · rust-lang/rust@fb802f2 (original) (raw)
`@@ -38,6 +38,15 @@ LL | let _val: &'static _ = &(Cell::new(1), 2).1;
`
38
38
`LL | };
`
39
39
` | - temporary value is freed at the end of this statement
`
40
40
``
``
41
`` +
error[E0493]: destructor of String
cannot be evaluated at compile-time
``
``
42
`+
--> $DIR/promote-not.rs:47:14
`
``
43
`+
|
`
``
44
`+
LL | let x = &String::new();
`
``
45
`+
| ^^^^^^^^^^^^^ the destructor for this type cannot be evaluated in constants
`
``
46
`+
...
`
``
47
`+
LL | };
`
``
48
`+
| - value is dropped here
`
``
49
+
41
50
`error[E0716]: temporary value dropped while borrowed
`
42
51
` --> $DIR/promote-not.rs:21:32
`
43
52
` |
`
`@@ -59,7 +68,7 @@ LL | }
`
59
68
` | - temporary value is freed at the end of this statement
`
60
69
``
61
70
`error[E0716]: temporary value dropped while borrowed
`
62
``
`-
--> $DIR/promote-not.rs:47:29
`
``
71
`+
--> $DIR/promote-not.rs:56:29
`
63
72
` |
`
64
73
`LL | let _val: &'static _ = &(Cell::new(1), 2).0;
`
65
74
` | ---------- ^^^^^^^^^^^^^^^^^ creates a temporary value which is freed while still in use
`
`@@ -70,7 +79,7 @@ LL | }
`
70
79
` | - temporary value is freed at the end of this statement
`
71
80
``
72
81
`error[E0716]: temporary value dropped while borrowed
`
73
``
`-
--> $DIR/promote-not.rs:48:29
`
``
82
`+
--> $DIR/promote-not.rs:57:29
`
74
83
` |
`
75
84
`LL | let _val: &'static _ = &(Cell::new(1), 2).1;
`
76
85
` | ---------- ^^^^^^^^^^^^^^^^^ creates a temporary value which is freed while still in use
`
`@@ -81,7 +90,7 @@ LL | }
`
81
90
` | - temporary value is freed at the end of this statement
`
82
91
``
83
92
`error[E0716]: temporary value dropped while borrowed
`
84
``
`-
--> $DIR/promote-not.rs:51:29
`
``
93
`+
--> $DIR/promote-not.rs:60:29
`
85
94
` |
`
86
95
`LL | let _val: &'static _ = &(1/0);
`
87
96
` | ---------- ^^^^^ creates a temporary value which is freed while still in use
`
`@@ -92,7 +101,7 @@ LL | }
`
92
101
` | - temporary value is freed at the end of this statement
`
93
102
``
94
103
`error[E0716]: temporary value dropped while borrowed
`
95
``
`-
--> $DIR/promote-not.rs:52:29
`
``
104
`+
--> $DIR/promote-not.rs:61:29
`
96
105
` |
`
97
106
`LL | let _val: &'static _ = &(1/(1-1));
`
98
107
` | ---------- ^^^^^^^^^ creates a temporary value which is freed while still in use
`
`@@ -103,7 +112,7 @@ LL | }
`
103
112
` | - temporary value is freed at the end of this statement
`
104
113
``
105
114
`error[E0716]: temporary value dropped while borrowed
`
106
``
`-
--> $DIR/promote-not.rs:53:29
`
``
115
`+
--> $DIR/promote-not.rs:62:29
`
107
116
` |
`
108
117
`LL | let _val: &'static _ = &((1+1)/(1-1));
`
109
118
` | ---------- ^^^^^^^^^^^^^ creates a temporary value which is freed while still in use
`
`@@ -114,7 +123,7 @@ LL | }
`
114
123
` | - temporary value is freed at the end of this statement
`
115
124
``
116
125
`error[E0716]: temporary value dropped while borrowed
`
117
``
`-
--> $DIR/promote-not.rs:54:29
`
``
126
`+
--> $DIR/promote-not.rs:63:29
`
118
127
` |
`
119
128
`LL | let _val: &'static _ = &(i32::MIN/-1);
`
120
129
` | ---------- ^^^^^^^^^^^^^ creates a temporary value which is freed while still in use
`
`@@ -125,7 +134,7 @@ LL | }
`
125
134
` | - temporary value is freed at the end of this statement
`
126
135
``
127
136
`error[E0716]: temporary value dropped while borrowed
`
128
``
`-
--> $DIR/promote-not.rs:55:29
`
``
137
`+
--> $DIR/promote-not.rs:64:29
`
129
138
` |
`
130
139
`LL | let _val: &'static _ = &(i32::MIN/(0-1));
`
131
140
` | ---------- ^^^^^^^^^^^^^^^^ creates a temporary value which is freed while still in use
`
`@@ -136,7 +145,7 @@ LL | }
`
136
145
` | - temporary value is freed at the end of this statement
`
137
146
``
138
147
`error[E0716]: temporary value dropped while borrowed
`
139
``
`-
--> $DIR/promote-not.rs:56:29
`
``
148
`+
--> $DIR/promote-not.rs:65:29
`
140
149
` |
`
141
150
`LL | let _val: &'static _ = &(-128i8/-1);
`
142
151
` | ---------- ^^^^^^^^^^^ creates a temporary value which is freed while still in use
`
`@@ -147,7 +156,7 @@ LL | }
`
147
156
` | - temporary value is freed at the end of this statement
`
148
157
``
149
158
`error[E0716]: temporary value dropped while borrowed
`
150
``
`-
--> $DIR/promote-not.rs:57:29
`
``
159
`+
--> $DIR/promote-not.rs:66:29
`
151
160
` |
`
152
161
`LL | let _val: &'static _ = &(1%0);
`
153
162
` | ---------- ^^^^^ creates a temporary value which is freed while still in use
`
`@@ -158,7 +167,7 @@ LL | }
`
158
167
` | - temporary value is freed at the end of this statement
`
159
168
``
160
169
`error[E0716]: temporary value dropped while borrowed
`
161
``
`-
--> $DIR/promote-not.rs:58:29
`
``
170
`+
--> $DIR/promote-not.rs:67:29
`
162
171
` |
`
163
172
`LL | let _val: &'static _ = &(1%(1-1));
`
164
173
` | ---------- ^^^^^^^^^ creates a temporary value which is freed while still in use
`
`@@ -169,7 +178,7 @@ LL | }
`
169
178
` | - temporary value is freed at the end of this statement
`
170
179
``
171
180
`error[E0716]: temporary value dropped while borrowed
`
172
``
`-
--> $DIR/promote-not.rs:59:29
`
``
181
`+
--> $DIR/promote-not.rs:68:29
`
173
182
` |
`
174
183
`LL | let _val: &'static _ = &([1,2,3][4]+1);
`
175
184
` | ---------- ^^^^^^^^^^^^^^ creates a temporary value which is freed while still in use
`
`@@ -180,7 +189,7 @@ LL | }
`
180
189
` | - temporary value is freed at the end of this statement
`
181
190
``
182
191
`error[E0716]: temporary value dropped while borrowed
`
183
``
`-
--> $DIR/promote-not.rs:62:29
`
``
192
`+
--> $DIR/promote-not.rs:72:29
`
184
193
` |
`
185
194
`LL | let _val: &'static _ = &TEST_DROP;
`
186
195
` | ---------- ^^^^^^^^^ creates a temporary value which is freed while still in use
`
`@@ -191,7 +200,7 @@ LL | }
`
191
200
` | - temporary value is freed at the end of this statement
`
192
201
``
193
202
`error[E0716]: temporary value dropped while borrowed
`
194
``
`-
--> $DIR/promote-not.rs:64:29
`
``
203
`+
--> $DIR/promote-not.rs:74:29
`
195
204
` |
`
196
205
`LL | let _val: &'static _ = &&TEST_DROP;
`
197
206
` | ---------- ^^^^^^^^^^ creates a temporary value which is freed while still in use
`
`@@ -202,7 +211,7 @@ LL | }
`
202
211
` | - temporary value is freed at the end of this statement
`
203
212
``
204
213
`error[E0716]: temporary value dropped while borrowed
`
205
``
`-
--> $DIR/promote-not.rs:64:30
`
``
214
`+
--> $DIR/promote-not.rs:74:30
`
206
215
` |
`
207
216
`LL | let _val: &'static _ = &&TEST_DROP;
`
208
217
` | ---------- ^^^^^^^^^ creates a temporary value which is freed while still in use
`
`@@ -213,7 +222,7 @@ LL | }
`
213
222
` | - temporary value is freed at the end of this statement
`
214
223
``
215
224
`error[E0716]: temporary value dropped while borrowed
`
216
``
`-
--> $DIR/promote-not.rs:67:29
`
``
225
`+
--> $DIR/promote-not.rs:77:29
`
217
226
` |
`
218
227
`LL | let _val: &'static _ = &(&TEST_DROP,);
`
219
228
` | ---------- ^^^^^^^^^^^^^ creates a temporary value which is freed while still in use
`
`@@ -224,7 +233,7 @@ LL | }
`
224
233
` | - temporary value is freed at the end of this statement
`
225
234
``
226
235
`error[E0716]: temporary value dropped while borrowed
`
227
``
`-
--> $DIR/promote-not.rs:67:31
`
``
236
`+
--> $DIR/promote-not.rs:77:31
`
228
237
` |
`
229
238
`LL | let _val: &'static _ = &(&TEST_DROP,);
`
230
239
` | ---------- ^^^^^^^^^ creates a temporary value which is freed while still in use
`
`@@ -235,7 +244,7 @@ LL | }
`
235
244
` | - temporary value is freed at the end of this statement
`
236
245
``
237
246
`error[E0716]: temporary value dropped while borrowed
`
238
``
`-
--> $DIR/promote-not.rs:70:29
`
``
247
`+
--> $DIR/promote-not.rs:80:29
`
239
248
` |
`
240
249
`LL | let _val: &'static _ = &[&TEST_DROP; 1];
`
241
250
` | ---------- ^^^^^^^^^^^^^^^ creates a temporary value which is freed while still in use
`
`@@ -246,7 +255,7 @@ LL | }
`
246
255
` | - temporary value is freed at the end of this statement
`
247
256
``
248
257
`error[E0716]: temporary value dropped while borrowed
`
249
``
`-
--> $DIR/promote-not.rs:70:31
`
``
258
`+
--> $DIR/promote-not.rs:80:31
`
250
259
` |
`
251
260
`LL | let _val: &'static _ = &[&TEST_DROP; 1];
`
252
261
` | ---------- ^^^^^^^^^ - temporary value is freed at the end of this statement
`
`@@ -255,7 +264,7 @@ LL | let _val: &'static _ = &[&TEST_DROP; 1];
`
255
264
`` | type annotation requires that borrow lasts for 'static
``
256
265
``
257
266
`error[E0716]: temporary value dropped while borrowed
`
258
``
`-
--> $DIR/promote-not.rs:79:26
`
``
267
`+
--> $DIR/promote-not.rs:89:26
`
259
268
` |
`
260
269
`LL | let x: &'static _ = &UnionWithCell { f1: 0 };
`
261
270
` | ---------- ^^^^^^^^^^^^^^^^^^^^^^^ creates a temporary value which is freed while still in use
`
`@@ -265,6 +274,7 @@ LL |
`
265
274
`LL | }
`
266
275
` | - temporary value is freed at the end of this statement
`
267
276
``
268
``
`-
error: aborting due to 25 previous errors
`
``
277
`+
error: aborting due to 26 previous errors
`
269
278
``
270
``
`` -
For more information about this error, try rustc --explain E0716
.
``
``
279
`+
Some errors have detailed explanations: E0493, E0716.
`
``
280
`` +
For more information about an error, try rustc --explain E0493
.
``