fix tests and formatting

This commit is contained in:
Vishnunarayan K I 2020-11-06 21:27:05 +05:30
parent 8bce9af78c
commit 6781907444
11 changed files with 19 additions and 43 deletions

View File

@ -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};

View File

@ -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),

View File

@ -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

View File

@ -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
}

View File

@ -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`.

View File

@ -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
}

View File

@ -7,13 +7,6 @@ LL | [(); { &loop { break } as *const _ as usize } ];
= note: see issue #51910 <https://github.com/rust-lang/rust/issues/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`.

View File

@ -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,
}

View File

@ -7,13 +7,6 @@ LL | match &1 as *const i32 as usize {
= note: see issue #51910 <https://github.com/rust-lang/rust/issues/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`.

View File

@ -4,7 +4,6 @@
struct Bug {
a: [(); (|| { 0 })()] //~ ERROR calls in constants are limited to
//~^ ERROR evaluation of constant value failed
}
fn main() {}

View File

@ -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`.