From 0801263279bbd44b7dbe88d5039a6b810a037f3b Mon Sep 17 00:00:00 2001 From: varkor Date: Fri, 2 Oct 2020 01:39:04 +0100 Subject: [PATCH 1/7] Fix missing diagnostic span for `impl Trait` with const generics --- compiler/rustc_typeck/src/astconv/generics.rs | 2 +- .../impl-trait-with-const-arguments.rs | 22 +++++++++++++++++++ .../impl-trait-with-const-arguments.stderr | 8 +++++++ 3 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 src/test/ui/const-generics/min_const_generics/impl-trait-with-const-arguments.rs create mode 100644 src/test/ui/const-generics/min_const_generics/impl-trait-with-const-arguments.stderr diff --git a/compiler/rustc_typeck/src/astconv/generics.rs b/compiler/rustc_typeck/src/astconv/generics.rs index b54de1d091608..b867798c76cf7 100644 --- a/compiler/rustc_typeck/src/astconv/generics.rs +++ b/compiler/rustc_typeck/src/astconv/generics.rs @@ -562,7 +562,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o { .args .iter() .filter_map(|arg| match arg { - GenericArg::Type(_) => Some(arg.span()), + GenericArg::Type(_) | GenericArg::Const(_) => Some(arg.span()), _ => None, }) .collect::>(); diff --git a/src/test/ui/const-generics/min_const_generics/impl-trait-with-const-arguments.rs b/src/test/ui/const-generics/min_const_generics/impl-trait-with-const-arguments.rs new file mode 100644 index 0000000000000..97ae3b838a391 --- /dev/null +++ b/src/test/ui/const-generics/min_const_generics/impl-trait-with-const-arguments.rs @@ -0,0 +1,22 @@ +#![feature(min_const_generics)] + +trait Usizer { + fn m(self) -> usize; +} + +fn f(u: impl Usizer) -> usize { + N + u.m() +} + +struct Usizable; + +impl Usizer for Usizable { + fn m(self) -> usize { + 16 + } +} + +fn main() { + assert_eq!(f::<4usize>(Usizable), 20usize); +//~^ ERROR cannot provide explicit generic arguments when `impl Trait` is used in argument position +} diff --git a/src/test/ui/const-generics/min_const_generics/impl-trait-with-const-arguments.stderr b/src/test/ui/const-generics/min_const_generics/impl-trait-with-const-arguments.stderr new file mode 100644 index 0000000000000..0a6d350986368 --- /dev/null +++ b/src/test/ui/const-generics/min_const_generics/impl-trait-with-const-arguments.stderr @@ -0,0 +1,8 @@ +error[E0632]: cannot provide explicit generic arguments when `impl Trait` is used in argument position + --> $DIR/impl-trait-with-const-arguments.rs:20:20 + | +LL | assert_eq!(f::<4usize>(Usizable), 20usize); + | ^^^^^^ explicit generic argument not allowed + +error: aborting due to previous error + From 1db05e032db798b3162926ee4b72072d3c4de56f Mon Sep 17 00:00:00 2001 From: varkor Date: Fri, 2 Oct 2020 02:21:15 +0100 Subject: [PATCH 2/7] Add various `min_const_generics` regression tests --- .../const-argument-if-length.rs | 18 +++++++++++ .../const-argument-if-length.stderr | 30 +++++++++++++++++++ .../generic-function-call-in-array-length.rs | 11 +++++++ .../generic-sum-in-array-length.rs | 7 +++++ .../generic-sum-in-array-length.stderr | 18 +++++++++++ .../intrinsics-type_name-as-const-argument.rs | 15 ++++++++++ ...rinsics-type_name-as-const-argument.stderr | 19 ++++++++++++ .../min_const_generics/issue-67375.rs | 9 ++++++ .../min_const_generics/issue-67375.stderr | 19 ++++++++++++ .../min_const_generics/issue-67945-1.rs | 18 +++++++++++ .../min_const_generics/issue-67945-1.stderr | 27 +++++++++++++++++ .../min_const_generics/issue-67945-2.rs | 16 ++++++++++ .../min_const_generics/issue-67945-2.stderr | 27 +++++++++++++++++ .../min_const_generics/issue-67945-3.rs | 12 ++++++++ .../min_const_generics/issue-67945-3.stderr | 8 +++++ .../static-reference-array-const-param.rs | 8 +++++ .../static-reference-array-const-param.stderr | 11 +++++++ .../transmute-const-param-static-reference.rs | 12 ++++++++ ...nsmute-const-param-static-reference.stderr | 11 +++++++ 19 files changed, 296 insertions(+) create mode 100644 src/test/ui/const-generics/min_const_generics/const-argument-if-length.rs create mode 100644 src/test/ui/const-generics/min_const_generics/const-argument-if-length.stderr create mode 100644 src/test/ui/const-generics/min_const_generics/generic-function-call-in-array-length.rs create mode 100644 src/test/ui/const-generics/min_const_generics/generic-sum-in-array-length.rs create mode 100644 src/test/ui/const-generics/min_const_generics/generic-sum-in-array-length.stderr create mode 100644 src/test/ui/const-generics/min_const_generics/intrinsics-type_name-as-const-argument.rs create mode 100644 src/test/ui/const-generics/min_const_generics/intrinsics-type_name-as-const-argument.stderr create mode 100644 src/test/ui/const-generics/min_const_generics/issue-67375.rs create mode 100644 src/test/ui/const-generics/min_const_generics/issue-67375.stderr create mode 100644 src/test/ui/const-generics/min_const_generics/issue-67945-1.rs create mode 100644 src/test/ui/const-generics/min_const_generics/issue-67945-1.stderr create mode 100644 src/test/ui/const-generics/min_const_generics/issue-67945-2.rs create mode 100644 src/test/ui/const-generics/min_const_generics/issue-67945-2.stderr create mode 100644 src/test/ui/const-generics/min_const_generics/issue-67945-3.rs create mode 100644 src/test/ui/const-generics/min_const_generics/issue-67945-3.stderr create mode 100644 src/test/ui/const-generics/min_const_generics/static-reference-array-const-param.rs create mode 100644 src/test/ui/const-generics/min_const_generics/static-reference-array-const-param.stderr create mode 100644 src/test/ui/const-generics/min_const_generics/transmute-const-param-static-reference.rs create mode 100644 src/test/ui/const-generics/min_const_generics/transmute-const-param-static-reference.stderr diff --git a/src/test/ui/const-generics/min_const_generics/const-argument-if-length.rs b/src/test/ui/const-generics/min_const_generics/const-argument-if-length.rs new file mode 100644 index 0000000000000..354630ae87896 --- /dev/null +++ b/src/test/ui/const-generics/min_const_generics/const-argument-if-length.rs @@ -0,0 +1,18 @@ +#![feature(min_const_generics)] + +pub const fn is_zst() -> usize { + if std::mem::size_of::() == 0 { + 1 + } else { + 0 + } +} + +pub struct AtLeastByte { + value: T, + //~^ ERROR the size for values of type `T` cannot be known at compilation time + pad: [u8; is_zst::()], + //~^ 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/const-argument-if-length.stderr b/src/test/ui/const-generics/min_const_generics/const-argument-if-length.stderr new file mode 100644 index 0000000000000..a5bd3ab274836 --- /dev/null +++ b/src/test/ui/const-generics/min_const_generics/const-argument-if-length.stderr @@ -0,0 +1,30 @@ +error: generic parameters must not be used inside of non trivial constant values + --> $DIR/const-argument-if-length.rs:14:24 + | +LL | pad: [u8; is_zst::()], + | ^ 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:12:12 + | +LL | pub struct AtLeastByte { + | - 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, + | ^^^^ ^ + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/const-generics/min_const_generics/generic-function-call-in-array-length.rs b/src/test/ui/const-generics/min_const_generics/generic-function-call-in-array-length.rs new file mode 100644 index 0000000000000..c52f402294203 --- /dev/null +++ b/src/test/ui/const-generics/min_const_generics/generic-function-call-in-array-length.rs @@ -0,0 +1,11 @@ +#![feature(min_const_generics)] + +const fn foo(n: usize) -> usize { n * 2 } + +fn bar() -> [u32; foo(N)] { + //~^ ERROR generic parameters must not be used inside of non trivial constant values + [0; foo(N)] + //~^ 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.rs b/src/test/ui/const-generics/min_const_generics/generic-sum-in-array-length.rs new file mode 100644 index 0000000000000..de7e5fe47283e --- /dev/null +++ b/src/test/ui/const-generics/min_const_generics/generic-sum-in-array-length.rs @@ -0,0 +1,7 @@ +#![feature(min_const_generics)] + +fn foo(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 + +fn main() {} diff --git a/src/test/ui/const-generics/min_const_generics/generic-sum-in-array-length.stderr b/src/test/ui/const-generics/min_const_generics/generic-sum-in-array-length.stderr new file mode 100644 index 0000000000000..45d0ba985a48a --- /dev/null +++ b/src/test/ui/const-generics/min_const_generics/generic-sum-in-array-length.stderr @@ -0,0 +1,18 @@ +error: generic parameters must not be used inside of non trivial constant values + --> $DIR/generic-sum-in-array-length.rs:3:53 + | +LL | fn foo(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:3:57 + | +LL | fn foo(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 + diff --git a/src/test/ui/const-generics/min_const_generics/intrinsics-type_name-as-const-argument.rs b/src/test/ui/const-generics/min_const_generics/intrinsics-type_name-as-const-argument.rs new file mode 100644 index 0000000000000..167a3f23c4c40 --- /dev/null +++ b/src/test/ui/const-generics/min_const_generics/intrinsics-type_name-as-const-argument.rs @@ -0,0 +1,15 @@ +#![feature(min_const_generics)] +#![feature(core_intrinsics)] + +trait Trait {} +//~^ ERROR `&'static str` is forbidden as the type of a const generic parameter + +struct Bug +where + T: Trait<{std::intrinsics::type_name::()}> + //~^ ERROR generic parameters must not be used inside of non trivial constant values +{ + t: T +} + +fn main() {} diff --git a/src/test/ui/const-generics/min_const_generics/intrinsics-type_name-as-const-argument.stderr b/src/test/ui/const-generics/min_const_generics/intrinsics-type_name-as-const-argument.stderr new file mode 100644 index 0000000000000..07147da1117a3 --- /dev/null +++ b/src/test/ui/const-generics/min_const_generics/intrinsics-type_name-as-const-argument.stderr @@ -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:9:44 + | +LL | T: Trait<{std::intrinsics::type_name::()}> + | ^ 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:4:22 + | +LL | trait Trait {} + | ^^^^^^^^^^^^ + | + = 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 + diff --git a/src/test/ui/const-generics/min_const_generics/issue-67375.rs b/src/test/ui/const-generics/min_const_generics/issue-67375.rs new file mode 100644 index 0000000000000..77ff10070e971 --- /dev/null +++ b/src/test/ui/const-generics/min_const_generics/issue-67375.rs @@ -0,0 +1,9 @@ +#![feature(min_const_generics)] + +struct Bug { + //~^ ERROR parameter `T` is never used + inner: [(); { [|_: &T| {}; 0].len() }], + //~^ 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/issue-67375.stderr b/src/test/ui/const-generics/min_const_generics/issue-67375.stderr new file mode 100644 index 0000000000000..345bdedfcb3e5 --- /dev/null +++ b/src/test/ui/const-generics/min_const_generics/issue-67375.stderr @@ -0,0 +1,19 @@ +error: generic parameters must not be used inside of non trivial constant values + --> $DIR/issue-67375.rs:5: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:3:12 + | +LL | struct Bug { + | ^ 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`. diff --git a/src/test/ui/const-generics/min_const_generics/issue-67945-1.rs b/src/test/ui/const-generics/min_const_generics/issue-67945-1.rs new file mode 100644 index 0000000000000..cb1c900eb4fa8 --- /dev/null +++ b/src/test/ui/const-generics/min_const_generics/issue-67945-1.rs @@ -0,0 +1,18 @@ +#![feature(min_const_generics)] + +use std::marker::PhantomData; + +use std::mem::{self, MaybeUninit}; + +struct Bug { + //~^ 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 + let b = &*(&x as *const _ as *const S); + //~^ ERROR generic parameters must not be used inside of non trivial constant values + 0 + }], +} + +fn main() {} diff --git a/src/test/ui/const-generics/min_const_generics/issue-67945-1.stderr b/src/test/ui/const-generics/min_const_generics/issue-67945-1.stderr new file mode 100644 index 0000000000000..a9a4fda8a479b --- /dev/null +++ b/src/test/ui/const-generics/min_const_generics/issue-67945-1.stderr @@ -0,0 +1,27 @@ +error: generic parameters must not be used inside of non trivial constant values + --> $DIR/issue-67945-1.rs:10: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:12: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:7:12 + | +LL | struct Bug { + | ^ 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`. diff --git a/src/test/ui/const-generics/min_const_generics/issue-67945-2.rs b/src/test/ui/const-generics/min_const_generics/issue-67945-2.rs new file mode 100644 index 0000000000000..4b0799dce1eb5 --- /dev/null +++ b/src/test/ui/const-generics/min_const_generics/issue-67945-2.rs @@ -0,0 +1,16 @@ +#![feature(min_const_generics)] + +use std::mem::MaybeUninit; + +struct Bug { + //~^ 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 + let b = &*(&x as *const _ as *const S); + //~^ ERROR generic parameters must not be used inside of non trivial constant values + 0 + }], +} + +fn main() {} diff --git a/src/test/ui/const-generics/min_const_generics/issue-67945-2.stderr b/src/test/ui/const-generics/min_const_generics/issue-67945-2.stderr new file mode 100644 index 0000000000000..8c40dc0eade80 --- /dev/null +++ b/src/test/ui/const-generics/min_const_generics/issue-67945-2.stderr @@ -0,0 +1,27 @@ +error: generic parameters must not be used inside of non trivial constant values + --> $DIR/issue-67945-2.rs:8: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:10: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:5:12 + | +LL | struct Bug { + | ^ 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`. diff --git a/src/test/ui/const-generics/min_const_generics/issue-67945-3.rs b/src/test/ui/const-generics/min_const_generics/issue-67945-3.rs new file mode 100644 index 0000000000000..cde7200458e21 --- /dev/null +++ b/src/test/ui/const-generics/min_const_generics/issue-67945-3.rs @@ -0,0 +1,12 @@ +#![feature(min_const_generics)] + +struct Bug { + A: [(); { + let x: Option> = None; + //~^ ERROR generic `Self` types are currently not permitted in anonymous constants + 0 + }], + B: S +} + +fn main() {} diff --git a/src/test/ui/const-generics/min_const_generics/issue-67945-3.stderr b/src/test/ui/const-generics/min_const_generics/issue-67945-3.stderr new file mode 100644 index 0000000000000..c5f919302dc85 --- /dev/null +++ b/src/test/ui/const-generics/min_const_generics/issue-67945-3.stderr @@ -0,0 +1,8 @@ +error: generic `Self` types are currently not permitted in anonymous constants + --> $DIR/issue-67945-3.rs:5:27 + | +LL | let x: Option> = None; + | ^^^^ + +error: aborting due to previous error + diff --git a/src/test/ui/const-generics/min_const_generics/static-reference-array-const-param.rs b/src/test/ui/const-generics/min_const_generics/static-reference-array-const-param.rs new file mode 100644 index 0000000000000..0ef17109bed40 --- /dev/null +++ b/src/test/ui/const-generics/min_const_generics/static-reference-array-const-param.rs @@ -0,0 +1,8 @@ +#![feature(min_const_generics)] + +fn a() {} +//~^ ERROR `&'static [u32]` is forbidden as the type of a const generic parameter + +fn main() { + a::<{&[]}>(); +} diff --git a/src/test/ui/const-generics/min_const_generics/static-reference-array-const-param.stderr b/src/test/ui/const-generics/min_const_generics/static-reference-array-const-param.stderr new file mode 100644 index 0000000000000..cc32d8a67fed0 --- /dev/null +++ b/src/test/ui/const-generics/min_const_generics/static-reference-array-const-param.stderr @@ -0,0 +1,11 @@ +error: `&'static [u32]` is forbidden as the type of a const generic parameter + --> $DIR/static-reference-array-const-param.rs:3:15 + | +LL | fn a() {} + | ^^^^^^^^^^^^^^ + | + = note: the only supported types are integers, `bool` and `char` + = note: more complex types are supported with `#[feature(const_generics)]` + +error: aborting due to previous error + diff --git a/src/test/ui/const-generics/min_const_generics/transmute-const-param-static-reference.rs b/src/test/ui/const-generics/min_const_generics/transmute-const-param-static-reference.rs new file mode 100644 index 0000000000000..dfa1ece2f3657 --- /dev/null +++ b/src/test/ui/const-generics/min_const_generics/transmute-const-param-static-reference.rs @@ -0,0 +1,12 @@ +#![feature(min_const_generics)] + +struct Const; +//~^ ERROR `&'static ()` is forbidden as the type of a const generic parameter + +fn main() { + const A: &'static () = unsafe { + std::mem::transmute(10 as *const ()) + }; + + let _ = Const::<{A}>; +} diff --git a/src/test/ui/const-generics/min_const_generics/transmute-const-param-static-reference.stderr b/src/test/ui/const-generics/min_const_generics/transmute-const-param-static-reference.stderr new file mode 100644 index 0000000000000..063120ad074a0 --- /dev/null +++ b/src/test/ui/const-generics/min_const_generics/transmute-const-param-static-reference.stderr @@ -0,0 +1,11 @@ +error: `&'static ()` is forbidden as the type of a const generic parameter + --> $DIR/transmute-const-param-static-reference.rs:3:23 + | +LL | struct Const; + | ^^^^^^^^^^^ + | + = note: the only supported types are integers, `bool` and `char` + = note: more complex types are supported with `#[feature(const_generics)]` + +error: aborting due to previous error + From 488b759d5ca97c167d6a35d59d18cfb5770e70d0 Mon Sep 17 00:00:00 2001 From: varkor Date: Fri, 2 Oct 2020 02:31:05 +0100 Subject: [PATCH 3/7] Replace "non trivial" with "non-trivial" --- compiler/rustc_feature/src/active.rs | 2 +- compiler/rustc_resolve/src/diagnostics.rs | 2 +- compiler/rustc_resolve/src/lib.rs | 2 +- .../array-size-in-generic-struct-param.min.stderr | 4 ++-- .../const-generics/array-size-in-generic-struct-param.rs | 4 ++-- .../feature-gate-const_evaluatable_checked.min.stderr | 2 +- .../feature-gate-const_evaluatable_checked.rs | 2 +- .../const_evaluatable_checked/simple.min.stderr | 4 ++-- .../const_evaluatable_checked/simple_fail.min.stderr | 2 +- .../const_evaluatable_checked/simple_fail.rs | 2 +- .../const-generics/issue-61522-array-len-succ.min.stderr | 4 ++-- src/test/ui/const-generics/issues/issue-61747.min.stderr | 2 +- src/test/ui/const-generics/issues/issue-61935.min.stderr | 2 +- src/test/ui/const-generics/issues/issue-61935.rs | 2 +- src/test/ui/const-generics/issues/issue-62220.min.stderr | 2 +- src/test/ui/const-generics/issues/issue-62220.rs | 2 +- src/test/ui/const-generics/issues/issue-62456.min.stderr | 2 +- src/test/ui/const-generics/issues/issue-62456.rs | 2 +- src/test/ui/const-generics/issues/issue-64494.min.stderr | 4 ++-- src/test/ui/const-generics/issues/issue-64494.rs | 4 ++-- src/test/ui/const-generics/issues/issue-66205.min.stderr | 2 +- src/test/ui/const-generics/issues/issue-66205.rs | 2 +- src/test/ui/const-generics/issues/issue-67739.min.stderr | 2 +- src/test/ui/const-generics/issues/issue-67739.rs | 2 +- src/test/ui/const-generics/issues/issue-68366.min.stderr | 2 +- src/test/ui/const-generics/issues/issue-68366.rs | 2 +- src/test/ui/const-generics/issues/issue-68977.min.stderr | 4 ++-- src/test/ui/const-generics/issues/issue-68977.rs | 4 ++-- src/test/ui/const-generics/issues/issue-72787.min.stderr | 8 ++++---- src/test/ui/const-generics/issues/issue-72787.rs | 8 ++++---- .../issues/issue-72819-generic-in-const-eval.min.stderr | 2 +- .../issues/issue-72819-generic-in-const-eval.rs | 2 +- .../issues/issue-76701-ty-param-in-const.min.stderr | 4 ++-- .../issues/issue-76701-ty-param-in-const.rs | 4 ++-- .../min_const_generics/complex-expression.rs | 8 ++++---- .../min_const_generics/complex-expression.stderr | 8 ++++---- .../min_const_generics/const-argument-if-length.rs | 2 +- .../min_const_generics/const-argument-if-length.stderr | 2 +- .../generic-function-call-in-array-length.rs | 4 ++-- .../min_const_generics/generic-sum-in-array-length.rs | 4 ++-- .../min_const_generics/generic-sum-in-array-length.stderr | 4 ++-- .../intrinsics-type_name-as-const-argument.rs | 2 +- .../intrinsics-type_name-as-const-argument.stderr | 2 +- .../ui/const-generics/min_const_generics/issue-67375.rs | 2 +- .../const-generics/min_const_generics/issue-67375.stderr | 2 +- .../ui/const-generics/min_const_generics/issue-67945-1.rs | 4 ++-- .../min_const_generics/issue-67945-1.stderr | 4 ++-- .../ui/const-generics/min_const_generics/issue-67945-2.rs | 4 ++-- .../min_const_generics/issue-67945-2.stderr | 4 ++-- .../min_const_generics/self-ty-in-const-1.stderr | 2 +- .../params-in-ct-in-ty-param-lazy-norm.min.stderr | 2 +- .../const-generics/params-in-ct-in-ty-param-lazy-norm.rs | 2 +- src/test/ui/const-generics/wf-misc.min.stderr | 4 ++-- src/test/ui/const-generics/wf-misc.rs | 4 ++-- 54 files changed, 85 insertions(+), 85 deletions(-) diff --git a/compiler/rustc_feature/src/active.rs b/compiler/rustc_feature/src/active.rs index 348cff8d2dad2..c4774de73e195 100644 --- a/compiler/rustc_feature/src/active.rs +++ b/compiler/rustc_feature/src/active.rs @@ -581,7 +581,7 @@ declare_features! ( /// Allows `if let` guard in match arms. (active, if_let_guard, "1.47.0", Some(51114), None), - /// Allows non trivial generic constants which have to be manually propageted upwards. + /// Allows non-trivial generic constants which have to be manually propageted upwards. (active, const_evaluatable_checked, "1.48.0", Some(76560), None), /// Allows basic arithmetic on floating point types in a `const fn`. diff --git a/compiler/rustc_resolve/src/diagnostics.rs b/compiler/rustc_resolve/src/diagnostics.rs index 612bc3e74911c..e3cf6d12bd5eb 100644 --- a/compiler/rustc_resolve/src/diagnostics.rs +++ b/compiler/rustc_resolve/src/diagnostics.rs @@ -469,7 +469,7 @@ impl<'a> Resolver<'a> { ResolutionError::ParamInNonTrivialAnonConst { name, is_type } => { let mut err = self.session.struct_span_err( span, - "generic parameters must not be used inside of non trivial constant values", + "generic parameters must not be used inside of non-trivial constant values", ); err.span_label( span, diff --git a/compiler/rustc_resolve/src/lib.rs b/compiler/rustc_resolve/src/lib.rs index 283db1404d0a4..fe8f592638594 100644 --- a/compiler/rustc_resolve/src/lib.rs +++ b/compiler/rustc_resolve/src/lib.rs @@ -218,7 +218,7 @@ enum ResolutionError<'a> { ParamInTyOfConstParam(Symbol), /// constant values inside of type parameter defaults must not depend on generic parameters. ParamInAnonConstInTyDefault(Symbol), - /// generic parameters must not be used inside of non trivial constant values. + /// generic parameters must not be used inside of non-trivial constant values. /// /// This error is only emitted when using `min_const_generics`. ParamInNonTrivialAnonConst { name: Symbol, is_type: bool }, diff --git a/src/test/ui/const-generics/array-size-in-generic-struct-param.min.stderr b/src/test/ui/const-generics/array-size-in-generic-struct-param.min.stderr index 809514e8a1c9d..0fc45513cd78a 100644 --- a/src/test/ui/const-generics/array-size-in-generic-struct-param.min.stderr +++ b/src/test/ui/const-generics/array-size-in-generic-struct-param.min.stderr @@ -1,4 +1,4 @@ -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 --> $DIR/array-size-in-generic-struct-param.rs:9:48 | LL | struct ArithArrayLen([u32; 0 + N]); @@ -6,7 +6,7 @@ LL | struct ArithArrayLen([u32; 0 + 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 +error: generic parameters must not be used inside of non-trivial constant values --> $DIR/array-size-in-generic-struct-param.rs:20:15 | LL | arr: [u8; CFG.arr_size], diff --git a/src/test/ui/const-generics/array-size-in-generic-struct-param.rs b/src/test/ui/const-generics/array-size-in-generic-struct-param.rs index 8bd3b78725957..dd45b6ed278e8 100644 --- a/src/test/ui/const-generics/array-size-in-generic-struct-param.rs +++ b/src/test/ui/const-generics/array-size-in-generic-struct-param.rs @@ -8,7 +8,7 @@ #[allow(dead_code)] struct ArithArrayLen([u32; 0 + N]); //[full]~^ ERROR constant expression depends on a generic parameter -//[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 #[derive(PartialEq, Eq)] struct Config { @@ -19,7 +19,7 @@ struct B { //[min]~^ ERROR `Config` is forbidden arr: [u8; CFG.arr_size], //[full]~^ ERROR constant expression depends on a generic parameter - //[min]~^^ ERROR generic parameters must not be used inside of non trivial + //[min]~^^ ERROR generic parameters must not be used inside of non-trivial } const C: Config = Config { arr_size: 5 }; diff --git a/src/test/ui/const-generics/const_evaluatable_checked/feature-gate-const_evaluatable_checked.min.stderr b/src/test/ui/const-generics/const_evaluatable_checked/feature-gate-const_evaluatable_checked.min.stderr index 269710db164b1..4b3235fd08783 100644 --- a/src/test/ui/const-generics/const_evaluatable_checked/feature-gate-const_evaluatable_checked.min.stderr +++ b/src/test/ui/const-generics/const_evaluatable_checked/feature-gate-const_evaluatable_checked.min.stderr @@ -1,4 +1,4 @@ -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 --> $DIR/feature-gate-const_evaluatable_checked.rs:6:33 | LL | type Arr = [u8; N - 1]; diff --git a/src/test/ui/const-generics/const_evaluatable_checked/feature-gate-const_evaluatable_checked.rs b/src/test/ui/const-generics/const_evaluatable_checked/feature-gate-const_evaluatable_checked.rs index af3090115f24a..d552e0f543080 100644 --- a/src/test/ui/const-generics/const_evaluatable_checked/feature-gate-const_evaluatable_checked.rs +++ b/src/test/ui/const-generics/const_evaluatable_checked/feature-gate-const_evaluatable_checked.rs @@ -4,7 +4,7 @@ #![cfg_attr(min, feature(min_const_generics))] type Arr = [u8; N - 1]; -//[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 fn test() -> Arr where Arr: Default { //[full]~^ ERROR constant expression depends diff --git a/src/test/ui/const-generics/const_evaluatable_checked/simple.min.stderr b/src/test/ui/const-generics/const_evaluatable_checked/simple.min.stderr index 3cac604a7b33a..85a15b1e75fdc 100644 --- a/src/test/ui/const-generics/const_evaluatable_checked/simple.min.stderr +++ b/src/test/ui/const-generics/const_evaluatable_checked/simple.min.stderr @@ -1,4 +1,4 @@ -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 --> $DIR/simple.rs:8:53 | LL | fn test() -> [u8; N - 1] where [u8; N - 1]: Default { @@ -6,7 +6,7 @@ LL | fn test() -> [u8; N - 1] where [u8; N - 1]: Default { | = 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 +error: generic parameters must not be used inside of non-trivial constant values --> $DIR/simple.rs:8:35 | LL | fn test() -> [u8; N - 1] where [u8; N - 1]: Default { diff --git a/src/test/ui/const-generics/const_evaluatable_checked/simple_fail.min.stderr b/src/test/ui/const-generics/const_evaluatable_checked/simple_fail.min.stderr index 042710f13273e..2eac9505624dd 100644 --- a/src/test/ui/const-generics/const_evaluatable_checked/simple_fail.min.stderr +++ b/src/test/ui/const-generics/const_evaluatable_checked/simple_fail.min.stderr @@ -1,4 +1,4 @@ -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 --> $DIR/simple_fail.rs:7:33 | LL | type Arr = [u8; N - 1]; diff --git a/src/test/ui/const-generics/const_evaluatable_checked/simple_fail.rs b/src/test/ui/const-generics/const_evaluatable_checked/simple_fail.rs index b15e0ff183954..637c940f71432 100644 --- a/src/test/ui/const-generics/const_evaluatable_checked/simple_fail.rs +++ b/src/test/ui/const-generics/const_evaluatable_checked/simple_fail.rs @@ -5,7 +5,7 @@ #![allow(incomplete_features)] type Arr = [u8; N - 1]; //[full]~ ERROR evaluation of constant -//[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 fn test() -> Arr where Arr: Sized { todo!() diff --git a/src/test/ui/const-generics/issue-61522-array-len-succ.min.stderr b/src/test/ui/const-generics/issue-61522-array-len-succ.min.stderr index a1b1a095041b3..2c1bc055b28ae 100644 --- a/src/test/ui/const-generics/issue-61522-array-len-succ.min.stderr +++ b/src/test/ui/const-generics/issue-61522-array-len-succ.min.stderr @@ -1,4 +1,4 @@ -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 --> $DIR/issue-61522-array-len-succ.rs:7:45 | LL | pub struct MyArray([u8; COUNT + 1]); @@ -6,7 +6,7 @@ LL | pub struct MyArray([u8; COUNT + 1]); | = help: it is currently only allowed to use either `COUNT` or `{ COUNT }` as generic constants -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 --> $DIR/issue-61522-array-len-succ.rs:12:30 | LL | fn inner(&self) -> &[u8; COUNT + 1] { diff --git a/src/test/ui/const-generics/issues/issue-61747.min.stderr b/src/test/ui/const-generics/issues/issue-61747.min.stderr index 2061b6c55bb7b..fdd9a569748e2 100644 --- a/src/test/ui/const-generics/issues/issue-61747.min.stderr +++ b/src/test/ui/const-generics/issues/issue-61747.min.stderr @@ -1,4 +1,4 @@ -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 --> $DIR/issue-61747.rs:8:30 | LL | fn successor() -> Const<{C + 1}> { diff --git a/src/test/ui/const-generics/issues/issue-61935.min.stderr b/src/test/ui/const-generics/issues/issue-61935.min.stderr index e5715ec658c5c..f461a31eeae3a 100644 --- a/src/test/ui/const-generics/issues/issue-61935.min.stderr +++ b/src/test/ui/const-generics/issues/issue-61935.min.stderr @@ -1,4 +1,4 @@ -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 --> $DIR/issue-61935.rs:10:23 | LL | Self:FooImpl<{N==0}> diff --git a/src/test/ui/const-generics/issues/issue-61935.rs b/src/test/ui/const-generics/issues/issue-61935.rs index 64257da030943..a181a8dabe5aa 100644 --- a/src/test/ui/const-generics/issues/issue-61935.rs +++ b/src/test/ui/const-generics/issues/issue-61935.rs @@ -9,7 +9,7 @@ impl Foo for [(); N] where Self:FooImpl<{N==0}> //[full]~^ERROR constant expression depends on a generic parameter -//[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 {} trait FooImpl{} diff --git a/src/test/ui/const-generics/issues/issue-62220.min.stderr b/src/test/ui/const-generics/issues/issue-62220.min.stderr index 943b689bf61af..84975e8f3be6b 100644 --- a/src/test/ui/const-generics/issues/issue-62220.min.stderr +++ b/src/test/ui/const-generics/issues/issue-62220.min.stderr @@ -1,4 +1,4 @@ -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 --> $DIR/issue-62220.rs:8:59 | LL | pub type TruncatedVector = Vector; diff --git a/src/test/ui/const-generics/issues/issue-62220.rs b/src/test/ui/const-generics/issues/issue-62220.rs index acb13ad1170f2..5694dc6d04da1 100644 --- a/src/test/ui/const-generics/issues/issue-62220.rs +++ b/src/test/ui/const-generics/issues/issue-62220.rs @@ -6,7 +6,7 @@ pub struct Vector([T; N]); pub type TruncatedVector = Vector; -//[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 impl Vector { /// Drop the last component and return the vector with one fewer dimension. diff --git a/src/test/ui/const-generics/issues/issue-62456.min.stderr b/src/test/ui/const-generics/issues/issue-62456.min.stderr index 335f0ead27871..f94ba8c0c9b87 100644 --- a/src/test/ui/const-generics/issues/issue-62456.min.stderr +++ b/src/test/ui/const-generics/issues/issue-62456.min.stderr @@ -1,4 +1,4 @@ -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 --> $DIR/issue-62456.rs:7:20 | LL | let _ = [0u64; N + 1]; diff --git a/src/test/ui/const-generics/issues/issue-62456.rs b/src/test/ui/const-generics/issues/issue-62456.rs index c96868c00a3d6..338ec42799d17 100644 --- a/src/test/ui/const-generics/issues/issue-62456.rs +++ b/src/test/ui/const-generics/issues/issue-62456.rs @@ -6,7 +6,7 @@ fn foo() { let _ = [0u64; N + 1]; //[full]~^ ERROR constant expression depends on a generic parameter - //[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 } fn main() {} diff --git a/src/test/ui/const-generics/issues/issue-64494.min.stderr b/src/test/ui/const-generics/issues/issue-64494.min.stderr index 07822f86f524b..f712171bbac61 100644 --- a/src/test/ui/const-generics/issues/issue-64494.min.stderr +++ b/src/test/ui/const-generics/issues/issue-64494.min.stderr @@ -1,4 +1,4 @@ -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 --> $DIR/issue-64494.rs:16:38 | LL | impl MyTrait for T where Is<{T::VAL == 5}>: True {} @@ -6,7 +6,7 @@ LL | impl MyTrait for T where Is<{T::VAL == 5}>: True {} | = note: type parameters are currently not permitted in anonymous constants -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 --> $DIR/issue-64494.rs:19:38 | LL | impl MyTrait for T where Is<{T::VAL == 6}>: True {} diff --git a/src/test/ui/const-generics/issues/issue-64494.rs b/src/test/ui/const-generics/issues/issue-64494.rs index 3b598a415223a..b62ebf846d5b1 100644 --- a/src/test/ui/const-generics/issues/issue-64494.rs +++ b/src/test/ui/const-generics/issues/issue-64494.rs @@ -15,10 +15,10 @@ impl True for Is<{true}> {} impl MyTrait for T where Is<{T::VAL == 5}>: True {} //[full]~^ ERROR constant expression depends on a generic parameter -//[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 impl MyTrait for T where Is<{T::VAL == 6}>: True {} //[full]~^ ERROR constant expression depends on a generic parameter -//[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 //[min]~| ERROR conflicting implementations of trait `MyTrait` fn main() {} diff --git a/src/test/ui/const-generics/issues/issue-66205.min.stderr b/src/test/ui/const-generics/issues/issue-66205.min.stderr index 86709c389b623..a18126ccfef6d 100644 --- a/src/test/ui/const-generics/issues/issue-66205.min.stderr +++ b/src/test/ui/const-generics/issues/issue-66205.min.stderr @@ -1,4 +1,4 @@ -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 --> $DIR/issue-66205.rs:8:14 | LL | fact::<{ N - 1 }>(); diff --git a/src/test/ui/const-generics/issues/issue-66205.rs b/src/test/ui/const-generics/issues/issue-66205.rs index e115eff356a7f..668f49852e1ef 100644 --- a/src/test/ui/const-generics/issues/issue-66205.rs +++ b/src/test/ui/const-generics/issues/issue-66205.rs @@ -7,7 +7,7 @@ fn fact() { fact::<{ N - 1 }>(); //[full]~^ ERROR constant expression depends on a generic parameter - //[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 } fn main() {} diff --git a/src/test/ui/const-generics/issues/issue-67739.min.stderr b/src/test/ui/const-generics/issues/issue-67739.min.stderr index 68f1733decb93..ba378de415654 100644 --- a/src/test/ui/const-generics/issues/issue-67739.min.stderr +++ b/src/test/ui/const-generics/issues/issue-67739.min.stderr @@ -1,4 +1,4 @@ -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 --> $DIR/issue-67739.rs:12:30 | LL | [0u8; mem::size_of::()]; diff --git a/src/test/ui/const-generics/issues/issue-67739.rs b/src/test/ui/const-generics/issues/issue-67739.rs index 72bf3ee9602fc..296e4d423c48a 100644 --- a/src/test/ui/const-generics/issues/issue-67739.rs +++ b/src/test/ui/const-generics/issues/issue-67739.rs @@ -11,7 +11,7 @@ pub trait Trait { fn associated_size(&self) -> usize { [0u8; mem::size_of::()]; //[full]~^ ERROR constant expression depends on a generic parameter - //[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 0 } } diff --git a/src/test/ui/const-generics/issues/issue-68366.min.stderr b/src/test/ui/const-generics/issues/issue-68366.min.stderr index 8d34bdc6ea0c8..73d6fec6f9b56 100644 --- a/src/test/ui/const-generics/issues/issue-68366.min.stderr +++ b/src/test/ui/const-generics/issues/issue-68366.min.stderr @@ -1,4 +1,4 @@ -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 --> $DIR/issue-68366.rs:12:37 | LL | impl Collatz<{Some(N)}> {} diff --git a/src/test/ui/const-generics/issues/issue-68366.rs b/src/test/ui/const-generics/issues/issue-68366.rs index 819fcaffea18c..ac313eb3b2ff3 100644 --- a/src/test/ui/const-generics/issues/issue-68366.rs +++ b/src/test/ui/const-generics/issues/issue-68366.rs @@ -11,7 +11,7 @@ struct Collatz>; impl Collatz<{Some(N)}> {} //~^ ERROR the const parameter -//[min]~^^ generic parameters must not be used inside of non trivial constant values +//[min]~^^ generic parameters must not be used inside of non-trivial constant values struct Foo; diff --git a/src/test/ui/const-generics/issues/issue-68977.min.stderr b/src/test/ui/const-generics/issues/issue-68977.min.stderr index 5b2137b244cb2..59d2be3ce4b42 100644 --- a/src/test/ui/const-generics/issues/issue-68977.min.stderr +++ b/src/test/ui/const-generics/issues/issue-68977.min.stderr @@ -1,4 +1,4 @@ -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 --> $DIR/issue-68977.rs:29:17 | LL | PhantomU8<{(INT_BITS + FRAC_BITS + 7) / 8}>; @@ -6,7 +6,7 @@ LL | PhantomU8<{(INT_BITS + FRAC_BITS + 7) / 8}>; | = help: it is currently only allowed to use either `INT_BITS` or `{ INT_BITS }` as generic constants -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 --> $DIR/issue-68977.rs:29:28 | LL | PhantomU8<{(INT_BITS + FRAC_BITS + 7) / 8}>; diff --git a/src/test/ui/const-generics/issues/issue-68977.rs b/src/test/ui/const-generics/issues/issue-68977.rs index 02e634efec3e7..49b305a5a783f 100644 --- a/src/test/ui/const-generics/issues/issue-68977.rs +++ b/src/test/ui/const-generics/issues/issue-68977.rs @@ -27,8 +27,8 @@ fxp_storage_impls! { type FxpStorageHelper = PhantomU8<{(INT_BITS + FRAC_BITS + 7) / 8}>; - //[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 + //[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 struct Fxp where diff --git a/src/test/ui/const-generics/issues/issue-72787.min.stderr b/src/test/ui/const-generics/issues/issue-72787.min.stderr index d3e9887fe209c..a4c80b1d8c01e 100644 --- a/src/test/ui/const-generics/issues/issue-72787.min.stderr +++ b/src/test/ui/const-generics/issues/issue-72787.min.stderr @@ -1,4 +1,4 @@ -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 --> $DIR/issue-72787.rs:11:17 | LL | Condition<{ LHS <= RHS }>: True @@ -6,7 +6,7 @@ LL | Condition<{ LHS <= RHS }>: True | = help: it is currently only allowed to use either `LHS` or `{ LHS }` as generic constants -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 --> $DIR/issue-72787.rs:11:24 | LL | Condition<{ LHS <= RHS }>: True @@ -14,7 +14,7 @@ LL | Condition<{ LHS <= RHS }>: True | = help: it is currently only allowed to use either `RHS` or `{ RHS }` as generic constants -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 --> $DIR/issue-72787.rs:26:25 | LL | IsLessOrEqual<{ 8 - I }, { 8 - J }>: True, @@ -22,7 +22,7 @@ LL | IsLessOrEqual<{ 8 - I }, { 8 - J }>: True, | = help: it is currently only allowed to use either `I` or `{ I }` as generic constants -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 --> $DIR/issue-72787.rs:26:36 | LL | IsLessOrEqual<{ 8 - I }, { 8 - J }>: True, diff --git a/src/test/ui/const-generics/issues/issue-72787.rs b/src/test/ui/const-generics/issues/issue-72787.rs index 45c20191c8848..779c1d2950e4d 100644 --- a/src/test/ui/const-generics/issues/issue-72787.rs +++ b/src/test/ui/const-generics/issues/issue-72787.rs @@ -10,8 +10,8 @@ pub trait True {} impl True for IsLessOrEqual where Condition<{ LHS <= RHS }>: True //[full]~^ Error constant expression depends on a generic parameter -//[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 +//[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 { } impl True for Condition {} @@ -28,8 +28,8 @@ where //[full]~| constant expression depends on a generic parameter //[full]~| constant expression depends on a generic parameter //[full]~| constant expression depends on a generic parameter -//[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 +//[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 // Condition<{ 8 - I <= 8 - J }>: True, { fn print() { diff --git a/src/test/ui/const-generics/issues/issue-72819-generic-in-const-eval.min.stderr b/src/test/ui/const-generics/issues/issue-72819-generic-in-const-eval.min.stderr index 48a1f0bd19c0a..afc14c7dcff57 100644 --- a/src/test/ui/const-generics/issues/issue-72819-generic-in-const-eval.min.stderr +++ b/src/test/ui/const-generics/issues/issue-72819-generic-in-const-eval.min.stderr @@ -1,4 +1,4 @@ -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 --> $DIR/issue-72819-generic-in-const-eval.rs:9:17 | LL | where Assert::<{N < usize::max_value() / 2}>: IsTrue, diff --git a/src/test/ui/const-generics/issues/issue-72819-generic-in-const-eval.rs b/src/test/ui/const-generics/issues/issue-72819-generic-in-const-eval.rs index b653b91d99d14..65c7f00a72ae5 100644 --- a/src/test/ui/const-generics/issues/issue-72819-generic-in-const-eval.rs +++ b/src/test/ui/const-generics/issues/issue-72819-generic-in-const-eval.rs @@ -8,7 +8,7 @@ struct Arr where Assert::<{N < usize::max_value() / 2}>: IsTrue, //[full]~^ ERROR constant expression depends on a generic parameter -//[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 { } diff --git a/src/test/ui/const-generics/issues/issue-76701-ty-param-in-const.min.stderr b/src/test/ui/const-generics/issues/issue-76701-ty-param-in-const.min.stderr index a39495e0b2db0..0db948d0a45db 100644 --- a/src/test/ui/const-generics/issues/issue-76701-ty-param-in-const.min.stderr +++ b/src/test/ui/const-generics/issues/issue-76701-ty-param-in-const.min.stderr @@ -1,4 +1,4 @@ -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 --> $DIR/issue-76701-ty-param-in-const.rs:6:46 | LL | fn ty_param() -> [u8; std::mem::size_of::()] { @@ -6,7 +6,7 @@ LL | fn ty_param() -> [u8; std::mem::size_of::()] { | = note: type parameters are currently not permitted in anonymous constants -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 --> $DIR/issue-76701-ty-param-in-const.rs:12:42 | LL | fn const_param() -> [u8; N + 1] { diff --git a/src/test/ui/const-generics/issues/issue-76701-ty-param-in-const.rs b/src/test/ui/const-generics/issues/issue-76701-ty-param-in-const.rs index 9252b592360d3..3c5bfb03f0801 100644 --- a/src/test/ui/const-generics/issues/issue-76701-ty-param-in-const.rs +++ b/src/test/ui/const-generics/issues/issue-76701-ty-param-in-const.rs @@ -5,13 +5,13 @@ fn ty_param() -> [u8; std::mem::size_of::()] { //[full]~^ ERROR constant expression depends on a generic parameter - //[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 todo!() } fn const_param() -> [u8; N + 1] { //[full]~^ ERROR constant expression depends on a generic parameter - //[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 todo!() } diff --git a/src/test/ui/const-generics/min_const_generics/complex-expression.rs b/src/test/ui/const-generics/min_const_generics/complex-expression.rs index f9cb0d2829d6e..c6380f6394d01 100644 --- a/src/test/ui/const-generics/min_const_generics/complex-expression.rs +++ b/src/test/ui/const-generics/min_const_generics/complex-expression.rs @@ -7,19 +7,19 @@ fn ok() -> [u8; M] { } struct Break0([u8; { N + 1 }]); -//~^ 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 struct Break1([u8; { { N } }]); -//~^ 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 fn break2() { let _: [u8; N + 1]; - //~^ 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 } fn break3() { let _ = [0; N + 1]; - //~^ 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 } trait Foo { diff --git a/src/test/ui/const-generics/min_const_generics/complex-expression.stderr b/src/test/ui/const-generics/min_const_generics/complex-expression.stderr index baed8d13f00f1..d8897f53d7f74 100644 --- a/src/test/ui/const-generics/min_const_generics/complex-expression.stderr +++ b/src/test/ui/const-generics/min_const_generics/complex-expression.stderr @@ -1,4 +1,4 @@ -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 --> $DIR/complex-expression.rs:9:38 | LL | struct Break0([u8; { N + 1 }]); @@ -6,7 +6,7 @@ LL | struct Break0([u8; { N + 1 }]); | = 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 +error: generic parameters must not be used inside of non-trivial constant values --> $DIR/complex-expression.rs:12:40 | LL | struct Break1([u8; { { N } }]); @@ -14,7 +14,7 @@ LL | struct Break1([u8; { { 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 +error: generic parameters must not be used inside of non-trivial constant values --> $DIR/complex-expression.rs:16:17 | LL | let _: [u8; N + 1]; @@ -22,7 +22,7 @@ LL | let _: [u8; N + 1]; | = 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 +error: generic parameters must not be used inside of non-trivial constant values --> $DIR/complex-expression.rs:21:17 | LL | let _ = [0; N + 1]; diff --git a/src/test/ui/const-generics/min_const_generics/const-argument-if-length.rs b/src/test/ui/const-generics/min_const_generics/const-argument-if-length.rs index 354630ae87896..03c78a2fe684e 100644 --- a/src/test/ui/const-generics/min_const_generics/const-argument-if-length.rs +++ b/src/test/ui/const-generics/min_const_generics/const-argument-if-length.rs @@ -12,7 +12,7 @@ pub struct AtLeastByte { value: T, //~^ ERROR the size for values of type `T` cannot be known at compilation time pad: [u8; is_zst::()], - //~^ 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 } fn main() {} diff --git a/src/test/ui/const-generics/min_const_generics/const-argument-if-length.stderr b/src/test/ui/const-generics/min_const_generics/const-argument-if-length.stderr index a5bd3ab274836..ae5677887a124 100644 --- a/src/test/ui/const-generics/min_const_generics/const-argument-if-length.stderr +++ b/src/test/ui/const-generics/min_const_generics/const-argument-if-length.stderr @@ -1,4 +1,4 @@ -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 --> $DIR/const-argument-if-length.rs:14:24 | LL | pad: [u8; is_zst::()], diff --git a/src/test/ui/const-generics/min_const_generics/generic-function-call-in-array-length.rs b/src/test/ui/const-generics/min_const_generics/generic-function-call-in-array-length.rs index c52f402294203..f5387d659b3fa 100644 --- a/src/test/ui/const-generics/min_const_generics/generic-function-call-in-array-length.rs +++ b/src/test/ui/const-generics/min_const_generics/generic-function-call-in-array-length.rs @@ -3,9 +3,9 @@ const fn foo(n: usize) -> usize { n * 2 } fn bar() -> [u32; foo(N)] { - //~^ 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 [0; foo(N)] - //~^ 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 } fn main() {} diff --git a/src/test/ui/const-generics/min_const_generics/generic-sum-in-array-length.rs b/src/test/ui/const-generics/min_const_generics/generic-sum-in-array-length.rs index de7e5fe47283e..ad0748297f53e 100644 --- a/src/test/ui/const-generics/min_const_generics/generic-sum-in-array-length.rs +++ b/src/test/ui/const-generics/min_const_generics/generic-sum-in-array-length.rs @@ -1,7 +1,7 @@ #![feature(min_const_generics)] fn foo(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 +//~^ 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 fn main() {} diff --git a/src/test/ui/const-generics/min_const_generics/generic-sum-in-array-length.stderr b/src/test/ui/const-generics/min_const_generics/generic-sum-in-array-length.stderr index 45d0ba985a48a..5af5c2b115d5f 100644 --- a/src/test/ui/const-generics/min_const_generics/generic-sum-in-array-length.stderr +++ b/src/test/ui/const-generics/min_const_generics/generic-sum-in-array-length.stderr @@ -1,4 +1,4 @@ -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 --> $DIR/generic-sum-in-array-length.rs:3:53 | LL | fn foo(bar: [usize; A + B]) {} @@ -6,7 +6,7 @@ LL | fn foo(bar: [usize; A + B]) {} | = 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 +error: generic parameters must not be used inside of non-trivial constant values --> $DIR/generic-sum-in-array-length.rs:3:57 | LL | fn foo(bar: [usize; A + B]) {} diff --git a/src/test/ui/const-generics/min_const_generics/intrinsics-type_name-as-const-argument.rs b/src/test/ui/const-generics/min_const_generics/intrinsics-type_name-as-const-argument.rs index 167a3f23c4c40..5b5958520937f 100644 --- a/src/test/ui/const-generics/min_const_generics/intrinsics-type_name-as-const-argument.rs +++ b/src/test/ui/const-generics/min_const_generics/intrinsics-type_name-as-const-argument.rs @@ -7,7 +7,7 @@ trait Trait {} struct Bug where T: Trait<{std::intrinsics::type_name::()}> - //~^ 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 { t: T } diff --git a/src/test/ui/const-generics/min_const_generics/intrinsics-type_name-as-const-argument.stderr b/src/test/ui/const-generics/min_const_generics/intrinsics-type_name-as-const-argument.stderr index 07147da1117a3..2645195282b20 100644 --- a/src/test/ui/const-generics/min_const_generics/intrinsics-type_name-as-const-argument.stderr +++ b/src/test/ui/const-generics/min_const_generics/intrinsics-type_name-as-const-argument.stderr @@ -1,4 +1,4 @@ -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 --> $DIR/intrinsics-type_name-as-const-argument.rs:9:44 | LL | T: Trait<{std::intrinsics::type_name::()}> diff --git a/src/test/ui/const-generics/min_const_generics/issue-67375.rs b/src/test/ui/const-generics/min_const_generics/issue-67375.rs index 77ff10070e971..308c48f8d325d 100644 --- a/src/test/ui/const-generics/min_const_generics/issue-67375.rs +++ b/src/test/ui/const-generics/min_const_generics/issue-67375.rs @@ -3,7 +3,7 @@ struct Bug { //~^ ERROR parameter `T` is never used inner: [(); { [|_: &T| {}; 0].len() }], - //~^ 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 } fn main() {} diff --git a/src/test/ui/const-generics/min_const_generics/issue-67375.stderr b/src/test/ui/const-generics/min_const_generics/issue-67375.stderr index 345bdedfcb3e5..9963be787b736 100644 --- a/src/test/ui/const-generics/min_const_generics/issue-67375.stderr +++ b/src/test/ui/const-generics/min_const_generics/issue-67375.stderr @@ -1,4 +1,4 @@ -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 --> $DIR/issue-67375.rs:5:25 | LL | inner: [(); { [|_: &T| {}; 0].len() }], diff --git a/src/test/ui/const-generics/min_const_generics/issue-67945-1.rs b/src/test/ui/const-generics/min_const_generics/issue-67945-1.rs index cb1c900eb4fa8..f335f294de80e 100644 --- a/src/test/ui/const-generics/min_const_generics/issue-67945-1.rs +++ b/src/test/ui/const-generics/min_const_generics/issue-67945-1.rs @@ -8,9 +8,9 @@ struct Bug { //~^ 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 + //~^ ERROR generic parameters must not be used inside of non-trivial constant values let b = &*(&x as *const _ as *const S); - //~^ 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 0 }], } diff --git a/src/test/ui/const-generics/min_const_generics/issue-67945-1.stderr b/src/test/ui/const-generics/min_const_generics/issue-67945-1.stderr index a9a4fda8a479b..4b6a1c7cf9166 100644 --- a/src/test/ui/const-generics/min_const_generics/issue-67945-1.stderr +++ b/src/test/ui/const-generics/min_const_generics/issue-67945-1.stderr @@ -1,4 +1,4 @@ -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 --> $DIR/issue-67945-1.rs:10:16 | LL | let x: S = MaybeUninit::uninit(); @@ -6,7 +6,7 @@ LL | let x: S = MaybeUninit::uninit(); | = note: type parameters are currently not permitted in anonymous constants -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 --> $DIR/issue-67945-1.rs:12:45 | LL | let b = &*(&x as *const _ as *const S); diff --git a/src/test/ui/const-generics/min_const_generics/issue-67945-2.rs b/src/test/ui/const-generics/min_const_generics/issue-67945-2.rs index 4b0799dce1eb5..9faa1e0694d4d 100644 --- a/src/test/ui/const-generics/min_const_generics/issue-67945-2.rs +++ b/src/test/ui/const-generics/min_const_generics/issue-67945-2.rs @@ -6,9 +6,9 @@ struct Bug { //~^ 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 + //~^ ERROR generic parameters must not be used inside of non-trivial constant values let b = &*(&x as *const _ as *const S); - //~^ 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 0 }], } diff --git a/src/test/ui/const-generics/min_const_generics/issue-67945-2.stderr b/src/test/ui/const-generics/min_const_generics/issue-67945-2.stderr index 8c40dc0eade80..39d7f1f936887 100644 --- a/src/test/ui/const-generics/min_const_generics/issue-67945-2.stderr +++ b/src/test/ui/const-generics/min_const_generics/issue-67945-2.stderr @@ -1,4 +1,4 @@ -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 --> $DIR/issue-67945-2.rs:8:16 | LL | let x: S = MaybeUninit::uninit(); @@ -6,7 +6,7 @@ LL | let x: S = MaybeUninit::uninit(); | = note: type parameters are currently not permitted in anonymous constants -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 --> $DIR/issue-67945-2.rs:10:45 | LL | let b = &*(&x as *const _ as *const S); diff --git a/src/test/ui/const-generics/min_const_generics/self-ty-in-const-1.stderr b/src/test/ui/const-generics/min_const_generics/self-ty-in-const-1.stderr index edb77a8743061..7dc81bf45af9a 100644 --- a/src/test/ui/const-generics/min_const_generics/self-ty-in-const-1.stderr +++ b/src/test/ui/const-generics/min_const_generics/self-ty-in-const-1.stderr @@ -1,4 +1,4 @@ -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 --> $DIR/self-ty-in-const-1.rs:4:41 | LL | fn t1() -> [u8; std::mem::size_of::()]; diff --git a/src/test/ui/const-generics/params-in-ct-in-ty-param-lazy-norm.min.stderr b/src/test/ui/const-generics/params-in-ct-in-ty-param-lazy-norm.min.stderr index e545ae8571f67..0dd591d891f2b 100644 --- a/src/test/ui/const-generics/params-in-ct-in-ty-param-lazy-norm.min.stderr +++ b/src/test/ui/const-generics/params-in-ct-in-ty-param-lazy-norm.min.stderr @@ -6,7 +6,7 @@ LL | struct Bar(T); | = note: using type defaults and const parameters in the same parameter list is currently not permitted -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 --> $DIR/params-in-ct-in-ty-param-lazy-norm.rs:7:44 | LL | struct Foo()]>(T, U); diff --git a/src/test/ui/const-generics/params-in-ct-in-ty-param-lazy-norm.rs b/src/test/ui/const-generics/params-in-ct-in-ty-param-lazy-norm.rs index e52773c78dbd3..b9d74850f37d6 100644 --- a/src/test/ui/const-generics/params-in-ct-in-ty-param-lazy-norm.rs +++ b/src/test/ui/const-generics/params-in-ct-in-ty-param-lazy-norm.rs @@ -6,7 +6,7 @@ struct Foo()]>(T, U); //[full]~^ ERROR constant values inside of type parameter defaults -//[min]~^^ ERROR generic parameters must not be used inside of non trivial +//[min]~^^ ERROR generic parameters must not be used inside of non-trivial // FIXME(const_generics:defaults): We still don't know how to we deal with type defaults. struct Bar(T); diff --git a/src/test/ui/const-generics/wf-misc.min.stderr b/src/test/ui/const-generics/wf-misc.min.stderr index f2acb8fc06e93..1c52d60174997 100644 --- a/src/test/ui/const-generics/wf-misc.min.stderr +++ b/src/test/ui/const-generics/wf-misc.min.stderr @@ -1,4 +1,4 @@ -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 --> $DIR/wf-misc.rs:9:17 | LL | let _: [u8; N + 1]; @@ -6,7 +6,7 @@ LL | let _: [u8; N + 1]; | = 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 +error: generic parameters must not be used inside of non-trivial constant values --> $DIR/wf-misc.rs:17:21 | LL | let _: Const::<{N + 1}>; diff --git a/src/test/ui/const-generics/wf-misc.rs b/src/test/ui/const-generics/wf-misc.rs index e6f7a9963e8f1..f8c41404c467b 100644 --- a/src/test/ui/const-generics/wf-misc.rs +++ b/src/test/ui/const-generics/wf-misc.rs @@ -8,7 +8,7 @@ pub fn arr_len() { let _: [u8; N + 1]; //[full]~^ ERROR constant expression depends on a generic parameter - //[min]~^^ ERROR generic parameters must not be used inside of non trivial + //[min]~^^ ERROR generic parameters must not be used inside of non-trivial } struct Const; @@ -16,7 +16,7 @@ struct Const; pub fn func_call() { let _: Const::<{N + 1}>; //[full]~^ ERROR constant expression depends on a generic parameter - //[min]~^^ ERROR generic parameters must not be used inside of non trivial + //[min]~^^ ERROR generic parameters must not be used inside of non-trivial } fn main() {} From 96eb68b1216e7fa0706a999595752bfd25dca886 Mon Sep 17 00:00:00 2001 From: varkor Date: Sat, 3 Oct 2020 14:25:10 +0100 Subject: [PATCH 4/7] Add `FIXME` for const generic defaults --- compiler/rustc_typeck/src/collect.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/compiler/rustc_typeck/src/collect.rs b/compiler/rustc_typeck/src/collect.rs index 9aca112a9142d..1f4f40fca9be3 100644 --- a/compiler/rustc_typeck/src/collect.rs +++ b/compiler/rustc_typeck/src/collect.rs @@ -222,6 +222,7 @@ impl Visitor<'tcx> for CollectItemTypesVisitor<'tcx> { hir::GenericParamKind::Const { .. } => { let def_id = self.tcx.hir().local_def_id(param.hir_id); self.tcx.ensure().type_of(def_id); + // FIXME(const_generics:defaults) } } } From 3631d2928764c0c321c60cbbe1bdd6ab5945d452 Mon Sep 17 00:00:00 2001 From: varkor Date: Sat, 3 Oct 2020 17:00:18 +0100 Subject: [PATCH 5/7] Add tests for `const_generics` --- .../const-argument-if-length.full.stderr | 42 +++++++++++++++++++ .../const-argument-if-length.min.stderr | 30 +++++++++++++ .../const-argument-if-length.rs | 10 ++++- ...-function-call-in-array-length.full.stderr | 10 +++++ ...c-function-call-in-array-length.min.stderr | 18 ++++++++ .../generic-function-call-in-array-length.rs | 11 +++-- .../generic-sum-in-array-length.full.stderr | 10 +++++ .../generic-sum-in-array-length.min.stderr | 18 ++++++++ .../generic-sum-in-array-length.rs | 11 +++-- ...cs-type_name-as-const-argument.full.stderr | 10 +++++ ...ics-type_name-as-const-argument.min.stderr | 19 +++++++++ .../intrinsics-type_name-as-const-argument.rs | 13 ++++-- .../issue-67375.full.stderr | 21 ++++++++++ .../min_const_generics/issue-67375.min.stderr | 19 +++++++++ .../min_const_generics/issue-67375.rs | 10 ++++- .../issue-67945-1.full.stderr | 26 ++++++++++++ .../issue-67945-1.min.stderr | 27 ++++++++++++ .../min_const_generics/issue-67945-1.rs | 11 +++-- .../issue-67945-2.full.stderr | 26 ++++++++++++ .../issue-67945-2.min.stderr | 27 ++++++++++++ .../min_const_generics/issue-67945-2.rs | 11 +++-- .../issue-67945-3.full.stderr | 16 +++++++ .../issue-67945-3.min.stderr | 8 ++++ .../min_const_generics/issue-67945-3.rs | 9 +++- 24 files changed, 392 insertions(+), 21 deletions(-) create mode 100644 src/test/ui/const-generics/min_const_generics/const-argument-if-length.full.stderr create mode 100644 src/test/ui/const-generics/min_const_generics/const-argument-if-length.min.stderr create mode 100644 src/test/ui/const-generics/min_const_generics/generic-function-call-in-array-length.full.stderr create mode 100644 src/test/ui/const-generics/min_const_generics/generic-function-call-in-array-length.min.stderr create mode 100644 src/test/ui/const-generics/min_const_generics/generic-sum-in-array-length.full.stderr create mode 100644 src/test/ui/const-generics/min_const_generics/generic-sum-in-array-length.min.stderr create mode 100644 src/test/ui/const-generics/min_const_generics/intrinsics-type_name-as-const-argument.full.stderr create mode 100644 src/test/ui/const-generics/min_const_generics/intrinsics-type_name-as-const-argument.min.stderr create mode 100644 src/test/ui/const-generics/min_const_generics/issue-67375.full.stderr create mode 100644 src/test/ui/const-generics/min_const_generics/issue-67375.min.stderr create mode 100644 src/test/ui/const-generics/min_const_generics/issue-67945-1.full.stderr create mode 100644 src/test/ui/const-generics/min_const_generics/issue-67945-1.min.stderr create mode 100644 src/test/ui/const-generics/min_const_generics/issue-67945-2.full.stderr create mode 100644 src/test/ui/const-generics/min_const_generics/issue-67945-2.min.stderr create mode 100644 src/test/ui/const-generics/min_const_generics/issue-67945-3.full.stderr create mode 100644 src/test/ui/const-generics/min_const_generics/issue-67945-3.min.stderr 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 index 0000000000000..9b1c1be1aa09b --- /dev/null +++ b/src/test/ui/const-generics/min_const_generics/const-argument-if-length.full.stderr @@ -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() -> usize { + | - this type parameter needs to be `Sized` +LL | if std::mem::size_of::() == 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() -> 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::()], + | ^^^^^^^^^^^^^ 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 { + | - 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, + | ^^^^ ^ + +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 index 0000000000000..c666dce479f65 --- /dev/null +++ b/src/test/ui/const-generics/min_const_generics/const-argument-if-length.min.stderr @@ -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::()], + | ^ 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 { + | - 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, + | ^^^^ ^ + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/const-generics/min_const_generics/const-argument-if-length.rs b/src/test/ui/const-generics/min_const_generics/const-argument-if-length.rs index 03c78a2fe684e..481ff97d68dbe 100644 --- a/src/test/ui/const-generics/min_const_generics/const-argument-if-length.rs +++ b/src/test/ui/const-generics/min_const_generics/const-argument-if-length.rs @@ -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() -> usize { if std::mem::size_of::() == 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 { value: T, //~^ ERROR the size for values of type `T` cannot be known at compilation time pad: [u8; is_zst::()], - //~^ 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 index 0000000000000..43b42d82d0c45 --- /dev/null +++ b/src/test/ui/const-generics/min_const_generics/generic-function-call-in-array-length.full.stderr @@ -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() -> [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 index 0000000000000..e7e968e4c2ad2 --- /dev/null +++ b/src/test/ui/const-generics/min_const_generics/generic-function-call-in-array-length.min.stderr @@ -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() -> [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 + diff --git a/src/test/ui/const-generics/min_const_generics/generic-function-call-in-array-length.rs b/src/test/ui/const-generics/min_const_generics/generic-function-call-in-array-length.rs index f5387d659b3fa..c8bbae29343dc 100644 --- a/src/test/ui/const-generics/min_const_generics/generic-function-call-in-array-length.rs +++ b/src/test/ui/const-generics/min_const_generics/generic-function-call-in-array-length.rs @@ -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() -> [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 index 0000000000000..d311e1c0bae01 --- /dev/null +++ b/src/test/ui/const-generics/min_const_generics/generic-sum-in-array-length.full.stderr @@ -0,0 +1,10 @@ +error: constant expression depends on a generic parameter + --> $DIR/generic-sum-in-array-length.rs:7:45 + | +LL | fn foo(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 index 0000000000000..6f157fbbbbb8a --- /dev/null +++ b/src/test/ui/const-generics/min_const_generics/generic-sum-in-array-length.min.stderr @@ -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(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(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 + diff --git a/src/test/ui/const-generics/min_const_generics/generic-sum-in-array-length.rs b/src/test/ui/const-generics/min_const_generics/generic-sum-in-array-length.rs index ad0748297f53e..810095b384baa 100644 --- a/src/test/ui/const-generics/min_const_generics/generic-sum-in-array-length.rs +++ b/src/test/ui/const-generics/min_const_generics/generic-sum-in-array-length.rs @@ -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(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 index 0000000000000..c09d16d0ab05b --- /dev/null +++ b/src/test/ui/const-generics/min_const_generics/intrinsics-type_name-as-const-argument.full.stderr @@ -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::()}> + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = 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 index 0000000000000..307db088bf892 --- /dev/null +++ b/src/test/ui/const-generics/min_const_generics/intrinsics-type_name-as-const-argument.min.stderr @@ -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::()}> + | ^ 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 {} + | ^^^^^^^^^^^^ + | + = 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 + diff --git a/src/test/ui/const-generics/min_const_generics/intrinsics-type_name-as-const-argument.rs b/src/test/ui/const-generics/min_const_generics/intrinsics-type_name-as-const-argument.rs index 5b5958520937f..37b6cf4bab92b 100644 --- a/src/test/ui/const-generics/min_const_generics/intrinsics-type_name-as-const-argument.rs +++ b/src/test/ui/const-generics/min_const_generics/intrinsics-type_name-as-const-argument.rs @@ -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 {} -//~^ 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 where T: Trait<{std::intrinsics::type_name::()}> - //~^ 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 index 0000000000000..e15d65f197e29 --- /dev/null +++ b/src/test/ui/const-generics/min_const_generics/issue-67375.full.stderr @@ -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 + +error[E0392]: parameter `T` is never used + --> $DIR/issue-67375.rs:7:12 + | +LL | struct Bug { + | ^ 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 index 0000000000000..b13d9fdab0d96 --- /dev/null +++ b/src/test/ui/const-generics/min_const_generics/issue-67375.min.stderr @@ -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 { + | ^ 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`. diff --git a/src/test/ui/const-generics/min_const_generics/issue-67375.rs b/src/test/ui/const-generics/min_const_generics/issue-67375.rs index 308c48f8d325d..994ec92cfb501 100644 --- a/src/test/ui/const-generics/min_const_generics/issue-67375.rs +++ b/src/test/ui/const-generics/min_const_generics/issue-67375.rs @@ -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 { //~^ 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 index 0000000000000..e79c4f5374e1a --- /dev/null +++ b/src/test/ui/const-generics/min_const_generics/issue-67945-1.full.stderr @@ -0,0 +1,26 @@ +error[E0308]: mismatched types + --> $DIR/issue-67945-1.rs:14:20 + | +LL | struct Bug { + | - 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 { + | ^ 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 index 0000000000000..949b5da5920b1 --- /dev/null +++ b/src/test/ui/const-generics/min_const_generics/issue-67945-1.min.stderr @@ -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 { + | ^ 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`. diff --git a/src/test/ui/const-generics/min_const_generics/issue-67945-1.rs b/src/test/ui/const-generics/min_const_generics/issue-67945-1.rs index f335f294de80e..d1a83e978d1b8 100644 --- a/src/test/ui/const-generics/min_const_generics/issue-67945-1.rs +++ b/src/test/ui/const-generics/min_const_generics/issue-67945-1.rs @@ -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 { //~^ 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 index 0000000000000..2f54b802df8a4 --- /dev/null +++ b/src/test/ui/const-generics/min_const_generics/issue-67945-2.full.stderr @@ -0,0 +1,26 @@ +error[E0308]: mismatched types + --> $DIR/issue-67945-2.rs:12:20 + | +LL | struct Bug { + | - 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 { + | ^ 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 index 0000000000000..ed445b3e8f790 --- /dev/null +++ b/src/test/ui/const-generics/min_const_generics/issue-67945-2.min.stderr @@ -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 { + | ^ 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`. diff --git a/src/test/ui/const-generics/min_const_generics/issue-67945-2.rs b/src/test/ui/const-generics/min_const_generics/issue-67945-2.rs index 9faa1e0694d4d..7f789297df034 100644 --- a/src/test/ui/const-generics/min_const_generics/issue-67945-2.rs +++ b/src/test/ui/const-generics/min_const_generics/issue-67945-2.rs @@ -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 { //~^ 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 index 0000000000000..c33b88588c0d0 --- /dev/null +++ b/src/test/ui/const-generics/min_const_generics/issue-67945-3.full.stderr @@ -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> = 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 index 0000000000000..9c6e101ece868 --- /dev/null +++ b/src/test/ui/const-generics/min_const_generics/issue-67945-3.min.stderr @@ -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> = None; + | ^^^^ + +error: aborting due to previous error + diff --git a/src/test/ui/const-generics/min_const_generics/issue-67945-3.rs b/src/test/ui/const-generics/min_const_generics/issue-67945-3.rs index cde7200458e21..bca079101e2b3 100644 --- a/src/test/ui/const-generics/min_const_generics/issue-67945-3.rs +++ b/src/test/ui/const-generics/min_const_generics/issue-67945-3.rs @@ -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 { A: [(); { + //[full]~^ ERROR constant expression depends on a generic parameter let x: Option> = 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 From 702906581e9bda1956c8adb593969196caccc2b8 Mon Sep 17 00:00:00 2001 From: varkor Date: Sat, 3 Oct 2020 18:01:11 +0100 Subject: [PATCH 6/7] Move tests --- .../const-argument-if-length.full.stderr | 0 .../const-argument-if-length.min.stderr | 0 .../const-argument-if-length.rs | 0 ...-function-call-in-array-length.full.stderr | 0 ...c-function-call-in-array-length.min.stderr | 0 .../generic-function-call-in-array-length.rs | 0 .../generic-sum-in-array-length.full.stderr | 0 .../generic-sum-in-array-length.min.stderr | 0 .../generic-sum-in-array-length.rs | 0 ...cs-type_name-as-const-argument.full.stderr | 0 ...ics-type_name-as-const-argument.min.stderr | 0 .../intrinsics-type_name-as-const-argument.rs | 0 .../issue-67375.full.stderr | 0 .../issue-67375.min.stderr | 0 .../{min_const_generics => }/issue-67375.rs | 0 .../issue-67945-1.full.stderr | 0 .../issue-67945-1.min.stderr | 0 .../{min_const_generics => }/issue-67945-1.rs | 0 .../issue-67945-2.full.stderr | 0 .../issue-67945-2.min.stderr | 0 .../{min_const_generics => }/issue-67945-2.rs | 0 .../issue-67945-3.full.stderr | 0 .../issue-67945-3.min.stderr | 0 .../{min_const_generics => }/issue-67945-3.rs | 0 .../const-argument-if-length.stderr | 30 ------------------- .../generic-sum-in-array-length.stderr | 18 ----------- ...rinsics-type_name-as-const-argument.stderr | 19 ------------ .../min_const_generics/issue-67375.stderr | 19 ------------ .../min_const_generics/issue-67945-1.stderr | 27 ----------------- .../min_const_generics/issue-67945-2.stderr | 27 ----------------- .../min_const_generics/issue-67945-3.stderr | 8 ----- 31 files changed, 148 deletions(-) rename src/test/ui/const-generics/{min_const_generics => }/const-argument-if-length.full.stderr (100%) rename src/test/ui/const-generics/{min_const_generics => }/const-argument-if-length.min.stderr (100%) rename src/test/ui/const-generics/{min_const_generics => }/const-argument-if-length.rs (100%) rename src/test/ui/const-generics/{min_const_generics => }/generic-function-call-in-array-length.full.stderr (100%) rename src/test/ui/const-generics/{min_const_generics => }/generic-function-call-in-array-length.min.stderr (100%) rename src/test/ui/const-generics/{min_const_generics => }/generic-function-call-in-array-length.rs (100%) rename src/test/ui/const-generics/{min_const_generics => }/generic-sum-in-array-length.full.stderr (100%) rename src/test/ui/const-generics/{min_const_generics => }/generic-sum-in-array-length.min.stderr (100%) rename src/test/ui/const-generics/{min_const_generics => }/generic-sum-in-array-length.rs (100%) rename src/test/ui/const-generics/{min_const_generics => }/intrinsics-type_name-as-const-argument.full.stderr (100%) rename src/test/ui/const-generics/{min_const_generics => }/intrinsics-type_name-as-const-argument.min.stderr (100%) rename src/test/ui/const-generics/{min_const_generics => }/intrinsics-type_name-as-const-argument.rs (100%) rename src/test/ui/const-generics/{min_const_generics => }/issue-67375.full.stderr (100%) rename src/test/ui/const-generics/{min_const_generics => }/issue-67375.min.stderr (100%) rename src/test/ui/const-generics/{min_const_generics => }/issue-67375.rs (100%) rename src/test/ui/const-generics/{min_const_generics => }/issue-67945-1.full.stderr (100%) rename src/test/ui/const-generics/{min_const_generics => }/issue-67945-1.min.stderr (100%) rename src/test/ui/const-generics/{min_const_generics => }/issue-67945-1.rs (100%) rename src/test/ui/const-generics/{min_const_generics => }/issue-67945-2.full.stderr (100%) rename src/test/ui/const-generics/{min_const_generics => }/issue-67945-2.min.stderr (100%) rename src/test/ui/const-generics/{min_const_generics => }/issue-67945-2.rs (100%) rename src/test/ui/const-generics/{min_const_generics => }/issue-67945-3.full.stderr (100%) rename src/test/ui/const-generics/{min_const_generics => }/issue-67945-3.min.stderr (100%) rename src/test/ui/const-generics/{min_const_generics => }/issue-67945-3.rs (100%) delete mode 100644 src/test/ui/const-generics/min_const_generics/const-argument-if-length.stderr delete mode 100644 src/test/ui/const-generics/min_const_generics/generic-sum-in-array-length.stderr delete mode 100644 src/test/ui/const-generics/min_const_generics/intrinsics-type_name-as-const-argument.stderr delete mode 100644 src/test/ui/const-generics/min_const_generics/issue-67375.stderr delete mode 100644 src/test/ui/const-generics/min_const_generics/issue-67945-1.stderr delete mode 100644 src/test/ui/const-generics/min_const_generics/issue-67945-2.stderr delete mode 100644 src/test/ui/const-generics/min_const_generics/issue-67945-3.stderr diff --git a/src/test/ui/const-generics/min_const_generics/const-argument-if-length.full.stderr b/src/test/ui/const-generics/const-argument-if-length.full.stderr similarity index 100% rename from src/test/ui/const-generics/min_const_generics/const-argument-if-length.full.stderr rename to src/test/ui/const-generics/const-argument-if-length.full.stderr diff --git a/src/test/ui/const-generics/min_const_generics/const-argument-if-length.min.stderr b/src/test/ui/const-generics/const-argument-if-length.min.stderr similarity index 100% rename from src/test/ui/const-generics/min_const_generics/const-argument-if-length.min.stderr rename to src/test/ui/const-generics/const-argument-if-length.min.stderr diff --git a/src/test/ui/const-generics/min_const_generics/const-argument-if-length.rs b/src/test/ui/const-generics/const-argument-if-length.rs similarity index 100% rename from src/test/ui/const-generics/min_const_generics/const-argument-if-length.rs rename to src/test/ui/const-generics/const-argument-if-length.rs 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/generic-function-call-in-array-length.full.stderr similarity index 100% rename from src/test/ui/const-generics/min_const_generics/generic-function-call-in-array-length.full.stderr rename to src/test/ui/const-generics/generic-function-call-in-array-length.full.stderr 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/generic-function-call-in-array-length.min.stderr similarity index 100% rename from src/test/ui/const-generics/min_const_generics/generic-function-call-in-array-length.min.stderr rename to src/test/ui/const-generics/generic-function-call-in-array-length.min.stderr diff --git a/src/test/ui/const-generics/min_const_generics/generic-function-call-in-array-length.rs b/src/test/ui/const-generics/generic-function-call-in-array-length.rs similarity index 100% rename from src/test/ui/const-generics/min_const_generics/generic-function-call-in-array-length.rs rename to src/test/ui/const-generics/generic-function-call-in-array-length.rs diff --git a/src/test/ui/const-generics/min_const_generics/generic-sum-in-array-length.full.stderr b/src/test/ui/const-generics/generic-sum-in-array-length.full.stderr similarity index 100% rename from src/test/ui/const-generics/min_const_generics/generic-sum-in-array-length.full.stderr rename to src/test/ui/const-generics/generic-sum-in-array-length.full.stderr diff --git a/src/test/ui/const-generics/min_const_generics/generic-sum-in-array-length.min.stderr b/src/test/ui/const-generics/generic-sum-in-array-length.min.stderr similarity index 100% rename from src/test/ui/const-generics/min_const_generics/generic-sum-in-array-length.min.stderr rename to src/test/ui/const-generics/generic-sum-in-array-length.min.stderr diff --git a/src/test/ui/const-generics/min_const_generics/generic-sum-in-array-length.rs b/src/test/ui/const-generics/generic-sum-in-array-length.rs similarity index 100% rename from src/test/ui/const-generics/min_const_generics/generic-sum-in-array-length.rs rename to src/test/ui/const-generics/generic-sum-in-array-length.rs 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/intrinsics-type_name-as-const-argument.full.stderr similarity index 100% rename from src/test/ui/const-generics/min_const_generics/intrinsics-type_name-as-const-argument.full.stderr rename to src/test/ui/const-generics/intrinsics-type_name-as-const-argument.full.stderr 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/intrinsics-type_name-as-const-argument.min.stderr similarity index 100% rename from src/test/ui/const-generics/min_const_generics/intrinsics-type_name-as-const-argument.min.stderr rename to src/test/ui/const-generics/intrinsics-type_name-as-const-argument.min.stderr diff --git a/src/test/ui/const-generics/min_const_generics/intrinsics-type_name-as-const-argument.rs b/src/test/ui/const-generics/intrinsics-type_name-as-const-argument.rs similarity index 100% rename from src/test/ui/const-generics/min_const_generics/intrinsics-type_name-as-const-argument.rs rename to src/test/ui/const-generics/intrinsics-type_name-as-const-argument.rs diff --git a/src/test/ui/const-generics/min_const_generics/issue-67375.full.stderr b/src/test/ui/const-generics/issue-67375.full.stderr similarity index 100% rename from src/test/ui/const-generics/min_const_generics/issue-67375.full.stderr rename to src/test/ui/const-generics/issue-67375.full.stderr diff --git a/src/test/ui/const-generics/min_const_generics/issue-67375.min.stderr b/src/test/ui/const-generics/issue-67375.min.stderr similarity index 100% rename from src/test/ui/const-generics/min_const_generics/issue-67375.min.stderr rename to src/test/ui/const-generics/issue-67375.min.stderr diff --git a/src/test/ui/const-generics/min_const_generics/issue-67375.rs b/src/test/ui/const-generics/issue-67375.rs similarity index 100% rename from src/test/ui/const-generics/min_const_generics/issue-67375.rs rename to src/test/ui/const-generics/issue-67375.rs diff --git a/src/test/ui/const-generics/min_const_generics/issue-67945-1.full.stderr b/src/test/ui/const-generics/issue-67945-1.full.stderr similarity index 100% rename from src/test/ui/const-generics/min_const_generics/issue-67945-1.full.stderr rename to src/test/ui/const-generics/issue-67945-1.full.stderr diff --git a/src/test/ui/const-generics/min_const_generics/issue-67945-1.min.stderr b/src/test/ui/const-generics/issue-67945-1.min.stderr similarity index 100% rename from src/test/ui/const-generics/min_const_generics/issue-67945-1.min.stderr rename to src/test/ui/const-generics/issue-67945-1.min.stderr diff --git a/src/test/ui/const-generics/min_const_generics/issue-67945-1.rs b/src/test/ui/const-generics/issue-67945-1.rs similarity index 100% rename from src/test/ui/const-generics/min_const_generics/issue-67945-1.rs rename to src/test/ui/const-generics/issue-67945-1.rs diff --git a/src/test/ui/const-generics/min_const_generics/issue-67945-2.full.stderr b/src/test/ui/const-generics/issue-67945-2.full.stderr similarity index 100% rename from src/test/ui/const-generics/min_const_generics/issue-67945-2.full.stderr rename to src/test/ui/const-generics/issue-67945-2.full.stderr diff --git a/src/test/ui/const-generics/min_const_generics/issue-67945-2.min.stderr b/src/test/ui/const-generics/issue-67945-2.min.stderr similarity index 100% rename from src/test/ui/const-generics/min_const_generics/issue-67945-2.min.stderr rename to src/test/ui/const-generics/issue-67945-2.min.stderr diff --git a/src/test/ui/const-generics/min_const_generics/issue-67945-2.rs b/src/test/ui/const-generics/issue-67945-2.rs similarity index 100% rename from src/test/ui/const-generics/min_const_generics/issue-67945-2.rs rename to src/test/ui/const-generics/issue-67945-2.rs diff --git a/src/test/ui/const-generics/min_const_generics/issue-67945-3.full.stderr b/src/test/ui/const-generics/issue-67945-3.full.stderr similarity index 100% rename from src/test/ui/const-generics/min_const_generics/issue-67945-3.full.stderr rename to src/test/ui/const-generics/issue-67945-3.full.stderr diff --git a/src/test/ui/const-generics/min_const_generics/issue-67945-3.min.stderr b/src/test/ui/const-generics/issue-67945-3.min.stderr similarity index 100% rename from src/test/ui/const-generics/min_const_generics/issue-67945-3.min.stderr rename to src/test/ui/const-generics/issue-67945-3.min.stderr diff --git a/src/test/ui/const-generics/min_const_generics/issue-67945-3.rs b/src/test/ui/const-generics/issue-67945-3.rs similarity index 100% rename from src/test/ui/const-generics/min_const_generics/issue-67945-3.rs rename to src/test/ui/const-generics/issue-67945-3.rs diff --git a/src/test/ui/const-generics/min_const_generics/const-argument-if-length.stderr b/src/test/ui/const-generics/min_const_generics/const-argument-if-length.stderr deleted file mode 100644 index ae5677887a124..0000000000000 --- a/src/test/ui/const-generics/min_const_generics/const-argument-if-length.stderr +++ /dev/null @@ -1,30 +0,0 @@ -error: generic parameters must not be used inside of non-trivial constant values - --> $DIR/const-argument-if-length.rs:14:24 - | -LL | pad: [u8; is_zst::()], - | ^ 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:12:12 - | -LL | pub struct AtLeastByte { - | - 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, - | ^^^^ ^ - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/const-generics/min_const_generics/generic-sum-in-array-length.stderr b/src/test/ui/const-generics/min_const_generics/generic-sum-in-array-length.stderr deleted file mode 100644 index 5af5c2b115d5f..0000000000000 --- a/src/test/ui/const-generics/min_const_generics/generic-sum-in-array-length.stderr +++ /dev/null @@ -1,18 +0,0 @@ -error: generic parameters must not be used inside of non-trivial constant values - --> $DIR/generic-sum-in-array-length.rs:3:53 - | -LL | fn foo(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:3:57 - | -LL | fn foo(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 - diff --git a/src/test/ui/const-generics/min_const_generics/intrinsics-type_name-as-const-argument.stderr b/src/test/ui/const-generics/min_const_generics/intrinsics-type_name-as-const-argument.stderr deleted file mode 100644 index 2645195282b20..0000000000000 --- a/src/test/ui/const-generics/min_const_generics/intrinsics-type_name-as-const-argument.stderr +++ /dev/null @@ -1,19 +0,0 @@ -error: generic parameters must not be used inside of non-trivial constant values - --> $DIR/intrinsics-type_name-as-const-argument.rs:9:44 - | -LL | T: Trait<{std::intrinsics::type_name::()}> - | ^ 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:4:22 - | -LL | trait Trait {} - | ^^^^^^^^^^^^ - | - = 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 - diff --git a/src/test/ui/const-generics/min_const_generics/issue-67375.stderr b/src/test/ui/const-generics/min_const_generics/issue-67375.stderr deleted file mode 100644 index 9963be787b736..0000000000000 --- a/src/test/ui/const-generics/min_const_generics/issue-67375.stderr +++ /dev/null @@ -1,19 +0,0 @@ -error: generic parameters must not be used inside of non-trivial constant values - --> $DIR/issue-67375.rs:5: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:3:12 - | -LL | struct Bug { - | ^ 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`. diff --git a/src/test/ui/const-generics/min_const_generics/issue-67945-1.stderr b/src/test/ui/const-generics/min_const_generics/issue-67945-1.stderr deleted file mode 100644 index 4b6a1c7cf9166..0000000000000 --- a/src/test/ui/const-generics/min_const_generics/issue-67945-1.stderr +++ /dev/null @@ -1,27 +0,0 @@ -error: generic parameters must not be used inside of non-trivial constant values - --> $DIR/issue-67945-1.rs:10: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:12: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:7:12 - | -LL | struct Bug { - | ^ 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`. diff --git a/src/test/ui/const-generics/min_const_generics/issue-67945-2.stderr b/src/test/ui/const-generics/min_const_generics/issue-67945-2.stderr deleted file mode 100644 index 39d7f1f936887..0000000000000 --- a/src/test/ui/const-generics/min_const_generics/issue-67945-2.stderr +++ /dev/null @@ -1,27 +0,0 @@ -error: generic parameters must not be used inside of non-trivial constant values - --> $DIR/issue-67945-2.rs:8: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:10: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:5:12 - | -LL | struct Bug { - | ^ 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`. diff --git a/src/test/ui/const-generics/min_const_generics/issue-67945-3.stderr b/src/test/ui/const-generics/min_const_generics/issue-67945-3.stderr deleted file mode 100644 index c5f919302dc85..0000000000000 --- a/src/test/ui/const-generics/min_const_generics/issue-67945-3.stderr +++ /dev/null @@ -1,8 +0,0 @@ -error: generic `Self` types are currently not permitted in anonymous constants - --> $DIR/issue-67945-3.rs:5:27 - | -LL | let x: Option> = None; - | ^^^^ - -error: aborting due to previous error - From 6647eeefb91a2f0e09f7df9f197917d22b01e846 Mon Sep 17 00:00:00 2001 From: varkor Date: Sat, 3 Oct 2020 18:48:56 +0100 Subject: [PATCH 7/7] Add `const_generics` test for `impl-trait-with-const-arguments` --- ...stderr => impl-trait-with-const-arguments.full.stderr} | 2 +- .../impl-trait-with-const-arguments.min.stderr | 8 ++++++++ .../impl-trait-with-const-arguments.rs | 6 +++++- 3 files changed, 14 insertions(+), 2 deletions(-) rename src/test/ui/const-generics/{min_const_generics/impl-trait-with-const-arguments.stderr => impl-trait-with-const-arguments.full.stderr} (83%) create mode 100644 src/test/ui/const-generics/impl-trait-with-const-arguments.min.stderr rename src/test/ui/const-generics/{min_const_generics => }/impl-trait-with-const-arguments.rs (69%) diff --git a/src/test/ui/const-generics/min_const_generics/impl-trait-with-const-arguments.stderr b/src/test/ui/const-generics/impl-trait-with-const-arguments.full.stderr similarity index 83% rename from src/test/ui/const-generics/min_const_generics/impl-trait-with-const-arguments.stderr rename to src/test/ui/const-generics/impl-trait-with-const-arguments.full.stderr index 0a6d350986368..a587cb618731a 100644 --- a/src/test/ui/const-generics/min_const_generics/impl-trait-with-const-arguments.stderr +++ b/src/test/ui/const-generics/impl-trait-with-const-arguments.full.stderr @@ -1,5 +1,5 @@ error[E0632]: cannot provide explicit generic arguments when `impl Trait` is used in argument position - --> $DIR/impl-trait-with-const-arguments.rs:20:20 + --> $DIR/impl-trait-with-const-arguments.rs:24:20 | LL | assert_eq!(f::<4usize>(Usizable), 20usize); | ^^^^^^ explicit generic argument not allowed diff --git a/src/test/ui/const-generics/impl-trait-with-const-arguments.min.stderr b/src/test/ui/const-generics/impl-trait-with-const-arguments.min.stderr new file mode 100644 index 0000000000000..a587cb618731a --- /dev/null +++ b/src/test/ui/const-generics/impl-trait-with-const-arguments.min.stderr @@ -0,0 +1,8 @@ +error[E0632]: cannot provide explicit generic arguments when `impl Trait` is used in argument position + --> $DIR/impl-trait-with-const-arguments.rs:24:20 + | +LL | assert_eq!(f::<4usize>(Usizable), 20usize); + | ^^^^^^ explicit generic argument not allowed + +error: aborting due to previous error + diff --git a/src/test/ui/const-generics/min_const_generics/impl-trait-with-const-arguments.rs b/src/test/ui/const-generics/impl-trait-with-const-arguments.rs similarity index 69% rename from src/test/ui/const-generics/min_const_generics/impl-trait-with-const-arguments.rs rename to src/test/ui/const-generics/impl-trait-with-const-arguments.rs index 97ae3b838a391..a4c75792ee359 100644 --- a/src/test/ui/const-generics/min_const_generics/impl-trait-with-const-arguments.rs +++ b/src/test/ui/const-generics/impl-trait-with-const-arguments.rs @@ -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))] trait Usizer { fn m(self) -> usize;