Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions tests/ui/range/range-negative-literal-unsigned-type.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// Regression tests for: https://github.com/rust-lang/rust/issues/136514

#![allow(unreachable_patterns)]
fn main() {
match 0u8 {
-1..=2 => {}
//~^ ERROR the trait bound `u8: Neg` is not satisfied
-0..=0 => {}
//~^ ERROR the trait bound `u8: Neg` is not satisfied
-256..=2 => {}
//~^ ERROR the trait bound `u8: Neg` is not satisfied
-255..=2 => {}
//~^ ERROR the trait bound `u8: Neg` is not satisfied
0..=-1 => {}
//~^ ERROR the trait bound `u8: Neg` is not satisfied
-2..=-1 => {}
//~^ ERROR the trait bound `u8: Neg` is not satisfied
//~| ERROR the trait bound `u8: Neg` is not satisfied
_ => {}
}
}
122 changes: 122 additions & 0 deletions tests/ui/range/range-negative-literal-unsigned-type.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
error[E0277]: the trait bound `u8: Neg` is not satisfied
--> $DIR/range-negative-literal-unsigned-type.rs:6:9
|
LL | -1..=2 => {}
| ^^ the trait `Neg` is not implemented for `u8`
|
= help: the following other types implement trait `Neg`:
&f128
&f16
&f32
&f64
&i128
&i16
&i32
&i64
and 12 others

error[E0277]: the trait bound `u8: Neg` is not satisfied
--> $DIR/range-negative-literal-unsigned-type.rs:8:9
|
LL | -0..=0 => {}
| ^^ the trait `Neg` is not implemented for `u8`
|
= help: the following other types implement trait `Neg`:
&f128
&f16
&f32
&f64
&i128
&i16
&i32
&i64
and 12 others

error[E0277]: the trait bound `u8: Neg` is not satisfied
--> $DIR/range-negative-literal-unsigned-type.rs:10:9
|
LL | -256..=2 => {}
| ^^^^ the trait `Neg` is not implemented for `u8`
|
= help: the following other types implement trait `Neg`:
&f128
&f16
&f32
&f64
&i128
&i16
&i32
&i64
and 12 others

error[E0277]: the trait bound `u8: Neg` is not satisfied
--> $DIR/range-negative-literal-unsigned-type.rs:12:9
|
LL | -255..=2 => {}
| ^^^^ the trait `Neg` is not implemented for `u8`
|
= help: the following other types implement trait `Neg`:
&f128
&f16
&f32
&f64
&i128
&i16
&i32
&i64
and 12 others

error[E0277]: the trait bound `u8: Neg` is not satisfied
--> $DIR/range-negative-literal-unsigned-type.rs:14:13
|
LL | 0..=-1 => {}
| ^^ the trait `Neg` is not implemented for `u8`
|
= help: the following other types implement trait `Neg`:
&f128
&f16
&f32
&f64
&i128
&i16
&i32
&i64
and 12 others

error[E0277]: the trait bound `u8: Neg` is not satisfied
--> $DIR/range-negative-literal-unsigned-type.rs:16:9
|
LL | -2..=-1 => {}
| ^^ the trait `Neg` is not implemented for `u8`
|
= help: the following other types implement trait `Neg`:
&f128
&f16
&f32
&f64
&i128
&i16
&i32
&i64
and 12 others

error[E0277]: the trait bound `u8: Neg` is not satisfied
--> $DIR/range-negative-literal-unsigned-type.rs:16:14
|
LL | -2..=-1 => {}
| ^^ the trait `Neg` is not implemented for `u8`
|
= help: the following other types implement trait `Neg`:
&f128
&f16
&f32
&f64
&i128
&i16
&i32
&i64
and 12 others

error: aborting due to 7 previous errors

For more information about this error, try `rustc --explain E0277`.
Loading