]> git.lizzy.rs Git - rust.git/commitdiff
Add tests for `const_generics`
authorvarkor <github@varkor.com>
Sat, 3 Oct 2020 16:00:18 +0000 (17:00 +0100)
committervarkor <github@varkor.com>
Sat, 3 Oct 2020 16:00:18 +0000 (17:00 +0100)
24 files changed:
src/test/ui/const-generics/min_const_generics/const-argument-if-length.full.stderr [new file with mode: 0644]
src/test/ui/const-generics/min_const_generics/const-argument-if-length.min.stderr [new file with mode: 0644]
src/test/ui/const-generics/min_const_generics/const-argument-if-length.rs
src/test/ui/const-generics/min_const_generics/generic-function-call-in-array-length.full.stderr [new file with mode: 0644]
src/test/ui/const-generics/min_const_generics/generic-function-call-in-array-length.min.stderr [new file with mode: 0644]
src/test/ui/const-generics/min_const_generics/generic-function-call-in-array-length.rs
src/test/ui/const-generics/min_const_generics/generic-sum-in-array-length.full.stderr [new file with mode: 0644]
src/test/ui/const-generics/min_const_generics/generic-sum-in-array-length.min.stderr [new file with mode: 0644]
src/test/ui/const-generics/min_const_generics/generic-sum-in-array-length.rs
src/test/ui/const-generics/min_const_generics/intrinsics-type_name-as-const-argument.full.stderr [new file with mode: 0644]
src/test/ui/const-generics/min_const_generics/intrinsics-type_name-as-const-argument.min.stderr [new file with mode: 0644]
src/test/ui/const-generics/min_const_generics/intrinsics-type_name-as-const-argument.rs
src/test/ui/const-generics/min_const_generics/issue-67375.full.stderr [new file with mode: 0644]
src/test/ui/const-generics/min_const_generics/issue-67375.min.stderr [new file with mode: 0644]
src/test/ui/const-generics/min_const_generics/issue-67375.rs
src/test/ui/const-generics/min_const_generics/issue-67945-1.full.stderr [new file with mode: 0644]
src/test/ui/const-generics/min_const_generics/issue-67945-1.min.stderr [new file with mode: 0644]
src/test/ui/const-generics/min_const_generics/issue-67945-1.rs
src/test/ui/const-generics/min_const_generics/issue-67945-2.full.stderr [new file with mode: 0644]
src/test/ui/const-generics/min_const_generics/issue-67945-2.min.stderr [new file with mode: 0644]
src/test/ui/const-generics/min_const_generics/issue-67945-2.rs
src/test/ui/const-generics/min_const_generics/issue-67945-3.full.stderr [new file with mode: 0644]
src/test/ui/const-generics/min_const_generics/issue-67945-3.min.stderr [new file with mode: 0644]
src/test/ui/const-generics/min_const_generics/issue-67945-3.rs

