Skip to content

Commit b13c2c3

Browse files
Bless tests now that we do promotion if min_const_fn fails
We bailed out of `QualifyAndPromoteConsts` immediately if the `min_const_fn` checks failed, which sometimes resulted in additional, spurious errors since promotion was skipped. We now do promotion in a completely separate pass, so this is no longer an issue.
1 parent b316384 commit b13c2c3

File tree

4 files changed

+7
-28
lines changed

4 files changed

+7
-28
lines changed

src/test/ui/consts/min_const_fn/min_const_fn.rs

-1
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,6 @@ const fn no_rpit() -> impl std::fmt::Debug {} //~ ERROR `impl Trait` in const fn
136136
const fn no_dyn_trait(_x: &dyn std::fmt::Debug) {} //~ ERROR trait bounds other than `Sized`
137137
const fn no_dyn_trait_ret() -> &'static dyn std::fmt::Debug { &() }
138138
//~^ ERROR trait bounds other than `Sized`
139-
//~| ERROR cannot return reference to temporary value
140139

141140
const fn no_unsafe() { unsafe {} }
142141

src/test/ui/consts/min_const_fn/min_const_fn.stderr

+5-14
Original file line numberDiff line numberDiff line change
@@ -286,17 +286,8 @@ LL | const fn no_dyn_trait_ret() -> &'static dyn std::fmt::Debug { &() }
286286
= note: for more information, see issue https://github.com/rust-lang/rust/issues/57563
287287
= help: add `#![feature(const_fn)]` to the crate attributes to enable
288288

289-
error[E0515]: cannot return reference to temporary value
290-
--> $DIR/min_const_fn.rs:137:63
291-
|
292-
LL | const fn no_dyn_trait_ret() -> &'static dyn std::fmt::Debug { &() }
293-
| ^--
294-
| ||
295-
| |temporary value created here
296-
| returns a reference to data owned by the current function
297-
298289
error[E0723]: trait bounds other than `Sized` on const fn parameters are unstable
299-
--> $DIR/min_const_fn.rs:143:41
290+
--> $DIR/min_const_fn.rs:142:41
300291
|
301292
LL | const fn really_no_traits_i_mean_it() { (&() as &dyn std::fmt::Debug, ()).1 }
302293
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -305,7 +296,7 @@ LL | const fn really_no_traits_i_mean_it() { (&() as &dyn std::fmt::Debug, ()).1
305296
= help: add `#![feature(const_fn)]` to the crate attributes to enable
306297

307298
error[E0723]: function pointers in const fn are unstable
308-
--> $DIR/min_const_fn.rs:146:21
299+
--> $DIR/min_const_fn.rs:145:21
309300
|
310301
LL | const fn no_fn_ptrs(_x: fn()) {}
311302
| ^^
@@ -314,15 +305,15 @@ LL | const fn no_fn_ptrs(_x: fn()) {}
314305
= help: add `#![feature(const_fn)]` to the crate attributes to enable
315306

316307
error[E0723]: function pointers in const fn are unstable
317-
--> $DIR/min_const_fn.rs:148:27
308+
--> $DIR/min_const_fn.rs:147:27
318309
|
319310
LL | const fn no_fn_ptrs2() -> fn() { fn foo() {} foo }
320311
| ^^^^
321312
|
322313
= note: for more information, see issue https://github.com/rust-lang/rust/issues/57563
323314
= help: add `#![feature(const_fn)]` to the crate attributes to enable
324315

325-
error: aborting due to 37 previous errors
316+
error: aborting due to 36 previous errors
326317

327-
Some errors have detailed explanations: E0493, E0515, E0723.
318+
Some errors have detailed explanations: E0493, E0723.
328319
For more information about an error, try `rustc --explain E0493`.

src/test/ui/consts/min_const_fn/min_const_fn_dyn.rs

-1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,5 @@ const fn no_inner_dyn_trait2(x: Hide) {
1111
}
1212
const fn no_inner_dyn_trait_ret() -> Hide { Hide(HasDyn { field: &0 }) }
1313
//~^ ERROR trait bounds other than `Sized`
14-
//~| ERROR temporary value dropped while borrowed
1514

1615
fn main() {}

src/test/ui/consts/min_const_fn/min_const_fn_dyn.stderr

+2-12
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,6 @@ LL | const fn no_inner_dyn_trait_ret() -> Hide { Hide(HasDyn { field: &0 }) }
1616
= note: for more information, see issue https://github.com/rust-lang/rust/issues/57563
1717
= help: add `#![feature(const_fn)]` to the crate attributes to enable
1818

19-
error[E0716]: temporary value dropped while borrowed
20-
--> $DIR/min_const_fn_dyn.rs:12:67
21-
|
22-
LL | const fn no_inner_dyn_trait_ret() -> Hide { Hide(HasDyn { field: &0 }) }
23-
| -^ - temporary value is freed at the end of this statement
24-
| ||
25-
| |creates a temporary which is freed while still in use
26-
| cast requires that borrow lasts for `'static`
27-
28-
error: aborting due to 3 previous errors
19+
error: aborting due to 2 previous errors
2920

30-
Some errors have detailed explanations: E0716, E0723.
31-
For more information about an error, try `rustc --explain E0716`.
21+
For more information about this error, try `rustc --explain E0723`.

0 commit comments

Comments
 (0)