mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-26 16:54:01 +00:00
ty: convert ErrorHandled::Reported
to ConstKind::Error
.
This commit is contained in:
parent
d7c4081b18
commit
77f38dc284
@ -18,6 +18,7 @@ use crate::ty::{List, ParamEnv, ParamEnvAnd, TyS};
|
|||||||
use polonius_engine::Atom;
|
use polonius_engine::Atom;
|
||||||
use rustc_ast::ast::{self, Ident};
|
use rustc_ast::ast::{self, Ident};
|
||||||
use rustc_data_structures::captures::Captures;
|
use rustc_data_structures::captures::Captures;
|
||||||
|
use rustc_errors::ErrorReported;
|
||||||
use rustc_hir as hir;
|
use rustc_hir as hir;
|
||||||
use rustc_hir::def_id::{DefId, LocalDefId};
|
use rustc_hir::def_id::{DefId, LocalDefId};
|
||||||
use rustc_index::vec::Idx;
|
use rustc_index::vec::Idx;
|
||||||
@ -2340,6 +2341,8 @@ impl<'tcx> Const<'tcx> {
|
|||||||
/// unevaluated constant.
|
/// unevaluated constant.
|
||||||
pub fn eval(&self, tcx: TyCtxt<'tcx>, param_env: ParamEnv<'tcx>) -> &Const<'tcx> {
|
pub fn eval(&self, tcx: TyCtxt<'tcx>, param_env: ParamEnv<'tcx>) -> &Const<'tcx> {
|
||||||
if let ConstKind::Unevaluated(did, substs, promoted) = self.val {
|
if let ConstKind::Unevaluated(did, substs, promoted) = self.val {
|
||||||
|
use crate::mir::interpret::ErrorHandled;
|
||||||
|
|
||||||
let param_env_and_substs = param_env.with_reveal_all().and(substs);
|
let param_env_and_substs = param_env.with_reveal_all().and(substs);
|
||||||
|
|
||||||
// HACK(eddyb) this erases lifetimes even though `const_eval_resolve`
|
// HACK(eddyb) this erases lifetimes even though `const_eval_resolve`
|
||||||
@ -2369,8 +2372,10 @@ impl<'tcx> Const<'tcx> {
|
|||||||
// (which may be identity substs, see above),
|
// (which may be identity substs, see above),
|
||||||
// can leak through `val` into the const we return.
|
// can leak through `val` into the const we return.
|
||||||
Ok(val) => Const::from_value(tcx, val, self.ty),
|
Ok(val) => Const::from_value(tcx, val, self.ty),
|
||||||
|
Err(ErrorHandled::TooGeneric | ErrorHandled::Linted) => self,
|
||||||
Err(_) => self,
|
Err(ErrorHandled::Reported(ErrorReported)) => {
|
||||||
|
tcx.mk_const(ty::Const { val: ty::ConstKind::Error, ty: self.ty })
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
self
|
self
|
||||||
|
@ -1,11 +1,9 @@
|
|||||||
fn main() {
|
fn main() {
|
||||||
loop {
|
loop {
|
||||||
|_: [_; break]| {} //~ ERROR: `break` outside of a loop
|
|_: [_; break]| {} //~ ERROR: `break` outside of a loop
|
||||||
//~^ ERROR mismatched types
|
|
||||||
}
|
}
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
|_: [_; continue]| {} //~ ERROR: `continue` outside of a loop
|
|_: [_; continue]| {} //~ ERROR: `continue` outside of a loop
|
||||||
//~^ ERROR mismatched types
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,30 +5,11 @@ LL | |_: [_; break]| {}
|
|||||||
| ^^^^^ cannot `break` outside of a loop
|
| ^^^^^ cannot `break` outside of a loop
|
||||||
|
|
||||||
error[E0268]: `continue` outside of a loop
|
error[E0268]: `continue` outside of a loop
|
||||||
--> $DIR/array-break-length.rs:8:17
|
--> $DIR/array-break-length.rs:7:17
|
||||||
|
|
|
|
||||||
LL | |_: [_; continue]| {}
|
LL | |_: [_; continue]| {}
|
||||||
| ^^^^^^^^ cannot `continue` outside of a loop
|
| ^^^^^^^^ cannot `continue` outside of a loop
|
||||||
|
|
||||||
error[E0308]: mismatched types
|
error: aborting due to 2 previous errors
|
||||||
--> $DIR/array-break-length.rs:3:9
|
|
||||||
|
|
|
||||||
LL | |_: [_; break]| {}
|
|
||||||
| ^^^^^^^^^^^^^^^^^^ expected `()`, found closure
|
|
||||||
|
|
|
||||||
= note: expected unit type `()`
|
|
||||||
found closure `[closure@$DIR/array-break-length.rs:3:9: 3:27]`
|
|
||||||
|
|
||||||
error[E0308]: mismatched types
|
For more information about this error, try `rustc --explain E0268`.
|
||||||
--> $DIR/array-break-length.rs:8:9
|
|
||||||
|
|
|
||||||
LL | |_: [_; continue]| {}
|
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^ expected `()`, found closure
|
|
||||||
|
|
|
||||||
= note: expected unit type `()`
|
|
||||||
found closure `[closure@$DIR/array-break-length.rs:8:9: 8:30]`
|
|
||||||
|
|
||||||
error: aborting due to 4 previous errors
|
|
||||||
|
|
||||||
Some errors have detailed explanations: E0268, E0308.
|
|
||||||
For more information about an error, try `rustc --explain E0268`.
|
|
||||||
|
@ -2,8 +2,6 @@ fn main() {
|
|||||||
|_: [_; continue]| {}; //~ ERROR: `continue` outside of a loop
|
|_: [_; continue]| {}; //~ ERROR: `continue` outside of a loop
|
||||||
|
|
||||||
while |_: [_; continue]| {} {} //~ ERROR: `continue` outside of a loop
|
while |_: [_; continue]| {} {} //~ ERROR: `continue` outside of a loop
|
||||||
//~^ ERROR mismatched types
|
|
||||||
|
|
||||||
while |_: [_; break]| {} {} //~ ERROR: `break` outside of a loop
|
while |_: [_; break]| {} {} //~ ERROR: `break` outside of a loop
|
||||||
//~^ ERROR mismatched types
|
|
||||||
}
|
}
|
||||||
|
@ -11,30 +11,11 @@ LL | while |_: [_; continue]| {} {}
|
|||||||
| ^^^^^^^^ cannot `continue` outside of a loop
|
| ^^^^^^^^ cannot `continue` outside of a loop
|
||||||
|
|
||||||
error[E0268]: `break` outside of a loop
|
error[E0268]: `break` outside of a loop
|
||||||
--> $DIR/closure-array-break-length.rs:7:19
|
--> $DIR/closure-array-break-length.rs:6:19
|
||||||
|
|
|
|
||||||
LL | while |_: [_; break]| {} {}
|
LL | while |_: [_; break]| {} {}
|
||||||
| ^^^^^ cannot `break` outside of a loop
|
| ^^^^^ cannot `break` outside of a loop
|
||||||
|
|
||||||
error[E0308]: mismatched types
|
error: aborting due to 3 previous errors
|
||||||
--> $DIR/closure-array-break-length.rs:4:11
|
|
||||||
|
|
|
||||||
LL | while |_: [_; continue]| {} {}
|
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^ expected `bool`, found closure
|
|
||||||
|
|
|
||||||
= note: expected type `bool`
|
|
||||||
found closure `[closure@$DIR/closure-array-break-length.rs:4:11: 4:32]`
|
|
||||||
|
|
||||||
error[E0308]: mismatched types
|
For more information about this error, try `rustc --explain E0268`.
|
||||||
--> $DIR/closure-array-break-length.rs:7:11
|
|
||||||
|
|
|
||||||
LL | while |_: [_; break]| {} {}
|
|
||||||
| ^^^^^^^^^^^^^^^^^^ expected `bool`, found closure
|
|
||||||
|
|
|
||||||
= note: expected type `bool`
|
|
||||||
found closure `[closure@$DIR/closure-array-break-length.rs:7:11: 7:29]`
|
|
||||||
|
|
||||||
error: aborting due to 5 previous errors
|
|
||||||
|
|
||||||
Some errors have detailed explanations: E0268, E0308.
|
|
||||||
For more information about an error, try `rustc --explain E0268`.
|
|
||||||
|
@ -19,7 +19,6 @@ const A_I8_I
|
|||||||
: [u32; (i8::MAX as usize) + 1]
|
: [u32; (i8::MAX as usize) + 1]
|
||||||
= [0; (i8::MAX + 1) as usize];
|
= [0; (i8::MAX + 1) as usize];
|
||||||
//~^ ERROR evaluation of constant value failed
|
//~^ ERROR evaluation of constant value failed
|
||||||
//~| ERROR mismatched types
|
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
foo(&A_I8_I[..]);
|
foo(&A_I8_I[..]);
|
||||||
|
@ -4,16 +4,6 @@ error[E0080]: evaluation of constant value failed
|
|||||||
LL | = [0; (i8::MAX + 1) as usize];
|
LL | = [0; (i8::MAX + 1) as usize];
|
||||||
| ^^^^^^^^^^^^^ attempt to add with overflow
|
| ^^^^^^^^^^^^^ attempt to add with overflow
|
||||||
|
|
||||||
error[E0308]: mismatched types
|
error: aborting due to previous error
|
||||||
--> $DIR/const-eval-overflow-3.rs:20:7
|
|
||||||
|
|
|
||||||
LL | = [0; (i8::MAX + 1) as usize];
|
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `128usize`, found `(i8::MAX + 1) as usize`
|
|
||||||
|
|
|
||||||
= note: expected array `[u32; 128]`
|
|
||||||
found array `[u32; _]`
|
|
||||||
|
|
||||||
error: aborting due to 2 previous errors
|
For more information about this error, try `rustc --explain E0080`.
|
||||||
|
|
||||||
Some errors have detailed explanations: E0080, E0308.
|
|
||||||
For more information about an error, try `rustc --explain E0080`.
|
|
||||||
|
@ -18,7 +18,6 @@ const A_I8_I
|
|||||||
= [0; (i8::MAX + 1u8) as usize];
|
= [0; (i8::MAX + 1u8) as usize];
|
||||||
//~^ ERROR mismatched types
|
//~^ ERROR mismatched types
|
||||||
//~| ERROR cannot add `u8` to `i8`
|
//~| ERROR cannot add `u8` to `i8`
|
||||||
//~| ERROR mismatched types
|
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
foo(&A_I8_I[..]);
|
foo(&A_I8_I[..]);
|
||||||
|
@ -12,16 +12,7 @@ LL | = [0; (i8::MAX + 1u8) as usize];
|
|||||||
|
|
|
|
||||||
= help: the trait `std::ops::Add<u8>` is not implemented for `i8`
|
= help: the trait `std::ops::Add<u8>` is not implemented for `i8`
|
||||||
|
|
||||||
error[E0308]: mismatched types
|
error: aborting due to 2 previous errors
|
||||||
--> $DIR/const-eval-overflow-3b.rs:18:7
|
|
||||||
|
|
|
||||||
LL | = [0; (i8::MAX + 1u8) as usize];
|
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `128usize`, found `(i8::MAX + 1u8) as usize`
|
|
||||||
|
|
|
||||||
= note: expected array `[u32; 128]`
|
|
||||||
found array `[u32; _]`
|
|
||||||
|
|
||||||
error: aborting due to 3 previous errors
|
|
||||||
|
|
||||||
Some errors have detailed explanations: E0277, E0308.
|
Some errors have detailed explanations: E0277, E0308.
|
||||||
For more information about an error, try `rustc --explain E0277`.
|
For more information about an error, try `rustc --explain E0277`.
|
||||||
|
@ -2,7 +2,7 @@ fn main() {
|
|||||||
// Make sure match uses the usual pointer comparison code path -- i.e., it should complain
|
// Make sure match uses the usual pointer comparison code path -- i.e., it should complain
|
||||||
// that pointer comparison is disallowed, not that parts of a pointer are accessed as raw
|
// that pointer comparison is disallowed, not that parts of a pointer are accessed as raw
|
||||||
// bytes.
|
// bytes.
|
||||||
let _: [u8; 0] = [4; { //~ ERROR mismatched types
|
let _: [u8; 0] = [4; {
|
||||||
match &1 as *const i32 as usize {
|
match &1 as *const i32 as usize {
|
||||||
//~^ ERROR casting pointers to integers in constants
|
//~^ ERROR casting pointers to integers in constants
|
||||||
//~| ERROR `match` is not allowed in a `const`
|
//~| ERROR `match` is not allowed in a `const`
|
||||||
|
@ -28,30 +28,7 @@ error[E0080]: evaluation of constant value failed
|
|||||||
LL | match &1 as *const i32 as usize {
|
LL | match &1 as *const i32 as usize {
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^ "pointer-to-integer cast" needs an rfc before being allowed inside constants
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^ "pointer-to-integer cast" needs an rfc before being allowed inside constants
|
||||||
|
|
||||||
error[E0308]: mismatched types
|
error: aborting due to 3 previous errors
|
||||||
--> $DIR/match-test-ptr-null.rs:5:22
|
|
||||||
|
|
|
||||||
LL | let _: [u8; 0] = [4; {
|
|
||||||
| ____________-------___^
|
|
||||||
| | |
|
|
||||||
| | expected due to this
|
|
||||||
LL | | match &1 as *const i32 as usize {
|
|
||||||
LL | |
|
|
||||||
LL | |
|
|
||||||
... |
|
|
||||||
LL | | }
|
|
||||||
LL | | }];
|
|
||||||
| |______^ expected `0usize`, found `{
|
|
||||||
match &1 as *const i32 as usize {
|
|
||||||
0 => 42,
|
|
||||||
n => n,
|
|
||||||
}
|
|
||||||
}`
|
|
||||||
|
|
|
||||||
= note: expected array `[u8; 0]`
|
|
||||||
found array `[u8; _]`
|
|
||||||
|
|
||||||
error: aborting due to 4 previous errors
|
Some errors have detailed explanations: E0080, E0658.
|
||||||
|
|
||||||
Some errors have detailed explanations: E0080, E0308, E0658.
|
|
||||||
For more information about an error, try `rustc --explain E0080`.
|
For more information about an error, try `rustc --explain E0080`.
|
||||||
|
@ -6,7 +6,6 @@ const X: usize = 42 && 39;
|
|||||||
//~| ERROR mismatched types
|
//~| ERROR mismatched types
|
||||||
//~| expected `usize`, found `bool`
|
//~| expected `usize`, found `bool`
|
||||||
const ARR: [i32; X] = [99; 34];
|
const ARR: [i32; X] = [99; 34];
|
||||||
//~^ ERROR evaluation of constant value failed
|
|
||||||
|
|
||||||
const X1: usize = 42 || 39;
|
const X1: usize = 42 || 39;
|
||||||
//~^ ERROR mismatched types
|
//~^ ERROR mismatched types
|
||||||
@ -16,7 +15,6 @@ const X1: usize = 42 || 39;
|
|||||||
//~| ERROR mismatched types
|
//~| ERROR mismatched types
|
||||||
//~| expected `usize`, found `bool`
|
//~| expected `usize`, found `bool`
|
||||||
const ARR1: [i32; X1] = [99; 47];
|
const ARR1: [i32; X1] = [99; 47];
|
||||||
//~^ ERROR evaluation of constant value failed
|
|
||||||
|
|
||||||
const X2: usize = -42 || -39;
|
const X2: usize = -42 || -39;
|
||||||
//~^ ERROR mismatched types
|
//~^ ERROR mismatched types
|
||||||
@ -26,7 +24,6 @@ const X2: usize = -42 || -39;
|
|||||||
//~| ERROR mismatched types
|
//~| ERROR mismatched types
|
||||||
//~| expected `usize`, found `bool`
|
//~| expected `usize`, found `bool`
|
||||||
const ARR2: [i32; X2] = [99; 18446744073709551607];
|
const ARR2: [i32; X2] = [99; 18446744073709551607];
|
||||||
//~^ ERROR evaluation of constant value failed
|
|
||||||
|
|
||||||
const X3: usize = -42 && -39;
|
const X3: usize = -42 && -39;
|
||||||
//~^ ERROR mismatched types
|
//~^ ERROR mismatched types
|
||||||
@ -36,43 +33,36 @@ const X3: usize = -42 && -39;
|
|||||||
//~| ERROR mismatched types
|
//~| ERROR mismatched types
|
||||||
//~| expected `usize`, found `bool`
|
//~| expected `usize`, found `bool`
|
||||||
const ARR3: [i32; X3] = [99; 6];
|
const ARR3: [i32; X3] = [99; 6];
|
||||||
//~^ ERROR evaluation of constant value failed
|
|
||||||
|
|
||||||
const Y: usize = 42.0 == 42.0;
|
const Y: usize = 42.0 == 42.0;
|
||||||
//~^ ERROR mismatched types
|
//~^ ERROR mismatched types
|
||||||
//~| expected `usize`, found `bool`
|
//~| expected `usize`, found `bool`
|
||||||
const ARRR: [i32; Y] = [99; 1];
|
const ARRR: [i32; Y] = [99; 1];
|
||||||
//~^ ERROR evaluation of constant value failed
|
|
||||||
|
|
||||||
const Y1: usize = 42.0 >= 42.0;
|
const Y1: usize = 42.0 >= 42.0;
|
||||||
//~^ ERROR mismatched types
|
//~^ ERROR mismatched types
|
||||||
//~| expected `usize`, found `bool`
|
//~| expected `usize`, found `bool`
|
||||||
const ARRR1: [i32; Y1] = [99; 1];
|
const ARRR1: [i32; Y1] = [99; 1];
|
||||||
//~^ ERROR evaluation of constant value failed
|
|
||||||
|
|
||||||
const Y2: usize = 42.0 <= 42.0;
|
const Y2: usize = 42.0 <= 42.0;
|
||||||
//~^ ERROR mismatched types
|
//~^ ERROR mismatched types
|
||||||
//~| expected `usize`, found `bool`
|
//~| expected `usize`, found `bool`
|
||||||
const ARRR2: [i32; Y2] = [99; 1];
|
const ARRR2: [i32; Y2] = [99; 1];
|
||||||
//~^ ERROR evaluation of constant value failed
|
|
||||||
|
|
||||||
const Y3: usize = 42.0 > 42.0;
|
const Y3: usize = 42.0 > 42.0;
|
||||||
//~^ ERROR mismatched types
|
//~^ ERROR mismatched types
|
||||||
//~| expected `usize`, found `bool`
|
//~| expected `usize`, found `bool`
|
||||||
const ARRR3: [i32; Y3] = [99; 0];
|
const ARRR3: [i32; Y3] = [99; 0];
|
||||||
//~^ ERROR evaluation of constant value failed
|
|
||||||
|
|
||||||
const Y4: usize = 42.0 < 42.0;
|
const Y4: usize = 42.0 < 42.0;
|
||||||
//~^ ERROR mismatched types
|
//~^ ERROR mismatched types
|
||||||
//~| expected `usize`, found `bool`
|
//~| expected `usize`, found `bool`
|
||||||
const ARRR4: [i32; Y4] = [99; 0];
|
const ARRR4: [i32; Y4] = [99; 0];
|
||||||
//~^ ERROR evaluation of constant value failed
|
|
||||||
|
|
||||||
const Y5: usize = 42.0 != 42.0;
|
const Y5: usize = 42.0 != 42.0;
|
||||||
//~^ ERROR mismatched types
|
//~^ ERROR mismatched types
|
||||||
//~| expected `usize`, found `bool`
|
//~| expected `usize`, found `bool`
|
||||||
const ARRR5: [i32; Y5] = [99; 0];
|
const ARRR5: [i32; Y5] = [99; 0];
|
||||||
//~^ ERROR evaluation of constant value failed
|
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let _ = ARR;
|
let _ = ARR;
|
||||||
|
@ -16,157 +16,96 @@ error[E0308]: mismatched types
|
|||||||
LL | const X: usize = 42 && 39;
|
LL | const X: usize = 42 && 39;
|
||||||
| ^^^^^^^^ expected `usize`, found `bool`
|
| ^^^^^^^^ expected `usize`, found `bool`
|
||||||
|
|
||||||
error[E0080]: evaluation of constant value failed
|
|
||||||
--> $DIR/const-integer-bool-ops.rs:8:18
|
|
||||||
|
|
|
||||||
LL | const ARR: [i32; X] = [99; 34];
|
|
||||||
| ^ referenced constant has errors
|
|
||||||
|
|
||||||
error[E0308]: mismatched types
|
error[E0308]: mismatched types
|
||||||
--> $DIR/const-integer-bool-ops.rs:11:19
|
--> $DIR/const-integer-bool-ops.rs:10:19
|
||||||
|
|
|
|
||||||
LL | const X1: usize = 42 || 39;
|
LL | const X1: usize = 42 || 39;
|
||||||
| ^^ expected `bool`, found integer
|
| ^^ expected `bool`, found integer
|
||||||
|
|
||||||
error[E0308]: mismatched types
|
error[E0308]: mismatched types
|
||||||
--> $DIR/const-integer-bool-ops.rs:11:25
|
--> $DIR/const-integer-bool-ops.rs:10:25
|
||||||
|
|
|
|
||||||
LL | const X1: usize = 42 || 39;
|
LL | const X1: usize = 42 || 39;
|
||||||
| ^^ expected `bool`, found integer
|
| ^^ expected `bool`, found integer
|
||||||
|
|
||||||
error[E0308]: mismatched types
|
error[E0308]: mismatched types
|
||||||
--> $DIR/const-integer-bool-ops.rs:11:19
|
--> $DIR/const-integer-bool-ops.rs:10:19
|
||||||
|
|
|
|
||||||
LL | const X1: usize = 42 || 39;
|
LL | const X1: usize = 42 || 39;
|
||||||
| ^^^^^^^^ expected `usize`, found `bool`
|
| ^^^^^^^^ expected `usize`, found `bool`
|
||||||
|
|
||||||
error[E0080]: evaluation of constant value failed
|
|
||||||
--> $DIR/const-integer-bool-ops.rs:18:19
|
|
||||||
|
|
|
||||||
LL | const ARR1: [i32; X1] = [99; 47];
|
|
||||||
| ^^ referenced constant has errors
|
|
||||||
|
|
||||||
error[E0308]: mismatched types
|
error[E0308]: mismatched types
|
||||||
--> $DIR/const-integer-bool-ops.rs:21:19
|
--> $DIR/const-integer-bool-ops.rs:19:19
|
||||||
|
|
|
|
||||||
LL | const X2: usize = -42 || -39;
|
LL | const X2: usize = -42 || -39;
|
||||||
| ^^^ expected `bool`, found integer
|
| ^^^ expected `bool`, found integer
|
||||||
|
|
||||||
error[E0308]: mismatched types
|
error[E0308]: mismatched types
|
||||||
--> $DIR/const-integer-bool-ops.rs:21:26
|
--> $DIR/const-integer-bool-ops.rs:19:26
|
||||||
|
|
|
|
||||||
LL | const X2: usize = -42 || -39;
|
LL | const X2: usize = -42 || -39;
|
||||||
| ^^^ expected `bool`, found integer
|
| ^^^ expected `bool`, found integer
|
||||||
|
|
||||||
error[E0308]: mismatched types
|
error[E0308]: mismatched types
|
||||||
--> $DIR/const-integer-bool-ops.rs:21:19
|
--> $DIR/const-integer-bool-ops.rs:19:19
|
||||||
|
|
|
|
||||||
LL | const X2: usize = -42 || -39;
|
LL | const X2: usize = -42 || -39;
|
||||||
| ^^^^^^^^^^ expected `usize`, found `bool`
|
| ^^^^^^^^^^ expected `usize`, found `bool`
|
||||||
|
|
||||||
error[E0080]: evaluation of constant value failed
|
error[E0308]: mismatched types
|
||||||
--> $DIR/const-integer-bool-ops.rs:28:19
|
--> $DIR/const-integer-bool-ops.rs:28:19
|
||||||
|
|
|
|
||||||
LL | const ARR2: [i32; X2] = [99; 18446744073709551607];
|
|
||||||
| ^^ referenced constant has errors
|
|
||||||
|
|
||||||
error[E0308]: mismatched types
|
|
||||||
--> $DIR/const-integer-bool-ops.rs:31:19
|
|
||||||
|
|
|
||||||
LL | const X3: usize = -42 && -39;
|
LL | const X3: usize = -42 && -39;
|
||||||
| ^^^ expected `bool`, found integer
|
| ^^^ expected `bool`, found integer
|
||||||
|
|
||||||
error[E0308]: mismatched types
|
error[E0308]: mismatched types
|
||||||
--> $DIR/const-integer-bool-ops.rs:31:26
|
--> $DIR/const-integer-bool-ops.rs:28:26
|
||||||
|
|
|
|
||||||
LL | const X3: usize = -42 && -39;
|
LL | const X3: usize = -42 && -39;
|
||||||
| ^^^ expected `bool`, found integer
|
| ^^^ expected `bool`, found integer
|
||||||
|
|
||||||
error[E0308]: mismatched types
|
error[E0308]: mismatched types
|
||||||
--> $DIR/const-integer-bool-ops.rs:31:19
|
--> $DIR/const-integer-bool-ops.rs:28:19
|
||||||
|
|
|
|
||||||
LL | const X3: usize = -42 && -39;
|
LL | const X3: usize = -42 && -39;
|
||||||
| ^^^^^^^^^^ expected `usize`, found `bool`
|
| ^^^^^^^^^^ expected `usize`, found `bool`
|
||||||
|
|
||||||
error[E0080]: evaluation of constant value failed
|
|
||||||
--> $DIR/const-integer-bool-ops.rs:38:19
|
|
||||||
|
|
|
||||||
LL | const ARR3: [i32; X3] = [99; 6];
|
|
||||||
| ^^ referenced constant has errors
|
|
||||||
|
|
||||||
error[E0308]: mismatched types
|
error[E0308]: mismatched types
|
||||||
--> $DIR/const-integer-bool-ops.rs:41:18
|
--> $DIR/const-integer-bool-ops.rs:37:18
|
||||||
|
|
|
|
||||||
LL | const Y: usize = 42.0 == 42.0;
|
LL | const Y: usize = 42.0 == 42.0;
|
||||||
| ^^^^^^^^^^^^ expected `usize`, found `bool`
|
| ^^^^^^^^^^^^ expected `usize`, found `bool`
|
||||||
|
|
||||||
error[E0080]: evaluation of constant value failed
|
|
||||||
--> $DIR/const-integer-bool-ops.rs:44:19
|
|
||||||
|
|
|
||||||
LL | const ARRR: [i32; Y] = [99; 1];
|
|
||||||
| ^ referenced constant has errors
|
|
||||||
|
|
||||||
error[E0308]: mismatched types
|
error[E0308]: mismatched types
|
||||||
--> $DIR/const-integer-bool-ops.rs:47:19
|
--> $DIR/const-integer-bool-ops.rs:42:19
|
||||||
|
|
|
|
||||||
LL | const Y1: usize = 42.0 >= 42.0;
|
LL | const Y1: usize = 42.0 >= 42.0;
|
||||||
| ^^^^^^^^^^^^ expected `usize`, found `bool`
|
| ^^^^^^^^^^^^ expected `usize`, found `bool`
|
||||||
|
|
||||||
error[E0080]: evaluation of constant value failed
|
|
||||||
--> $DIR/const-integer-bool-ops.rs:50:20
|
|
||||||
|
|
|
||||||
LL | const ARRR1: [i32; Y1] = [99; 1];
|
|
||||||
| ^^ referenced constant has errors
|
|
||||||
|
|
||||||
error[E0308]: mismatched types
|
error[E0308]: mismatched types
|
||||||
--> $DIR/const-integer-bool-ops.rs:53:19
|
--> $DIR/const-integer-bool-ops.rs:47:19
|
||||||
|
|
|
|
||||||
LL | const Y2: usize = 42.0 <= 42.0;
|
LL | const Y2: usize = 42.0 <= 42.0;
|
||||||
| ^^^^^^^^^^^^ expected `usize`, found `bool`
|
| ^^^^^^^^^^^^ expected `usize`, found `bool`
|
||||||
|
|
||||||
error[E0080]: evaluation of constant value failed
|
|
||||||
--> $DIR/const-integer-bool-ops.rs:56:20
|
|
||||||
|
|
|
||||||
LL | const ARRR2: [i32; Y2] = [99; 1];
|
|
||||||
| ^^ referenced constant has errors
|
|
||||||
|
|
||||||
error[E0308]: mismatched types
|
error[E0308]: mismatched types
|
||||||
--> $DIR/const-integer-bool-ops.rs:59:19
|
--> $DIR/const-integer-bool-ops.rs:52:19
|
||||||
|
|
|
|
||||||
LL | const Y3: usize = 42.0 > 42.0;
|
LL | const Y3: usize = 42.0 > 42.0;
|
||||||
| ^^^^^^^^^^^ expected `usize`, found `bool`
|
| ^^^^^^^^^^^ expected `usize`, found `bool`
|
||||||
|
|
||||||
error[E0080]: evaluation of constant value failed
|
|
||||||
--> $DIR/const-integer-bool-ops.rs:62:20
|
|
||||||
|
|
|
||||||
LL | const ARRR3: [i32; Y3] = [99; 0];
|
|
||||||
| ^^ referenced constant has errors
|
|
||||||
|
|
||||||
error[E0308]: mismatched types
|
error[E0308]: mismatched types
|
||||||
--> $DIR/const-integer-bool-ops.rs:65:19
|
--> $DIR/const-integer-bool-ops.rs:57:19
|
||||||
|
|
|
|
||||||
LL | const Y4: usize = 42.0 < 42.0;
|
LL | const Y4: usize = 42.0 < 42.0;
|
||||||
| ^^^^^^^^^^^ expected `usize`, found `bool`
|
| ^^^^^^^^^^^ expected `usize`, found `bool`
|
||||||
|
|
||||||
error[E0080]: evaluation of constant value failed
|
|
||||||
--> $DIR/const-integer-bool-ops.rs:68:20
|
|
||||||
|
|
|
||||||
LL | const ARRR4: [i32; Y4] = [99; 0];
|
|
||||||
| ^^ referenced constant has errors
|
|
||||||
|
|
||||||
error[E0308]: mismatched types
|
error[E0308]: mismatched types
|
||||||
--> $DIR/const-integer-bool-ops.rs:71:19
|
--> $DIR/const-integer-bool-ops.rs:62:19
|
||||||
|
|
|
|
||||||
LL | const Y5: usize = 42.0 != 42.0;
|
LL | const Y5: usize = 42.0 != 42.0;
|
||||||
| ^^^^^^^^^^^^ expected `usize`, found `bool`
|
| ^^^^^^^^^^^^ expected `usize`, found `bool`
|
||||||
|
|
||||||
error[E0080]: evaluation of constant value failed
|
error: aborting due to 18 previous errors
|
||||||
--> $DIR/const-integer-bool-ops.rs:74:20
|
|
||||||
|
|
|
||||||
LL | const ARRR5: [i32; Y5] = [99; 0];
|
|
||||||
| ^^ referenced constant has errors
|
|
||||||
|
|
||||||
error: aborting due to 28 previous errors
|
For more information about this error, try `rustc --explain E0308`.
|
||||||
|
|
||||||
Some errors have detailed explanations: E0080, E0308.
|
|
||||||
For more information about an error, try `rustc --explain E0080`.
|
|
||||||
|
@ -4,7 +4,6 @@ const TUP: (usize,) = 5usize << 64;
|
|||||||
//~^ ERROR mismatched types
|
//~^ ERROR mismatched types
|
||||||
//~| expected tuple, found `usize`
|
//~| expected tuple, found `usize`
|
||||||
const ARR: [i32; TUP.0] = [];
|
const ARR: [i32; TUP.0] = [];
|
||||||
//~^ ERROR evaluation of constant value failed
|
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
}
|
}
|
||||||
|
@ -7,13 +7,6 @@ LL | const TUP: (usize,) = 5usize << 64;
|
|||||||
= note: expected tuple `(usize,)`
|
= note: expected tuple `(usize,)`
|
||||||
found type `usize`
|
found type `usize`
|
||||||
|
|
||||||
error[E0080]: evaluation of constant value failed
|
error: aborting due to previous error
|
||||||
--> $DIR/const-tup-index-span.rs:6:18
|
|
||||||
|
|
|
||||||
LL | const ARR: [i32; TUP.0] = [];
|
|
||||||
| ^^^ referenced constant has errors
|
|
||||||
|
|
||||||
error: aborting due to 2 previous errors
|
For more information about this error, try `rustc --explain E0308`.
|
||||||
|
|
||||||
Some errors have detailed explanations: E0080, E0308.
|
|
||||||
For more information about an error, try `rustc --explain E0080`.
|
|
||||||
|
@ -17,5 +17,4 @@ fn main() {
|
|||||||
= [0; Dim3::dim()];
|
= [0; Dim3::dim()];
|
||||||
//~^ ERROR E0015
|
//~^ ERROR E0015
|
||||||
//~| ERROR E0080
|
//~| ERROR E0080
|
||||||
//~| ERROR mismatched types
|
|
||||||
}
|
}
|
||||||
|
@ -22,19 +22,7 @@ error[E0080]: evaluation of constant value failed
|
|||||||
LL | = [0; Dim3::dim()];
|
LL | = [0; Dim3::dim()];
|
||||||
| ^^^^^^^^^^^ calling non-const function `<Dim3 as Dim>::dim`
|
| ^^^^^^^^^^^ calling non-const function `<Dim3 as Dim>::dim`
|
||||||
|
|
||||||
error[E0308]: mismatched types
|
error: aborting due to 4 previous errors
|
||||||
--> $DIR/issue-39559-2.rs:17:11
|
|
||||||
|
|
|
||||||
LL | let array: [usize; Dim3::dim()]
|
|
||||||
| -------------------- expected due to this
|
|
||||||
...
|
|
||||||
LL | = [0; Dim3::dim()];
|
|
||||||
| ^^^^^^^^^^^^^^^^ expected `Dim3::dim()`, found `Dim3::dim()`
|
|
||||||
|
|
|
||||||
= note: expected array `[usize; _]`
|
|
||||||
found array `[usize; _]`
|
|
||||||
|
|
||||||
error: aborting due to 5 previous errors
|
Some errors have detailed explanations: E0015, E0080.
|
||||||
|
|
||||||
Some errors have detailed explanations: E0015, E0080, E0308.
|
|
||||||
For more information about an error, try `rustc --explain E0015`.
|
For more information about an error, try `rustc --explain E0015`.
|
||||||
|
@ -5,7 +5,6 @@ enum Foo {
|
|||||||
|
|
||||||
enum Bar {
|
enum Bar {
|
||||||
A = Foo::A as isize
|
A = Foo::A as isize
|
||||||
//~^ ERROR evaluation of constant value failed
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() {}
|
fn main() {}
|
||||||
|
@ -6,13 +6,6 @@ LL | A = "" + 1
|
|||||||
| |
|
| |
|
||||||
| &str
|
| &str
|
||||||
|
|
||||||
error[E0080]: evaluation of constant value failed
|
error: aborting due to previous error
|
||||||
--> $DIR/issue-41394.rs:7:9
|
|
||||||
|
|
|
||||||
LL | A = Foo::A as isize
|
|
||||||
| ^^^^^^^^^^^^^^^ referenced constant has errors
|
|
||||||
|
|
||||||
error: aborting due to 2 previous errors
|
For more information about this error, try `rustc --explain E0369`.
|
||||||
|
|
||||||
Some errors have detailed explanations: E0080, E0369.
|
|
||||||
For more information about an error, try `rustc --explain E0080`.
|
|
||||||
|
@ -2,5 +2,4 @@ fn main() {
|
|||||||
const N: u32 = 1_000;
|
const N: u32 = 1_000;
|
||||||
const M: usize = (f64::from(N) * std::f64::LOG10_2) as usize; //~ ERROR cannot find value
|
const M: usize = (f64::from(N) * std::f64::LOG10_2) as usize; //~ ERROR cannot find value
|
||||||
let mut digits = [0u32; M];
|
let mut digits = [0u32; M];
|
||||||
//~^ ERROR evaluation of constant value failed
|
|
||||||
}
|
}
|
||||||
|
@ -11,13 +11,6 @@ LL | use std::f32::consts::LOG10_2;
|
|||||||
LL | use std::f64::consts::LOG10_2;
|
LL | use std::f64::consts::LOG10_2;
|
||||||
|
|
|
|
||||||
|
|
||||||
error[E0080]: evaluation of constant value failed
|
error: aborting due to previous error
|
||||||
--> $DIR/issue-50599.rs:4:29
|
|
||||||
|
|
|
||||||
LL | let mut digits = [0u32; M];
|
|
||||||
| ^ referenced constant has errors
|
|
||||||
|
|
||||||
error: aborting due to 2 previous errors
|
For more information about this error, try `rustc --explain E0425`.
|
||||||
|
|
||||||
Some errors have detailed explanations: E0080, E0425.
|
|
||||||
For more information about an error, try `rustc --explain E0080`.
|
|
||||||
|
@ -4,6 +4,5 @@ static A: &'static [u32] = &[1];
|
|||||||
static B: [u32; 1] = [0; A.len()];
|
static B: [u32; 1] = [0; A.len()];
|
||||||
//~^ ERROR [E0013]
|
//~^ ERROR [E0013]
|
||||||
//~| ERROR evaluation of constant value failed
|
//~| ERROR evaluation of constant value failed
|
||||||
//~| ERROR mismatched types
|
|
||||||
|
|
||||||
fn main() {}
|
fn main() {}
|
||||||
|
@ -12,16 +12,7 @@ error[E0080]: evaluation of constant value failed
|
|||||||
LL | static B: [u32; 1] = [0; A.len()];
|
LL | static B: [u32; 1] = [0; A.len()];
|
||||||
| ^ constant accesses static
|
| ^ constant accesses static
|
||||||
|
|
||||||
error[E0308]: mismatched types
|
error: aborting due to 2 previous errors
|
||||||
--> $DIR/issue-52060.rs:4:22
|
|
||||||
|
|
|
||||||
LL | static B: [u32; 1] = [0; A.len()];
|
|
||||||
| ^^^^^^^^^^^^ expected `1usize`, found `A.len()`
|
|
||||||
|
|
|
||||||
= note: expected array `[u32; 1]`
|
|
||||||
found array `[u32; _]`
|
|
||||||
|
|
||||||
error: aborting due to 3 previous errors
|
Some errors have detailed explanations: E0013, E0080.
|
||||||
|
|
||||||
Some errors have detailed explanations: E0013, E0080, E0308.
|
|
||||||
For more information about an error, try `rustc --explain E0013`.
|
For more information about an error, try `rustc --explain E0013`.
|
||||||
|
@ -11,8 +11,6 @@ trait Tt {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn f(z: [f32; ARR_LEN]) -> [f32; ARR_LEN] {
|
fn f(z: [f32; ARR_LEN]) -> [f32; ARR_LEN] {
|
||||||
//~^ ERROR evaluation of constant value failed
|
|
||||||
//~| ERROR evaluation of constant value failed
|
|
||||||
z
|
z
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -15,19 +15,7 @@ LL | const fn const_val<T: Sized>() -> usize {
|
|||||||
|
|
|
|
||||||
= note: cannot satisfy `_: Tt`
|
= note: cannot satisfy `_: Tt`
|
||||||
|
|
||||||
error[E0080]: evaluation of constant value failed
|
error: aborting due to 2 previous errors
|
||||||
--> $DIR/issue-54954.rs:13:15
|
|
||||||
|
|
|
||||||
LL | fn f(z: [f32; ARR_LEN]) -> [f32; ARR_LEN] {
|
|
||||||
| ^^^^^^^ referenced constant has errors
|
|
||||||
|
|
||||||
error[E0080]: evaluation of constant value failed
|
Some errors have detailed explanations: E0283, E0379.
|
||||||
--> $DIR/issue-54954.rs:13:34
|
For more information about an error, try `rustc --explain E0283`.
|
||||||
|
|
|
||||||
LL | fn f(z: [f32; ARR_LEN]) -> [f32; ARR_LEN] {
|
|
||||||
| ^^^^^^^ referenced constant has errors
|
|
||||||
|
|
||||||
error: aborting due to 4 previous errors
|
|
||||||
|
|
||||||
Some errors have detailed explanations: E0080, E0283, E0379.
|
|
||||||
For more information about an error, try `rustc --explain E0080`.
|
|
||||||
|
@ -23,8 +23,7 @@ fn h<const N: usize>() {
|
|||||||
fn i<const N: usize>() {
|
fn i<const N: usize>() {
|
||||||
static a: [u8; N] = [0; N];
|
static a: [u8; N] = [0; N];
|
||||||
//~^ ERROR can't use generic parameters from outer function
|
//~^ ERROR can't use generic parameters from outer function
|
||||||
//~^^ ERROR can't use generic parameters from outer function
|
//~| ERROR can't use generic parameters from outer function
|
||||||
//~| ERROR mismatched types
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() {}
|
fn main() {}
|
||||||
|
@ -48,16 +48,6 @@ LL | #![feature(const_generics)]
|
|||||||
|
|
|
|
||||||
= note: `#[warn(incomplete_features)]` on by default
|
= note: `#[warn(incomplete_features)]` on by default
|
||||||
|
|
||||||
error[E0308]: mismatched types
|
error: aborting due to 5 previous errors; 1 warning emitted
|
||||||
--> $DIR/issue-65035-static-with-parent-generics.rs:24:25
|
|
||||||
|
|
|
||||||
LL | static a: [u8; N] = [0; N];
|
|
||||||
| ^^^^^^ expected `N`, found `N`
|
|
||||||
|
|
|
||||||
= note: expected array `[u8; _]`
|
|
||||||
found array `[u8; _]`
|
|
||||||
|
|
||||||
error: aborting due to 6 previous errors; 1 warning emitted
|
For more information about this error, try `rustc --explain E0401`.
|
||||||
|
|
||||||
Some errors have detailed explanations: E0308, E0401.
|
|
||||||
For more information about an error, try `rustc --explain E0308`.
|
|
||||||
|
@ -2,6 +2,4 @@ fn main() {
|
|||||||
let v = vec![0];
|
let v = vec![0];
|
||||||
const l: usize = v.count(); //~ ERROR attempt to use a non-constant value in a constant
|
const l: usize = v.count(); //~ ERROR attempt to use a non-constant value in a constant
|
||||||
let s: [u32; l] = v.into_iter().collect();
|
let s: [u32; l] = v.into_iter().collect();
|
||||||
//~^ ERROR evaluation of constant value failed
|
|
||||||
//~^^ ERROR a value of type
|
|
||||||
}
|
}
|
||||||
|
@ -4,21 +4,6 @@ error[E0435]: attempt to use a non-constant value in a constant
|
|||||||
LL | const l: usize = v.count();
|
LL | const l: usize = v.count();
|
||||||
| ^ non-constant value
|
| ^ non-constant value
|
||||||
|
|
||||||
error[E0080]: evaluation of constant value failed
|
error: aborting due to previous error
|
||||||
--> $DIR/type-dependent-def-issue-49241.rs:4:18
|
|
||||||
|
|
|
||||||
LL | let s: [u32; l] = v.into_iter().collect();
|
|
||||||
| ^ referenced constant has errors
|
|
||||||
|
|
||||||
error[E0277]: a value of type `[u32; _]` cannot be built from an iterator over elements of type `{integer}`
|
For more information about this error, try `rustc --explain E0435`.
|
||||||
--> $DIR/type-dependent-def-issue-49241.rs:4:37
|
|
||||||
|
|
|
||||||
LL | let s: [u32; l] = v.into_iter().collect();
|
|
||||||
| ^^^^^^^ value of type `[u32; _]` cannot be built from `std::iter::Iterator<Item={integer}>`
|
|
||||||
|
|
|
||||||
= help: the trait `std::iter::FromIterator<{integer}>` is not implemented for `[u32; _]`
|
|
||||||
|
|
||||||
error: aborting due to 3 previous errors
|
|
||||||
|
|
||||||
Some errors have detailed explanations: E0080, E0277, E0435.
|
|
||||||
For more information about an error, try `rustc --explain E0080`.
|
|
||||||
|
Loading…
Reference in New Issue
Block a user