Move tests from test/run-fail
to UI
This commit is contained in:
parent
43271a39ad
commit
e69748ba4f
160 changed files with 404 additions and 125 deletions
|
@ -1,24 +0,0 @@
|
|||
// error-pattern:quux
|
||||
|
||||
use std::marker::PhantomData;
|
||||
|
||||
fn test00_start(ch: chan_t<isize>, message: isize) {
|
||||
send(ch, message);
|
||||
}
|
||||
|
||||
type task_id = isize;
|
||||
type port_id = isize;
|
||||
|
||||
struct chan_t<T> {
|
||||
task: task_id,
|
||||
port: port_id,
|
||||
marker: PhantomData<*mut T>,
|
||||
}
|
||||
|
||||
fn send<T: Send>(_ch: chan_t<T>, _data: T) {
|
||||
panic!();
|
||||
}
|
||||
|
||||
fn main() {
|
||||
panic!("quux");
|
||||
}
|
|
@ -1,9 +0,0 @@
|
|||
// error-pattern:thread 'main' panicked at 'attempt to shift left with overflow'
|
||||
// compile-flags: -C debug-assertions
|
||||
|
||||
#![warn(arithmetic_overflow)]
|
||||
#![warn(const_err)]
|
||||
|
||||
fn main() {
|
||||
let _x = 1_i32 << 32;
|
||||
}
|
|
@ -1,9 +0,0 @@
|
|||
// error-pattern:thread 'main' panicked at 'attempt to shift left with overflow'
|
||||
// compile-flags: -C debug-assertions
|
||||
|
||||
#![warn(arithmetic_overflow)]
|
||||
#![warn(const_err)]
|
||||
|
||||
fn main() {
|
||||
let _x = 1 << -1;
|
||||
}
|
|
@ -1,9 +0,0 @@
|
|||
// error-pattern:thread 'main' panicked at 'attempt to shift left with overflow'
|
||||
// compile-flags: -C debug-assertions
|
||||
|
||||
#![warn(arithmetic_overflow)]
|
||||
#![warn(const_err)]
|
||||
|
||||
fn main() {
|
||||
let _x = 1_u64 << 64;
|
||||
}
|
|
@ -1,9 +0,0 @@
|
|||
// error-pattern:thread 'main' panicked at 'attempt to shift right with overflow'
|
||||
// compile-flags: -C debug-assertions
|
||||
|
||||
#![warn(arithmetic_overflow)]
|
||||
#![warn(const_err)]
|
||||
|
||||
fn main() {
|
||||
let _x = -1_i32 >> 32;
|
||||
}
|
|
@ -1,9 +0,0 @@
|
|||
// error-pattern:thread 'main' panicked at 'attempt to shift right with overflow'
|
||||
// compile-flags: -C debug-assertions
|
||||
|
||||
#![warn(arithmetic_overflow)]
|
||||
#![warn(const_err)]
|
||||
|
||||
fn main() {
|
||||
let _x = -1_i32 >> -1;
|
||||
}
|
|
@ -1,9 +0,0 @@
|
|||
// error-pattern:thread 'main' panicked at 'attempt to shift right with overflow'
|
||||
// compile-flags: -C debug-assertions
|
||||
|
||||
#![warn(arithmetic_overflow)]
|
||||
#![warn(const_err)]
|
||||
|
||||
fn main() {
|
||||
let _x = -1_i64 >> 64;
|
||||
}
|
|
@ -1,9 +0,0 @@
|
|||
// error-pattern:thread 'main' panicked at 'attempt to shift right with overflow'
|
||||
// compile-flags: -C debug-assertions
|
||||
|
||||
#![warn(arithmetic_overflow)]
|
||||
#![warn(const_err)]
|
||||
|
||||
fn main() {
|
||||
let _n = 1i64 >> [64][0];
|
||||
}
|
|
@ -1,10 +0,0 @@
|
|||
// error-pattern:thread 'main' panicked at 'attempt to shift right with overflow'
|
||||
// compile-flags: -C debug-assertions
|
||||
|
||||
#![warn(arithmetic_overflow)]
|
||||
#![warn(const_err)]
|
||||
#![feature(const_indexing)]
|
||||
|
||||
fn main() {
|
||||
let _n = 1i64 >> [64][0];
|
||||
}
|
|
@ -1,3 +1,4 @@
|
|||
// run-fail
|
||||
// error-pattern:index out of bounds
|
||||
|
||||
use std::usize;
|
|
@ -1,4 +1,6 @@
|
|||
// Test bounds checking for DST raw slices
|
||||
|
||||
// run-fail
|
||||
// error-pattern:index out of bounds
|
||||
#[allow(unconditional_panic)]
|
||||
fn main() {
|
|
@ -1,9 +1,10 @@
|
|||
// run-fail
|
||||
// error-pattern:quux
|
||||
|
||||
fn foo() -> ! {
|
||||
panic!("quux");
|
||||
}
|
||||
|
||||
#[allow(resolve_trait_on_defaulted_unit)]
|
||||
fn main() {
|
||||
foo() == foo(); // these types wind up being defaulted to ()
|
||||
}
|
|
@ -1,8 +1,11 @@
|
|||
// run-fail
|
||||
// error-pattern:quux
|
||||
|
||||
fn my_err(s: String) -> ! {
|
||||
println!("{}", s);
|
||||
panic!("quux");
|
||||
}
|
||||
|
||||
fn main() {
|
||||
3_usize == my_err("bye".to_string());
|
||||
}
|
|
@ -1,3 +1,4 @@
|
|||
// run-fail
|
||||
// error-pattern:panic 1
|
||||
|
||||
// revisions: migrate mir
|
|
@ -1,3 +1,4 @@
|
|||
// run-fail
|
||||
// error-pattern:oops
|
||||
|
||||
fn main() {
|
|
@ -1,5 +1,6 @@
|
|||
#![allow(unconditional_panic, const_err)]
|
||||
|
||||
// run-fail
|
||||
// error-pattern: attempt to divide by zero
|
||||
|
||||
fn main() {
|
|
@ -1,3 +1,4 @@
|
|||
// run-fail
|
||||
// error-pattern:explicit panic
|
||||
|
||||
fn f() -> ! {
|
|
@ -1,3 +1,4 @@
|
|||
// run-fail
|
||||
// error-pattern:generator resumed after panicking
|
||||
|
||||
// Test that we get the correct message for resuming a panicked generator.
|
|
@ -1,3 +1,4 @@
|
|||
// run-fail
|
||||
// error-pattern:capacity overflow
|
||||
|
||||
use std::collections::hash_map::HashMap;
|
|
@ -1,3 +1,4 @@
|
|||
// run-fail
|
||||
// error-pattern:explicit panic
|
||||
|
||||
fn f() -> ! {
|
|
@ -1,3 +1,4 @@
|
|||
// run-fail
|
||||
// error-pattern:explicit panic
|
||||
|
||||
fn main() {
|
|
@ -1,4 +1,6 @@
|
|||
// run-fail
|
||||
// error-pattern:Number is odd
|
||||
|
||||
fn even(x: usize) -> bool {
|
||||
if x < 2 {
|
||||
return false;
|
|
@ -1,8 +1,11 @@
|
|||
// run-fail
|
||||
// error-pattern:quux
|
||||
|
||||
fn my_err(s: String) -> ! {
|
||||
println!("{}", s);
|
||||
panic!("quux");
|
||||
}
|
||||
|
||||
fn main() {
|
||||
if my_err("bye".to_string()) {
|
||||
}
|
|
@ -1,5 +1,6 @@
|
|||
// Issue #7580
|
||||
|
||||
// run-fail
|
||||
// error-pattern:panic works
|
||||
|
||||
use std::*;
|
|
@ -1,3 +1,4 @@
|
|||
// run-fail
|
||||
// error-pattern:explicit panic
|
||||
|
||||
pub fn main() {
|
|
@ -1,3 +1,4 @@
|
|||
// run-fail
|
||||
// error-pattern:bad input
|
||||
|
||||
fn main() {
|
|
@ -1,3 +1,4 @@
|
|||
// run-fail
|
||||
// error-pattern:stop
|
||||
|
||||
// #18576
|
||||
|
@ -10,4 +11,5 @@ fn main() {
|
|||
let pointer = other;
|
||||
pointer();
|
||||
}
|
||||
|
||||
extern "C" fn other() {}
|
|
@ -1,5 +1,6 @@
|
|||
// Regression test for Issue #20971.
|
||||
|
||||
// run-fail
|
||||
// error-pattern:Hello, world!
|
||||
|
||||
pub trait Parser {
|
||||
|
@ -12,7 +13,7 @@ impl Parser for () {
|
|||
fn parse(&mut self, input: ()) {}
|
||||
}
|
||||
|
||||
pub fn many() -> Box<Parser<Input = <() as Parser>::Input> + 'static> {
|
||||
pub fn many() -> Box<dyn Parser<Input = <() as Parser>::Input> + 'static> {
|
||||
panic!("Hello, world!")
|
||||
}
|
||||
|
|
@ -1,3 +1,4 @@
|
|||
// run-fail
|
||||
// error-pattern:panic evaluated
|
||||
|
||||
#[allow(unused_variables)]
|
|
@ -1,3 +1,4 @@
|
|||
// run-fail
|
||||
// error-pattern:panic evaluated
|
||||
|
||||
#[allow(unused_variables)]
|
|
@ -1,12 +1,13 @@
|
|||
// run-fail
|
||||
// error-pattern:explicit panic
|
||||
|
||||
use std::sync::Arc;
|
||||
|
||||
enum e<T> {
|
||||
ee(Arc<T>),
|
||||
enum Err<T> {
|
||||
Errr(Arc<T>),
|
||||
}
|
||||
|
||||
fn foo() -> e<isize> {
|
||||
fn foo() -> Err<isize> {
|
||||
panic!();
|
||||
}
|
||||
|
|
@ -1,3 +1,4 @@
|
|||
// run-fail
|
||||
// error-pattern:index out of bounds
|
||||
|
||||
use std::mem;
|
|
@ -1,3 +1,4 @@
|
|||
// run-fail
|
||||
// error-pattern:custom message
|
||||
|
||||
fn main() {
|
|
@ -1,6 +1,7 @@
|
|||
// Regression test: issue had to do with "givens" in region inference,
|
||||
// which were not being considered during the contraction phase.
|
||||
|
||||
// run-fail
|
||||
// error-pattern:explicit panic
|
||||
|
||||
struct Parser<'i: 't, 't>(&'i u8, &'t u8);
|
|
@ -1,3 +1,4 @@
|
|||
// run-fail
|
||||
// error-pattern:index out of bounds: the len is 5 but the index is 5
|
||||
|
||||
const fn test(x: usize) -> i32 {
|
|
@ -1,9 +1,10 @@
|
|||
// run-fail
|
||||
// error-pattern:so long
|
||||
|
||||
#![allow(unused_allocation)]
|
||||
#![allow(unreachable_code)]
|
||||
#![allow(unused_variables)]
|
||||
|
||||
|
||||
// error-pattern:so long
|
||||
fn main() {
|
||||
let mut x = Vec::new();
|
||||
let y = vec![3];
|
|
@ -1,6 +1,7 @@
|
|||
// check that panics in destructors during assignment do not leave
|
||||
// destroyed values lying around for other destructors to observe.
|
||||
|
||||
// run-fail
|
||||
// error-pattern:panicking destructors ftw!
|
||||
|
||||
struct Observer<'a>(&'a mut FilledOnDrop);
|
|
@ -1,3 +1,4 @@
|
|||
// run-fail
|
||||
// error-pattern:overflow
|
||||
|
||||
use std::time::{Instant, Duration};
|
|
@ -1,3 +1,4 @@
|
|||
// run-fail
|
||||
// error-pattern:overflow
|
||||
|
||||
use std::time::{Duration, SystemTime};
|
|
@ -1,3 +1,4 @@
|
|||
// run-fail
|
||||
// error-pattern:overflow
|
||||
|
||||
use std::time::{Instant, Duration};
|
|
@ -1,3 +1,4 @@
|
|||
// run-fail
|
||||
// error-pattern:overflow
|
||||
|
||||
use std::time::{Duration, SystemTime};
|
|
@ -1,3 +1,4 @@
|
|||
// run-fail
|
||||
// error-pattern: thread 'main' panicked at 'explicit panic'
|
||||
|
||||
fn main() {
|
|
@ -1,3 +1,4 @@
|
|||
// run-fail
|
||||
// error-pattern:explicit panic
|
||||
|
||||
fn foo<T>(t: T) {}
|
25
src/test/ui/issues/issue-811.rs
Normal file
25
src/test/ui/issues/issue-811.rs
Normal file
|
@ -0,0 +1,25 @@
|
|||
// run-fail
|
||||
// error-pattern:quux
|
||||
|
||||
use std::marker::PhantomData;
|
||||
|
||||
fn test00_start(ch: Chan<isize>, message: isize) {
|
||||
send(ch, message);
|
||||
}
|
||||
|
||||
type TaskId = isize;
|
||||
type PortId = isize;
|
||||
|
||||
struct Chan<T> {
|
||||
task: TaskId,
|
||||
port: PortId,
|
||||
marker: PhantomData<*mut T>,
|
||||
}
|
||||
|
||||
fn send<T: Send>(_ch: Chan<T>, _data: T) {
|
||||
panic!();
|
||||
}
|
||||
|
||||
fn main() {
|
||||
panic!("quux");
|
||||
}
|
|
@ -1,3 +1,4 @@
|
|||
// run-fail
|
||||
// error-pattern:beep boop
|
||||
|
||||
#![allow(unused_variables)]
|
|
@ -1,3 +1,4 @@
|
|||
// run-fail
|
||||
// error-pattern:moop
|
||||
|
||||
fn main() {
|
|
@ -1,3 +1,4 @@
|
|||
// run-fail
|
||||
// error-pattern:assertion failed: 1 == 2
|
||||
|
||||
fn main() {
|
|
@ -1,3 +1,4 @@
|
|||
// run-fail
|
||||
// error-pattern:assertion failed: `(left == right)`
|
||||
// error-pattern: left: `14`
|
||||
// error-pattern:right: `15`
|
|
@ -1,3 +1,4 @@
|
|||
// run-fail
|
||||
// error-pattern:panicked at 'assertion failed: false'
|
||||
|
||||
fn main() {
|
|
@ -1,3 +1,4 @@
|
|||
// run-fail
|
||||
// error-pattern:panicked at 'test-assert-fmt 42 rust'
|
||||
|
||||
fn main() {
|
|
@ -1,3 +1,4 @@
|
|||
// run-fail
|
||||
// error-pattern:panicked at 'test-assert-owned'
|
||||
|
||||
fn main() {
|
|
@ -1,3 +1,4 @@
|
|||
// run-fail
|
||||
// error-pattern:panicked at 'test-assert-static'
|
||||
|
||||
fn main() {
|
|
@ -1,3 +1,4 @@
|
|||
// run-fail
|
||||
// error-pattern:assertion failed: `(left != right)`
|
||||
// error-pattern: left: `14`
|
||||
// error-pattern:right: `14`
|
|
@ -1,3 +1,4 @@
|
|||
// run-fail
|
||||
// error-pattern:test
|
||||
|
||||
fn main() {
|
|
@ -1,3 +1,4 @@
|
|||
// run-fail
|
||||
// error-pattern:test
|
||||
|
||||
fn main() {
|
|
@ -1,3 +1,4 @@
|
|||
// run-fail
|
||||
// error-pattern:test
|
||||
|
||||
fn f() {
|
|
@ -1,4 +1,6 @@
|
|||
// run-fail
|
||||
// error-pattern:not implemented
|
||||
|
||||
fn main() {
|
||||
unimplemented!()
|
||||
}
|
|
@ -1,4 +1,6 @@
|
|||
// run-fail
|
||||
// error-pattern:internal error: entered unreachable code: 6 is not prime
|
||||
|
||||
fn main() {
|
||||
unreachable!("{} is not {}", 6u32, "prime");
|
||||
}
|
|
@ -1,4 +1,6 @@
|
|||
// run-fail
|
||||
// error-pattern:internal error: entered unreachable code
|
||||
|
||||
fn main() {
|
||||
unreachable!()
|
||||
}
|
|
@ -1,4 +1,6 @@
|
|||
// run-fail
|
||||
// error-pattern:internal error: entered unreachable code: uhoh
|
||||
|
||||
fn main() {
|
||||
unreachable!("uhoh")
|
||||
}
|
|
@ -1,4 +1,6 @@
|
|||
// run-fail
|
||||
// error-pattern:internal error: entered unreachable code
|
||||
|
||||
fn main() {
|
||||
unreachable!()
|
||||
}
|
|
@ -1,3 +1,4 @@
|
|||
// run-fail
|
||||
// error-pattern:explicit panic
|
||||
|
||||
fn f() -> ! {
|
|
@ -1,3 +1,4 @@
|
|||
// run-fail
|
||||
// error-pattern:explicit panic
|
||||
|
||||
fn main() {
|
|
@ -1,3 +1,4 @@
|
|||
// run-fail
|
||||
// error-pattern:explicit panic
|
||||
|
||||
#![allow(unreachable_code)]
|
|
@ -1,4 +1,6 @@
|
|||
// run-fail
|
||||
// error-pattern:quux
|
||||
|
||||
fn f() -> ! {
|
||||
panic!("quux")
|
||||
}
|
|
@ -1,4 +1,6 @@
|
|||
// run-fail
|
||||
// error-pattern:squirrelcupcake
|
||||
|
||||
fn cmp() -> isize {
|
||||
match (Some('a'), None::<char>) {
|
||||
(Some(_), _) => {
|
|
@ -1,6 +1,7 @@
|
|||
// Meta test for compiletest: check that when we give the wrong error
|
||||
// patterns, the test fails.
|
||||
|
||||
// run-fail
|
||||
// revisions: foo bar
|
||||
// should-fail
|
||||
//[foo] error-pattern:bar
|
|
@ -1,6 +1,7 @@
|
|||
// Meta test for compiletest: check that when we give the right error
|
||||
// patterns, the test passes. See all `meta-revision-bad.rs`.
|
||||
|
||||
// run-fail
|
||||
// revisions: foo bar
|
||||
//[foo] error-pattern:foo
|
||||
//[bar] error-pattern:bar
|
|
@ -1,3 +1,4 @@
|
|||
// run-fail
|
||||
// error-pattern:converging_fn called
|
||||
// error-pattern:0 dropped
|
||||
// error-pattern:exit
|
|
@ -1,3 +1,4 @@
|
|||
// run-fail
|
||||
// error-pattern:complex called
|
||||
// error-pattern:dropped
|
||||
// error-pattern:exit
|
|
@ -1,3 +1,4 @@
|
|||
// run-fail
|
||||
// error-pattern:diverging_fn called
|
||||
|
||||
fn diverging_fn() -> ! {
|
|
@ -1,3 +1,4 @@
|
|||
// run-fail
|
||||
// error-pattern:diverging_fn called
|
||||
// error-pattern:0 dropped
|
||||
|
|
@ -1,3 +1,4 @@
|
|||
// run-fail
|
||||
// error-pattern:panic 1
|
||||
// error-pattern:drop 2
|
||||
|
|
@ -1,3 +1,4 @@
|
|||
// run-fail
|
||||
// error-pattern:drop 1
|
||||
// error-pattern:drop 2
|
||||
// ignore-cloudabi no std::process
|
|
@ -1,3 +1,4 @@
|
|||
// run-fail
|
||||
// error-pattern:drop 1
|
||||
// ignore-cloudabi no std::process
|
||||
|
|
@ -1,3 +1,4 @@
|
|||
// run-fail
|
||||
// error-pattern:unwind happens
|
||||
// error-pattern:drop 3
|
||||
// error-pattern:drop 2
|
|
@ -1,3 +1,4 @@
|
|||
// run-fail
|
||||
// error-pattern:index out of bounds: the len is 5 but the index is 10
|
||||
|
||||
const C: [u32; 5] = [0; 5];
|
|
@ -1,3 +1,4 @@
|
|||
// run-fail
|
||||
// error-pattern:index out of bounds: the len is 5 but the index is 10
|
||||
|
||||
const C: &'static [u8; 5] = b"hello";
|
|
@ -1,3 +1,4 @@
|
|||
// run-fail
|
||||
// error-pattern:index out of bounds: the len is 5 but the index is 10
|
||||
|
||||
const C: &'static [u8; 5] = b"hello";
|
|
@ -1,5 +1,6 @@
|
|||
// Test that ! coerces to other types.
|
||||
|
||||
// run-fail
|
||||
// error-pattern:aah!
|
||||
|
||||
fn call_another_fn<T, F: FnOnce() -> T>(f: F) -> T {
|
|
@ -1,3 +1,4 @@
|
|||
// run-fail
|
||||
// error-pattern:attempt to divide by zero
|
||||
#[allow(unconditional_panic)]
|
||||
fn main() {
|
|
@ -1,3 +1,4 @@
|
|||
// run-fail
|
||||
// error-pattern:attempt to calculate the remainder with a divisor of zero
|
||||
#[allow(unconditional_panic)]
|
||||
fn main() {
|
|
@ -1,3 +1,4 @@
|
|||
// run-fail
|
||||
// error-pattern:thread 'main' panicked at 'attempt to add with overflow'
|
||||
// compile-flags: -C debug-assertions
|
||||
|
9
src/test/ui/numbers-arithmetic/overflowing-lsh-1.rs
Normal file
9
src/test/ui/numbers-arithmetic/overflowing-lsh-1.rs
Normal file
|
@ -0,0 +1,9 @@
|
|||
// build-fail
|
||||
// compile-flags: -C debug-assertions
|
||||
|
||||
#![deny(arithmetic_overflow, const_err)]
|
||||
|
||||
fn main() {
|
||||
let _x = 1_i32 << 32;
|
||||
//~^ ERROR: this arithmetic operation will overflow
|
||||
}
|
14
src/test/ui/numbers-arithmetic/overflowing-lsh-1.stderr
Normal file
14
src/test/ui/numbers-arithmetic/overflowing-lsh-1.stderr
Normal file
|
@ -0,0 +1,14 @@
|
|||
error: this arithmetic operation will overflow
|
||||
--> $DIR/overflowing-lsh-1.rs:7:14
|
||||
|
|
||||
LL | let _x = 1_i32 << 32;
|
||||
| ^^^^^^^^^^^ attempt to shift left with overflow
|
||||
|
|
||||
note: the lint level is defined here
|
||||
--> $DIR/overflowing-lsh-1.rs:4:9
|
||||
|
|
||||
LL | #![deny(arithmetic_overflow, const_err)]
|
||||
| ^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: aborting due to previous error
|
||||
|
9
src/test/ui/numbers-arithmetic/overflowing-lsh-2.rs
Normal file
9
src/test/ui/numbers-arithmetic/overflowing-lsh-2.rs
Normal file
|
@ -0,0 +1,9 @@
|
|||
// build-fail
|
||||
// compile-flags: -C debug-assertions
|
||||
|
||||
#![deny(arithmetic_overflow, const_err)]
|
||||
|
||||
fn main() {
|
||||
let _x = 1 << -1;
|
||||
//~^ ERROR: this arithmetic operation will overflow
|
||||
}
|
14
src/test/ui/numbers-arithmetic/overflowing-lsh-2.stderr
Normal file
14
src/test/ui/numbers-arithmetic/overflowing-lsh-2.stderr
Normal file
|
@ -0,0 +1,14 @@
|
|||
error: this arithmetic operation will overflow
|
||||
--> $DIR/overflowing-lsh-2.rs:7:14
|
||||
|
|
||||
LL | let _x = 1 << -1;
|
||||
| ^^^^^^^ attempt to shift left with overflow
|
||||
|
|
||||
note: the lint level is defined here
|
||||
--> $DIR/overflowing-lsh-2.rs:4:9
|
||||
|
|
||||
LL | #![deny(arithmetic_overflow, const_err)]
|
||||
| ^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: aborting due to previous error
|
||||
|
9
src/test/ui/numbers-arithmetic/overflowing-lsh-3.rs
Normal file
9
src/test/ui/numbers-arithmetic/overflowing-lsh-3.rs
Normal file
|
@ -0,0 +1,9 @@
|
|||
// build-fail
|
||||
// compile-flags: -C debug-assertions
|
||||
|
||||
#![deny(arithmetic_overflow, const_err)]
|
||||
|
||||
fn main() {
|
||||
let _x = 1_u64 << 64;
|
||||
//~^ ERROR: this arithmetic operation will overflow
|
||||
}
|
14
src/test/ui/numbers-arithmetic/overflowing-lsh-3.stderr
Normal file
14
src/test/ui/numbers-arithmetic/overflowing-lsh-3.stderr
Normal file
|
@ -0,0 +1,14 @@
|
|||
error: this arithmetic operation will overflow
|
||||
--> $DIR/overflowing-lsh-3.rs:7:14
|
||||
|
|
||||
LL | let _x = 1_u64 << 64;
|
||||
| ^^^^^^^^^^^ attempt to shift left with overflow
|
||||
|
|
||||
note: the lint level is defined here
|
||||
--> $DIR/overflowing-lsh-3.rs:4:9
|
||||
|
|
||||
LL | #![deny(arithmetic_overflow, const_err)]
|
||||
| ^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: aborting due to previous error
|
||||
|
|
@ -1,15 +1,15 @@
|
|||
// error-pattern:thread 'main' panicked at 'attempt to shift left with overflow'
|
||||
// build-fail
|
||||
// compile-flags: -C debug-assertions
|
||||
|
||||
// This function is checking that our automatic truncation does not
|
||||
// sidestep the overflow checking.
|
||||
|
||||
#![warn(arithmetic_overflow)]
|
||||
#![warn(const_err)]
|
||||
#![deny(arithmetic_overflow, const_err)]
|
||||
|
||||
fn main() {
|
||||
// this signals overflow when checking is on
|
||||
let x = 1_i8 << 17;
|
||||
//~^ ERROR: this arithmetic operation will overflow
|
||||
|
||||
// ... but when checking is off, the fallback will truncate the
|
||||
// input to its lower three bits (= 1). Note that this is *not*
|
14
src/test/ui/numbers-arithmetic/overflowing-lsh-4.stderr
Normal file
14
src/test/ui/numbers-arithmetic/overflowing-lsh-4.stderr
Normal file
|
@ -0,0 +1,14 @@
|
|||
error: this arithmetic operation will overflow
|
||||
--> $DIR/overflowing-lsh-4.rs:11:13
|
||||
|
|
||||
LL | let x = 1_i8 << 17;
|
||||
| ^^^^^^^^^^ attempt to shift left with overflow
|
||||
|
|
||||
note: the lint level is defined here
|
||||
--> $DIR/overflowing-lsh-4.rs:7:9
|
||||
|
|
||||
LL | #![deny(arithmetic_overflow, const_err)]
|
||||
| ^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: aborting due to previous error
|
||||
|
|
@ -1,3 +1,4 @@
|
|||
// run-fail
|
||||
// error-pattern:thread 'main' panicked at 'attempt to multiply with overflow'
|
||||
// compile-flags: -C debug-assertions
|
||||
|
|
@ -1,3 +1,4 @@
|
|||
// run-fail
|
||||
// error-pattern:thread 'main' panicked at 'attempt to negate with overflow'
|
||||
// compile-flags: -C debug-assertions
|
||||
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Reference in a new issue