diff --git a/src/test/ui/const-generics/min_const_generics/const-argument-if-length.full.stderr b/src/test/ui/const-generics/min_const_generics/const-argument-if-length.full.stderr
new file mode 100644 (file)
index 0000000..9b1c1be
--- /dev/null
@@ -0,0 +1,42 @@
+error[E0277]: the size for values of type `T` cannot be known at compilation time
+  --> $DIR/const-argument-if-length.rs:8:28
+   |
+LL | pub const fn is_zst<T: ?Sized>() -> usize {
+   |                     - this type parameter needs to be `Sized`
+LL |     if std::mem::size_of::<T>() == 0 {
+   |                            ^ doesn't have a size known at compile-time
+   | 
+  ::: $SRC_DIR/core/src/mem/mod.rs:LL:COL
+   |
+LL | pub const fn size_of<T>() -> usize {
+   |                      - required by this bound in `std::mem::size_of`
+
+error[E0080]: evaluation of constant value failed
+  --> $DIR/const-argument-if-length.rs:19:15
+   |
+LL |     pad: [u8; is_zst::<T>()],
+   |               ^^^^^^^^^^^^^ referenced constant has errors
+
+error[E0277]: the size for values of type `T` cannot be known at compilation time
+  --> $DIR/const-argument-if-length.rs:17:12
+   |
+LL | pub struct AtLeastByte<T: ?Sized> {
+   |                        - this type parameter needs to be `Sized`
+LL |     value: T,
+   |            ^ doesn't have a size known at compile-time
+   |
+   = note: only the last field of a struct may have a dynamically sized type
+   = help: change the field's type to have a statically known size
+help: borrowed types always have a statically known size
+   |
+LL |     value: &T,
+   |            ^
+help: the `Box` type always has a statically known size and allocates its contents in the heap
+   |
+LL |     value: Box<T>,
+   |            ^^^^ ^
+
+error: aborting due to 3 previous errors
+
+Some errors have detailed explanations: E0080, E0277.
+For more information about an error, try `rustc --explain E0080`.
diff --git a/src/test/ui/const-generics/min_const_generics/const-argument-if-length.min.stderr b/src/test/ui/const-generics/min_const_generics/const-argument-if-length.min.stderr
new file mode 100644 (file)
index 0000000..c666dce
--- /dev/null
@@ -0,0 +1,30 @@
+error: generic parameters must not be used inside of non-trivial constant values
+  --> $DIR/const-argument-if-length.rs:19:24
+   |
+LL |     pad: [u8; is_zst::<T>()],
+   |                        ^ non-trivial anonymous constants must not depend on the parameter `T`
+   |
+   = note: type parameters are currently not permitted in anonymous constants
+
+error[E0277]: the size for values of type `T` cannot be known at compilation time
+  --> $DIR/const-argument-if-length.rs:17:12
+   |
+LL | pub struct AtLeastByte<T: ?Sized> {
+   |                        - this type parameter needs to be `Sized`
+LL |     value: T,
+   |            ^ doesn't have a size known at compile-time
+   |
+   = note: only the last field of a struct may have a dynamically sized type
+   = help: change the field's type to have a statically known size
+help: borrowed types always have a statically known size
+   |
+LL |     value: &T,
+   |            ^
+help: the `Box` type always has a statically known size and allocates its contents in the heap
+   |
+LL |     value: Box<T>,
+   |            ^^^^ ^
+
+error: aborting due to 2 previous errors
+
+For more information about this error, try `rustc --explain E0277`.
index 03c78a2fe684e36de811e1068a590e1120f0a831..481ff97d68dbe02f1f2a1068dcdf65f876a65ea5 100644 (file)
@@ -1,7 +1,12 @@
-#![feature(min_const_generics)]
+// revisions: full min
+
+#![cfg_attr(full, allow(incomplete_features))]
+#![cfg_attr(full, feature(const_generics))]
+#![cfg_attr(min, feature(min_const_generics))]
 
 pub const fn is_zst<T: ?Sized>() -> usize {
     if std::mem::size_of::<T>() == 0 {
+        //[full]~^ ERROR the size for values of type `T` cannot be known at compilation time
         1
     } else {
         0
@@ -12,7 +17,8 @@ pub struct AtLeastByte<T: ?Sized> {
     value: T,
     //~^ ERROR the size for values of type `T` cannot be known at compilation time
     pad: [u8; is_zst::<T>()],
-    //~^ ERROR generic parameters must not be used inside of non-trivial constant values
+    //[min]~^ ERROR generic parameters must not be used inside of non-trivial constant values
+    //[full]~^^ ERROR evaluation of constant value failed
 }
 
 fn main() {}
diff --git a/src/test/ui/const-generics/min_const_generics/generic-function-call-in-array-length.full.stderr b/src/test/ui/const-generics/min_const_generics/generic-function-call-in-array-length.full.stderr
new file mode 100644 (file)
index 0000000..43b42d8
--- /dev/null
@@ -0,0 +1,10 @@
+error: constant expression depends on a generic parameter
+  --> $DIR/generic-function-call-in-array-length.rs:9:29
+   |
+LL | fn bar<const N: usize>() -> [u32; foo(N)] {
+   |                             ^^^^^^^^^^^^^
+   |
+   = note: this may fail depending on what value the parameter takes
+
+error: aborting due to previous error
+
diff --git a/src/test/ui/const-generics/min_const_generics/generic-function-call-in-array-length.min.stderr b/src/test/ui/const-generics/min_const_generics/generic-function-call-in-array-length.min.stderr
new file mode 100644 (file)
index 0000000..e7e968e
--- /dev/null
@@ -0,0 +1,18 @@
+error: generic parameters must not be used inside of non-trivial constant values
+  --> $DIR/generic-function-call-in-array-length.rs:9:39
+   |
+LL | fn bar<const N: usize>() -> [u32; foo(N)] {
+   |                                       ^ non-trivial anonymous constants must not depend on the parameter `N`
+   |
+   = help: it is currently only allowed to use either `N` or `{ N }` as generic constants
+
+error: generic parameters must not be used inside of non-trivial constant values
+  --> $DIR/generic-function-call-in-array-length.rs:12:13
+   |
+LL |     [0; foo(N)]
+   |             ^ non-trivial anonymous constants must not depend on the parameter `N`
+   |
+   = help: it is currently only allowed to use either `N` or `{ N }` as generic constants
+
+error: aborting due to 2 previous errors
+
index f5387d659b3faf292a47ddcda48d7f5fab5ee8f0..c8bbae29343dc094e5695ef6532befaa65e57fdf 100644 (file)
@@ -1,11 +1,16 @@
-#![feature(min_const_generics)]
+// revisions: full min
+
+#![cfg_attr(full, allow(incomplete_features))]
+#![cfg_attr(full, feature(const_generics))]
+#![cfg_attr(min, feature(min_const_generics))]
 
 const fn foo(n: usize) -> usize { n * 2 }
 
 fn bar<const N: usize>() -> [u32; foo(N)] {
-    //~^ ERROR generic parameters must not be used inside of non-trivial constant values
+    //[min]~^ ERROR generic parameters must not be used inside of non-trivial constant values
+    //[full]~^^ ERROR constant expression depends on a generic parameter
     [0; foo(N)]
-    //~^ ERROR generic parameters must not be used inside of non-trivial constant values
+    //[min]~^ ERROR generic parameters must not be used inside of non-trivial constant values
 }
 
 fn main() {}
diff --git a/src/test/ui/const-generics/min_const_generics/generic-sum-in-array-length.full.stderr b/src/test/ui/const-generics/min_const_generics/generic-sum-in-array-length.full.stderr
new file mode 100644 (file)
index 0000000..d311e1c
--- /dev/null
@@ -0,0 +1,10 @@
+error: constant expression depends on a generic parameter
+  --> $DIR/generic-sum-in-array-length.rs:7:45
+   |
+LL | fn foo<const A: usize, const B: usize>(bar: [usize; A + B]) {}
+   |                                             ^^^^^^^^^^^^^^
+   |
+   = note: this may fail depending on what value the parameter takes
+
+error: aborting due to previous error
+
diff --git a/src/test/ui/const-generics/min_const_generics/generic-sum-in-array-length.min.stderr b/src/test/ui/const-generics/min_const_generics/generic-sum-in-array-length.min.stderr
new file mode 100644 (file)
index 0000000..6f157fb
--- /dev/null
@@ -0,0 +1,18 @@
+error: generic parameters must not be used inside of non-trivial constant values
+  --> $DIR/generic-sum-in-array-length.rs:7:53
+   |
+LL | fn foo<const A: usize, const B: usize>(bar: [usize; A + B]) {}
+   |                                                     ^ non-trivial anonymous constants must not depend on the parameter `A`
+   |
+   = help: it is currently only allowed to use either `A` or `{ A }` as generic constants
+
+error: generic parameters must not be used inside of non-trivial constant values
+  --> $DIR/generic-sum-in-array-length.rs:7:57
+   |
+LL | fn foo<const A: usize, const B: usize>(bar: [usize; A + B]) {}
+   |                                                         ^ non-trivial anonymous constants must not depend on the parameter `B`
+   |
+   = help: it is currently only allowed to use either `B` or `{ B }` as generic constants
+
+error: aborting due to 2 previous errors
+
index ad0748297f53ebe42a4dfb512728305553bcfa1b..810095b384baa3ee5ab46372264aada3268a37c7 100644 (file)
@@ -1,7 +1,12 @@
-#![feature(min_const_generics)]
+// revisions: full min
+
+#![cfg_attr(full, allow(incomplete_features))]
+#![cfg_attr(full, feature(const_generics))]
+#![cfg_attr(min, feature(min_const_generics))]
 
 fn foo<const A: usize, const B: usize>(bar: [usize; A + B]) {}
-//~^ ERROR generic parameters must not be used inside of non-trivial constant values
-//~| ERROR generic parameters must not be used inside of non-trivial constant values
+//[min]~^ ERROR generic parameters must not be used inside of non-trivial constant values
+//[min]~| ERROR generic parameters must not be used inside of non-trivial constant values
+//[full]~^^^ ERROR constant expression depends on a generic parameter
 
 fn main() {}
diff --git a/src/test/ui/const-generics/min_const_generics/intrinsics-type_name-as-const-argument.full.stderr b/src/test/ui/const-generics/min_const_generics/intrinsics-type_name-as-const-argument.full.stderr
new file mode 100644 (file)
index 0000000..c09d16d
--- /dev/null
@@ -0,0 +1,10 @@
+error: constant expression depends on a generic parameter
+  --> $DIR/intrinsics-type_name-as-const-argument.rs:15:8
+   |
+LL |     T: Trait<{std::intrinsics::type_name::<T>()}>
+   |        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+   |
+   = note: this may fail depending on what value the parameter takes
+
+error: aborting due to previous error
+
diff --git a/src/test/ui/const-generics/min_const_generics/intrinsics-type_name-as-const-argument.min.stderr b/src/test/ui/const-generics/min_const_generics/intrinsics-type_name-as-const-argument.min.stderr
new file mode 100644 (file)
index 0000000..307db08
--- /dev/null
@@ -0,0 +1,19 @@
+error: generic parameters must not be used inside of non-trivial constant values
+  --> $DIR/intrinsics-type_name-as-const-argument.rs:15:44
+   |
+LL |     T: Trait<{std::intrinsics::type_name::<T>()}>
+   |                                            ^ non-trivial anonymous constants must not depend on the parameter `T`
+   |
+   = note: type parameters are currently not permitted in anonymous constants
+
+error: `&'static str` is forbidden as the type of a const generic parameter
+  --> $DIR/intrinsics-type_name-as-const-argument.rs:10:22
+   |
+LL | trait Trait<const S: &'static str> {}
+   |                      ^^^^^^^^^^^^
+   |
+   = note: the only supported types are integers, `bool` and `char`
+   = note: more complex types are supported with `#[feature(const_generics)]`
+
+error: aborting due to 2 previous errors
+
index 5b5958520937f8903aef7d739e34f50516564e4d..37b6cf4bab92bf9f57ea4c91316d4f04729a6a1d 100644 (file)
@@ -1,13 +1,20 @@
-#![feature(min_const_generics)]
+// revisions: full min
+
+#![cfg_attr(full, allow(incomplete_features))]
+#![cfg_attr(full, feature(const_generics))]
+#![cfg_attr(min, feature(min_const_generics))]
+
 #![feature(core_intrinsics)]
+#![feature(const_type_name)]
 
 trait Trait<const S: &'static str> {}
-//~^ ERROR `&'static str` is forbidden as the type of a const generic parameter
+//[min]~^ ERROR `&'static str` is forbidden as the type of a const generic parameter
 
 struct Bug<T>
 where
     T: Trait<{std::intrinsics::type_name::<T>()}>
-    //~^ ERROR generic parameters must not be used inside of non-trivial constant values
+    //[min]~^ ERROR generic parameters must not be used inside of non-trivial constant values
+    //[full]~^^ ERROR constant expression depends on a generic parameter
 {
     t: T
 }
diff --git a/src/test/ui/const-generics/min_const_generics/issue-67375.full.stderr b/src/test/ui/const-generics/min_const_generics/issue-67375.full.stderr
new file mode 100644 (file)
index 0000000..e15d65f
--- /dev/null
@@ -0,0 +1,21 @@
+warning: cannot use constants which depend on generic parameters in types
+  --> $DIR/issue-67375.rs:9:12
+   |
+LL |     inner: [(); { [|_: &T| {}; 0].len() }],
+   |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+   |
+   = note: `#[warn(const_evaluatable_unchecked)]` on by default
+   = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+   = note: for more information, see issue #76200 <https://github.com/rust-lang/rust/issues/76200>
+
+error[E0392]: parameter `T` is never used
+  --> $DIR/issue-67375.rs:7:12
+   |
+LL | struct Bug<T> {
+   |            ^ unused parameter
+   |
+   = help: consider removing `T`, referring to it in a field, or using a marker such as `PhantomData`
+
+error: aborting due to previous error; 1 warning emitted
+
+For more information about this error, try `rustc --explain E0392`.
diff --git a/src/test/ui/const-generics/min_const_generics/issue-67375.min.stderr b/src/test/ui/const-generics/min_const_generics/issue-67375.min.stderr
new file mode 100644 (file)
index 0000000..b13d9fd
--- /dev/null
@@ -0,0 +1,19 @@
+error: generic parameters must not be used inside of non-trivial constant values
+  --> $DIR/issue-67375.rs:9:25
+   |
+LL |     inner: [(); { [|_: &T| {}; 0].len() }],
+   |                         ^ non-trivial anonymous constants must not depend on the parameter `T`
+   |
+   = note: type parameters are currently not permitted in anonymous constants
+
+error[E0392]: parameter `T` is never used
+  --> $DIR/issue-67375.rs:7:12
+   |
+LL | struct Bug<T> {
+   |            ^ unused parameter
+   |
+   = help: consider removing `T`, referring to it in a field, or using a marker such as `PhantomData`
+
+error: aborting due to 2 previous errors
+
+For more information about this error, try `rustc --explain E0392`.
index 308c48f8d325d559ac010435a6e02708500aa1cf..994ec92cfb501b4135cdd96690559eb0503f899c 100644 (file)
@@ -1,9 +1,15 @@
-#![feature(min_const_generics)]
+// revisions: full min
+
+#![cfg_attr(full, allow(incomplete_features))]
+#![cfg_attr(full, feature(const_generics))]
+#![cfg_attr(min, feature(min_const_generics))]
 
 struct Bug<T> {
     //~^ ERROR parameter `T` is never used
     inner: [(); { [|_: &T| {}; 0].len() }],
-    //~^ ERROR generic parameters must not be used inside of non-trivial constant values
+    //[min]~^ ERROR generic parameters must not be used inside of non-trivial constant values
+    //[full]~^^ WARN cannot use constants which depend on generic parameters in types
+    //[full]~^^^ WARN this was previously accepted by the compiler
 }
 
 fn main() {}
diff --git a/src/test/ui/const-generics/min_const_generics/issue-67945-1.full.stderr b/src/test/ui/const-generics/min_const_generics/issue-67945-1.full.stderr
new file mode 100644 (file)
index 0000000..e79c4f5
--- /dev/null
@@ -0,0 +1,26 @@
+error[E0308]: mismatched types
+  --> $DIR/issue-67945-1.rs:14:20
+   |
+LL | struct Bug<S> {
+   |            - this type parameter
+...
+LL |         let x: S = MaybeUninit::uninit();
+   |                -   ^^^^^^^^^^^^^^^^^^^^^ expected type parameter `S`, found union `MaybeUninit`
+   |                |
+   |                expected due to this
+   |
+   = note: expected type parameter `S`
+                       found union `MaybeUninit<_>`
+
+error[E0392]: parameter `S` is never used
+  --> $DIR/issue-67945-1.rs:11:12
+   |
+LL | struct Bug<S> {
+   |            ^ unused parameter
+   |
+   = help: consider removing `S`, referring to it in a field, or using a marker such as `PhantomData`
+
+error: aborting due to 2 previous errors
+
+Some errors have detailed explanations: E0308, E0392.
+For more information about an error, try `rustc --explain E0308`.
diff --git a/src/test/ui/const-generics/min_const_generics/issue-67945-1.min.stderr b/src/test/ui/const-generics/min_const_generics/issue-67945-1.min.stderr
new file mode 100644 (file)
index 0000000..949b5da
--- /dev/null
@@ -0,0 +1,27 @@
+error: generic parameters must not be used inside of non-trivial constant values
+  --> $DIR/issue-67945-1.rs:14:16
+   |
+LL |         let x: S = MaybeUninit::uninit();
+   |                ^ non-trivial anonymous constants must not depend on the parameter `S`
+   |
+   = note: type parameters are currently not permitted in anonymous constants
+
+error: generic parameters must not be used inside of non-trivial constant values
+  --> $DIR/issue-67945-1.rs:17:45
+   |
+LL |         let b = &*(&x as *const _ as *const S);
+   |                                             ^ non-trivial anonymous constants must not depend on the parameter `S`
+   |
+   = note: type parameters are currently not permitted in anonymous constants
+
+error[E0392]: parameter `S` is never used
+  --> $DIR/issue-67945-1.rs:11:12
+   |
+LL | struct Bug<S> {
+   |            ^ unused parameter
+   |
+   = help: consider removing `S`, referring to it in a field, or using a marker such as `PhantomData`
+
+error: aborting due to 3 previous errors
+
+For more information about this error, try `rustc --explain E0392`.
index f335f294de80e9265a8b721f602a31574a52358e..d1a83e978d1b8243276fd389235c6da931cd097c 100644 (file)
@@ -1,4 +1,8 @@
-#![feature(min_const_generics)]
+// revisions: full min
+
+#![cfg_attr(full, allow(incomplete_features))]
+#![cfg_attr(full, feature(const_generics))]
+#![cfg_attr(min, feature(min_const_generics))]
 
 use std::marker::PhantomData;
 
@@ -8,9 +12,10 @@ struct Bug<S> {
     //~^ ERROR parameter `S` is never used
     A: [(); {
         let x: S = MaybeUninit::uninit();
-        //~^ ERROR generic parameters must not be used inside of non-trivial constant values
+        //[min]~^ ERROR generic parameters must not be used inside of non-trivial constant values
+        //[full]~^^ ERROR mismatched types
         let b = &*(&x as *const _ as *const S);
-        //~^ ERROR generic parameters must not be used inside of non-trivial constant values
+        //[min]~^ ERROR generic parameters must not be used inside of non-trivial constant values
         0
     }],
 }
diff --git a/src/test/ui/const-generics/min_const_generics/issue-67945-2.full.stderr b/src/test/ui/const-generics/min_const_generics/issue-67945-2.full.stderr
new file mode 100644 (file)
index 0000000..2f54b80
--- /dev/null
@@ -0,0 +1,26 @@
+error[E0308]: mismatched types
+  --> $DIR/issue-67945-2.rs:12:20
+   |
+LL | struct Bug<S> {
+   |            - this type parameter
+...
+LL |         let x: S = MaybeUninit::uninit();
+   |                -   ^^^^^^^^^^^^^^^^^^^^^ expected type parameter `S`, found union `MaybeUninit`
+   |                |
+   |                expected due to this
+   |
+   = note: expected type parameter `S`
+                       found union `MaybeUninit<_>`
+
+error[E0392]: parameter `S` is never used
+  --> $DIR/issue-67945-2.rs:9:12
+   |
+LL | struct Bug<S> {
+   |            ^ unused parameter
+   |
+   = help: consider removing `S`, referring to it in a field, or using a marker such as `PhantomData`
+
+error: aborting due to 2 previous errors
+
+Some errors have detailed explanations: E0308, E0392.
+For more information about an error, try `rustc --explain E0308`.
diff --git a/src/test/ui/const-generics/min_const_generics/issue-67945-2.min.stderr b/src/test/ui/const-generics/min_const_generics/issue-67945-2.min.stderr
new file mode 100644 (file)
index 0000000..ed445b3
--- /dev/null
@@ -0,0 +1,27 @@
+error: generic parameters must not be used inside of non-trivial constant values
+  --> $DIR/issue-67945-2.rs:12:16
+   |
+LL |         let x: S = MaybeUninit::uninit();
+   |                ^ non-trivial anonymous constants must not depend on the parameter `S`
+   |
+   = note: type parameters are currently not permitted in anonymous constants
+
+error: generic parameters must not be used inside of non-trivial constant values
+  --> $DIR/issue-67945-2.rs:15:45
+   |
+LL |         let b = &*(&x as *const _ as *const S);
+   |                                             ^ non-trivial anonymous constants must not depend on the parameter `S`
+   |
+   = note: type parameters are currently not permitted in anonymous constants
+
+error[E0392]: parameter `S` is never used
+  --> $DIR/issue-67945-2.rs:9:12
+   |
+LL | struct Bug<S> {
+   |            ^ unused parameter
+   |
+   = help: consider removing `S`, referring to it in a field, or using a marker such as `PhantomData`
+
+error: aborting due to 3 previous errors
+
+For more information about this error, try `rustc --explain E0392`.
index 9faa1e0694d4d917483d7642543c69ebddbb7b5f..7f789297df0342663baabc7c670be306381ec62b 100644 (file)
@@ -1,4 +1,8 @@
-#![feature(min_const_generics)]
+// revisions: full min
+
+#![cfg_attr(full, allow(incomplete_features))]
+#![cfg_attr(full, feature(const_generics))]
+#![cfg_attr(min, feature(min_const_generics))]
 
 use std::mem::MaybeUninit;
 
@@ -6,9 +10,10 @@ struct Bug<S> {
     //~^ ERROR parameter `S` is never used
     A: [(); {
         let x: S = MaybeUninit::uninit();
-        //~^ ERROR generic parameters must not be used inside of non-trivial constant values
+        //[min]~^ ERROR generic parameters must not be used inside of non-trivial constant values
+        //[full]~^^ ERROR mismatched types
         let b = &*(&x as *const _ as *const S);
-        //~^ ERROR generic parameters must not be used inside of non-trivial constant values
+        //[min]~^ ERROR generic parameters must not be used inside of non-trivial constant values
         0
     }],
 }
diff --git a/src/test/ui/const-generics/min_const_generics/issue-67945-3.full.stderr b/src/test/ui/const-generics/min_const_generics/issue-67945-3.full.stderr
new file mode 100644 (file)
index 0000000..c33b885
--- /dev/null
@@ -0,0 +1,16 @@
+error: constant expression depends on a generic parameter
+  --> $DIR/issue-67945-3.rs:8:8
+   |
+LL |       A: [(); {
+   |  ________^
+LL | |
+LL | |         let x: Option<Box<Self>> = None;
+LL | |
+LL | |         0
+LL | |     }],
+   | |______^
+   |
+   = note: this may fail depending on what value the parameter takes
+
+error: aborting due to previous error
+
diff --git a/src/test/ui/const-generics/min_const_generics/issue-67945-3.min.stderr b/src/test/ui/const-generics/min_const_generics/issue-67945-3.min.stderr
new file mode 100644 (file)
index 0000000..9c6e101
--- /dev/null
@@ -0,0 +1,8 @@
+error: generic `Self` types are currently not permitted in anonymous constants
+  --> $DIR/issue-67945-3.rs:10:27
+   |
+LL |         let x: Option<Box<Self>> = None;
+   |                           ^^^^
+
+error: aborting due to previous error
+
index cde7200458e21292d2860e95c03e6b15a3581bea..bca079101e2b30a08f2d964777e6d3df8d7f5d85 100644 (file)
@@ -1,9 +1,14 @@
-#![feature(min_const_generics)]
+// revisions: full min
+
+#![cfg_attr(full, allow(incomplete_features))]
+#![cfg_attr(full, feature(const_generics))]
+#![cfg_attr(min, feature(min_const_generics))]
 
 struct Bug<S: ?Sized> {
     A: [(); {
+        //[full]~^ ERROR constant expression depends on a generic parameter
         let x: Option<Box<Self>> = None;
-        //~^ ERROR generic `Self` types are currently not permitted in anonymous constants
+        //[min]~^ ERROR generic `Self` types are currently not permitted in anonymous constants
         0
     }],
     B: S