From 837b550238aa671a591ccf282dddeab29cadb206 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sat, 18 May 2024 04:49:42 +0200 Subject: Merging upstream version 1.71.1+dfsg1. Signed-off-by: Daniel Baumann --- tests/ui/enum-discriminant/auxiliary/issue-41394.rs | 16 ++++++++++++++++ tests/ui/enum-discriminant/issue-41394-rpass.rs | 8 ++++++++ tests/ui/enum-discriminant/issue-41394.rs | 10 ++++++++++ tests/ui/enum-discriminant/issue-41394.stderr | 11 +++++++++++ .../issue-70453-generics-in-discr-ice-2.rs | 2 +- .../issue-70453-generics-in-discr-ice-2.stderr | 5 ++--- .../issue-70453-generics-in-discr-ice.rs | 2 +- .../issue-70453-generics-in-discr-ice.stderr | 5 ++--- .../issue-70453-polymorphic-ctfe.stderr | 5 ++--- 9 files changed, 53 insertions(+), 11 deletions(-) create mode 100644 tests/ui/enum-discriminant/auxiliary/issue-41394.rs create mode 100644 tests/ui/enum-discriminant/issue-41394-rpass.rs create mode 100644 tests/ui/enum-discriminant/issue-41394.rs create mode 100644 tests/ui/enum-discriminant/issue-41394.stderr (limited to 'tests/ui/enum-discriminant') diff --git a/tests/ui/enum-discriminant/auxiliary/issue-41394.rs b/tests/ui/enum-discriminant/auxiliary/issue-41394.rs new file mode 100644 index 000000000..2e650efc7 --- /dev/null +++ b/tests/ui/enum-discriminant/auxiliary/issue-41394.rs @@ -0,0 +1,16 @@ +#![crate_type = "lib"] + +#[repr(u32)] +pub enum Foo { + Foo = Private::Variant as u32 +} + +#[repr(u8)] +enum Private { + Variant = 42 +} + +#[inline(always)] +pub fn foo() -> Foo { + Foo::Foo +} diff --git a/tests/ui/enum-discriminant/issue-41394-rpass.rs b/tests/ui/enum-discriminant/issue-41394-rpass.rs new file mode 100644 index 000000000..37c652523 --- /dev/null +++ b/tests/ui/enum-discriminant/issue-41394-rpass.rs @@ -0,0 +1,8 @@ +// run-pass +// aux-build:issue-41394.rs + +extern crate issue_41394 as lib; + +fn main() { + assert_eq!(lib::foo() as u32, 42); +} diff --git a/tests/ui/enum-discriminant/issue-41394.rs b/tests/ui/enum-discriminant/issue-41394.rs new file mode 100644 index 000000000..06a330813 --- /dev/null +++ b/tests/ui/enum-discriminant/issue-41394.rs @@ -0,0 +1,10 @@ +enum Foo { + A = "" + 1 + //~^ ERROR cannot add `{integer}` to `&str` +} + +enum Bar { + A = Foo::A as isize +} + +fn main() {} diff --git a/tests/ui/enum-discriminant/issue-41394.stderr b/tests/ui/enum-discriminant/issue-41394.stderr new file mode 100644 index 000000000..fa95ca9c1 --- /dev/null +++ b/tests/ui/enum-discriminant/issue-41394.stderr @@ -0,0 +1,11 @@ +error[E0369]: cannot add `{integer}` to `&str` + --> $DIR/issue-41394.rs:2:12 + | +LL | A = "" + 1 + | -- ^ - {integer} + | | + | &str + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0369`. diff --git a/tests/ui/enum-discriminant/issue-70453-generics-in-discr-ice-2.rs b/tests/ui/enum-discriminant/issue-70453-generics-in-discr-ice-2.rs index ad9fcc25b..62137c0c8 100644 --- a/tests/ui/enum-discriminant/issue-70453-generics-in-discr-ice-2.rs +++ b/tests/ui/enum-discriminant/issue-70453-generics-in-discr-ice-2.rs @@ -7,7 +7,7 @@ use core::intrinsics::discriminant_value; enum MyWeirdOption { None = 0, Some(T) = std::mem::size_of::(), - //~^ ERROR generic parameters may not be used in const operations + //~^ ERROR generic parameters may not be used in enum discriminant values } fn main() { diff --git a/tests/ui/enum-discriminant/issue-70453-generics-in-discr-ice-2.stderr b/tests/ui/enum-discriminant/issue-70453-generics-in-discr-ice-2.stderr index e4e10468d..2cb159ee2 100644 --- a/tests/ui/enum-discriminant/issue-70453-generics-in-discr-ice-2.stderr +++ b/tests/ui/enum-discriminant/issue-70453-generics-in-discr-ice-2.stderr @@ -1,11 +1,10 @@ -error: generic parameters may not be used in const operations +error: generic parameters may not be used in enum discriminant values --> $DIR/issue-70453-generics-in-discr-ice-2.rs:9:35 | LL | Some(T) = std::mem::size_of::(), | ^ cannot perform const operation using `T` | - = note: type parameters may not be used in const expressions - = help: use `#![feature(generic_const_exprs)]` to allow generic const expressions + = note: type parameters may not be used in enum discriminant values error: aborting due to previous error diff --git a/tests/ui/enum-discriminant/issue-70453-generics-in-discr-ice.rs b/tests/ui/enum-discriminant/issue-70453-generics-in-discr-ice.rs index a0fb788a5..093c57534 100644 --- a/tests/ui/enum-discriminant/issue-70453-generics-in-discr-ice.rs +++ b/tests/ui/enum-discriminant/issue-70453-generics-in-discr-ice.rs @@ -8,7 +8,7 @@ enum MyWeirdOption { //~^ ERROR parameter `T` is never used None = 0, Some = std::mem::size_of::(), - //~^ ERROR generic parameters may not be used in const operations + //~^ ERROR generic parameters may not be used in enum discriminant values } fn main() { diff --git a/tests/ui/enum-discriminant/issue-70453-generics-in-discr-ice.stderr b/tests/ui/enum-discriminant/issue-70453-generics-in-discr-ice.stderr index 7ea8a3912..fac3ce07a 100644 --- a/tests/ui/enum-discriminant/issue-70453-generics-in-discr-ice.stderr +++ b/tests/ui/enum-discriminant/issue-70453-generics-in-discr-ice.stderr @@ -1,11 +1,10 @@ -error: generic parameters may not be used in const operations +error: generic parameters may not be used in enum discriminant values --> $DIR/issue-70453-generics-in-discr-ice.rs:10:32 | LL | Some = std::mem::size_of::(), | ^ cannot perform const operation using `T` | - = note: type parameters may not be used in const expressions - = help: use `#![feature(generic_const_exprs)]` to allow generic const expressions + = note: type parameters may not be used in enum discriminant values error[E0392]: parameter `T` is never used --> $DIR/issue-70453-generics-in-discr-ice.rs:7:20 diff --git a/tests/ui/enum-discriminant/issue-70453-polymorphic-ctfe.stderr b/tests/ui/enum-discriminant/issue-70453-polymorphic-ctfe.stderr index 0a7a63160..15cd6d303 100644 --- a/tests/ui/enum-discriminant/issue-70453-polymorphic-ctfe.stderr +++ b/tests/ui/enum-discriminant/issue-70453-polymorphic-ctfe.stderr @@ -1,11 +1,10 @@ -error: generic parameters may not be used in const operations +error: generic parameters may not be used in enum discriminant values --> $DIR/issue-70453-polymorphic-ctfe.rs:9:41 | LL | Some(T) = core::mem::size_of::<*mut T>(), | ^ cannot perform const operation using `T` | - = note: type parameters may not be used in const expressions - = help: use `#![feature(generic_const_exprs)]` to allow generic const expressions + = note: type parameters may not be used in enum discriminant values error: aborting due to previous error -- cgit v1.2.3