Auto merge of #71201 - Dylan-DPC:rollup-23202uf, r=Dylan-DPC
Rollup of 5 pull requests Successful merges: - #70566 (Don't bail out before linting in generic contexts.) - #71141 (Provide better compiler output when using `?` on `Option` in fn returning `Result` and vice-versa) - #71149 (remove an impossible branch from check_consts) - #71179 (fix more clippy warnings) - #71191 (Clean up E0520 explanation) Failed merges: r? @ghost
This commit is contained in:
commit
7f3df57724
41 changed files with 318 additions and 255 deletions
|
|
@ -1,146 +1,152 @@
|
|||
error: this arithmetic operation will overflow
|
||||
--> $DIR/lint-exceeding-bitshifts.rs:22:13
|
||||
warning: this arithmetic operation will overflow
|
||||
--> $DIR/lint-exceeding-bitshifts.rs:18:20
|
||||
|
|
||||
LL | let _ = x << 42;
|
||||
| ^^^^^^^ attempt to shift left with overflow
|
||||
LL | const N: i32 = T::N << 42;
|
||||
| ^^^^^^^^^^ attempt to shift left with overflow
|
||||
|
|
||||
note: the lint level is defined here
|
||||
--> $DIR/lint-exceeding-bitshifts.rs:9:9
|
||||
|
|
||||
LL | #![deny(arithmetic_overflow, const_err)]
|
||||
LL | #![warn(arithmetic_overflow, const_err)]
|
||||
| ^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: this arithmetic operation will overflow
|
||||
warning: this arithmetic operation will overflow
|
||||
--> $DIR/lint-exceeding-bitshifts.rs:22:13
|
||||
|
|
||||
LL | let _ = x << 42;
|
||||
| ^^^^^^^ attempt to shift left with overflow
|
||||
|
||||
warning: this arithmetic operation will overflow
|
||||
--> $DIR/lint-exceeding-bitshifts.rs:27:15
|
||||
|
|
||||
LL | let n = 1u8 << 8;
|
||||
| ^^^^^^^^ attempt to shift left with overflow
|
||||
|
||||
error: this arithmetic operation will overflow
|
||||
warning: this arithmetic operation will overflow
|
||||
--> $DIR/lint-exceeding-bitshifts.rs:29:15
|
||||
|
|
||||
LL | let n = 1u16 << 16;
|
||||
| ^^^^^^^^^^ attempt to shift left with overflow
|
||||
|
||||
error: this arithmetic operation will overflow
|
||||
warning: this arithmetic operation will overflow
|
||||
--> $DIR/lint-exceeding-bitshifts.rs:31:15
|
||||
|
|
||||
LL | let n = 1u32 << 32;
|
||||
| ^^^^^^^^^^ attempt to shift left with overflow
|
||||
|
||||
error: this arithmetic operation will overflow
|
||||
warning: this arithmetic operation will overflow
|
||||
--> $DIR/lint-exceeding-bitshifts.rs:33:15
|
||||
|
|
||||
LL | let n = 1u64 << 64;
|
||||
| ^^^^^^^^^^ attempt to shift left with overflow
|
||||
|
||||
error: this arithmetic operation will overflow
|
||||
warning: this arithmetic operation will overflow
|
||||
--> $DIR/lint-exceeding-bitshifts.rs:35:15
|
||||
|
|
||||
LL | let n = 1i8 << 8;
|
||||
| ^^^^^^^^ attempt to shift left with overflow
|
||||
|
||||
error: this arithmetic operation will overflow
|
||||
warning: this arithmetic operation will overflow
|
||||
--> $DIR/lint-exceeding-bitshifts.rs:37:15
|
||||
|
|
||||
LL | let n = 1i16 << 16;
|
||||
| ^^^^^^^^^^ attempt to shift left with overflow
|
||||
|
||||
error: this arithmetic operation will overflow
|
||||
warning: this arithmetic operation will overflow
|
||||
--> $DIR/lint-exceeding-bitshifts.rs:39:15
|
||||
|
|
||||
LL | let n = 1i32 << 32;
|
||||
| ^^^^^^^^^^ attempt to shift left with overflow
|
||||
|
||||
error: this arithmetic operation will overflow
|
||||
warning: this arithmetic operation will overflow
|
||||
--> $DIR/lint-exceeding-bitshifts.rs:41:15
|
||||
|
|
||||
LL | let n = 1i64 << 64;
|
||||
| ^^^^^^^^^^ attempt to shift left with overflow
|
||||
|
||||
error: this arithmetic operation will overflow
|
||||
warning: this arithmetic operation will overflow
|
||||
--> $DIR/lint-exceeding-bitshifts.rs:44:15
|
||||
|
|
||||
LL | let n = 1u8 >> 8;
|
||||
| ^^^^^^^^ attempt to shift right with overflow
|
||||
|
||||
error: this arithmetic operation will overflow
|
||||
warning: this arithmetic operation will overflow
|
||||
--> $DIR/lint-exceeding-bitshifts.rs:46:15
|
||||
|
|
||||
LL | let n = 1u16 >> 16;
|
||||
| ^^^^^^^^^^ attempt to shift right with overflow
|
||||
|
||||
error: this arithmetic operation will overflow
|
||||
warning: this arithmetic operation will overflow
|
||||
--> $DIR/lint-exceeding-bitshifts.rs:48:15
|
||||
|
|
||||
LL | let n = 1u32 >> 32;
|
||||
| ^^^^^^^^^^ attempt to shift right with overflow
|
||||
|
||||
error: this arithmetic operation will overflow
|
||||
warning: this arithmetic operation will overflow
|
||||
--> $DIR/lint-exceeding-bitshifts.rs:50:15
|
||||
|
|
||||
LL | let n = 1u64 >> 64;
|
||||
| ^^^^^^^^^^ attempt to shift right with overflow
|
||||
|
||||
error: this arithmetic operation will overflow
|
||||
warning: this arithmetic operation will overflow
|
||||
--> $DIR/lint-exceeding-bitshifts.rs:52:15
|
||||
|
|
||||
LL | let n = 1i8 >> 8;
|
||||
| ^^^^^^^^ attempt to shift right with overflow
|
||||
|
||||
error: this arithmetic operation will overflow
|
||||
warning: this arithmetic operation will overflow
|
||||
--> $DIR/lint-exceeding-bitshifts.rs:54:15
|
||||
|
|
||||
LL | let n = 1i16 >> 16;
|
||||
| ^^^^^^^^^^ attempt to shift right with overflow
|
||||
|
||||
error: this arithmetic operation will overflow
|
||||
warning: this arithmetic operation will overflow
|
||||
--> $DIR/lint-exceeding-bitshifts.rs:56:15
|
||||
|
|
||||
LL | let n = 1i32 >> 32;
|
||||
| ^^^^^^^^^^ attempt to shift right with overflow
|
||||
|
||||
error: this arithmetic operation will overflow
|
||||
warning: this arithmetic operation will overflow
|
||||
--> $DIR/lint-exceeding-bitshifts.rs:58:15
|
||||
|
|
||||
LL | let n = 1i64 >> 64;
|
||||
| ^^^^^^^^^^ attempt to shift right with overflow
|
||||
|
||||
error: this arithmetic operation will overflow
|
||||
warning: this arithmetic operation will overflow
|
||||
--> $DIR/lint-exceeding-bitshifts.rs:62:15
|
||||
|
|
||||
LL | let n = n << 8;
|
||||
| ^^^^^^ attempt to shift left with overflow
|
||||
|
||||
error: this arithmetic operation will overflow
|
||||
warning: this arithmetic operation will overflow
|
||||
--> $DIR/lint-exceeding-bitshifts.rs:64:15
|
||||
|
|
||||
LL | let n = 1u8 << -8;
|
||||
| ^^^^^^^^^ attempt to shift left with overflow
|
||||
|
||||
error: this arithmetic operation will overflow
|
||||
warning: this arithmetic operation will overflow
|
||||
--> $DIR/lint-exceeding-bitshifts.rs:69:15
|
||||
|
|
||||
LL | let n = 1u8 << (4+4);
|
||||
| ^^^^^^^^^^^^ attempt to shift left with overflow
|
||||
|
||||
error: this arithmetic operation will overflow
|
||||
warning: this arithmetic operation will overflow
|
||||
--> $DIR/lint-exceeding-bitshifts.rs:71:15
|
||||
|
|
||||
LL | let n = 1i64 >> [64][0];
|
||||
| ^^^^^^^^^^^^^^^ attempt to shift right with overflow
|
||||
|
||||
error: this arithmetic operation will overflow
|
||||
warning: this arithmetic operation will overflow
|
||||
--> $DIR/lint-exceeding-bitshifts.rs:77:15
|
||||
|
|
||||
LL | let n = 1_isize << BITS;
|
||||
| ^^^^^^^^^^^^^^^ attempt to shift left with overflow
|
||||
|
||||
error: this arithmetic operation will overflow
|
||||
warning: this arithmetic operation will overflow
|
||||
--> $DIR/lint-exceeding-bitshifts.rs:78:15
|
||||
|
|
||||
LL | let n = 1_usize << BITS;
|
||||
| ^^^^^^^^^^^^^^^ attempt to shift left with overflow
|
||||
|
||||
error: aborting due to 23 previous errors
|
||||
warning: 24 warnings emitted
|
||||
|
||||
|
|
|
|||
|
|
@ -1,146 +1,152 @@
|
|||
error: this arithmetic operation will overflow
|
||||
--> $DIR/lint-exceeding-bitshifts.rs:22:13
|
||||
warning: this arithmetic operation will overflow
|
||||
--> $DIR/lint-exceeding-bitshifts.rs:18:20
|
||||
|
|
||||
LL | let _ = x << 42;
|
||||
| ^^^^^^^ attempt to shift left with overflow
|
||||
LL | const N: i32 = T::N << 42;
|
||||
| ^^^^^^^^^^ attempt to shift left with overflow
|
||||
|
|
||||
note: the lint level is defined here
|
||||
--> $DIR/lint-exceeding-bitshifts.rs:9:9
|
||||
|
|
||||
LL | #![deny(arithmetic_overflow, const_err)]
|
||||
LL | #![warn(arithmetic_overflow, const_err)]
|
||||
| ^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: this arithmetic operation will overflow
|
||||
warning: this arithmetic operation will overflow
|
||||
--> $DIR/lint-exceeding-bitshifts.rs:22:13
|
||||
|
|
||||
LL | let _ = x << 42;
|
||||
| ^^^^^^^ attempt to shift left with overflow
|
||||
|
||||
warning: this arithmetic operation will overflow
|
||||
--> $DIR/lint-exceeding-bitshifts.rs:27:15
|
||||
|
|
||||
LL | let n = 1u8 << 8;
|
||||
| ^^^^^^^^ attempt to shift left with overflow
|
||||
|
||||
error: this arithmetic operation will overflow
|
||||
warning: this arithmetic operation will overflow
|
||||
--> $DIR/lint-exceeding-bitshifts.rs:29:15
|
||||
|
|
||||
LL | let n = 1u16 << 16;
|
||||
| ^^^^^^^^^^ attempt to shift left with overflow
|
||||
|
||||
error: this arithmetic operation will overflow
|
||||
warning: this arithmetic operation will overflow
|
||||
--> $DIR/lint-exceeding-bitshifts.rs:31:15
|
||||
|
|
||||
LL | let n = 1u32 << 32;
|
||||
| ^^^^^^^^^^ attempt to shift left with overflow
|
||||
|
||||
error: this arithmetic operation will overflow
|
||||
warning: this arithmetic operation will overflow
|
||||
--> $DIR/lint-exceeding-bitshifts.rs:33:15
|
||||
|
|
||||
LL | let n = 1u64 << 64;
|
||||
| ^^^^^^^^^^ attempt to shift left with overflow
|
||||
|
||||
error: this arithmetic operation will overflow
|
||||
warning: this arithmetic operation will overflow
|
||||
--> $DIR/lint-exceeding-bitshifts.rs:35:15
|
||||
|
|
||||
LL | let n = 1i8 << 8;
|
||||
| ^^^^^^^^ attempt to shift left with overflow
|
||||
|
||||
error: this arithmetic operation will overflow
|
||||
warning: this arithmetic operation will overflow
|
||||
--> $DIR/lint-exceeding-bitshifts.rs:37:15
|
||||
|
|
||||
LL | let n = 1i16 << 16;
|
||||
| ^^^^^^^^^^ attempt to shift left with overflow
|
||||
|
||||
error: this arithmetic operation will overflow
|
||||
warning: this arithmetic operation will overflow
|
||||
--> $DIR/lint-exceeding-bitshifts.rs:39:15
|
||||
|
|
||||
LL | let n = 1i32 << 32;
|
||||
| ^^^^^^^^^^ attempt to shift left with overflow
|
||||
|
||||
error: this arithmetic operation will overflow
|
||||
warning: this arithmetic operation will overflow
|
||||
--> $DIR/lint-exceeding-bitshifts.rs:41:15
|
||||
|
|
||||
LL | let n = 1i64 << 64;
|
||||
| ^^^^^^^^^^ attempt to shift left with overflow
|
||||
|
||||
error: this arithmetic operation will overflow
|
||||
warning: this arithmetic operation will overflow
|
||||
--> $DIR/lint-exceeding-bitshifts.rs:44:15
|
||||
|
|
||||
LL | let n = 1u8 >> 8;
|
||||
| ^^^^^^^^ attempt to shift right with overflow
|
||||
|
||||
error: this arithmetic operation will overflow
|
||||
warning: this arithmetic operation will overflow
|
||||
--> $DIR/lint-exceeding-bitshifts.rs:46:15
|
||||
|
|
||||
LL | let n = 1u16 >> 16;
|
||||
| ^^^^^^^^^^ attempt to shift right with overflow
|
||||
|
||||
error: this arithmetic operation will overflow
|
||||
warning: this arithmetic operation will overflow
|
||||
--> $DIR/lint-exceeding-bitshifts.rs:48:15
|
||||
|
|
||||
LL | let n = 1u32 >> 32;
|
||||
| ^^^^^^^^^^ attempt to shift right with overflow
|
||||
|
||||
error: this arithmetic operation will overflow
|
||||
warning: this arithmetic operation will overflow
|
||||
--> $DIR/lint-exceeding-bitshifts.rs:50:15
|
||||
|
|
||||
LL | let n = 1u64 >> 64;
|
||||
| ^^^^^^^^^^ attempt to shift right with overflow
|
||||
|
||||
error: this arithmetic operation will overflow
|
||||
warning: this arithmetic operation will overflow
|
||||
--> $DIR/lint-exceeding-bitshifts.rs:52:15
|
||||
|
|
||||
LL | let n = 1i8 >> 8;
|
||||
| ^^^^^^^^ attempt to shift right with overflow
|
||||
|
||||
error: this arithmetic operation will overflow
|
||||
warning: this arithmetic operation will overflow
|
||||
--> $DIR/lint-exceeding-bitshifts.rs:54:15
|
||||
|
|
||||
LL | let n = 1i16 >> 16;
|
||||
| ^^^^^^^^^^ attempt to shift right with overflow
|
||||
|
||||
error: this arithmetic operation will overflow
|
||||
warning: this arithmetic operation will overflow
|
||||
--> $DIR/lint-exceeding-bitshifts.rs:56:15
|
||||
|
|
||||
LL | let n = 1i32 >> 32;
|
||||
| ^^^^^^^^^^ attempt to shift right with overflow
|
||||
|
||||
error: this arithmetic operation will overflow
|
||||
warning: this arithmetic operation will overflow
|
||||
--> $DIR/lint-exceeding-bitshifts.rs:58:15
|
||||
|
|
||||
LL | let n = 1i64 >> 64;
|
||||
| ^^^^^^^^^^ attempt to shift right with overflow
|
||||
|
||||
error: this arithmetic operation will overflow
|
||||
warning: this arithmetic operation will overflow
|
||||
--> $DIR/lint-exceeding-bitshifts.rs:62:15
|
||||
|
|
||||
LL | let n = n << 8;
|
||||
| ^^^^^^ attempt to shift left with overflow
|
||||
|
||||
error: this arithmetic operation will overflow
|
||||
warning: this arithmetic operation will overflow
|
||||
--> $DIR/lint-exceeding-bitshifts.rs:64:15
|
||||
|
|
||||
LL | let n = 1u8 << -8;
|
||||
| ^^^^^^^^^ attempt to shift left with overflow
|
||||
|
||||
error: this arithmetic operation will overflow
|
||||
warning: this arithmetic operation will overflow
|
||||
--> $DIR/lint-exceeding-bitshifts.rs:69:15
|
||||
|
|
||||
LL | let n = 1u8 << (4+4);
|
||||
| ^^^^^^^^^^^^ attempt to shift left with overflow
|
||||
|
||||
error: this arithmetic operation will overflow
|
||||
warning: this arithmetic operation will overflow
|
||||
--> $DIR/lint-exceeding-bitshifts.rs:71:15
|
||||
|
|
||||
LL | let n = 1i64 >> [64][0];
|
||||
| ^^^^^^^^^^^^^^^ attempt to shift right with overflow
|
||||
|
||||
error: this arithmetic operation will overflow
|
||||
warning: this arithmetic operation will overflow
|
||||
--> $DIR/lint-exceeding-bitshifts.rs:77:15
|
||||
|
|
||||
LL | let n = 1_isize << BITS;
|
||||
| ^^^^^^^^^^^^^^^ attempt to shift left with overflow
|
||||
|
||||
error: this arithmetic operation will overflow
|
||||
warning: this arithmetic operation will overflow
|
||||
--> $DIR/lint-exceeding-bitshifts.rs:78:15
|
||||
|
|
||||
LL | let n = 1_usize << BITS;
|
||||
| ^^^^^^^^^^^^^^^ attempt to shift left with overflow
|
||||
|
||||
error: aborting due to 23 previous errors
|
||||
warning: 24 warnings emitted
|
||||
|
||||
|
|
|
|||
|
|
@ -1,146 +1,152 @@
|
|||
error: this arithmetic operation will overflow
|
||||
--> $DIR/lint-exceeding-bitshifts.rs:22:13
|
||||
warning: this arithmetic operation will overflow
|
||||
--> $DIR/lint-exceeding-bitshifts.rs:18:20
|
||||
|
|
||||
LL | let _ = x << 42;
|
||||
| ^^^^^^^ attempt to shift left with overflow
|
||||
LL | const N: i32 = T::N << 42;
|
||||
| ^^^^^^^^^^ attempt to shift left with overflow
|
||||
|
|
||||
note: the lint level is defined here
|
||||
--> $DIR/lint-exceeding-bitshifts.rs:9:9
|
||||
|
|
||||
LL | #![deny(arithmetic_overflow, const_err)]
|
||||
LL | #![warn(arithmetic_overflow, const_err)]
|
||||
| ^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: this arithmetic operation will overflow
|
||||
warning: this arithmetic operation will overflow
|
||||
--> $DIR/lint-exceeding-bitshifts.rs:22:13
|
||||
|
|
||||
LL | let _ = x << 42;
|
||||
| ^^^^^^^ attempt to shift left with overflow
|
||||
|
||||
warning: this arithmetic operation will overflow
|
||||
--> $DIR/lint-exceeding-bitshifts.rs:27:15
|
||||
|
|
||||
LL | let n = 1u8 << 8;
|
||||
| ^^^^^^^^ attempt to shift left with overflow
|
||||
|
||||
error: this arithmetic operation will overflow
|
||||
warning: this arithmetic operation will overflow
|
||||
--> $DIR/lint-exceeding-bitshifts.rs:29:15
|
||||
|
|
||||
LL | let n = 1u16 << 16;
|
||||
| ^^^^^^^^^^ attempt to shift left with overflow
|
||||
|
||||
error: this arithmetic operation will overflow
|
||||
warning: this arithmetic operation will overflow
|
||||
--> $DIR/lint-exceeding-bitshifts.rs:31:15
|
||||
|
|
||||
LL | let n = 1u32 << 32;
|
||||
| ^^^^^^^^^^ attempt to shift left with overflow
|
||||
|
||||
error: this arithmetic operation will overflow
|
||||
warning: this arithmetic operation will overflow
|
||||
--> $DIR/lint-exceeding-bitshifts.rs:33:15
|
||||
|
|
||||
LL | let n = 1u64 << 64;
|
||||
| ^^^^^^^^^^ attempt to shift left with overflow
|
||||
|
||||
error: this arithmetic operation will overflow
|
||||
warning: this arithmetic operation will overflow
|
||||
--> $DIR/lint-exceeding-bitshifts.rs:35:15
|
||||
|
|
||||
LL | let n = 1i8 << 8;
|
||||
| ^^^^^^^^ attempt to shift left with overflow
|
||||
|
||||
error: this arithmetic operation will overflow
|
||||
warning: this arithmetic operation will overflow
|
||||
--> $DIR/lint-exceeding-bitshifts.rs:37:15
|
||||
|
|
||||
LL | let n = 1i16 << 16;
|
||||
| ^^^^^^^^^^ attempt to shift left with overflow
|
||||
|
||||
error: this arithmetic operation will overflow
|
||||
warning: this arithmetic operation will overflow
|
||||
--> $DIR/lint-exceeding-bitshifts.rs:39:15
|
||||
|
|
||||
LL | let n = 1i32 << 32;
|
||||
| ^^^^^^^^^^ attempt to shift left with overflow
|
||||
|
||||
error: this arithmetic operation will overflow
|
||||
warning: this arithmetic operation will overflow
|
||||
--> $DIR/lint-exceeding-bitshifts.rs:41:15
|
||||
|
|
||||
LL | let n = 1i64 << 64;
|
||||
| ^^^^^^^^^^ attempt to shift left with overflow
|
||||
|
||||
error: this arithmetic operation will overflow
|
||||
warning: this arithmetic operation will overflow
|
||||
--> $DIR/lint-exceeding-bitshifts.rs:44:15
|
||||
|
|
||||
LL | let n = 1u8 >> 8;
|
||||
| ^^^^^^^^ attempt to shift right with overflow
|
||||
|
||||
error: this arithmetic operation will overflow
|
||||
warning: this arithmetic operation will overflow
|
||||
--> $DIR/lint-exceeding-bitshifts.rs:46:15
|
||||
|
|
||||
LL | let n = 1u16 >> 16;
|
||||
| ^^^^^^^^^^ attempt to shift right with overflow
|
||||
|
||||
error: this arithmetic operation will overflow
|
||||
warning: this arithmetic operation will overflow
|
||||
--> $DIR/lint-exceeding-bitshifts.rs:48:15
|
||||
|
|
||||
LL | let n = 1u32 >> 32;
|
||||
| ^^^^^^^^^^ attempt to shift right with overflow
|
||||
|
||||
error: this arithmetic operation will overflow
|
||||
warning: this arithmetic operation will overflow
|
||||
--> $DIR/lint-exceeding-bitshifts.rs:50:15
|
||||
|
|
||||
LL | let n = 1u64 >> 64;
|
||||
| ^^^^^^^^^^ attempt to shift right with overflow
|
||||
|
||||
error: this arithmetic operation will overflow
|
||||
warning: this arithmetic operation will overflow
|
||||
--> $DIR/lint-exceeding-bitshifts.rs:52:15
|
||||
|
|
||||
LL | let n = 1i8 >> 8;
|
||||
| ^^^^^^^^ attempt to shift right with overflow
|
||||
|
||||
error: this arithmetic operation will overflow
|
||||
warning: this arithmetic operation will overflow
|
||||
--> $DIR/lint-exceeding-bitshifts.rs:54:15
|
||||
|
|
||||
LL | let n = 1i16 >> 16;
|
||||
| ^^^^^^^^^^ attempt to shift right with overflow
|
||||
|
||||
error: this arithmetic operation will overflow
|
||||
warning: this arithmetic operation will overflow
|
||||
--> $DIR/lint-exceeding-bitshifts.rs:56:15
|
||||
|
|
||||
LL | let n = 1i32 >> 32;
|
||||
| ^^^^^^^^^^ attempt to shift right with overflow
|
||||
|
||||
error: this arithmetic operation will overflow
|
||||
warning: this arithmetic operation will overflow
|
||||
--> $DIR/lint-exceeding-bitshifts.rs:58:15
|
||||
|
|
||||
LL | let n = 1i64 >> 64;
|
||||
| ^^^^^^^^^^ attempt to shift right with overflow
|
||||
|
||||
error: this arithmetic operation will overflow
|
||||
warning: this arithmetic operation will overflow
|
||||
--> $DIR/lint-exceeding-bitshifts.rs:62:15
|
||||
|
|
||||
LL | let n = n << 8;
|
||||
| ^^^^^^ attempt to shift left with overflow
|
||||
|
||||
error: this arithmetic operation will overflow
|
||||
warning: this arithmetic operation will overflow
|
||||
--> $DIR/lint-exceeding-bitshifts.rs:64:15
|
||||
|
|
||||
LL | let n = 1u8 << -8;
|
||||
| ^^^^^^^^^ attempt to shift left with overflow
|
||||
|
||||
error: this arithmetic operation will overflow
|
||||
warning: this arithmetic operation will overflow
|
||||
--> $DIR/lint-exceeding-bitshifts.rs:69:15
|
||||
|
|
||||
LL | let n = 1u8 << (4+4);
|
||||
| ^^^^^^^^^^^^ attempt to shift left with overflow
|
||||
|
||||
error: this arithmetic operation will overflow
|
||||
warning: this arithmetic operation will overflow
|
||||
--> $DIR/lint-exceeding-bitshifts.rs:71:15
|
||||
|
|
||||
LL | let n = 1i64 >> [64][0];
|
||||
| ^^^^^^^^^^^^^^^ attempt to shift right with overflow
|
||||
|
||||
error: this arithmetic operation will overflow
|
||||
warning: this arithmetic operation will overflow
|
||||
--> $DIR/lint-exceeding-bitshifts.rs:77:15
|
||||
|
|
||||
LL | let n = 1_isize << BITS;
|
||||
| ^^^^^^^^^^^^^^^ attempt to shift left with overflow
|
||||
|
||||
error: this arithmetic operation will overflow
|
||||
warning: this arithmetic operation will overflow
|
||||
--> $DIR/lint-exceeding-bitshifts.rs:78:15
|
||||
|
|
||||
LL | let n = 1_usize << BITS;
|
||||
| ^^^^^^^^^^^^^^^ attempt to shift left with overflow
|
||||
|
||||
error: aborting due to 23 previous errors
|
||||
warning: 24 warnings emitted
|
||||
|
||||
|
|
|
|||
|
|
@ -3,10 +3,10 @@
|
|||
//[opt]compile-flags: -O
|
||||
//[opt_with_overflow_checks]compile-flags: -C overflow-checks=on -O
|
||||
|
||||
// build-fail
|
||||
// build-pass
|
||||
|
||||
#![crate_type="lib"]
|
||||
#![deny(arithmetic_overflow, const_err)]
|
||||
#![warn(arithmetic_overflow, const_err)]
|
||||
#![allow(unused_variables)]
|
||||
#![allow(dead_code)]
|
||||
|
||||
|
|
@ -15,65 +15,65 @@ pub trait Foo {
|
|||
}
|
||||
|
||||
impl<T: Foo> Foo for Vec<T> {
|
||||
const N: i32 = T::N << 42; // FIXME this should warn
|
||||
const N: i32 = T::N << 42; //~ WARN: arithmetic operation will overflow
|
||||
}
|
||||
|
||||
pub fn foo(x: i32) {
|
||||
let _ = x << 42; //~ ERROR: arithmetic operation will overflow
|
||||
let _ = x << 42; //~ WARN: arithmetic operation will overflow
|
||||
}
|
||||
|
||||
pub fn main() {
|
||||
let n = 1u8 << 7;
|
||||
let n = 1u8 << 8; //~ ERROR: arithmetic operation will overflow
|
||||
let n = 1u8 << 8; //~ WARN: arithmetic operation will overflow
|
||||
let n = 1u16 << 15;
|
||||
let n = 1u16 << 16; //~ ERROR: arithmetic operation will overflow
|
||||
let n = 1u16 << 16; //~ WARN: arithmetic operation will overflow
|
||||
let n = 1u32 << 31;
|
||||
let n = 1u32 << 32; //~ ERROR: arithmetic operation will overflow
|
||||
let n = 1u32 << 32; //~ WARN: arithmetic operation will overflow
|
||||
let n = 1u64 << 63;
|
||||
let n = 1u64 << 64; //~ ERROR: arithmetic operation will overflow
|
||||
let n = 1u64 << 64; //~ WARN: arithmetic operation will overflow
|
||||
let n = 1i8 << 7;
|
||||
let n = 1i8 << 8; //~ ERROR: arithmetic operation will overflow
|
||||
let n = 1i8 << 8; //~ WARN: arithmetic operation will overflow
|
||||
let n = 1i16 << 15;
|
||||
let n = 1i16 << 16; //~ ERROR: arithmetic operation will overflow
|
||||
let n = 1i16 << 16; //~ WARN: arithmetic operation will overflow
|
||||
let n = 1i32 << 31;
|
||||
let n = 1i32 << 32; //~ ERROR: arithmetic operation will overflow
|
||||
let n = 1i32 << 32; //~ WARN: arithmetic operation will overflow
|
||||
let n = 1i64 << 63;
|
||||
let n = 1i64 << 64; //~ ERROR: arithmetic operation will overflow
|
||||
let n = 1i64 << 64; //~ WARN: arithmetic operation will overflow
|
||||
|
||||
let n = 1u8 >> 7;
|
||||
let n = 1u8 >> 8; //~ ERROR: arithmetic operation will overflow
|
||||
let n = 1u8 >> 8; //~ WARN: arithmetic operation will overflow
|
||||
let n = 1u16 >> 15;
|
||||
let n = 1u16 >> 16; //~ ERROR: arithmetic operation will overflow
|
||||
let n = 1u16 >> 16; //~ WARN: arithmetic operation will overflow
|
||||
let n = 1u32 >> 31;
|
||||
let n = 1u32 >> 32; //~ ERROR: arithmetic operation will overflow
|
||||
let n = 1u32 >> 32; //~ WARN: arithmetic operation will overflow
|
||||
let n = 1u64 >> 63;
|
||||
let n = 1u64 >> 64; //~ ERROR: arithmetic operation will overflow
|
||||
let n = 1u64 >> 64; //~ WARN: arithmetic operation will overflow
|
||||
let n = 1i8 >> 7;
|
||||
let n = 1i8 >> 8; //~ ERROR: arithmetic operation will overflow
|
||||
let n = 1i8 >> 8; //~ WARN: arithmetic operation will overflow
|
||||
let n = 1i16 >> 15;
|
||||
let n = 1i16 >> 16; //~ ERROR: arithmetic operation will overflow
|
||||
let n = 1i16 >> 16; //~ WARN: arithmetic operation will overflow
|
||||
let n = 1i32 >> 31;
|
||||
let n = 1i32 >> 32; //~ ERROR: arithmetic operation will overflow
|
||||
let n = 1i32 >> 32; //~ WARN: arithmetic operation will overflow
|
||||
let n = 1i64 >> 63;
|
||||
let n = 1i64 >> 64; //~ ERROR: arithmetic operation will overflow
|
||||
let n = 1i64 >> 64; //~ WARN: arithmetic operation will overflow
|
||||
|
||||
let n = 1u8;
|
||||
let n = n << 7;
|
||||
let n = n << 8; //~ ERROR: arithmetic operation will overflow
|
||||
let n = n << 8; //~ WARN: arithmetic operation will overflow
|
||||
|
||||
let n = 1u8 << -8; //~ ERROR: arithmetic operation will overflow
|
||||
let n = 1u8 << -8; //~ WARN: arithmetic operation will overflow
|
||||
|
||||
let n = 1i8<<(1isize+-1);
|
||||
|
||||
let n = 1u8 << (4+3);
|
||||
let n = 1u8 << (4+4); //~ ERROR: arithmetic operation will overflow
|
||||
let n = 1u8 << (4+4); //~ WARN: arithmetic operation will overflow
|
||||
let n = 1i64 >> [63][0];
|
||||
let n = 1i64 >> [64][0]; //~ ERROR: arithmetic operation will overflow
|
||||
let n = 1i64 >> [64][0]; //~ WARN: arithmetic operation will overflow
|
||||
|
||||
#[cfg(target_pointer_width = "32")]
|
||||
const BITS: usize = 32;
|
||||
#[cfg(target_pointer_width = "64")]
|
||||
const BITS: usize = 64;
|
||||
let n = 1_isize << BITS; //~ ERROR: arithmetic operation will overflow
|
||||
let n = 1_usize << BITS; //~ ERROR: arithmetic operation will overflow
|
||||
let n = 1_isize << BITS; //~ WARN: arithmetic operation will overflow
|
||||
let n = 1_usize << BITS; //~ WARN: arithmetic operation will overflow
|
||||
}
|
||||
|
|
|
|||
13
src/test/ui/option-to-result.rs
Normal file
13
src/test/ui/option-to-result.rs
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
fn main(){ }
|
||||
|
||||
fn test_result() -> Result<(),()> {
|
||||
let a:Option<()> = Some(());
|
||||
a?;//~ ERROR `?` couldn't convert the error
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn test_option() -> Option<i32>{
|
||||
let a:Result<i32, i32> = Ok(5);
|
||||
a?;//~ ERROR `?` couldn't convert the error
|
||||
Some(5)
|
||||
}
|
||||
29
src/test/ui/option-to-result.stderr
Normal file
29
src/test/ui/option-to-result.stderr
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
error[E0277]: `?` couldn't convert the error to `()`
|
||||
--> $DIR/option-to-result.rs:5:6
|
||||
|
|
||||
LL | a?;
|
||||
| ^ the trait `std::convert::From<std::option::NoneError>` is not implemented for `()`
|
||||
|
|
||||
= note: the question mark operation (`?`) implicitly performs a conversion on the error value using the `From` trait
|
||||
= note: required by `std::convert::From::from`
|
||||
help: consider converting the `Option<T>` into a `Result<T, _>` using `Option::ok_or` or `Option::ok_or_else`
|
||||
|
|
||||
LL | a.ok_or_else(|| /* error value */)?;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error[E0277]: `?` couldn't convert the error to `std::option::NoneError`
|
||||
--> $DIR/option-to-result.rs:11:6
|
||||
|
|
||||
LL | a?;
|
||||
| ^ the trait `std::convert::From<i32>` is not implemented for `std::option::NoneError`
|
||||
|
|
||||
= note: the question mark operation (`?`) implicitly performs a conversion on the error value using the `From` trait
|
||||
= note: required by `std::convert::From::from`
|
||||
help: consider converting the `Result<T, _>` into an `Option<T>` using `Result::ok`
|
||||
|
|
||||
LL | a.ok()?;
|
||||
| ^^^^^
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0277`.
|
||||
|
|
@ -6,6 +6,10 @@ LL | x?;
|
|||
|
|
||||
= note: the question mark operation (`?`) implicitly performs a conversion on the error value using the `From` trait
|
||||
= note: required by `std::convert::From::from`
|
||||
help: consider converting the `Option<T>` into a `Result<T, _>` using `Option::ok_or` or `Option::ok_or_else`
|
||||
|
|
||||
LL | x.ok_or_else(|| /* error value */)?;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error[E0277]: the `?` operator can only be used in a function that returns `Result` or `Option` (or another type that implements `std::ops::Try`)
|
||||
--> $DIR/try-on-option.rs:13:5
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue