Rollup merge of #151963 - mcraeynest:main, r=Kivooeo

Add regression test for negative literal in a range of unsigned type

Simple regression test for rust-lang/rust#136514
This commit is contained in:
Stuart Cook 2026-02-02 10:28:34 +11:00 committed by GitHub
commit cfdd14d964
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 143 additions and 0 deletions

View file

@ -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
_ => {}
}
}

View file

@ -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`.