From 6781907444c0b80fb57a1a6ad971ed76ade90b16 Mon Sep 17 00:00:00 2001 From: Vishnunarayan K I Date: Fri, 6 Nov 2020 21:27:05 +0530 Subject: [PATCH] fix tests and formatting --- compiler/rustc_mir/src/const_eval/eval_queries.rs | 2 +- .../rustc_mir/src/transform/check_consts/qualifs.rs | 6 +++++- .../src/transform/check_consts/validation.rs | 6 +++++- src/test/ui/consts/const-call.rs | 1 - src/test/ui/consts/const-call.stderr | 11 ++--------- src/test/ui/consts/const-eval/issue-52442.rs | 1 - src/test/ui/consts/const-eval/issue-52442.stderr | 11 ++--------- src/test/ui/consts/const-eval/match-test-ptr-null.rs | 1 - .../ui/consts/const-eval/match-test-ptr-null.stderr | 11 ++--------- .../ui/consts/issue-68542-closure-in-array-len.rs | 1 - .../ui/consts/issue-68542-closure-in-array-len.stderr | 11 ++--------- 11 files changed, 19 insertions(+), 43 deletions(-) diff --git a/compiler/rustc_mir/src/const_eval/eval_queries.rs b/compiler/rustc_mir/src/const_eval/eval_queries.rs index 90b610428cf..4d4d8a31eb4 100644 --- a/compiler/rustc_mir/src/const_eval/eval_queries.rs +++ b/compiler/rustc_mir/src/const_eval/eval_queries.rs @@ -6,10 +6,10 @@ use crate::interpret::{ ScalarMaybeUninit, StackPopCleanup, }; +use rustc_errors::ErrorReported; use rustc_hir::def::DefKind; use rustc_middle::mir; use rustc_middle::mir::interpret::ErrorHandled; -use rustc_errors::ErrorReported; use rustc_middle::traits::Reveal; use rustc_middle::ty::print::with_no_trimmed_paths; use rustc_middle::ty::{self, subst::Subst, TyCtxt}; diff --git a/compiler/rustc_mir/src/transform/check_consts/qualifs.rs b/compiler/rustc_mir/src/transform/check_consts/qualifs.rs index c57b49b69ce..129985543a0 100644 --- a/compiler/rustc_mir/src/transform/check_consts/qualifs.rs +++ b/compiler/rustc_mir/src/transform/check_consts/qualifs.rs @@ -9,7 +9,11 @@ use rustc_trait_selection::traits; use super::ConstCx; -pub fn in_any_value_of_ty(cx: &ConstCx<'_, 'tcx>, ty: Ty<'tcx>, error_occured: bool) -> ConstQualifs { +pub fn in_any_value_of_ty( + cx: &ConstCx<'_, 'tcx>, + ty: Ty<'tcx>, + error_occured: bool, +) -> ConstQualifs { ConstQualifs { has_mut_interior: HasMutInterior::in_any_value_of_ty(cx, ty), needs_drop: NeedsDrop::in_any_value_of_ty(cx, ty), diff --git a/compiler/rustc_mir/src/transform/check_consts/validation.rs b/compiler/rustc_mir/src/transform/check_consts/validation.rs index 50617278044..ab65bc5a338 100644 --- a/compiler/rustc_mir/src/transform/check_consts/validation.rs +++ b/compiler/rustc_mir/src/transform/check_consts/validation.rs @@ -123,7 +123,11 @@ impl Qualifs<'mir, 'tcx> { has_mut_interior.get().contains(local) || self.indirectly_mutable(ccx, local, location) } - fn in_return_place(&mut self, ccx: &'mir ConstCx<'mir, 'tcx>, error_occured: bool) -> ConstQualifs { + fn in_return_place( + &mut self, + ccx: &'mir ConstCx<'mir, 'tcx>, + error_occured: bool, + ) -> ConstQualifs { // Find the `Return` terminator if one exists. // // If no `Return` terminator exists, this MIR is divergent. Just return the conservative diff --git a/src/test/ui/consts/const-call.rs b/src/test/ui/consts/const-call.rs index 3d5b64ed4c2..db642988971 100644 --- a/src/test/ui/consts/const-call.rs +++ b/src/test/ui/consts/const-call.rs @@ -5,5 +5,4 @@ fn f(x: usize) -> usize { fn main() { let _ = [0; f(2)]; //~^ ERROR calls in constants are limited to constant functions - //~| ERROR evaluation of constant value failed } diff --git a/src/test/ui/consts/const-call.stderr b/src/test/ui/consts/const-call.stderr index d11add818d9..9761348bab8 100644 --- a/src/test/ui/consts/const-call.stderr +++ b/src/test/ui/consts/const-call.stderr @@ -4,13 +4,6 @@ error[E0015]: calls in constants are limited to constant functions, tuple struct LL | let _ = [0; f(2)]; | ^^^^ -error[E0080]: evaluation of constant value failed - --> $DIR/const-call.rs:6:17 - | -LL | let _ = [0; f(2)]; - | ^^^^ calling non-const function `f` +error: aborting due to previous error -error: aborting due to 2 previous errors - -Some errors have detailed explanations: E0015, E0080. -For more information about an error, try `rustc --explain E0015`. +For more information about this error, try `rustc --explain E0015`. diff --git a/src/test/ui/consts/const-eval/issue-52442.rs b/src/test/ui/consts/const-eval/issue-52442.rs index ea24578c7dd..159b48d42b6 100644 --- a/src/test/ui/consts/const-eval/issue-52442.rs +++ b/src/test/ui/consts/const-eval/issue-52442.rs @@ -1,5 +1,4 @@ fn main() { [(); { &loop { break } as *const _ as usize } ]; //~^ ERROR casting pointers to integers in constants is unstable - //~| ERROR evaluation of constant value failed } diff --git a/src/test/ui/consts/const-eval/issue-52442.stderr b/src/test/ui/consts/const-eval/issue-52442.stderr index 53a87837e16..2a8f34279c3 100644 --- a/src/test/ui/consts/const-eval/issue-52442.stderr +++ b/src/test/ui/consts/const-eval/issue-52442.stderr @@ -7,13 +7,6 @@ LL | [(); { &loop { break } as *const _ as usize } ]; = note: see issue #51910 for more information = help: add `#![feature(const_raw_ptr_to_usize_cast)]` to the crate attributes to enable -error[E0080]: evaluation of constant value failed - --> $DIR/issue-52442.rs:2:13 - | -LL | [(); { &loop { break } as *const _ as usize } ]; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ "pointer-to-integer cast" needs an rfc before being allowed inside constants +error: aborting due to previous error -error: aborting due to 2 previous errors - -Some errors have detailed explanations: E0080, E0658. -For more information about an error, try `rustc --explain E0080`. +For more information about this error, try `rustc --explain E0658`. diff --git a/src/test/ui/consts/const-eval/match-test-ptr-null.rs b/src/test/ui/consts/const-eval/match-test-ptr-null.rs index f6b5ad005a8..d980eb92a24 100644 --- a/src/test/ui/consts/const-eval/match-test-ptr-null.rs +++ b/src/test/ui/consts/const-eval/match-test-ptr-null.rs @@ -5,7 +5,6 @@ fn main() { let _: [u8; 0] = [4; { match &1 as *const i32 as usize { //~^ ERROR casting pointers to integers in constants - //~| ERROR evaluation of constant value failed 0 => 42, n => n, } diff --git a/src/test/ui/consts/const-eval/match-test-ptr-null.stderr b/src/test/ui/consts/const-eval/match-test-ptr-null.stderr index 48dbe661492..22d6bb16944 100644 --- a/src/test/ui/consts/const-eval/match-test-ptr-null.stderr +++ b/src/test/ui/consts/const-eval/match-test-ptr-null.stderr @@ -7,13 +7,6 @@ LL | match &1 as *const i32 as usize { = note: see issue #51910 for more information = help: add `#![feature(const_raw_ptr_to_usize_cast)]` to the crate attributes to enable -error[E0080]: evaluation of constant value failed - --> $DIR/match-test-ptr-null.rs:6:15 - | -LL | match &1 as *const i32 as usize { - | ^^^^^^^^^^^^^^^^^^^^^^^^^ "pointer-to-integer cast" needs an rfc before being allowed inside constants +error: aborting due to previous error -error: aborting due to 2 previous errors - -Some errors have detailed explanations: E0080, E0658. -For more information about an error, try `rustc --explain E0080`. +For more information about this error, try `rustc --explain E0658`. diff --git a/src/test/ui/consts/issue-68542-closure-in-array-len.rs b/src/test/ui/consts/issue-68542-closure-in-array-len.rs index 2e721b85334..d77fd9aa831 100644 --- a/src/test/ui/consts/issue-68542-closure-in-array-len.rs +++ b/src/test/ui/consts/issue-68542-closure-in-array-len.rs @@ -4,7 +4,6 @@ struct Bug { a: [(); (|| { 0 })()] //~ ERROR calls in constants are limited to - //~^ ERROR evaluation of constant value failed } fn main() {} diff --git a/src/test/ui/consts/issue-68542-closure-in-array-len.stderr b/src/test/ui/consts/issue-68542-closure-in-array-len.stderr index 8c839f94e3b..74d70e18a24 100644 --- a/src/test/ui/consts/issue-68542-closure-in-array-len.stderr +++ b/src/test/ui/consts/issue-68542-closure-in-array-len.stderr @@ -4,13 +4,6 @@ error[E0015]: calls in constants are limited to constant functions, tuple struct LL | a: [(); (|| { 0 })()] | ^^^^^^^^^^^^ -error[E0080]: evaluation of constant value failed - --> $DIR/issue-68542-closure-in-array-len.rs:6:13 - | -LL | a: [(); (|| { 0 })()] - | ^^^^^^^^^^^^ calling non-const function `Bug::a::{constant#0}::{closure#0}` +error: aborting due to previous error -error: aborting due to 2 previous errors - -Some errors have detailed explanations: E0015, E0080. -For more information about an error, try `rustc --explain E0015`. +For more information about this error, try `rustc --explain E0015`.