diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-30 03:57:31 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-30 03:57:31 +0000 |
commit | dc0db358abe19481e475e10c32149b53370f1a1c (patch) | |
tree | ab8ce99c4b255ce46f99ef402c27916055b899ee /tests/ui/discrim | |
parent | Releasing progress-linux version 1.71.1+dfsg1-2~progress7.99u1. (diff) | |
download | rustc-dc0db358abe19481e475e10c32149b53370f1a1c.tar.xz rustc-dc0db358abe19481e475e10c32149b53370f1a1c.zip |
Merging upstream version 1.72.1+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/ui/discrim')
-rw-r--r-- | tests/ui/discrim/discrim-ill-typed.rs | 114 | ||||
-rw-r--r-- | tests/ui/discrim/discrim-ill-typed.stderr | 91 | ||||
-rw-r--r-- | tests/ui/discrim/discrim-overflow-2.rs | 80 | ||||
-rw-r--r-- | tests/ui/discrim/discrim-overflow-2.stderr | 67 | ||||
-rw-r--r-- | tests/ui/discrim/discrim-overflow.rs | 99 | ||||
-rw-r--r-- | tests/ui/discrim/discrim-overflow.stderr | 67 |
6 files changed, 0 insertions, 518 deletions
diff --git a/tests/ui/discrim/discrim-ill-typed.rs b/tests/ui/discrim/discrim-ill-typed.rs deleted file mode 100644 index 3cf0ea0e6..000000000 --- a/tests/ui/discrim/discrim-ill-typed.rs +++ /dev/null @@ -1,114 +0,0 @@ -// When explicit discriminant value has -// a type that does not match the representation -// type, rustc should fail gracefully. - -// See also run-pass/discrim-explicit-23030.rs where the input types -// are correct. - -#![allow(dead_code, unused_variables, unused_imports)] - -fn f_i8() { - #[repr(i8)] - enum A { - Ok = i8::MAX - 1, - Ok2, - OhNo = 0_u8, - //~^ ERROR mismatched types - //~| expected `i8`, found `u8` - } - - let x = A::Ok; -} - -fn f_u8() { - #[repr(u8)] - enum A { - Ok = u8::MAX - 1, - Ok2, - OhNo = 0_i8, - //~^ ERROR mismatched types - //~| expected `u8`, found `i8` - } - - let x = A::Ok; -} - -fn f_i16() { - #[repr(i16)] - enum A { - Ok = i16::MAX - 1, - Ok2, - OhNo = 0_u16, - //~^ ERROR mismatched types - //~| expected `i16`, found `u16` - } - - let x = A::Ok; -} - -fn f_u16() { - #[repr(u16)] - enum A { - Ok = u16::MAX - 1, - Ok2, - OhNo = 0_i16, - //~^ ERROR mismatched types - //~| expected `u16`, found `i16` - } - - let x = A::Ok; -} - -fn f_i32() { - #[repr(i32)] - enum A { - Ok = i32::MAX - 1, - Ok2, - OhNo = 0_u32, - //~^ ERROR mismatched types - //~| expected `i32`, found `u32` - } - - let x = A::Ok; -} - -fn f_u32() { - #[repr(u32)] - enum A { - Ok = u32::MAX - 1, - Ok2, - OhNo = 0_i32, - //~^ ERROR mismatched types - //~| expected `u32`, found `i32` - } - - let x = A::Ok; -} - -fn f_i64() { - #[repr(i64)] - enum A { - Ok = i64::MAX - 1, - Ok2, - OhNo = 0_u64, - //~^ ERROR mismatched types - //~| expected `i64`, found `u64` - } - - let x = A::Ok; -} - -fn f_u64() { - #[repr(u64)] - enum A { - Ok = u64::MAX - 1, - Ok2, - OhNo = 0_i64, - //~^ ERROR mismatched types - //~| expected `u64`, found `i64` - } - - let x = A::Ok; -} - -fn main() { } diff --git a/tests/ui/discrim/discrim-ill-typed.stderr b/tests/ui/discrim/discrim-ill-typed.stderr deleted file mode 100644 index 27f516341..000000000 --- a/tests/ui/discrim/discrim-ill-typed.stderr +++ /dev/null @@ -1,91 +0,0 @@ -error[E0308]: mismatched types - --> $DIR/discrim-ill-typed.rs:15:16 - | -LL | OhNo = 0_u8, - | ^^^^ expected `i8`, found `u8` - | -help: change the type of the numeric literal from `u8` to `i8` - | -LL | OhNo = 0_i8, - | ~~ - -error[E0308]: mismatched types - --> $DIR/discrim-ill-typed.rs:28:16 - | -LL | OhNo = 0_i8, - | ^^^^ expected `u8`, found `i8` - | -help: change the type of the numeric literal from `i8` to `u8` - | -LL | OhNo = 0_u8, - | ~~ - -error[E0308]: mismatched types - --> $DIR/discrim-ill-typed.rs:41:16 - | -LL | OhNo = 0_u16, - | ^^^^^ expected `i16`, found `u16` - | -help: change the type of the numeric literal from `u16` to `i16` - | -LL | OhNo = 0_i16, - | ~~~ - -error[E0308]: mismatched types - --> $DIR/discrim-ill-typed.rs:54:16 - | -LL | OhNo = 0_i16, - | ^^^^^ expected `u16`, found `i16` - | -help: change the type of the numeric literal from `i16` to `u16` - | -LL | OhNo = 0_u16, - | ~~~ - -error[E0308]: mismatched types - --> $DIR/discrim-ill-typed.rs:67:16 - | -LL | OhNo = 0_u32, - | ^^^^^ expected `i32`, found `u32` - | -help: change the type of the numeric literal from `u32` to `i32` - | -LL | OhNo = 0_i32, - | ~~~ - -error[E0308]: mismatched types - --> $DIR/discrim-ill-typed.rs:80:16 - | -LL | OhNo = 0_i32, - | ^^^^^ expected `u32`, found `i32` - | -help: change the type of the numeric literal from `i32` to `u32` - | -LL | OhNo = 0_u32, - | ~~~ - -error[E0308]: mismatched types - --> $DIR/discrim-ill-typed.rs:93:16 - | -LL | OhNo = 0_u64, - | ^^^^^ expected `i64`, found `u64` - | -help: change the type of the numeric literal from `u64` to `i64` - | -LL | OhNo = 0_i64, - | ~~~ - -error[E0308]: mismatched types - --> $DIR/discrim-ill-typed.rs:106:16 - | -LL | OhNo = 0_i64, - | ^^^^^ expected `u64`, found `i64` - | -help: change the type of the numeric literal from `i64` to `u64` - | -LL | OhNo = 0_u64, - | ~~~ - -error: aborting due to 8 previous errors - -For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/discrim/discrim-overflow-2.rs b/tests/ui/discrim/discrim-overflow-2.rs deleted file mode 100644 index ca24317c5..000000000 --- a/tests/ui/discrim/discrim-overflow-2.rs +++ /dev/null @@ -1,80 +0,0 @@ -// Issue 23030: Detect overflowing discriminant -// -// Check that we detect the overflow even if enum is not used. - -// See also run-pass/discrim-explicit-23030.rs where the suggested -// workaround is tested. - -fn f_i8() { - #[repr(i8)] - enum A { - Ok = i8::MAX - 1, - Ok2, - OhNo, //~ ERROR enum discriminant overflowed [E0370] - } -} - -fn f_u8() { - #[repr(u8)] - enum A { - Ok = u8::MAX - 1, - Ok2, - OhNo, //~ ERROR enum discriminant overflowed [E0370] - } -} - -fn f_i16() { - #[repr(i16)] - enum A { - Ok = i16::MAX - 1, - Ok2, - OhNo, //~ ERROR enum discriminant overflowed [E0370] - } -} - -fn f_u16() { - #[repr(u16)] - enum A { - Ok = u16::MAX - 1, - Ok2, - OhNo, //~ ERROR enum discriminant overflowed [E0370] - } -} - -fn f_i32() { - #[repr(i32)] - enum A { - Ok = i32::MAX - 1, - Ok2, - OhNo, //~ ERROR enum discriminant overflowed [E0370] - } -} - -fn f_u32() { - #[repr(u32)] - enum A { - Ok = u32::MAX - 1, - Ok2, - OhNo, //~ ERROR enum discriminant overflowed [E0370] - } -} - -fn f_i64() { - #[repr(i64)] - enum A { - Ok = i64::MAX - 1, - Ok2, - OhNo, //~ ERROR enum discriminant overflowed [E0370] - } -} - -fn f_u64() { - #[repr(u64)] - enum A { - Ok = u64::MAX - 1, - Ok2, - OhNo, //~ ERROR enum discriminant overflowed [E0370] - } -} - -fn main() { } diff --git a/tests/ui/discrim/discrim-overflow-2.stderr b/tests/ui/discrim/discrim-overflow-2.stderr deleted file mode 100644 index 3ca84c667..000000000 --- a/tests/ui/discrim/discrim-overflow-2.stderr +++ /dev/null @@ -1,67 +0,0 @@ -error[E0370]: enum discriminant overflowed - --> $DIR/discrim-overflow-2.rs:13:9 - | -LL | OhNo, - | ^^^^ overflowed on value after 127 - | - = note: explicitly set `OhNo = -128` if that is desired outcome - -error[E0370]: enum discriminant overflowed - --> $DIR/discrim-overflow-2.rs:22:9 - | -LL | OhNo, - | ^^^^ overflowed on value after 255 - | - = note: explicitly set `OhNo = 0` if that is desired outcome - -error[E0370]: enum discriminant overflowed - --> $DIR/discrim-overflow-2.rs:31:9 - | -LL | OhNo, - | ^^^^ overflowed on value after 32767 - | - = note: explicitly set `OhNo = -32768` if that is desired outcome - -error[E0370]: enum discriminant overflowed - --> $DIR/discrim-overflow-2.rs:40:9 - | -LL | OhNo, - | ^^^^ overflowed on value after 65535 - | - = note: explicitly set `OhNo = 0` if that is desired outcome - -error[E0370]: enum discriminant overflowed - --> $DIR/discrim-overflow-2.rs:49:9 - | -LL | OhNo, - | ^^^^ overflowed on value after 2147483647 - | - = note: explicitly set `OhNo = -2147483648` if that is desired outcome - -error[E0370]: enum discriminant overflowed - --> $DIR/discrim-overflow-2.rs:58:9 - | -LL | OhNo, - | ^^^^ overflowed on value after 4294967295 - | - = note: explicitly set `OhNo = 0` if that is desired outcome - -error[E0370]: enum discriminant overflowed - --> $DIR/discrim-overflow-2.rs:67:9 - | -LL | OhNo, - | ^^^^ overflowed on value after 9223372036854775807 - | - = note: explicitly set `OhNo = -9223372036854775808` if that is desired outcome - -error[E0370]: enum discriminant overflowed - --> $DIR/discrim-overflow-2.rs:76:9 - | -LL | OhNo, - | ^^^^ overflowed on value after 18446744073709551615 - | - = note: explicitly set `OhNo = 0` if that is desired outcome - -error: aborting due to 8 previous errors - -For more information about this error, try `rustc --explain E0370`. diff --git a/tests/ui/discrim/discrim-overflow.rs b/tests/ui/discrim/discrim-overflow.rs deleted file mode 100644 index 774ced93c..000000000 --- a/tests/ui/discrim/discrim-overflow.rs +++ /dev/null @@ -1,99 +0,0 @@ -// Issue 23030: Detect overflowing discriminant - -// See also run-pass/discrim-explicit-23030.rs where the suggested -// workaround is tested. - -fn f_i8() { - #[repr(i8)] - enum A { - Ok = i8::MAX - 1, - Ok2, - OhNo, //~ ERROR enum discriminant overflowed [E0370] - } - - let x = A::Ok; -} - -fn f_u8() { - #[repr(u8)] - enum A { - Ok = u8::MAX - 1, - Ok2, - OhNo, //~ ERROR enum discriminant overflowed [E0370] - } - - let x = A::Ok; -} - -fn f_i16() { - #[repr(i16)] - enum A { - Ok = i16::MAX - 1, - Ok2, - OhNo, //~ ERROR enum discriminant overflowed [E0370] - } - - let x = A::Ok; -} - -fn f_u16() { - #[repr(u16)] - enum A { - Ok = u16::MAX - 1, - Ok2, - OhNo, //~ ERROR enum discriminant overflowed [E0370] - //~| overflowed on value after 65535 - } - - let x = A::Ok; -} - -fn f_i32() { - #[repr(i32)] - enum A { - Ok = i32::MAX - 1, - Ok2, - OhNo, //~ ERROR enum discriminant overflowed [E0370] - //~| overflowed on value after 2147483647 - } - - let x = A::Ok; -} - -fn f_u32() { - #[repr(u32)] - enum A { - Ok = u32::MAX - 1, - Ok2, - OhNo, //~ ERROR enum discriminant overflowed [E0370] - //~| overflowed on value after 4294967295 - } - - let x = A::Ok; -} - -fn f_i64() { - #[repr(i64)] - enum A { - Ok = i64::MAX - 1, - Ok2, - OhNo, //~ ERROR enum discriminant overflowed [E0370] - //~| overflowed on value after 9223372036854775807 - } - - let x = A::Ok; -} - -fn f_u64() { - #[repr(u64)] - enum A { - Ok = u64::MAX - 1, - Ok2, - OhNo, //~ ERROR enum discriminant overflowed [E0370] - //~| overflowed on value after 18446744073709551615 - } - - let x = A::Ok; -} - -fn main() { } diff --git a/tests/ui/discrim/discrim-overflow.stderr b/tests/ui/discrim/discrim-overflow.stderr deleted file mode 100644 index 1b331bb1b..000000000 --- a/tests/ui/discrim/discrim-overflow.stderr +++ /dev/null @@ -1,67 +0,0 @@ -error[E0370]: enum discriminant overflowed - --> $DIR/discrim-overflow.rs:11:9 - | -LL | OhNo, - | ^^^^ overflowed on value after 127 - | - = note: explicitly set `OhNo = -128` if that is desired outcome - -error[E0370]: enum discriminant overflowed - --> $DIR/discrim-overflow.rs:22:9 - | -LL | OhNo, - | ^^^^ overflowed on value after 255 - | - = note: explicitly set `OhNo = 0` if that is desired outcome - -error[E0370]: enum discriminant overflowed - --> $DIR/discrim-overflow.rs:33:9 - | -LL | OhNo, - | ^^^^ overflowed on value after 32767 - | - = note: explicitly set `OhNo = -32768` if that is desired outcome - -error[E0370]: enum discriminant overflowed - --> $DIR/discrim-overflow.rs:44:9 - | -LL | OhNo, - | ^^^^ overflowed on value after 65535 - | - = note: explicitly set `OhNo = 0` if that is desired outcome - -error[E0370]: enum discriminant overflowed - --> $DIR/discrim-overflow.rs:56:9 - | -LL | OhNo, - | ^^^^ overflowed on value after 2147483647 - | - = note: explicitly set `OhNo = -2147483648` if that is desired outcome - -error[E0370]: enum discriminant overflowed - --> $DIR/discrim-overflow.rs:68:9 - | -LL | OhNo, - | ^^^^ overflowed on value after 4294967295 - | - = note: explicitly set `OhNo = 0` if that is desired outcome - -error[E0370]: enum discriminant overflowed - --> $DIR/discrim-overflow.rs:80:9 - | -LL | OhNo, - | ^^^^ overflowed on value after 9223372036854775807 - | - = note: explicitly set `OhNo = -9223372036854775808` if that is desired outcome - -error[E0370]: enum discriminant overflowed - --> $DIR/discrim-overflow.rs:92:9 - | -LL | OhNo, - | ^^^^ overflowed on value after 18446744073709551615 - | - = note: explicitly set `OhNo = 0` if that is desired outcome - -error: aborting due to 8 previous errors - -For more information about this error, try `rustc --explain E0370`. |