summaryrefslogtreecommitdiffstats
path: root/src/test/ui/lint/lint-enum-intrinsics-non-enums.rs
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:19:03 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:19:03 +0000
commit64d98f8ee037282c35007b64c2649055c56af1db (patch)
tree5492bcf97fce41ee1c0b1cc2add283f3e66cdab0 /src/test/ui/lint/lint-enum-intrinsics-non-enums.rs
parentAdding debian version 1.67.1+dfsg1-1. (diff)
downloadrustc-64d98f8ee037282c35007b64c2649055c56af1db.tar.xz
rustc-64d98f8ee037282c35007b64c2649055c56af1db.zip
Merging upstream version 1.68.2+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/test/ui/lint/lint-enum-intrinsics-non-enums.rs')
-rw-r--r--src/test/ui/lint/lint-enum-intrinsics-non-enums.rs67
1 files changed, 0 insertions, 67 deletions
diff --git a/src/test/ui/lint/lint-enum-intrinsics-non-enums.rs b/src/test/ui/lint/lint-enum-intrinsics-non-enums.rs
deleted file mode 100644
index 8ad337064..000000000
--- a/src/test/ui/lint/lint-enum-intrinsics-non-enums.rs
+++ /dev/null
@@ -1,67 +0,0 @@
-// Test the enum_intrinsics_non_enums lint.
-
-#![feature(variant_count)]
-
-use std::mem::{discriminant, variant_count};
-
-enum SomeEnum {
- A,
- B,
-}
-
-struct SomeStruct;
-
-fn generic_discriminant<T>(v: &T) {
- discriminant::<T>(v);
-}
-
-fn generic_variant_count<T>() -> usize {
- variant_count::<T>()
-}
-
-fn test_discriminant() {
- discriminant(&SomeEnum::A);
- generic_discriminant(&SomeEnum::B);
-
- discriminant(&());
- //~^ error: the return value of `mem::discriminant` is unspecified when called with a non-enum type
-
- discriminant(&&SomeEnum::B);
- //~^ error: the return value of `mem::discriminant` is unspecified when called with a non-enum type
-
- discriminant(&SomeStruct);
- //~^ error: the return value of `mem::discriminant` is unspecified when called with a non-enum type
-
- discriminant(&123u32);
- //~^ error: the return value of `mem::discriminant` is unspecified when called with a non-enum type
-
- discriminant(&&123i8);
- //~^ error: the return value of `mem::discriminant` is unspecified when called with a non-enum type
-}
-
-fn test_variant_count() {
- variant_count::<SomeEnum>();
- generic_variant_count::<SomeEnum>();
-
- variant_count::<&str>();
- //~^ error: the return value of `mem::variant_count` is unspecified when called with a non-enum type
-
- variant_count::<*const u8>();
- //~^ error: the return value of `mem::variant_count` is unspecified when called with a non-enum type
-
- variant_count::<()>();
- //~^ error: the return value of `mem::variant_count` is unspecified when called with a non-enum type
-
- variant_count::<&SomeEnum>();
- //~^ error: the return value of `mem::variant_count` is unspecified when called with a non-enum type
-}
-
-fn main() {
- test_discriminant();
- test_variant_count();
-
- // The lint ignores cases where the type is generic, so these should be
- // allowed even though their return values are unspecified
- generic_variant_count::<SomeStruct>();
- generic_discriminant::<SomeStruct>(&SomeStruct);
-}