Skip to content

Commit b57fe64

Browse files
committed
fix tests and formatting
1 parent 3e012e2 commit b57fe64

11 files changed

+19
-43
lines changed

compiler/rustc_mir/src/const_eval/eval_queries.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ use crate::interpret::{
66
ScalarMaybeUninit, StackPopCleanup,
77
};
88

9+
use rustc_errors::ErrorReported;
910
use rustc_hir::def::DefKind;
1011
use rustc_middle::mir;
1112
use rustc_middle::mir::interpret::ErrorHandled;
12-
use rustc_errors::ErrorReported;
1313
use rustc_middle::traits::Reveal;
1414
use rustc_middle::ty::print::with_no_trimmed_paths;
1515
use rustc_middle::ty::{self, subst::Subst, TyCtxt};

compiler/rustc_mir/src/transform/check_consts/qualifs.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,11 @@ use rustc_trait_selection::traits;
99

1010
use super::ConstCx;
1111

12-
pub fn in_any_value_of_ty(cx: &ConstCx<'_, 'tcx>, ty: Ty<'tcx>, error_occured: bool) -> ConstQualifs {
12+
pub fn in_any_value_of_ty(
13+
cx: &ConstCx<'_, 'tcx>,
14+
ty: Ty<'tcx>,
15+
error_occured: bool,
16+
) -> ConstQualifs {
1317
ConstQualifs {
1418
has_mut_interior: HasMutInterior::in_any_value_of_ty(cx, ty),
1519
needs_drop: NeedsDrop::in_any_value_of_ty(cx, ty),

compiler/rustc_mir/src/transform/check_consts/validation.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,11 @@ impl Qualifs<'mir, 'tcx> {
123123
has_mut_interior.get().contains(local) || self.indirectly_mutable(ccx, local, location)
124124
}
125125

126-
fn in_return_place(&mut self, ccx: &'mir ConstCx<'mir, 'tcx>, error_occured: bool) -> ConstQualifs {
126+
fn in_return_place(
127+
&mut self,
128+
ccx: &'mir ConstCx<'mir, 'tcx>,
129+
error_occured: bool,
130+
) -> ConstQualifs {
127131
// Find the `Return` terminator if one exists.
128132
//
129133
// If no `Return` terminator exists, this MIR is divergent. Just return the conservative

src/test/ui/consts/const-call.rs

-1
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,4 @@ fn f(x: usize) -> usize {
55
fn main() {
66
let _ = [0; f(2)];
77
//~^ ERROR calls in constants are limited to constant functions
8-
//~| ERROR evaluation of constant value failed
98
}

src/test/ui/consts/const-call.stderr

+2-9
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,6 @@ error[E0015]: calls in constants are limited to constant functions, tuple struct
44
LL | let _ = [0; f(2)];
55
| ^^^^
66

7-
error[E0080]: evaluation of constant value failed
8-
--> $DIR/const-call.rs:6:17
9-
|
10-
LL | let _ = [0; f(2)];
11-
| ^^^^ calling non-const function `f`
12-
13-
error: aborting due to 2 previous errors
7+
error: aborting due to previous error
148

15-
Some errors have detailed explanations: E0015, E0080.
16-
For more information about an error, try `rustc --explain E0015`.
9+
For more information about this error, try `rustc --explain E0015`.
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
fn main() {
22
[(); { &loop { break } as *const _ as usize } ];
33
//~^ ERROR casting pointers to integers in constants is unstable
4-
//~| ERROR evaluation of constant value failed
54
}

src/test/ui/consts/const-eval/issue-52442.stderr

+2-9
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,6 @@ LL | [(); { &loop { break } as *const _ as usize } ];
77
= note: see issue #51910 <https://github.com/rust-lang/rust/issues/51910> for more information
88
= help: add `#![feature(const_raw_ptr_to_usize_cast)]` to the crate attributes to enable
99

10-
error[E0080]: evaluation of constant value failed
11-
--> $DIR/issue-52442.rs:2:13
12-
|
13-
LL | [(); { &loop { break } as *const _ as usize } ];
14-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ "pointer-to-integer cast" needs an rfc before being allowed inside constants
15-
16-
error: aborting due to 2 previous errors
10+
error: aborting due to previous error
1711

18-
Some errors have detailed explanations: E0080, E0658.
19-
For more information about an error, try `rustc --explain E0080`.
12+
For more information about this error, try `rustc --explain E0658`.

src/test/ui/consts/const-eval/match-test-ptr-null.rs

-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ fn main() {
55
let _: [u8; 0] = [4; {
66
match &1 as *const i32 as usize {
77
//~^ ERROR casting pointers to integers in constants
8-
//~| ERROR evaluation of constant value failed
98
0 => 42,
109
n => n,
1110
}

src/test/ui/consts/const-eval/match-test-ptr-null.stderr

+2-9
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,6 @@ LL | match &1 as *const i32 as usize {
77
= note: see issue #51910 <https://github.com/rust-lang/rust/issues/51910> for more information
88
= help: add `#![feature(const_raw_ptr_to_usize_cast)]` to the crate attributes to enable
99

10-
error[E0080]: evaluation of constant value failed
11-
--> $DIR/match-test-ptr-null.rs:6:15
12-
|
13-
LL | match &1 as *const i32 as usize {
14-
| ^^^^^^^^^^^^^^^^^^^^^^^^^ "pointer-to-integer cast" needs an rfc before being allowed inside constants
15-
16-
error: aborting due to 2 previous errors
10+
error: aborting due to previous error
1711

18-
Some errors have detailed explanations: E0080, E0658.
19-
For more information about an error, try `rustc --explain E0080`.
12+
For more information about this error, try `rustc --explain E0658`.

src/test/ui/consts/issue-68542-closure-in-array-len.rs

-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
struct Bug {
66
a: [(); (|| { 0 })()] //~ ERROR calls in constants are limited to
7-
//~^ ERROR evaluation of constant value failed
87
}
98

109
fn main() {}

src/test/ui/consts/issue-68542-closure-in-array-len.stderr

+2-9
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,6 @@ error[E0015]: calls in constants are limited to constant functions, tuple struct
44
LL | a: [(); (|| { 0 })()]
55
| ^^^^^^^^^^^^
66

7-
error[E0080]: evaluation of constant value failed
8-
--> $DIR/issue-68542-closure-in-array-len.rs:6:13
9-
|
10-
LL | a: [(); (|| { 0 })()]
11-
| ^^^^^^^^^^^^ calling non-const function `Bug::a::{constant#0}::{closure#0}`
12-
13-
error: aborting due to 2 previous errors
7+
error: aborting due to previous error
148

15-
Some errors have detailed explanations: E0015, E0080.
16-
For more information about an error, try `rustc --explain E0015`.
9+
For more information about this error, try `rustc --explain E0015`.

0 commit comments

Comments
 (0)