File tree Expand file tree Collapse file tree 2 files changed +49
-0
lines changed Expand file tree Collapse file tree 2 files changed +49
-0
lines changed Original file line number Diff line number Diff line change 1+ //! Check that overflowing literals are in patterns are rejected
2+
3+ #![ feature( pattern_types) ]
4+ #![ feature( pattern_type_macro) ]
5+
6+ use std:: pat:: pattern_type;
7+
8+ type TooBig = pattern_type ! ( u8 is 500 ..) ;
9+ //~^ ERROR: literal out of range for `u8`
10+ type TooSmall = pattern_type ! ( i8 is -500 ..) ;
11+ //~^ ERROR: literal out of range for `i8`
12+ type TooBigSigned = pattern_type ! ( i8 is 200 ..) ;
13+ //~^ ERROR: literal out of range for `i8`
14+
15+ fn main ( ) {
16+ match 5_u8 {
17+ 500 => { }
18+ _ => { }
19+ }
20+ }
Original file line number Diff line number Diff line change 1+ error: literal out of range for `u8`
2+ --> $DIR/overflowing-literals.rs:8:35
3+ |
4+ LL | type TooBig = pattern_type!(u8 is 500..);
5+ | ^^^
6+ |
7+ = note: the literal `500` does not fit into the type `u8` whose range is `0..=255`
8+ = note: `#[deny(overflowing_literals)]` on by default
9+
10+ error: literal out of range for `i8`
11+ --> $DIR/overflowing-literals.rs:10:37
12+ |
13+ LL | type TooSmall = pattern_type!(i8 is -500..);
14+ | ^^^^
15+ |
16+ = note: the literal `-500` does not fit into the type `i8` whose range is `-128..=127`
17+ = help: consider using the type `i16` instead
18+
19+ error: literal out of range for `i8`
20+ --> $DIR/overflowing-literals.rs:12:41
21+ |
22+ LL | type TooBigSigned = pattern_type!(i8 is 200..);
23+ | ^^^
24+ |
25+ = note: the literal `200` does not fit into the type `i8` whose range is `-128..=127`
26+ = help: consider using the type `u8` instead
27+
28+ error: aborting due to 3 previous errors
29+
You can’t perform that action at this time.
0 commit comments