update tests
This commit is contained in:
parent
69d2d735bc
commit
db9b8cef86
69 changed files with 48 additions and 215 deletions
|
@ -1,5 +1,5 @@
|
|||
// revisions: cfail
|
||||
#![feature(generic_const_exprs, adt_const_params, const_generics_defaults)]
|
||||
#![feature(generic_const_exprs, adt_const_params)]
|
||||
#![allow(incomplete_features)]
|
||||
// regression test for #77650
|
||||
struct C<T, const N: core::num::NonZeroUsize>([T; N.get()])
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
#![crate_name = "foo"]
|
||||
#![feature(const_generics_defaults)]
|
||||
|
||||
// @has foo/struct.Foo.html '//pre[@class="rust struct"]' \
|
||||
// 'pub struct Foo<const M: usize = 10_usize, const N: usize = M, T = i32>(_);'
|
||||
|
|
|
@ -1,30 +0,0 @@
|
|||
error: type parameters must be declared prior to const parameters
|
||||
--> $DIR/argument_order.rs:4:28
|
||||
|
|
||||
LL | struct Bad<const N: usize, T> {
|
||||
| -----------------^- help: reorder the parameters: lifetimes, then types, then consts: `<T, const N: usize>`
|
||||
|
||||
error: lifetime parameters must be declared prior to const parameters
|
||||
--> $DIR/argument_order.rs:10:32
|
||||
|
|
||||
LL | struct AlsoBad<const N: usize, 'a, T, 'b, const M: usize, U> {
|
||||
| -----------------^^-----^^-------------------- help: reorder the parameters: lifetimes, then types, then consts: `<'a, 'b, T, U, const N: usize, const M: usize>`
|
||||
|
||||
error: type parameters must be declared prior to const parameters
|
||||
--> $DIR/argument_order.rs:10:36
|
||||
|
|
||||
LL | struct AlsoBad<const N: usize, 'a, T, 'b, const M: usize, U> {
|
||||
| ---------------------^----------------------^- help: reorder the parameters: lifetimes, then types, then consts: `<'a, 'b, T, U, const N: usize, const M: usize>`
|
||||
|
||||
error[E0747]: lifetime provided when a type was expected
|
||||
--> $DIR/argument_order.rs:18:23
|
||||
|
|
||||
LL | let _: AlsoBad<7, 'static, u32, 'static, 17, u16>;
|
||||
| ^^^^^^^
|
||||
|
|
||||
= note: lifetime arguments must be provided before type arguments
|
||||
= help: reorder the arguments: lifetimes, then types, then consts: `<'a, 'b, T, U, N, M>`
|
||||
|
||||
error: aborting due to 4 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0747`.
|
|
@ -1,15 +1,10 @@
|
|||
// revisions: full min
|
||||
#![cfg_attr(full, feature(const_generics_defaults))]
|
||||
|
||||
struct Bad<const N: usize, T> {
|
||||
//[min]~^ ERROR type parameters must be declared prior to const parameters
|
||||
arr: [u8; { N }],
|
||||
another: T,
|
||||
}
|
||||
|
||||
struct AlsoBad<const N: usize, 'a, T, 'b, const M: usize, U> {
|
||||
//~^ ERROR lifetime parameters must be declared prior
|
||||
//[min]~^^ ERROR type parameters must be declared prior to const parameters
|
||||
a: &'a T,
|
||||
b: &'b U,
|
||||
}
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
error: lifetime parameters must be declared prior to const parameters
|
||||
--> $DIR/argument_order.rs:10:32
|
||||
--> $DIR/argument_order.rs:6:32
|
||||
|
|
||||
LL | struct AlsoBad<const N: usize, 'a, T, 'b, const M: usize, U> {
|
||||
| -----------------^^-----^^-------------------- help: reorder the parameters: lifetimes, then consts and types: `<'a, 'b, const N: usize, T, const M: usize, U>`
|
||||
|
||||
error[E0747]: lifetime provided when a type was expected
|
||||
--> $DIR/argument_order.rs:18:23
|
||||
--> $DIR/argument_order.rs:13:23
|
||||
|
|
||||
LL | let _: AlsoBad<7, 'static, u32, 'static, 17, u16>;
|
||||
| ^^^^^^^
|
|
@ -3,9 +3,6 @@ error[E0747]: constant provided when a type was expected
|
|||
|
|
||||
LL | fn foo<const N: usize>() -> Array<N, ()> {
|
||||
| ^
|
||||
|
|
||||
= note: type arguments must be provided before constant arguments
|
||||
= help: reorder the arguments: types, then consts: `<T, N>`
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
|
|
@ -1,14 +0,0 @@
|
|||
error: lifetime parameters must be declared prior to const parameters
|
||||
--> $DIR/const-param-before-other-params.rs:5:21
|
||||
|
|
||||
LL | fn bar<const X: u8, 'a>(_: &'a ()) {
|
||||
| --------------^^- help: reorder the parameters: lifetimes, then types, then consts: `<'a, const X: u8>`
|
||||
|
||||
error: type parameters must be declared prior to const parameters
|
||||
--> $DIR/const-param-before-other-params.rs:9:21
|
||||
|
|
||||
LL | fn foo<const X: u8, T>(_: &T) {}
|
||||
| --------------^- help: reorder the parameters: lifetimes, then types, then consts: `<T, const X: u8>`
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
|
@ -1,12 +1,7 @@
|
|||
// revisions: full min
|
||||
#![cfg_attr(full, feature(const_generics_defaults))]
|
||||
#![cfg_attr(full, allow(incomplete_features))]
|
||||
|
||||
fn bar<const X: u8, 'a>(_: &'a ()) {
|
||||
//~^ ERROR lifetime parameters must be declared prior to const parameters
|
||||
}
|
||||
|
||||
fn foo<const X: u8, T>(_: &T) {}
|
||||
//[min]~^ ERROR type parameters must be declared prior to const parameters
|
||||
|
||||
fn main() {}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
error: lifetime parameters must be declared prior to const parameters
|
||||
--> $DIR/const-param-before-other-params.rs:5:21
|
||||
--> $DIR/const-param-before-other-params.rs:1:21
|
||||
|
|
||||
LL | fn bar<const X: u8, 'a>(_: &'a ()) {
|
||||
| --------------^^- help: reorder the parameters: lifetimes, then consts and types: `<'a, const X: u8>`
|
|
@ -1,5 +1,3 @@
|
|||
#![feature(const_generics_defaults)]
|
||||
|
||||
pub struct Defaulted<const N: usize=3>;
|
||||
impl Defaulted {
|
||||
pub fn new() -> Self {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
error: generic parameters may not be used in const operations
|
||||
--> $DIR/complex-generic-default-expr.rs:7:47
|
||||
--> $DIR/complex-generic-default-expr.rs:6:47
|
||||
|
|
||||
LL | struct Foo<const N: usize, const M: usize = { N + 1 }>;
|
||||
| ^ cannot perform const operation using `N`
|
||||
|
@ -8,7 +8,7 @@ LL | struct Foo<const N: usize, const M: usize = { N + 1 }>;
|
|||
= help: use `#![feature(generic_const_exprs)]` to allow generic const expressions
|
||||
|
||||
error: generic parameters may not be used in const operations
|
||||
--> $DIR/complex-generic-default-expr.rs:10:62
|
||||
--> $DIR/complex-generic-default-expr.rs:9:62
|
||||
|
|
||||
LL | struct Bar<T, const TYPE_SIZE: usize = { std::mem::size_of::<T>() }>(T);
|
||||
| ^ cannot perform const operation using `T`
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
// revisions: full min
|
||||
//[full] check-pass
|
||||
#![cfg_attr(full, feature(generic_const_exprs))]
|
||||
#![feature(const_generics_defaults)]
|
||||
#![allow(incomplete_features)]
|
||||
#![cfg_attr(full, allow(incomplete_features))]
|
||||
|
||||
struct Foo<const N: usize, const M: usize = { N + 1 }>;
|
||||
//[min]~^ ERROR generic parameters may not be used in const operations
|
||||
|
|
|
@ -1,12 +1,8 @@
|
|||
// [full] run-pass
|
||||
// revisions: full min
|
||||
// run-pass
|
||||
// Checks a complicated usage of unordered params
|
||||
#![cfg_attr(full, feature(const_generics_defaults))]
|
||||
#![cfg_attr(full, allow(incomplete_features))]
|
||||
#![allow(dead_code)]
|
||||
|
||||
struct NestedArrays<'a, const N: usize, A: 'a, const M: usize, T:'a =u32> {
|
||||
//[min]~^ ERROR type parameters must be declared prior to const parameters
|
||||
args: &'a [&'a [T; M]; N],
|
||||
specifier: A,
|
||||
}
|
||||
|
|
|
@ -1,6 +1,4 @@
|
|||
// run-pass
|
||||
#![feature(const_generics_defaults)]
|
||||
|
||||
pub struct ConstDefault<const N: usize = 3>;
|
||||
|
||||
impl<const N: usize> ConstDefault<N> {
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
// run-pass
|
||||
#![feature(const_generics_defaults)]
|
||||
struct Foo<const N: usize, const M: usize = N>([u8; N], [u8; M]);
|
||||
|
||||
fn foo<const N: usize>() -> Foo<N> {
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
// run-pass
|
||||
#![feature(const_generics_defaults)]
|
||||
struct Foo<const N: usize, T = [u8; N]>(T);
|
||||
|
||||
impl<const N: usize> Foo<N> {
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
// run-pass
|
||||
#![feature(staged_api)]
|
||||
#![feature(const_generics_defaults)]
|
||||
#![allow(incomplete_features)]
|
||||
// FIXME(const_generics_defaults): It seems like we aren't testing the right thing here,
|
||||
// I would assume that we want the attributes to apply to the const parameter defaults
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
#![feature(const_generics_defaults)]
|
||||
|
||||
struct Struct<const N: usize = { Self; 10 }>;
|
||||
//~^ ERROR generic parameters cannot use `Self` in their defaults [E0735]
|
||||
|
||||
|
|
|
@ -1,17 +1,17 @@
|
|||
error[E0735]: generic parameters cannot use `Self` in their defaults
|
||||
--> $DIR/default-const-param-cannot-reference-self.rs:3:34
|
||||
--> $DIR/default-const-param-cannot-reference-self.rs:1:34
|
||||
|
|
||||
LL | struct Struct<const N: usize = { Self; 10 }>;
|
||||
| ^^^^ `Self` in generic parameter default
|
||||
|
||||
error[E0735]: generic parameters cannot use `Self` in their defaults
|
||||
--> $DIR/default-const-param-cannot-reference-self.rs:6:30
|
||||
--> $DIR/default-const-param-cannot-reference-self.rs:4:30
|
||||
|
|
||||
LL | enum Enum<const N: usize = { Self; 10 }> { }
|
||||
| ^^^^ `Self` in generic parameter default
|
||||
|
||||
error[E0735]: generic parameters cannot use `Self` in their defaults
|
||||
--> $DIR/default-const-param-cannot-reference-self.rs:9:32
|
||||
--> $DIR/default-const-param-cannot-reference-self.rs:7:32
|
||||
|
|
||||
LL | union Union<const N: usize = { Self; 10 }> { not_empty: () }
|
||||
| ^^^^ `Self` in generic parameter default
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
#![feature(const_generics_defaults)]
|
||||
|
||||
struct Foo<const N: usize>;
|
||||
|
||||
impl<const N: usize = 1> Foo<N> {}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
error: defaults for const parameters are only allowed in `struct`, `enum`, `type`, or `trait` definitions
|
||||
--> $DIR/default-on-impl.rs:5:12
|
||||
--> $DIR/default-on-impl.rs:3:12
|
||||
|
|
||||
LL | impl<const N: usize = 1> Foo<N> {}
|
||||
| ^
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
#![feature(const_generics_defaults)]
|
||||
struct Foo<const N: u8 = { 255 + 1 }>;
|
||||
//~^ ERROR evaluation of constant value failed
|
||||
fn main() {}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
error[E0080]: evaluation of constant value failed
|
||||
--> $DIR/default-param-wf-concrete.rs:2:28
|
||||
--> $DIR/default-param-wf-concrete.rs:1:28
|
||||
|
|
||||
LL | struct Foo<const N: u8 = { 255 + 1 }>;
|
||||
| ^^^^^^^ attempt to compute `u8::MAX + 1_u8`, which would overflow
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
#![feature(const_generics_defaults)]
|
||||
|
||||
// test that defaulted const params are not used to help type inference
|
||||
|
||||
struct Foo<const N: u32 = 2>;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
error[E0282]: type annotations needed for `Foo<{_: u32}>`
|
||||
--> $DIR/doesnt_infer.rs:13:15
|
||||
--> $DIR/doesnt_infer.rs:11:15
|
||||
|
|
||||
LL | let foo = Foo::foo();
|
||||
| --- ^^^^^^^^ cannot infer the value of const parameter `N`
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
// aux-build:const_defaulty.rs
|
||||
// check-pass
|
||||
#![feature(const_generics_defaults)]
|
||||
|
||||
extern crate const_defaulty;
|
||||
use const_defaulty::Defaulted;
|
||||
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
#![feature(const_generics_defaults)]
|
||||
|
||||
struct Foo<const N: usize = M, const M: usize = 10>;
|
||||
//~^ ERROR generic parameters with a default cannot use forward declared identifiers
|
||||
|
||||
|
|
|
@ -1,23 +1,23 @@
|
|||
error[E0128]: generic parameters with a default cannot use forward declared identifiers
|
||||
--> $DIR/forward-declared.rs:3:29
|
||||
--> $DIR/forward-declared.rs:1:29
|
||||
|
|
||||
LL | struct Foo<const N: usize = M, const M: usize = 10>;
|
||||
| ^ defaulted generic parameters cannot be forward declared
|
||||
|
||||
error[E0128]: generic parameters with a default cannot use forward declared identifiers
|
||||
--> $DIR/forward-declared.rs:6:27
|
||||
--> $DIR/forward-declared.rs:4:27
|
||||
|
|
||||
LL | enum Bar<const N: usize = M, const M: usize = 10> {}
|
||||
| ^ defaulted generic parameters cannot be forward declared
|
||||
|
||||
error[E0128]: generic parameters with a default cannot use forward declared identifiers
|
||||
--> $DIR/forward-declared.rs:9:30
|
||||
--> $DIR/forward-declared.rs:7:30
|
||||
|
|
||||
LL | struct Foo2<const N: usize = N>;
|
||||
| ^ defaulted generic parameters cannot be forward declared
|
||||
|
||||
error[E0128]: generic parameters with a default cannot use forward declared identifiers
|
||||
--> $DIR/forward-declared.rs:12:28
|
||||
--> $DIR/forward-declared.rs:10:28
|
||||
|
|
||||
LL | enum Bar2<const N: usize = N> {}
|
||||
| ^ defaulted generic parameters cannot be forward declared
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#![feature(generic_const_exprs, const_generics_defaults)]
|
||||
#![feature(generic_const_exprs)]
|
||||
#![allow(incomplete_features)]
|
||||
|
||||
struct Foo<const N: usize, const M: usize = { N + 1 }>;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#![feature(generic_const_exprs, const_generics_defaults)]
|
||||
#![feature(generic_const_exprs)]
|
||||
#![allow(incomplete_features)]
|
||||
|
||||
struct Foo<const N: usize, const M: usize = { N + 1 }>;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#![feature(generic_const_exprs, const_generics_defaults)]
|
||||
#![feature(generic_const_exprs)]
|
||||
#![allow(incomplete_features)]
|
||||
|
||||
pub struct Foo<const N: usize, const M: usize = { N + 1 }>;
|
||||
|
|
|
@ -1,14 +0,0 @@
|
|||
error: lifetime parameters must be declared prior to const parameters
|
||||
--> $DIR/intermixed-lifetime.rs:5:28
|
||||
|
|
||||
LL | struct Foo<const N: usize, 'a, T = u32>(&'a (), T);
|
||||
| -----------------^^---------- help: reorder the parameters: lifetimes, then consts and types: `<'a, const N: usize, T = u32>`
|
||||
|
||||
error: lifetime parameters must be declared prior to type parameters
|
||||
--> $DIR/intermixed-lifetime.rs:8:37
|
||||
|
|
||||
LL | struct Bar<const N: usize, T = u32, 'a>(&'a (), T);
|
||||
| --------------------------^^- help: reorder the parameters: lifetimes, then consts and types: `<'a, const N: usize, T = u32>`
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
|
@ -1,6 +1,4 @@
|
|||
// Checks that lifetimes cannot be interspersed between consts and types.
|
||||
// revisions: full min
|
||||
#![feature(const_generics_defaults)]
|
||||
|
||||
struct Foo<const N: usize, 'a, T = u32>(&'a (), T);
|
||||
//~^ Error lifetime parameters must be declared prior to const parameters
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
error: lifetime parameters must be declared prior to const parameters
|
||||
--> $DIR/intermixed-lifetime.rs:5:28
|
||||
--> $DIR/intermixed-lifetime.rs:3:28
|
||||
|
|
||||
LL | struct Foo<const N: usize, 'a, T = u32>(&'a (), T);
|
||||
| -----------------^^---------- help: reorder the parameters: lifetimes, then consts and types: `<'a, const N: usize, T = u32>`
|
||||
|
||||
error: lifetime parameters must be declared prior to type parameters
|
||||
--> $DIR/intermixed-lifetime.rs:8:37
|
||||
--> $DIR/intermixed-lifetime.rs:6:37
|
||||
|
|
||||
LL | struct Bar<const N: usize, T = u32, 'a>(&'a (), T);
|
||||
| --------------------------^^- help: reorder the parameters: lifetimes, then consts and types: `<'a, const N: usize, T = u32>`
|
|
@ -1,5 +1,3 @@
|
|||
#![feature(const_generics_defaults)]
|
||||
|
||||
pub struct Example<const N: usize=13>;
|
||||
pub struct Example2<T=u32, const N: usize=13>(T);
|
||||
pub struct Example3<const N: usize=13, T=u32>(T);
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
error[E0308]: mismatched types
|
||||
--> $DIR/mismatch.rs:9:28
|
||||
--> $DIR/mismatch.rs:7:28
|
||||
|
|
||||
LL | let e: Example::<13> = ();
|
||||
| ------------- ^^ expected struct `Example`, found `()`
|
||||
|
@ -10,7 +10,7 @@ LL | let e: Example::<13> = ();
|
|||
found unit type `()`
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/mismatch.rs:12:34
|
||||
--> $DIR/mismatch.rs:10:34
|
||||
|
|
||||
LL | let e: Example2::<u32, 13> = ();
|
||||
| ------------------- ^^ expected struct `Example2`, found `()`
|
||||
|
@ -21,7 +21,7 @@ LL | let e: Example2::<u32, 13> = ();
|
|||
found unit type `()`
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/mismatch.rs:15:34
|
||||
--> $DIR/mismatch.rs:13:34
|
||||
|
|
||||
LL | let e: Example3::<13, u32> = ();
|
||||
| ------------------- ^^ expected struct `Example3`, found `()`
|
||||
|
@ -32,7 +32,7 @@ LL | let e: Example3::<13, u32> = ();
|
|||
found unit type `()`
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/mismatch.rs:18:28
|
||||
--> $DIR/mismatch.rs:16:28
|
||||
|
|
||||
LL | let e: Example3::<7> = ();
|
||||
| ------------- ^^ expected struct `Example3`, found `()`
|
||||
|
@ -43,7 +43,7 @@ LL | let e: Example3::<7> = ();
|
|||
found unit type `()`
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/mismatch.rs:21:28
|
||||
--> $DIR/mismatch.rs:19:28
|
||||
|
|
||||
LL | let e: Example4::<7> = ();
|
||||
| ------------- ^^ expected struct `Example4`, found `()`
|
||||
|
|
|
@ -1,8 +0,0 @@
|
|||
error: type parameters must be declared prior to const parameters
|
||||
--> $DIR/needs-feature.rs:7:26
|
||||
|
|
||||
LL | struct A<const N: usize, T=u32>(T);
|
||||
| -----------------^----- help: reorder the parameters: lifetimes, then types, then consts: `<T = u32, const N: usize>`
|
||||
|
||||
error: aborting due to previous error
|
||||
|
|
@ -1,12 +0,0 @@
|
|||
//[full] run-pass
|
||||
// Verifies that having generic parameters after constants is not permitted without the
|
||||
// `const_generics_defaults` feature.
|
||||
// revisions: min full
|
||||
#![cfg_attr(full, feature(const_generics_defaults))]
|
||||
|
||||
struct A<const N: usize, T=u32>(T);
|
||||
//[min]~^ ERROR type parameters must be declared prior
|
||||
|
||||
fn main() {
|
||||
let _: A<3> = A(0);
|
||||
}
|
|
@ -1,4 +1,3 @@
|
|||
#![feature(const_generics_defaults)]
|
||||
struct Foo<const M: usize = 10, 'a>(&'a u32);
|
||||
//~^ Error lifetime parameters must be declared prior to const parameters
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
error: lifetime parameters must be declared prior to const parameters
|
||||
--> $DIR/param-order-err-pretty-prints-default.rs:2:33
|
||||
--> $DIR/param-order-err-pretty-prints-default.rs:1:33
|
||||
|
|
||||
LL | struct Foo<const M: usize = 10, 'a>(&'a u32);
|
||||
| ----------------------^^- help: reorder the parameters: lifetimes, then consts and types: `<'a, const M: usize = 10>`
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
// compile-flags: -Z unpretty=expanded
|
||||
|
||||
#![crate_type = "lib"]
|
||||
#![feature(const_generics_defaults)]
|
||||
|
||||
trait Foo<const KIND: bool = true> {}
|
||||
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
// compile-flags: -Z unpretty=expanded
|
||||
|
||||
#![crate_type = "lib"]
|
||||
#![feature(const_generics_defaults)]
|
||||
#[prelude_import]
|
||||
use ::std::prelude::rust_2015::*;
|
||||
#[macro_use]
|
||||
|
|
|
@ -2,8 +2,6 @@
|
|||
|
||||
// run-pass
|
||||
|
||||
#![feature(const_generics_defaults)]
|
||||
|
||||
#[repr(C)]
|
||||
pub struct Loaf<T: Sized, const N: usize = 1> {
|
||||
head: [T; N],
|
||||
|
|
|
@ -1,6 +1,4 @@
|
|||
// run-pass
|
||||
#![feature(const_generics_defaults)]
|
||||
|
||||
struct Uwu<const N: u32 = 1, const M: u32 = N>;
|
||||
|
||||
trait Trait {}
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
#![feature(const_generics_defaults)]
|
||||
|
||||
struct Uwu<const N: u32 = 1, const M: u32 = N>;
|
||||
|
||||
trait Trait {}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
error[E0277]: the trait bound `Uwu<10_u32, 12_u32>: Trait` is not satisfied
|
||||
--> $DIR/rp_impl_trait_fail.rs:8:14
|
||||
--> $DIR/rp_impl_trait_fail.rs:6:14
|
||||
|
|
||||
LL | fn rawr() -> impl Trait {
|
||||
| ^^^^^^^^^^ the trait `Trait` is not implemented for `Uwu<10_u32, 12_u32>`
|
||||
|
@ -8,7 +8,7 @@ LL | fn rawr() -> impl Trait {
|
|||
<Uwu<N> as Trait>
|
||||
|
||||
error[E0277]: the trait bound `u32: Traitor<N, N>` is not satisfied
|
||||
--> $DIR/rp_impl_trait_fail.rs:19:26
|
||||
--> $DIR/rp_impl_trait_fail.rs:17:26
|
||||
|
|
||||
LL | fn uwu<const N: u8>() -> impl Traitor<N> {
|
||||
| ^^^^^^^^^^^^^^^ the trait `Traitor<N, N>` is not implemented for `u32`
|
||||
|
@ -17,7 +17,7 @@ LL | fn uwu<const N: u8>() -> impl Traitor<N> {
|
|||
<u32 as Traitor<N, 2_u8>>
|
||||
|
||||
error[E0277]: the trait bound `u64: Traitor<1_u8, 1_u8>` is not satisfied
|
||||
--> $DIR/rp_impl_trait_fail.rs:24:13
|
||||
--> $DIR/rp_impl_trait_fail.rs:22:13
|
||||
|
|
||||
LL | fn owo() -> impl Traitor {
|
||||
| ^^^^^^^^^^^^ the trait `Traitor<1_u8, 1_u8>` is not implemented for `u64`
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
// run-pass
|
||||
// Checks that type param defaults are allowed after const params.
|
||||
#![feature(const_generics_defaults)]
|
||||
#![allow(dead_code)]
|
||||
|
||||
struct FixedOutput<'a, const N: usize, T=u32> {
|
||||
|
|
|
@ -1,6 +1,4 @@
|
|||
// run-pass
|
||||
#![feature(const_generics_defaults)]
|
||||
|
||||
trait Trait<const N: u8 = 12> {
|
||||
fn uwu(&self) -> u8 {
|
||||
N
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
#![feature(const_generics_defaults)]
|
||||
|
||||
trait Trait<const N: u8 = 12> {
|
||||
fn uwu(&self) -> u8 {
|
||||
N
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
error[E0277]: the trait bound `u32: Trait` is not satisfied
|
||||
--> $DIR/trait_objects_fail.rs:28:9
|
||||
--> $DIR/trait_objects_fail.rs:26:9
|
||||
|
|
||||
LL | foo(&10_u32);
|
||||
| --- ^^^^^^^ the trait `Trait` is not implemented for `u32`
|
||||
|
@ -11,7 +11,7 @@ LL | foo(&10_u32);
|
|||
= note: required for the cast to the object type `dyn Trait`
|
||||
|
||||
error[E0277]: the trait bound `bool: Traitor<{_: u8}, {_: u8}>` is not satisfied
|
||||
--> $DIR/trait_objects_fail.rs:30:9
|
||||
--> $DIR/trait_objects_fail.rs:28:9
|
||||
|
|
||||
LL | bar(&true);
|
||||
| --- ^^^^^ the trait `Traitor<{_: u8}, {_: u8}>` is not implemented for `bool`
|
||||
|
|
|
@ -1,6 +1,4 @@
|
|||
// check-pass
|
||||
#![feature(const_generics_defaults)]
|
||||
|
||||
struct N;
|
||||
|
||||
struct Foo<const N: usize = 1, T = N>(T);
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
#![feature(const_generics_defaults)]
|
||||
|
||||
struct Ooopsies<const N: u8 = { u8::MAX + 1 }>;
|
||||
//~^ error: evaluation of constant value failed
|
||||
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
error[E0080]: evaluation of constant value failed
|
||||
--> $DIR/wfness.rs:3:33
|
||||
--> $DIR/wfness.rs:1:33
|
||||
|
|
||||
LL | struct Ooopsies<const N: u8 = { u8::MAX + 1 }>;
|
||||
| ^^^^^^^^^^^ attempt to compute `u8::MAX + 1_u8`, which would overflow
|
||||
|
||||
error[E0277]: the trait bound `(): Trait<2_u8>` is not satisfied
|
||||
--> $DIR/wfness.rs:8:47
|
||||
--> $DIR/wfness.rs:6:47
|
||||
|
|
||||
LL | struct WhereClause<const N: u8 = 2> where (): Trait<N>;
|
||||
| ^^^^^^^^ the trait `Trait<2_u8>` is not implemented for `()`
|
||||
|
@ -14,7 +14,7 @@ LL | struct WhereClause<const N: u8 = 2> where (): Trait<N>;
|
|||
<() as Trait<3_u8>>
|
||||
|
||||
error[E0277]: the trait bound `(): Trait<1_u8>` is not satisfied
|
||||
--> $DIR/wfness.rs:16:13
|
||||
--> $DIR/wfness.rs:14:13
|
||||
|
|
||||
LL | fn foo() -> DependentDefaultWfness {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^ the trait `Trait<1_u8>` is not implemented for `()`
|
||||
|
@ -22,7 +22,7 @@ LL | fn foo() -> DependentDefaultWfness {
|
|||
= help: the following implementations were found:
|
||||
<() as Trait<3_u8>>
|
||||
note: required by a bound in `WhereClause`
|
||||
--> $DIR/wfness.rs:8:47
|
||||
--> $DIR/wfness.rs:6:47
|
||||
|
|
||||
LL | struct WhereClause<const N: u8 = 2> where (): Trait<N>;
|
||||
| ^^^^^^^^ required by this bound in `WhereClause`
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
#![feature(const_generics_defaults)]
|
||||
|
||||
struct A<T = u32, const N: usize> {
|
||||
//~^ ERROR generic parameters with a default must be trailing
|
||||
arg: T,
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
error: generic parameters with a default must be trailing
|
||||
--> $DIR/wrong-order.rs:3:10
|
||||
--> $DIR/wrong-order.rs:1:10
|
||||
|
|
||||
LL | struct A<T = u32, const N: usize> {
|
||||
| ^
|
||||
|
||||
error: generic parameters with a default must be trailing
|
||||
--> $DIR/wrong-order.rs:8:18
|
||||
--> $DIR/wrong-order.rs:6:18
|
||||
|
|
||||
LL | struct Foo<const N: u8 = 3, T>(T);
|
||||
| ^
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
// check-pass
|
||||
#![feature(generic_const_exprs, const_generics_defaults)]
|
||||
#![feature(generic_const_exprs)]
|
||||
#![allow(incomplete_features)]
|
||||
struct Foo<const N: usize, const M: usize = { N + 1 }>;
|
||||
struct Bar<const N: usize>(Foo<N, 3>);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#![feature(adt_const_params, const_generics_defaults)]
|
||||
#![feature(adt_const_params)]
|
||||
#![allow(incomplete_features)]
|
||||
|
||||
#[derive(PartialEq, Eq)]
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
#![crate_type = "lib"]
|
||||
#![feature(const_generics_defaults)]
|
||||
#![allow(incomplete_features, dead_code)]
|
||||
#![allow(dead_code)]
|
||||
|
||||
struct Both<const N: usize=3, T> {
|
||||
//~^ ERROR: generic parameters with a default must be
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
error: generic parameters with a default must be trailing
|
||||
--> $DIR/const_default_first.rs:5:19
|
||||
--> $DIR/const_default_first.rs:4:19
|
||||
|
|
||||
LL | struct Both<const N: usize=3, T> {
|
||||
| ^
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
#![crate_type = "lib"]
|
||||
#![feature(const_generics_defaults)]
|
||||
|
||||
fn foo<const SIZE: usize = 5usize>() {}
|
||||
//~^ ERROR defaults for const parameters are
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
error: defaults for const parameters are only allowed in `struct`, `enum`, `type`, or `trait` definitions
|
||||
--> $DIR/default_function_param.rs:4:14
|
||||
--> $DIR/default_function_param.rs:3:14
|
||||
|
|
||||
LL | fn foo<const SIZE: usize = 5usize>() {}
|
||||
| ^^^^
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// check-pass
|
||||
trait Foo<const KIND: bool = true> {}
|
||||
//~^ ERROR default values for const generic parameters are experimental
|
||||
|
||||
fn main() {}
|
||||
|
|
|
@ -1,12 +0,0 @@
|
|||
error[E0658]: default values for const generic parameters are experimental
|
||||
--> $DIR/default_trait_param.rs:1:28
|
||||
|
|
||||
LL | trait Foo<const KIND: bool = true> {}
|
||||
| ^^^^^^
|
||||
|
|
||||
= note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information
|
||||
= help: add `#![feature(const_generics_defaults)]` to the crate attributes to enable
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0658`.
|
|
@ -1,5 +1,4 @@
|
|||
// run-pass
|
||||
#![feature(const_generics_defaults)]
|
||||
#![allow(dead_code)]
|
||||
|
||||
struct Both<T=u32, const N: usize=3> {
|
||||
|
|
|
@ -3,8 +3,6 @@ error: generic parameters with a default must be trailing
|
|||
|
|
||||
LL | struct Bar<T = [u8; N], const N: usize>(T);
|
||||
| ^
|
||||
|
|
||||
= note: using type defaults and const parameters in the same parameter list is currently not permitted
|
||||
|
||||
error: generic parameters may not be used in const operations
|
||||
--> $DIR/params-in-ct-in-ty-param-lazy-norm.rs:5:44
|
||||
|
|
|
@ -1,11 +1,6 @@
|
|||
// [full] run-pass
|
||||
// revisions: full min
|
||||
// run-pass
|
||||
// Verifies that having generic parameters after constants is permitted
|
||||
#![cfg_attr(full, feature(const_generics_defaults))]
|
||||
#![cfg_attr(full, allow(incomplete_features))]
|
||||
|
||||
#[allow(dead_code)]
|
||||
struct A<const N: usize, T>(T);
|
||||
//[min]~^ ERROR type parameters must be declared prior to const parameters
|
||||
|
||||
fn main() {}
|
||||
|
|
|
@ -1,6 +1,4 @@
|
|||
// check-pass
|
||||
#![feature(const_generics_defaults)]
|
||||
|
||||
#[derive(Clone, PartialEq, Debug)]
|
||||
struct Example<T, const N: usize = 1usize>([T; N]);
|
||||
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
#![allow(dead_code)]
|
||||
#![feature(const_generics_defaults)]
|
||||
|
||||
// This test checks that generic parameter re-ordering diagnostic suggestions mention that
|
||||
// consts come after types and lifetimes when the `const_generics_defaults` feature is enabled.
|
||||
// consts come after types and lifetimes.
|
||||
// We cannot run rustfix on this test because of the above const generics warning.
|
||||
|
||||
struct A;
|
||||
|
|
|
@ -1,6 +1,3 @@
|
|||
#![allow(incomplete_features)]
|
||||
#![feature(const_generics_defaults)]
|
||||
|
||||
struct X<const N: u8>();
|
||||
|
||||
impl X<N> {}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue