mirror of
https://github.com/rust-lang/rust.git
synced 2025-05-14 02:49:40 +00:00
Add regression test
This commit is contained in:
parent
8df89d1cb0
commit
d1231eabf9
20
tests/ui/pattern/overflowing-literals.rs
Normal file
20
tests/ui/pattern/overflowing-literals.rs
Normal file
@ -0,0 +1,20 @@
|
||||
//! Check that overflowing literals are in patterns are rejected
|
||||
|
||||
#![feature(pattern_types)]
|
||||
#![feature(pattern_type_macro)]
|
||||
|
||||
use std::pat::pattern_type;
|
||||
|
||||
type TooBig = pattern_type!(u8 is 500..);
|
||||
//~^ ERROR: literal out of range for `u8`
|
||||
type TooSmall = pattern_type!(i8 is -500..);
|
||||
//~^ ERROR: literal out of range for `i8`
|
||||
type TooBigSigned = pattern_type!(i8 is 200..);
|
||||
//~^ ERROR: literal out of range for `i8`
|
||||
|
||||
fn main() {
|
||||
match 5_u8 {
|
||||
500 => {}
|
||||
_ => {}
|
||||
}
|
||||
}
|
29
tests/ui/pattern/overflowing-literals.stderr
Normal file
29
tests/ui/pattern/overflowing-literals.stderr
Normal file
@ -0,0 +1,29 @@
|
||||
error: literal out of range for `u8`
|
||||
--> $DIR/overflowing-literals.rs:8:35
|
||||
|
|
||||
LL | type TooBig = pattern_type!(u8 is 500..);
|
||||
| ^^^
|
||||
|
|
||||
= note: the literal `500` does not fit into the type `u8` whose range is `0..=255`
|
||||
= note: `#[deny(overflowing_literals)]` on by default
|
||||
|
||||
error: literal out of range for `i8`
|
||||
--> $DIR/overflowing-literals.rs:10:37
|
||||
|
|
||||
LL | type TooSmall = pattern_type!(i8 is -500..);
|
||||
| ^^^^
|
||||
|
|
||||
= note: the literal `-500` does not fit into the type `i8` whose range is `-128..=127`
|
||||
= help: consider using the type `i16` instead
|
||||
|
||||
error: literal out of range for `i8`
|
||||
--> $DIR/overflowing-literals.rs:12:41
|
||||
|
|
||||
LL | type TooBigSigned = pattern_type!(i8 is 200..);
|
||||
| ^^^
|
||||
|
|
||||
= note: the literal `200` does not fit into the type `i8` whose range is `-128..=127`
|
||||
= help: consider using the type `u8` instead
|
||||
|
||||
error: aborting due to 3 previous errors
|
||||
|
Loading…
Reference in New Issue
Block a user