feature(const_generics) -> feature(const_param_types)
This commit is contained in:
parent
c0e853f274
commit
0c28e028b6
574 changed files with 849 additions and 4305 deletions
|
|
@ -1,6 +1,3 @@
|
|||
#![feature(const_generics)]
|
||||
//~^ WARN the feature `const_generics` is incomplete
|
||||
|
||||
fn is_123<const N: usize>(x: [u32; N]) -> bool {
|
||||
match x {
|
||||
[1, 2] => true, //~ ERROR mismatched types
|
||||
|
|
|
|||
|
|
@ -1,14 +1,5 @@
|
|||
warning: the feature `const_generics` is incomplete and may not be safe to use and/or cause compiler crashes
|
||||
--> $DIR/match_arr_unknown_len.rs:1:12
|
||||
|
|
||||
LL | #![feature(const_generics)]
|
||||
| ^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: `#[warn(incomplete_features)]` on by default
|
||||
= note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/match_arr_unknown_len.rs:6:9
|
||||
--> $DIR/match_arr_unknown_len.rs:3:9
|
||||
|
|
||||
LL | [1, 2] => true,
|
||||
| ^^^^^^ expected `2_usize`, found `N`
|
||||
|
|
@ -16,6 +7,6 @@ LL | [1, 2] => true,
|
|||
= note: expected array `[u32; 2]`
|
||||
found array `[u32; N]`
|
||||
|
||||
error: aborting due to previous error; 1 warning emitted
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0308`.
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ LL | let _array: [u32; <A as Foo>::Y];
|
|||
| ^ cannot perform const operation using `A`
|
||||
|
|
||||
= note: type parameters may not be used in const expressions
|
||||
= help: use `#![feature(const_generics)]` and `#![feature(generic_const_exprs)]` to allow generic const expressions
|
||||
= help: use `#![feature(generic_const_exprs)]` to allow generic const expressions
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ LL | links: [u32; A::LINKS], // Shouldn't suggest bounds already there.
|
|||
| ^^^^^^^^ cannot perform const operation using `A`
|
||||
|
|
||||
= note: type parameters may not be used in const expressions
|
||||
= help: use `#![feature(const_generics)]` and `#![feature(generic_const_exprs)]` to allow generic const expressions
|
||||
= help: use `#![feature(generic_const_exprs)]` to allow generic const expressions
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
// edition:2018
|
||||
// revisions: full min
|
||||
|
||||
#![cfg_attr(full, feature(const_generics))]
|
||||
#![cfg_attr(full, feature(const_param_types))]
|
||||
#![cfg_attr(full, allow(incomplete_features))]
|
||||
|
||||
struct Foo;
|
||||
|
|
|
|||
|
|
@ -1,9 +0,0 @@
|
|||
error[E0158]: const parameters cannot be referenced in patterns
|
||||
--> $DIR/const-param.rs:8:9
|
||||
|
|
||||
LL | N => {}
|
||||
| ^
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0158`.
|
||||
|
|
@ -1,7 +1,4 @@
|
|||
// Identifier pattern referring to a const generic parameter is an error (issue #68853).
|
||||
// revisions: full min
|
||||
#![cfg_attr(full, feature(const_generics))]
|
||||
#![cfg_attr(full, allow(incomplete_features))]
|
||||
|
||||
fn check<const N: usize>() {
|
||||
match 1 {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
error[E0158]: const parameters cannot be referenced in patterns
|
||||
--> $DIR/const-param.rs:8:9
|
||||
--> $DIR/const-param.rs:5:9
|
||||
|
|
||||
LL | N => {}
|
||||
| ^
|
||||
|
|
@ -1,8 +1,4 @@
|
|||
// check-pass
|
||||
// revisions: full min
|
||||
|
||||
#![cfg_attr(full, feature(const_generics))]
|
||||
#![cfg_attr(full, allow(incomplete_features))]
|
||||
|
||||
trait Trait {}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,11 +1,11 @@
|
|||
error: lifetime parameters must be declared prior to const parameters
|
||||
--> $DIR/argument_order.rs:11:32
|
||||
--> $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 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:19:23
|
||||
--> $DIR/argument_order.rs:18:23
|
||||
|
|
||||
LL | let _: AlsoBad<7, 'static, u32, 'static, 17, u16>;
|
||||
| ^^^^^^^
|
||||
|
|
|
|||
|
|
@ -1,23 +1,23 @@
|
|||
error: type parameters must be declared prior to const parameters
|
||||
--> $DIR/argument_order.rs:5:28
|
||||
--> $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:11:32
|
||||
--> $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:11:36
|
||||
--> $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:19:23
|
||||
--> $DIR/argument_order.rs:18:23
|
||||
|
|
||||
LL | let _: AlsoBad<7, 'static, u32, 'static, 17, u16>;
|
||||
| ^^^^^^^
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
// revisions: full min
|
||||
#![cfg_attr(full, feature(const_generics))]
|
||||
#![cfg_attr(full, allow(incomplete_features))]
|
||||
#![cfg_attr(full, feature(const_generics_defaults))]
|
||||
|
||||
struct Bad<const N: usize, T> {
|
||||
//[min]~^ ERROR type parameters must be declared prior to const parameters
|
||||
|
|
|
|||
|
|
@ -1,18 +0,0 @@
|
|||
error: constant expression depends on a generic parameter
|
||||
--> $DIR/array-size-in-generic-struct-param.rs:8:38
|
||||
|
|
||||
LL | struct ArithArrayLen<const N: usize>([u32; 0 + N]);
|
||||
| ^^^^^^^^^^^^
|
||||
|
|
||||
= note: this may fail depending on what value the parameter takes
|
||||
|
||||
error: constant expression depends on a generic parameter
|
||||
--> $DIR/array-size-in-generic-struct-param.rs:19:10
|
||||
|
|
||||
LL | arr: [u8; CFG.arr_size],
|
||||
| ^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: this may fail depending on what value the parameter takes
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
|
|
@ -1,7 +1,4 @@
|
|||
// run-pass
|
||||
// revisions: full min
|
||||
#![cfg_attr(full, feature(const_generics))]
|
||||
#![cfg_attr(full, allow(incomplete_features))]
|
||||
|
||||
#![allow(dead_code)]
|
||||
|
||||
|
|
|
|||
|
|
@ -1,17 +0,0 @@
|
|||
error[E0277]: the trait bound `u16: Bar<N>` is not satisfied
|
||||
--> $DIR/associated-type-bound-fail.rs:13:5
|
||||
|
|
||||
LL | type Assoc = u16;
|
||||
| ^^^^^^^^^^^^^^^^^ the trait `Bar<N>` is not implemented for `u16`
|
||||
|
|
||||
= help: the following implementations were found:
|
||||
<u16 as Bar<3_usize>>
|
||||
note: required by a bound in `Foo::Assoc`
|
||||
--> $DIR/associated-type-bound-fail.rs:8:17
|
||||
|
|
||||
LL | type Assoc: Bar<N>;
|
||||
| ^^^^^^ required by this bound in `Foo::Assoc`
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0277`.
|
||||
|
|
@ -1,7 +1,3 @@
|
|||
// revisions: full min
|
||||
#![cfg_attr(full, allow(incomplete_features))]
|
||||
#![cfg_attr(full, feature(const_generics))]
|
||||
|
||||
trait Bar<const N: usize> {}
|
||||
|
||||
trait Foo<const N: usize> {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
error[E0277]: the trait bound `u16: Bar<N>` is not satisfied
|
||||
--> $DIR/associated-type-bound-fail.rs:13:5
|
||||
--> $DIR/associated-type-bound-fail.rs:9:5
|
||||
|
|
||||
LL | type Assoc = u16;
|
||||
| ^^^^^^^^^^^^^^^^^ the trait `Bar<N>` is not implemented for `u16`
|
||||
|
|
@ -7,7 +7,7 @@ LL | type Assoc = u16;
|
|||
= help: the following implementations were found:
|
||||
<u16 as Bar<3_usize>>
|
||||
note: required by a bound in `Foo::Assoc`
|
||||
--> $DIR/associated-type-bound-fail.rs:8:17
|
||||
--> $DIR/associated-type-bound-fail.rs:4:17
|
||||
|
|
||||
LL | type Assoc: Bar<N>;
|
||||
| ^^^^^^ required by this bound in `Foo::Assoc`
|
||||
|
|
@ -1,8 +1,4 @@
|
|||
// run-pass
|
||||
// revisions: full min
|
||||
#![cfg_attr(full, allow(incomplete_features))]
|
||||
#![cfg_attr(full, feature(const_generics))]
|
||||
|
||||
trait Bar<const N: usize> {}
|
||||
|
||||
trait Foo<const N: usize> {
|
||||
|
|
|
|||
|
|
@ -1,6 +1,3 @@
|
|||
#![cfg_attr(full, feature(const_generics))]
|
||||
#![cfg_attr(full, allow(incomplete_features))]
|
||||
|
||||
pub struct Struct<const N: usize>(pub [u8; N]);
|
||||
|
||||
pub type Alias = Struct<2>;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,4 @@
|
|||
// edition:2018
|
||||
#![cfg_attr(full, feature(const_generics))]
|
||||
#![cfg_attr(full, allow(incomplete_features))]
|
||||
|
||||
pub trait Foo<const N: usize> {}
|
||||
struct Local;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
#![feature(const_generics, generic_const_exprs)]
|
||||
#![feature(generic_const_exprs)]
|
||||
#![allow(incomplete_features)]
|
||||
|
||||
// library portion of regression test for #87674
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
#![feature(const_generics, generic_const_exprs)]
|
||||
#![feature(generic_const_exprs)]
|
||||
#![allow(incomplete_features)]
|
||||
|
||||
// library portion of testing that `impl Trait<{ expr }>` doesnt
|
||||
|
|
|
|||
|
|
@ -1,9 +1,4 @@
|
|||
// run-pass
|
||||
// revisions: full min
|
||||
|
||||
#![cfg_attr(full, feature(const_generics))]
|
||||
#![cfg_attr(full, allow(incomplete_features))]
|
||||
|
||||
pub trait Foo {
|
||||
fn foo(&self);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,9 +1,4 @@
|
|||
// run-pass
|
||||
// revisions: full min
|
||||
|
||||
#![cfg_attr(full, feature(const_generics))]
|
||||
#![cfg_attr(full, allow(incomplete_features))]
|
||||
|
||||
use std::fmt::Debug;
|
||||
|
||||
#[derive(Debug)]
|
||||
|
|
|
|||
|
|
@ -1,7 +1,4 @@
|
|||
// check-pass
|
||||
// revisions: full min
|
||||
#![cfg_attr(full, feature(const_generics))]
|
||||
#![cfg_attr(full, allow(incomplete_features))]
|
||||
|
||||
// This test confirms that the types can be inferred correctly for this example with const
|
||||
// generics. Previously this would ICE, and more recently error.
|
||||
|
|
|
|||
|
|
@ -1,52 +0,0 @@
|
|||
error: expressions must be enclosed in braces to be used as const generic arguments
|
||||
--> $DIR/closing-args-token.rs:10:9
|
||||
|
|
||||
LL | S::<5 + 2 >> 7>;
|
||||
| ^^^^^
|
||||
|
|
||||
help: enclose the `const` expression in braces
|
||||
|
|
||||
LL | S::<{ 5 + 2 } >> 7>;
|
||||
| + +
|
||||
|
||||
error: comparison operators cannot be chained
|
||||
--> $DIR/closing-args-token.rs:10:16
|
||||
|
|
||||
LL | S::<5 + 2 >> 7>;
|
||||
| ^ ^
|
||||
|
|
||||
help: split the comparison into two
|
||||
|
|
||||
LL | S::<5 + 2 >> 7 && 7>;
|
||||
| ++++
|
||||
|
||||
error: comparison operators cannot be chained
|
||||
--> $DIR/closing-args-token.rs:16:20
|
||||
|
|
||||
LL | S::<{ 5 + 2 } >> 7>;
|
||||
| ^ ^
|
||||
|
|
||||
help: split the comparison into two
|
||||
|
|
||||
LL | S::<{ 5 + 2 } >> 7 && 7>;
|
||||
| ++++
|
||||
|
||||
error: expected expression, found `;`
|
||||
--> $DIR/closing-args-token.rs:21:16
|
||||
|
|
||||
LL | T::<0 >= 3>;
|
||||
| ^ expected expression
|
||||
|
||||
error: comparison operators cannot be chained
|
||||
--> $DIR/closing-args-token.rs:27:12
|
||||
|
|
||||
LL | T::<x >>= 2 > 0>;
|
||||
| ^^ ^
|
||||
|
|
||||
help: split the comparison into two
|
||||
|
|
||||
LL | T::<x >>= 2 && 2 > 0>;
|
||||
| ++++
|
||||
|
||||
error: aborting due to 5 previous errors
|
||||
|
||||
|
|
@ -1,9 +1,4 @@
|
|||
// run-pass
|
||||
// revisions: full min
|
||||
|
||||
#![cfg_attr(full, feature(const_generics))]
|
||||
#![cfg_attr(full, allow(incomplete_features))]
|
||||
|
||||
fn foo<const N: usize>(v: &[u8; N]) -> &[u8] {
|
||||
v
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,9 +1,5 @@
|
|||
// Test that a concrete const type i.e. A<2>, can be used as an argument type in a function
|
||||
// run-pass
|
||||
// revisions: full min
|
||||
|
||||
#![cfg_attr(full, feature(const_generics))]
|
||||
#![cfg_attr(full, allow(incomplete_features))]
|
||||
|
||||
struct A<const N: usize>; // ok
|
||||
|
||||
|
|
|
|||
|
|
@ -1,10 +1,6 @@
|
|||
// Test that a method/associated non-method within an impl block of a concrete const type i.e. A<2>,
|
||||
// is callable.
|
||||
// run-pass
|
||||
// revisions: full min
|
||||
|
||||
#![cfg_attr(full, feature(const_generics))]
|
||||
#![cfg_attr(full, allow(incomplete_features))]
|
||||
|
||||
pub struct A<const N: u32>;
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
// run-pass
|
||||
// revisions: full min
|
||||
|
||||
#![cfg_attr(full, feature(const_generics))]
|
||||
#![cfg_attr(full, feature(generic_const_exprs))]
|
||||
#![cfg_attr(full, allow(incomplete_features))]
|
||||
|
||||
trait IsZeroTrait<const IS_ZERO: bool>{}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
// run-pass
|
||||
#![feature(const_generics, generic_const_exprs)]
|
||||
#![feature(generic_const_exprs)]
|
||||
#![allow(incomplete_features)]
|
||||
|
||||
// This tests that the `conservative_is_privately_uninhabited` fn doesn't cause
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
// run-pass
|
||||
#![feature(const_generics, generic_const_exprs)]
|
||||
#![feature(generic_const_exprs)]
|
||||
#![allow(incomplete_features)]
|
||||
|
||||
// This tests that the `conservative_is_privately_uninhabited` fn doesn't cause
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ LL | let _: [u8; foo::<T>()];
|
|||
| ^ cannot perform const operation using `T`
|
||||
|
|
||||
= note: type parameters may not be used in const expressions
|
||||
= help: use `#![feature(const_generics)]` and `#![feature(generic_const_exprs)]` to allow generic const expressions
|
||||
= help: use `#![feature(generic_const_exprs)]` to allow generic const expressions
|
||||
|
||||
error: generic parameters may not be used in const operations
|
||||
--> $DIR/const-arg-in-const-arg.rs:14:23
|
||||
|
|
@ -14,7 +14,7 @@ LL | let _: [u8; bar::<N>()];
|
|||
| ^ cannot perform const operation using `N`
|
||||
|
|
||||
= help: const parameters may only be used as standalone arguments, i.e. `N`
|
||||
= help: use `#![feature(const_generics)]` and `#![feature(generic_const_exprs)]` to allow generic const expressions
|
||||
= help: use `#![feature(generic_const_exprs)]` to allow generic const expressions
|
||||
|
||||
error: generic parameters may not be used in const operations
|
||||
--> $DIR/const-arg-in-const-arg.rs:24:23
|
||||
|
|
@ -23,7 +23,7 @@ LL | let _ = [0; bar::<N>()];
|
|||
| ^ cannot perform const operation using `N`
|
||||
|
|
||||
= help: const parameters may only be used as standalone arguments, i.e. `N`
|
||||
= help: use `#![feature(const_generics)]` and `#![feature(generic_const_exprs)]` to allow generic const expressions
|
||||
= help: use `#![feature(generic_const_exprs)]` to allow generic const expressions
|
||||
|
||||
error: generic parameters may not be used in const operations
|
||||
--> $DIR/const-arg-in-const-arg.rs:29:24
|
||||
|
|
@ -32,7 +32,7 @@ LL | let _: Foo<{ foo::<T>() }>;
|
|||
| ^ cannot perform const operation using `T`
|
||||
|
|
||||
= note: type parameters may not be used in const expressions
|
||||
= help: use `#![feature(const_generics)]` and `#![feature(generic_const_exprs)]` to allow generic const expressions
|
||||
= help: use `#![feature(generic_const_exprs)]` to allow generic const expressions
|
||||
|
||||
error: generic parameters may not be used in const operations
|
||||
--> $DIR/const-arg-in-const-arg.rs:30:24
|
||||
|
|
@ -41,7 +41,7 @@ LL | let _: Foo<{ bar::<N>() }>;
|
|||
| ^ cannot perform const operation using `N`
|
||||
|
|
||||
= help: const parameters may only be used as standalone arguments, i.e. `N`
|
||||
= help: use `#![feature(const_generics)]` and `#![feature(generic_const_exprs)]` to allow generic const expressions
|
||||
= help: use `#![feature(generic_const_exprs)]` to allow generic const expressions
|
||||
|
||||
error: generic parameters may not be used in const operations
|
||||
--> $DIR/const-arg-in-const-arg.rs:35:27
|
||||
|
|
@ -50,7 +50,7 @@ LL | let _ = Foo::<{ foo::<T>() }>;
|
|||
| ^ cannot perform const operation using `T`
|
||||
|
|
||||
= note: type parameters may not be used in const expressions
|
||||
= help: use `#![feature(const_generics)]` and `#![feature(generic_const_exprs)]` to allow generic const expressions
|
||||
= help: use `#![feature(generic_const_exprs)]` to allow generic const expressions
|
||||
|
||||
error: generic parameters may not be used in const operations
|
||||
--> $DIR/const-arg-in-const-arg.rs:36:27
|
||||
|
|
@ -59,7 +59,7 @@ LL | let _ = Foo::<{ bar::<N>() }>;
|
|||
| ^ cannot perform const operation using `N`
|
||||
|
|
||||
= help: const parameters may only be used as standalone arguments, i.e. `N`
|
||||
= help: use `#![feature(const_generics)]` and `#![feature(generic_const_exprs)]` to allow generic const expressions
|
||||
= help: use `#![feature(generic_const_exprs)]` to allow generic const expressions
|
||||
|
||||
error[E0658]: a non-static lifetime is not allowed in a `const`
|
||||
--> $DIR/const-arg-in-const-arg.rs:15:23
|
||||
|
|
@ -67,8 +67,8 @@ error[E0658]: a non-static lifetime is not allowed in a `const`
|
|||
LL | let _: [u8; faz::<'a>(&())];
|
||||
| ^^
|
||||
|
|
||||
= note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information
|
||||
= help: add `#![feature(const_generics)]` to the crate attributes to enable
|
||||
= note: see issue #76560 <https://github.com/rust-lang/rust/issues/76560> for more information
|
||||
= help: add `#![feature(generic_const_exprs)]` to the crate attributes to enable
|
||||
|
||||
error[E0658]: a non-static lifetime is not allowed in a `const`
|
||||
--> $DIR/const-arg-in-const-arg.rs:16:23
|
||||
|
|
@ -76,8 +76,8 @@ error[E0658]: a non-static lifetime is not allowed in a `const`
|
|||
LL | let _: [u8; baz::<'a>(&())];
|
||||
| ^^
|
||||
|
|
||||
= note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information
|
||||
= help: add `#![feature(const_generics)]` to the crate attributes to enable
|
||||
= note: see issue #76560 <https://github.com/rust-lang/rust/issues/76560> for more information
|
||||
= help: add `#![feature(generic_const_exprs)]` to the crate attributes to enable
|
||||
|
||||
error[E0658]: a non-static lifetime is not allowed in a `const`
|
||||
--> $DIR/const-arg-in-const-arg.rs:17:23
|
||||
|
|
@ -85,8 +85,8 @@ error[E0658]: a non-static lifetime is not allowed in a `const`
|
|||
LL | let _: [u8; faz::<'b>(&())];
|
||||
| ^^
|
||||
|
|
||||
= note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information
|
||||
= help: add `#![feature(const_generics)]` to the crate attributes to enable
|
||||
= note: see issue #76560 <https://github.com/rust-lang/rust/issues/76560> for more information
|
||||
= help: add `#![feature(generic_const_exprs)]` to the crate attributes to enable
|
||||
|
||||
error[E0658]: a non-static lifetime is not allowed in a `const`
|
||||
--> $DIR/const-arg-in-const-arg.rs:18:23
|
||||
|
|
@ -94,8 +94,8 @@ error[E0658]: a non-static lifetime is not allowed in a `const`
|
|||
LL | let _: [u8; baz::<'b>(&())];
|
||||
| ^^
|
||||
|
|
||||
= note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information
|
||||
= help: add `#![feature(const_generics)]` to the crate attributes to enable
|
||||
= note: see issue #76560 <https://github.com/rust-lang/rust/issues/76560> for more information
|
||||
= help: add `#![feature(generic_const_exprs)]` to the crate attributes to enable
|
||||
|
||||
error[E0658]: a non-static lifetime is not allowed in a `const`
|
||||
--> $DIR/const-arg-in-const-arg.rs:25:23
|
||||
|
|
@ -103,8 +103,8 @@ error[E0658]: a non-static lifetime is not allowed in a `const`
|
|||
LL | let _ = [0; faz::<'a>(&())];
|
||||
| ^^
|
||||
|
|
||||
= note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information
|
||||
= help: add `#![feature(const_generics)]` to the crate attributes to enable
|
||||
= note: see issue #76560 <https://github.com/rust-lang/rust/issues/76560> for more information
|
||||
= help: add `#![feature(generic_const_exprs)]` to the crate attributes to enable
|
||||
|
||||
error[E0658]: a non-static lifetime is not allowed in a `const`
|
||||
--> $DIR/const-arg-in-const-arg.rs:26:23
|
||||
|
|
@ -112,8 +112,8 @@ error[E0658]: a non-static lifetime is not allowed in a `const`
|
|||
LL | let _ = [0; baz::<'a>(&())];
|
||||
| ^^
|
||||
|
|
||||
= note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information
|
||||
= help: add `#![feature(const_generics)]` to the crate attributes to enable
|
||||
= note: see issue #76560 <https://github.com/rust-lang/rust/issues/76560> for more information
|
||||
= help: add `#![feature(generic_const_exprs)]` to the crate attributes to enable
|
||||
|
||||
error[E0658]: a non-static lifetime is not allowed in a `const`
|
||||
--> $DIR/const-arg-in-const-arg.rs:27:23
|
||||
|
|
@ -121,8 +121,8 @@ error[E0658]: a non-static lifetime is not allowed in a `const`
|
|||
LL | let _ = [0; faz::<'b>(&())];
|
||||
| ^^
|
||||
|
|
||||
= note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information
|
||||
= help: add `#![feature(const_generics)]` to the crate attributes to enable
|
||||
= note: see issue #76560 <https://github.com/rust-lang/rust/issues/76560> for more information
|
||||
= help: add `#![feature(generic_const_exprs)]` to the crate attributes to enable
|
||||
|
||||
error[E0658]: a non-static lifetime is not allowed in a `const`
|
||||
--> $DIR/const-arg-in-const-arg.rs:28:23
|
||||
|
|
@ -130,8 +130,8 @@ error[E0658]: a non-static lifetime is not allowed in a `const`
|
|||
LL | let _ = [0; baz::<'b>(&())];
|
||||
| ^^
|
||||
|
|
||||
= note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information
|
||||
= help: add `#![feature(const_generics)]` to the crate attributes to enable
|
||||
= note: see issue #76560 <https://github.com/rust-lang/rust/issues/76560> for more information
|
||||
= help: add `#![feature(generic_const_exprs)]` to the crate attributes to enable
|
||||
|
||||
error[E0658]: a non-static lifetime is not allowed in a `const`
|
||||
--> $DIR/const-arg-in-const-arg.rs:31:24
|
||||
|
|
@ -139,8 +139,8 @@ error[E0658]: a non-static lifetime is not allowed in a `const`
|
|||
LL | let _: Foo<{ faz::<'a>(&()) }>;
|
||||
| ^^
|
||||
|
|
||||
= note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information
|
||||
= help: add `#![feature(const_generics)]` to the crate attributes to enable
|
||||
= note: see issue #76560 <https://github.com/rust-lang/rust/issues/76560> for more information
|
||||
= help: add `#![feature(generic_const_exprs)]` to the crate attributes to enable
|
||||
|
||||
error[E0658]: a non-static lifetime is not allowed in a `const`
|
||||
--> $DIR/const-arg-in-const-arg.rs:32:24
|
||||
|
|
@ -148,8 +148,8 @@ error[E0658]: a non-static lifetime is not allowed in a `const`
|
|||
LL | let _: Foo<{ baz::<'a>(&()) }>;
|
||||
| ^^
|
||||
|
|
||||
= note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information
|
||||
= help: add `#![feature(const_generics)]` to the crate attributes to enable
|
||||
= note: see issue #76560 <https://github.com/rust-lang/rust/issues/76560> for more information
|
||||
= help: add `#![feature(generic_const_exprs)]` to the crate attributes to enable
|
||||
|
||||
error[E0658]: a non-static lifetime is not allowed in a `const`
|
||||
--> $DIR/const-arg-in-const-arg.rs:33:24
|
||||
|
|
@ -157,8 +157,8 @@ error[E0658]: a non-static lifetime is not allowed in a `const`
|
|||
LL | let _: Foo<{ faz::<'b>(&()) }>;
|
||||
| ^^
|
||||
|
|
||||
= note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information
|
||||
= help: add `#![feature(const_generics)]` to the crate attributes to enable
|
||||
= note: see issue #76560 <https://github.com/rust-lang/rust/issues/76560> for more information
|
||||
= help: add `#![feature(generic_const_exprs)]` to the crate attributes to enable
|
||||
|
||||
error[E0658]: a non-static lifetime is not allowed in a `const`
|
||||
--> $DIR/const-arg-in-const-arg.rs:34:24
|
||||
|
|
@ -166,8 +166,8 @@ error[E0658]: a non-static lifetime is not allowed in a `const`
|
|||
LL | let _: Foo<{ baz::<'b>(&()) }>;
|
||||
| ^^
|
||||
|
|
||||
= note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information
|
||||
= help: add `#![feature(const_generics)]` to the crate attributes to enable
|
||||
= note: see issue #76560 <https://github.com/rust-lang/rust/issues/76560> for more information
|
||||
= help: add `#![feature(generic_const_exprs)]` to the crate attributes to enable
|
||||
|
||||
error[E0658]: a non-static lifetime is not allowed in a `const`
|
||||
--> $DIR/const-arg-in-const-arg.rs:37:27
|
||||
|
|
@ -175,8 +175,8 @@ error[E0658]: a non-static lifetime is not allowed in a `const`
|
|||
LL | let _ = Foo::<{ faz::<'a>(&()) }>;
|
||||
| ^^
|
||||
|
|
||||
= note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information
|
||||
= help: add `#![feature(const_generics)]` to the crate attributes to enable
|
||||
= note: see issue #76560 <https://github.com/rust-lang/rust/issues/76560> for more information
|
||||
= help: add `#![feature(generic_const_exprs)]` to the crate attributes to enable
|
||||
|
||||
error[E0658]: a non-static lifetime is not allowed in a `const`
|
||||
--> $DIR/const-arg-in-const-arg.rs:38:27
|
||||
|
|
@ -184,8 +184,8 @@ error[E0658]: a non-static lifetime is not allowed in a `const`
|
|||
LL | let _ = Foo::<{ baz::<'a>(&()) }>;
|
||||
| ^^
|
||||
|
|
||||
= note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information
|
||||
= help: add `#![feature(const_generics)]` to the crate attributes to enable
|
||||
= note: see issue #76560 <https://github.com/rust-lang/rust/issues/76560> for more information
|
||||
= help: add `#![feature(generic_const_exprs)]` to the crate attributes to enable
|
||||
|
||||
error[E0658]: a non-static lifetime is not allowed in a `const`
|
||||
--> $DIR/const-arg-in-const-arg.rs:39:27
|
||||
|
|
@ -193,8 +193,8 @@ error[E0658]: a non-static lifetime is not allowed in a `const`
|
|||
LL | let _ = Foo::<{ faz::<'b>(&()) }>;
|
||||
| ^^
|
||||
|
|
||||
= note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information
|
||||
= help: add `#![feature(const_generics)]` to the crate attributes to enable
|
||||
= note: see issue #76560 <https://github.com/rust-lang/rust/issues/76560> for more information
|
||||
= help: add `#![feature(generic_const_exprs)]` to the crate attributes to enable
|
||||
|
||||
error[E0658]: a non-static lifetime is not allowed in a `const`
|
||||
--> $DIR/const-arg-in-const-arg.rs:40:27
|
||||
|
|
@ -202,8 +202,8 @@ error[E0658]: a non-static lifetime is not allowed in a `const`
|
|||
LL | let _ = Foo::<{ baz::<'b>(&()) }>;
|
||||
| ^^
|
||||
|
|
||||
= note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information
|
||||
= help: add `#![feature(const_generics)]` to the crate attributes to enable
|
||||
= note: see issue #76560 <https://github.com/rust-lang/rust/issues/76560> for more information
|
||||
= help: add `#![feature(generic_const_exprs)]` to the crate attributes to enable
|
||||
|
||||
error: aborting due to 23 previous errors
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
// revisions: min
|
||||
// FIXME(const_generics): This test currently causes an ICE because
|
||||
// FIXME(generic_const_exprs): This test currently causes an ICE because
|
||||
// we don't yet correctly deal with lifetimes, reenable this test once
|
||||
// this is fixed.
|
||||
|
||||
|
|
|
|||
|
|
@ -1,9 +1,4 @@
|
|||
// run-pass
|
||||
// revisions: full min
|
||||
|
||||
#![cfg_attr(full, feature(const_generics))]
|
||||
#![cfg_attr(full, allow(incomplete_features))]
|
||||
|
||||
fn const_u32_identity<const X: u32>() -> u32 {
|
||||
X
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,9 +0,0 @@
|
|||
error[E0747]: constant provided when a type was expected
|
||||
--> $DIR/const-arg-type-arg-misordered.rs:7:35
|
||||
|
|
||||
LL | fn foo<const N: usize>() -> Array<N, ()> {
|
||||
| ^
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0747`.
|
||||
|
|
@ -1,7 +1,3 @@
|
|||
// revisions: full min
|
||||
#![cfg_attr(full, feature(const_generics))]
|
||||
#![cfg_attr(full, allow(incomplete_features))]
|
||||
|
||||
type Array<T, const N: usize> = [T; N];
|
||||
|
||||
fn foo<const N: usize>() -> Array<N, ()> {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
error[E0747]: constant provided when a type was expected
|
||||
--> $DIR/const-arg-type-arg-misordered.rs:7:35
|
||||
--> $DIR/const-arg-type-arg-misordered.rs:3:35
|
||||
|
|
||||
LL | fn foo<const N: usize>() -> Array<N, ()> {
|
||||
| ^
|
||||
|
|
@ -1,15 +0,0 @@
|
|||
error[E0308]: mismatched types
|
||||
--> $DIR/const-argument-cross-crate-mismatch.rs:9:67
|
||||
|
|
||||
LL | let _ = const_generic_lib::function(const_generic_lib::Struct([0u8, 1u8]));
|
||||
| ^^^^^^^^^^ expected an array with a fixed size of 3 elements, found one with 2 elements
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/const-argument-cross-crate-mismatch.rs:11:65
|
||||
|
|
||||
LL | let _: const_generic_lib::Alias = const_generic_lib::Struct([0u8, 1u8, 2u8]);
|
||||
| ^^^^^^^^^^^^^^^ expected an array with a fixed size of 2 elements, found one with 3 elements
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0308`.
|
||||
|
|
@ -1,7 +1,4 @@
|
|||
// aux-build:const_generic_lib.rs
|
||||
// revisions: full min
|
||||
#![cfg_attr(full, feature(const_generics))]
|
||||
#![cfg_attr(full, allow(incomplete_features))]
|
||||
|
||||
extern crate const_generic_lib;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,11 +1,11 @@
|
|||
error[E0308]: mismatched types
|
||||
--> $DIR/const-argument-cross-crate-mismatch.rs:9:67
|
||||
--> $DIR/const-argument-cross-crate-mismatch.rs:6:67
|
||||
|
|
||||
LL | let _ = const_generic_lib::function(const_generic_lib::Struct([0u8, 1u8]));
|
||||
| ^^^^^^^^^^ expected an array with a fixed size of 3 elements, found one with 2 elements
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/const-argument-cross-crate-mismatch.rs:11:65
|
||||
--> $DIR/const-argument-cross-crate-mismatch.rs:8:65
|
||||
|
|
||||
LL | let _: const_generic_lib::Alias = const_generic_lib::Struct([0u8, 1u8, 2u8]);
|
||||
| ^^^^^^^^^^^^^^^ expected an array with a fixed size of 2 elements, found one with 3 elements
|
||||
|
|
@ -1,24 +1,5 @@
|
|||
error[E0277]: the size for values of type `T` cannot be known at compilation time
|
||||
--> $DIR/const-argument-if-length.rs:7:28
|
||||
|
|
||||
LL | pub const fn is_zst<T: ?Sized>() -> usize {
|
||||
| - this type parameter needs to be `std::marker::Sized`
|
||||
LL | if std::mem::size_of::<T>() == 0 {
|
||||
| ^ doesn't have a size known at compile-time
|
||||
|
|
||||
note: required by a bound in `std::mem::size_of`
|
||||
--> $SRC_DIR/core/src/mem/mod.rs:LL:COL
|
||||
|
|
||||
LL | pub const fn size_of<T>() -> usize {
|
||||
| ^ required by this bound in `std::mem::size_of`
|
||||
help: consider removing the `?Sized` bound to make the type parameter `Sized`
|
||||
|
|
||||
LL - pub const fn is_zst<T: ?Sized>() -> usize {
|
||||
LL + pub const fn is_zst<T>() -> usize {
|
||||
|
|
||||
|
||||
error[E0277]: the size for values of type `T` cannot be known at compilation time
|
||||
--> $DIR/const-argument-if-length.rs:16:12
|
||||
--> $DIR/const-argument-if-length.rs:15:12
|
||||
|
|
||||
LL | pub struct AtLeastByte<T: ?Sized> {
|
||||
| - this type parameter needs to be `std::marker::Sized`
|
||||
|
|
@ -41,6 +22,14 @@ help: the `Box` type always has a statically known size and allocates its conten
|
|||
LL | value: Box<T>,
|
||||
| ++++ +
|
||||
|
||||
error: unconstrained generic constant
|
||||
--> $DIR/const-argument-if-length.rs:17:10
|
||||
|
|
||||
LL | pad: [u8; is_zst::<T>()],
|
||||
| ^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= help: try adding a `where` bound using this expression: `where [(); is_zst::<T>()]:`
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0277`.
|
||||
|
|
|
|||
|
|
@ -1,14 +1,14 @@
|
|||
error: generic parameters may not be used in const operations
|
||||
--> $DIR/const-argument-if-length.rs:18:24
|
||||
--> $DIR/const-argument-if-length.rs:17:24
|
||||
|
|
||||
LL | pad: [u8; is_zst::<T>()],
|
||||
| ^ cannot perform const operation using `T`
|
||||
|
|
||||
= note: type parameters may not be used in const expressions
|
||||
= help: use `#![feature(const_generics)]` and `#![feature(generic_const_exprs)]` to allow generic const expressions
|
||||
= help: use `#![feature(generic_const_exprs)]` to allow generic const expressions
|
||||
|
||||
error[E0277]: the size for values of type `T` cannot be known at compilation time
|
||||
--> $DIR/const-argument-if-length.rs:16:12
|
||||
--> $DIR/const-argument-if-length.rs:15:12
|
||||
|
|
||||
LL | pub struct AtLeastByte<T: ?Sized> {
|
||||
| - this type parameter needs to be `std::marker::Sized`
|
||||
|
|
|
|||
|
|
@ -1,11 +1,10 @@
|
|||
// revisions: full min
|
||||
|
||||
#![cfg_attr(full, feature(generic_const_exprs))]
|
||||
#![cfg_attr(full, allow(incomplete_features))]
|
||||
#![cfg_attr(full, feature(const_generics))]
|
||||
|
||||
pub const fn is_zst<T: ?Sized>() -> usize {
|
||||
if std::mem::size_of::<T>() == 0 {
|
||||
//[full]~^ ERROR the size for values of type `T` cannot be known at compilation time
|
||||
1
|
||||
} else {
|
||||
0
|
||||
|
|
@ -17,6 +16,7 @@ pub struct AtLeastByte<T: ?Sized> {
|
|||
//~^ ERROR the size for values of type `T` cannot be known at compilation time
|
||||
pad: [u8; is_zst::<T>()],
|
||||
//[min]~^ ERROR generic parameters may not be used in const operations
|
||||
//[full]~^^ ERROR unconstrained generic constant
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
// revisions: full
|
||||
// FIXME(#75323) Omitted min revision for now due to ICE.
|
||||
|
||||
#![cfg_attr(full, feature(const_generics))]
|
||||
#![cfg_attr(full, feature(generic_const_exprs))]
|
||||
#![cfg_attr(full, allow(incomplete_features))]
|
||||
#![allow(dead_code)]
|
||||
|
||||
|
|
|
|||
|
|
@ -1,13 +0,0 @@
|
|||
error: expressions must be enclosed in braces to be used as const generic arguments
|
||||
--> $DIR/const-expression-parameter.rs:15:20
|
||||
|
|
||||
LL | i32_identity::<1 + 2>();
|
||||
| ^^^^^
|
||||
|
|
||||
help: enclose the `const` expression in braces
|
||||
|
|
||||
LL | i32_identity::<{ 1 + 2 }>();
|
||||
| + +
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
|
@ -1,9 +1,5 @@
|
|||
// Checks that `const fn` with const params can be used.
|
||||
// run-pass
|
||||
// revisions: full min
|
||||
|
||||
#![cfg_attr(full, feature(const_generics))]
|
||||
#![cfg_attr(full, allow(incomplete_features))]
|
||||
|
||||
const fn const_u32_identity<const X: u32>() -> u32 {
|
||||
X
|
||||
|
|
|
|||
|
|
@ -1,19 +0,0 @@
|
|||
// run-pass
|
||||
// revisions: full min
|
||||
|
||||
#![cfg_attr(full, feature(const_generics))]
|
||||
#![cfg_attr(full, allow(incomplete_features))]
|
||||
|
||||
struct Foo<T, const N: usize>([T; N]);
|
||||
|
||||
impl<T, const N: usize> Foo<T, N> {
|
||||
fn foo(&self) -> usize {
|
||||
N
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let foo = Foo([0u32; 21]);
|
||||
assert_eq!(foo.0, [0u32; 21]);
|
||||
assert_eq!(foo.foo(), 21);
|
||||
}
|
||||
|
|
@ -1,8 +1,4 @@
|
|||
// run-pass
|
||||
// revisions: full min
|
||||
|
||||
#![cfg_attr(full, feature(const_generics))]
|
||||
#![cfg_attr(full, allow(incomplete_features))]
|
||||
|
||||
#[derive(Debug)]
|
||||
struct S<const N: usize>;
|
||||
|
|
|
|||
|
|
@ -1,8 +1,4 @@
|
|||
// check-pass
|
||||
// revisions: full min
|
||||
|
||||
#![cfg_attr(full, feature(const_generics))]
|
||||
#![cfg_attr(full, allow(incomplete_features))]
|
||||
|
||||
struct Foo<const A: usize, const B: usize>;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
error: lifetime parameters must be declared prior to const parameters
|
||||
--> $DIR/const-param-before-other-params.rs:5:21
|
||||
|
|
||||
LL | fn bar<const X: (), 'a>(_: &'a ()) {
|
||||
| --------------^^- help: reorder the parameters: lifetimes, then consts and types: `<'a, const X: ()>`
|
||||
LL | fn bar<const X: u8, 'a>(_: &'a ()) {
|
||||
| --------------^^- help: reorder the parameters: lifetimes, then consts and types: `<'a, const X: u8>`
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
|
|
|||
|
|
@ -1,32 +1,14 @@
|
|||
error: lifetime parameters must be declared prior to const parameters
|
||||
--> $DIR/const-param-before-other-params.rs:5:21
|
||||
|
|
||||
LL | fn bar<const X: (), 'a>(_: &'a ()) {
|
||||
| --------------^^- help: reorder the parameters: lifetimes, then types, then consts: `<'a, const X: ()>`
|
||||
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:10:21
|
||||
--> $DIR/const-param-before-other-params.rs:9:21
|
||||
|
|
||||
LL | fn foo<const X: (), T>(_: &T) {}
|
||||
| --------------^- help: reorder the parameters: lifetimes, then types, then consts: `<T, const X: ()>`
|
||||
LL | fn foo<const X: u8, T>(_: &T) {}
|
||||
| --------------^- help: reorder the parameters: lifetimes, then types, then consts: `<T, const X: u8>`
|
||||
|
||||
error: `()` is forbidden as the type of a const generic parameter
|
||||
--> $DIR/const-param-before-other-params.rs:5:17
|
||||
|
|
||||
LL | fn bar<const X: (), 'a>(_: &'a ()) {
|
||||
| ^^
|
||||
|
|
||||
= note: the only supported types are integers, `bool` and `char`
|
||||
= help: more complex types are supported with `#![feature(const_generics)]`
|
||||
|
||||
error: `()` is forbidden as the type of a const generic parameter
|
||||
--> $DIR/const-param-before-other-params.rs:10:17
|
||||
|
|
||||
LL | fn foo<const X: (), T>(_: &T) {}
|
||||
| ^^
|
||||
|
|
||||
= note: the only supported types are integers, `bool` and `char`
|
||||
= help: more complex types are supported with `#![feature(const_generics)]`
|
||||
|
||||
error: aborting due to 4 previous errors
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
|
|
|
|||
|
|
@ -1,14 +1,12 @@
|
|||
// revisions: full min
|
||||
#![cfg_attr(full, feature(const_generics))]
|
||||
#![cfg_attr(full, feature(const_generics_defaults))]
|
||||
#![cfg_attr(full, allow(incomplete_features))]
|
||||
|
||||
fn bar<const X: (), 'a>(_: &'a ()) {
|
||||
fn bar<const X: u8, 'a>(_: &'a ()) {
|
||||
//~^ ERROR lifetime parameters must be declared prior to const parameters
|
||||
//[min]~^^ ERROR `()` is forbidden as the type of a const generic parameter
|
||||
}
|
||||
|
||||
fn foo<const X: (), T>(_: &T) {}
|
||||
fn foo<const X: u8, T>(_: &T) {}
|
||||
//[min]~^ ERROR type parameters must be declared prior to const parameters
|
||||
//[min]~^^ ERROR `()` is forbidden as the type of a const generic parameter
|
||||
|
||||
fn main() {}
|
||||
|
|
|
|||
|
|
@ -1,29 +1,29 @@
|
|||
error[E0637]: `&` without an explicit lifetime name cannot be used here
|
||||
--> $DIR/const-param-elided-lifetime.rs:10:19
|
||||
--> $DIR/const-param-elided-lifetime.rs:9:19
|
||||
|
|
||||
LL | struct A<const N: &u8>;
|
||||
| ^ explicit lifetime name needed here
|
||||
|
||||
error[E0637]: `&` without an explicit lifetime name cannot be used here
|
||||
--> $DIR/const-param-elided-lifetime.rs:15:15
|
||||
--> $DIR/const-param-elided-lifetime.rs:14:15
|
||||
|
|
||||
LL | impl<const N: &u8> A<N> {
|
||||
| ^ explicit lifetime name needed here
|
||||
|
||||
error[E0637]: `&` without an explicit lifetime name cannot be used here
|
||||
--> $DIR/const-param-elided-lifetime.rs:18:21
|
||||
--> $DIR/const-param-elided-lifetime.rs:17:21
|
||||
|
|
||||
LL | fn foo<const M: &u8>(&self) {}
|
||||
| ^ explicit lifetime name needed here
|
||||
|
||||
error[E0637]: `&` without an explicit lifetime name cannot be used here
|
||||
--> $DIR/const-param-elided-lifetime.rs:23:15
|
||||
--> $DIR/const-param-elided-lifetime.rs:22:15
|
||||
|
|
||||
LL | impl<const N: &u8> B for A<N> {}
|
||||
| ^ explicit lifetime name needed here
|
||||
|
||||
error[E0637]: `&` without an explicit lifetime name cannot be used here
|
||||
--> $DIR/const-param-elided-lifetime.rs:27:17
|
||||
--> $DIR/const-param-elided-lifetime.rs:26:17
|
||||
|
|
||||
LL | fn bar<const N: &u8>() {}
|
||||
| ^ explicit lifetime name needed here
|
||||
|
|
|
|||
|
|
@ -1,77 +1,77 @@
|
|||
error[E0637]: `&` without an explicit lifetime name cannot be used here
|
||||
--> $DIR/const-param-elided-lifetime.rs:10:19
|
||||
--> $DIR/const-param-elided-lifetime.rs:9:19
|
||||
|
|
||||
LL | struct A<const N: &u8>;
|
||||
| ^ explicit lifetime name needed here
|
||||
|
||||
error[E0637]: `&` without an explicit lifetime name cannot be used here
|
||||
--> $DIR/const-param-elided-lifetime.rs:15:15
|
||||
--> $DIR/const-param-elided-lifetime.rs:14:15
|
||||
|
|
||||
LL | impl<const N: &u8> A<N> {
|
||||
| ^ explicit lifetime name needed here
|
||||
|
||||
error[E0637]: `&` without an explicit lifetime name cannot be used here
|
||||
--> $DIR/const-param-elided-lifetime.rs:18:21
|
||||
--> $DIR/const-param-elided-lifetime.rs:17:21
|
||||
|
|
||||
LL | fn foo<const M: &u8>(&self) {}
|
||||
| ^ explicit lifetime name needed here
|
||||
|
||||
error[E0637]: `&` without an explicit lifetime name cannot be used here
|
||||
--> $DIR/const-param-elided-lifetime.rs:23:15
|
||||
--> $DIR/const-param-elided-lifetime.rs:22:15
|
||||
|
|
||||
LL | impl<const N: &u8> B for A<N> {}
|
||||
| ^ explicit lifetime name needed here
|
||||
|
||||
error[E0637]: `&` without an explicit lifetime name cannot be used here
|
||||
--> $DIR/const-param-elided-lifetime.rs:27:17
|
||||
--> $DIR/const-param-elided-lifetime.rs:26:17
|
||||
|
|
||||
LL | fn bar<const N: &u8>() {}
|
||||
| ^ explicit lifetime name needed here
|
||||
|
||||
error: `&'static u8` is forbidden as the type of a const generic parameter
|
||||
--> $DIR/const-param-elided-lifetime.rs:10:19
|
||||
--> $DIR/const-param-elided-lifetime.rs:9:19
|
||||
|
|
||||
LL | struct A<const N: &u8>;
|
||||
| ^^^
|
||||
|
|
||||
= note: the only supported types are integers, `bool` and `char`
|
||||
= help: more complex types are supported with `#![feature(const_generics)]`
|
||||
= help: more complex types are supported with `#![feature(const_param_types)]`
|
||||
|
||||
error: `&'static u8` is forbidden as the type of a const generic parameter
|
||||
--> $DIR/const-param-elided-lifetime.rs:15:15
|
||||
--> $DIR/const-param-elided-lifetime.rs:14:15
|
||||
|
|
||||
LL | impl<const N: &u8> A<N> {
|
||||
| ^^^
|
||||
|
|
||||
= note: the only supported types are integers, `bool` and `char`
|
||||
= help: more complex types are supported with `#![feature(const_generics)]`
|
||||
= help: more complex types are supported with `#![feature(const_param_types)]`
|
||||
|
||||
error: `&'static u8` is forbidden as the type of a const generic parameter
|
||||
--> $DIR/const-param-elided-lifetime.rs:18:21
|
||||
--> $DIR/const-param-elided-lifetime.rs:17:21
|
||||
|
|
||||
LL | fn foo<const M: &u8>(&self) {}
|
||||
| ^^^
|
||||
|
|
||||
= note: the only supported types are integers, `bool` and `char`
|
||||
= help: more complex types are supported with `#![feature(const_generics)]`
|
||||
= help: more complex types are supported with `#![feature(const_param_types)]`
|
||||
|
||||
error: `&'static u8` is forbidden as the type of a const generic parameter
|
||||
--> $DIR/const-param-elided-lifetime.rs:23:15
|
||||
--> $DIR/const-param-elided-lifetime.rs:22:15
|
||||
|
|
||||
LL | impl<const N: &u8> B for A<N> {}
|
||||
| ^^^
|
||||
|
|
||||
= note: the only supported types are integers, `bool` and `char`
|
||||
= help: more complex types are supported with `#![feature(const_generics)]`
|
||||
= help: more complex types are supported with `#![feature(const_param_types)]`
|
||||
|
||||
error: `&'static u8` is forbidden as the type of a const generic parameter
|
||||
--> $DIR/const-param-elided-lifetime.rs:27:17
|
||||
--> $DIR/const-param-elided-lifetime.rs:26:17
|
||||
|
|
||||
LL | fn bar<const N: &u8>() {}
|
||||
| ^^^
|
||||
|
|
||||
= note: the only supported types are integers, `bool` and `char`
|
||||
= help: more complex types are supported with `#![feature(const_generics)]`
|
||||
= help: more complex types are supported with `#![feature(const_param_types)]`
|
||||
|
||||
error: aborting due to 10 previous errors
|
||||
|
||||
|
|
|
|||
|
|
@ -3,8 +3,7 @@
|
|||
// elided lifetimes within the type of a const generic parameters to be 'static, like elided
|
||||
// lifetimes within const/static items.
|
||||
// revisions: full min
|
||||
|
||||
#![cfg_attr(full, feature(const_generics))]
|
||||
#![cfg_attr(full, feature(const_param_types))]
|
||||
#![cfg_attr(full, allow(incomplete_features))]
|
||||
|
||||
struct A<const N: &u8>;
|
||||
|
|
|
|||
|
|
@ -1,13 +0,0 @@
|
|||
error[E0401]: can't use generic parameters from outer function
|
||||
--> $DIR/const-param-from-outer-fn.rs:8:9
|
||||
|
|
||||
LL | fn foo<const X: u32>() {
|
||||
| - const parameter from outer function
|
||||
LL | fn bar() -> u32 {
|
||||
| --- try adding a local generic parameter in this method instead
|
||||
LL | X
|
||||
| ^ use of generic parameter from outer function
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0401`.
|
||||
|
|
@ -1,8 +1,5 @@
|
|||
// edition:2018
|
||||
// check-pass
|
||||
// revisions: full min
|
||||
#![cfg_attr(full, feature(const_generics))]
|
||||
#![cfg_attr(full, allow(incomplete_features))]
|
||||
|
||||
async fn foo<const N: usize>(arg: [u8; N]) -> usize { arg.len() }
|
||||
|
||||
|
|
|
|||
|
|
@ -1,11 +0,0 @@
|
|||
// Check that const parameters are permitted in traits.
|
||||
// run-pass
|
||||
// revisions: full min
|
||||
|
||||
#![cfg_attr(full, feature(const_generics))]
|
||||
#![cfg_attr(full, allow(incomplete_features))]
|
||||
|
||||
|
||||
trait Trait<const T: u8> {}
|
||||
|
||||
fn main() {}
|
||||
|
|
@ -17,7 +17,7 @@ LL | pub struct Dependent<const N: usize, const X: [u8; N]>([(); N]);
|
|||
| ^^^^^^^
|
||||
|
|
||||
= note: the only supported types are integers, `bool` and `char`
|
||||
= help: more complex types are supported with `#![feature(const_generics)]`
|
||||
= help: more complex types are supported with `#![feature(const_param_types)]`
|
||||
|
||||
error: `[u8; _]` is forbidden as the type of a const generic parameter
|
||||
--> $DIR/const-param-type-depends-on-const-param.rs:15:35
|
||||
|
|
@ -26,7 +26,7 @@ LL | pub struct SelfDependent<const N: [u8; N]>;
|
|||
| ^^^^^^^
|
||||
|
|
||||
= note: the only supported types are integers, `bool` and `char`
|
||||
= help: more complex types are supported with `#![feature(const_generics)]`
|
||||
= help: more complex types are supported with `#![feature(const_param_types)]`
|
||||
|
||||
error: aborting due to 4 previous errors
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
// revisions: full min
|
||||
|
||||
#![cfg_attr(full, feature(const_generics))]
|
||||
#![cfg_attr(full, feature(const_param_types))]
|
||||
#![cfg_attr(full, allow(incomplete_features))]
|
||||
|
||||
// Currently, const parameters cannot depend on other generic parameters,
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
// revisions: full min
|
||||
|
||||
#![cfg_attr(full, feature(const_generics))]
|
||||
#![cfg_attr(full, feature(const_param_types))]
|
||||
#![cfg_attr(full, allow(incomplete_features))]
|
||||
|
||||
// Currently, const parameters cannot depend on other generic parameters,
|
||||
|
|
|
|||
|
|
@ -1,14 +0,0 @@
|
|||
error: const parameter `x` should have an upper case name
|
||||
--> $DIR/const-parameter-uppercase-lint.rs:8:15
|
||||
|
|
||||
LL | fn noop<const x: u32>() {
|
||||
| ^ help: convert the identifier to upper case (notice the capitalization): `X`
|
||||
|
|
||||
note: the lint level is defined here
|
||||
--> $DIR/const-parameter-uppercase-lint.rs:6:9
|
||||
|
|
||||
LL | #![deny(non_upper_case_globals)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
|
@ -1,8 +1,3 @@
|
|||
// revisions: full min
|
||||
|
||||
#![cfg_attr(full, feature(const_generics))]
|
||||
#![cfg_attr(full, allow(incomplete_features))]
|
||||
|
||||
#![deny(non_upper_case_globals)]
|
||||
|
||||
fn noop<const x: u32>() {
|
||||
|
|
|
|||
|
|
@ -1,11 +1,11 @@
|
|||
error: const parameter `x` should have an upper case name
|
||||
--> $DIR/const-parameter-uppercase-lint.rs:8:15
|
||||
--> $DIR/const-parameter-uppercase-lint.rs:3:15
|
||||
|
|
||||
LL | fn noop<const x: u32>() {
|
||||
| ^ help: convert the identifier to upper case (notice the capitalization): `X`
|
||||
|
|
||||
note: the lint level is defined here
|
||||
--> $DIR/const-parameter-uppercase-lint.rs:6:9
|
||||
--> $DIR/const-parameter-uppercase-lint.rs:1:9
|
||||
|
|
||||
LL | #![deny(non_upper_case_globals)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
@ -1,18 +0,0 @@
|
|||
// Check that arrays can be used with generic const and type.
|
||||
// run-pass
|
||||
// revisions: full min
|
||||
|
||||
#![cfg_attr(full, feature(const_generics))]
|
||||
#![cfg_attr(full, allow(incomplete_features))]
|
||||
|
||||
#![allow(dead_code, unused_variables)]
|
||||
|
||||
struct ConstArray<T, const LEN: usize> {
|
||||
array: [T; LEN],
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let arr = ConstArray::<i32, 8> {
|
||||
array: [0; 8],
|
||||
};
|
||||
}
|
||||
|
|
@ -2,7 +2,7 @@
|
|||
// run-pass
|
||||
// revisions: full min
|
||||
|
||||
#![cfg_attr(full, feature(const_generics))]
|
||||
#![cfg_attr(full, feature(const_param_types))]
|
||||
#![cfg_attr(full, allow(incomplete_features))]
|
||||
|
||||
struct A<const N: u8>;
|
||||
|
|
|
|||
|
|
@ -1,10 +1,6 @@
|
|||
// aux-build:crayte.rs
|
||||
// edition:2018
|
||||
// run-pass
|
||||
// revisions: full min
|
||||
|
||||
#![cfg_attr(full, feature(const_generics))]
|
||||
#![cfg_attr(full, allow(incomplete_features))]
|
||||
extern crate crayte;
|
||||
|
||||
use crayte::*;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,4 @@
|
|||
#![cfg_attr(full, feature(const_generics))]
|
||||
#![feature(const_generics_defaults)]
|
||||
#![allow(incomplete_features)]
|
||||
|
||||
pub struct Defaulted<const N: usize=3>;
|
||||
impl Defaulted {
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ LL | struct Foo<const N: usize, const M: usize = { N + 1 }>;
|
|||
| ^ cannot perform const operation using `N`
|
||||
|
|
||||
= help: const parameters may only be used as standalone arguments, i.e. `N`
|
||||
= help: use `#![feature(const_generics)]` and `#![feature(generic_const_exprs)]` to allow generic const expressions
|
||||
= 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
|
||||
|
|
@ -14,7 +14,7 @@ LL | struct Bar<T, const TYPE_SIZE: usize = { std::mem::size_of::<T>() }>(T);
|
|||
| ^ cannot perform const operation using `T`
|
||||
|
|
||||
= note: type parameters may not be used in const expressions
|
||||
= help: use `#![feature(const_generics)]` and `#![feature(generic_const_exprs)]` to allow generic const expressions
|
||||
= help: use `#![feature(generic_const_exprs)]` to allow generic const expressions
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
// revisions: full min
|
||||
//[full] check-pass
|
||||
#![cfg_attr(full, feature(const_generics))]
|
||||
#![cfg_attr(full, feature(generic_const_exprs))]
|
||||
#![feature(const_generics_defaults)]
|
||||
#![allow(incomplete_features)]
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
// [full] run-pass
|
||||
// revisions: full min
|
||||
// Checks a complicated usage of unordered params
|
||||
#![cfg_attr(full, feature(const_generics))]
|
||||
#![cfg_attr(full, feature(const_generics_defaults))]
|
||||
#![cfg_attr(full, allow(incomplete_features))]
|
||||
#![allow(dead_code)]
|
||||
|
||||
|
|
|
|||
|
|
@ -1,9 +1,5 @@
|
|||
// run-pass
|
||||
// revisions: full min
|
||||
#![cfg_attr(full, feature(const_generics))]
|
||||
#![feature(const_generics_defaults)]
|
||||
#![allow(incomplete_features)]
|
||||
|
||||
|
||||
pub struct ConstDefault<const N: usize = 3>;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,13 +1,12 @@
|
|||
// run-pass
|
||||
#![feature(staged_api)]
|
||||
|
||||
#![feature(const_generics)]
|
||||
#![feature(const_generics_defaults)]
|
||||
#![allow(incomplete_features)]
|
||||
|
||||
// FIXME(const_generics): 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
|
||||
// themselves.
|
||||
#![stable(feature = "const_default_test", since="none")]
|
||||
|
||||
|
||||
#[unstable(feature = "const_default_stable", issue="none")]
|
||||
pub struct ConstDefaultUnstable<const N: usize = 3>;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,8 +0,0 @@
|
|||
error: defaults for const parameters are only allowed in `struct`, `enum`, `type`, or `trait` definitions
|
||||
--> $DIR/default-on-impl.rs:8:12
|
||||
|
|
||||
LL | impl<const N: usize = 1> Foo<N> {}
|
||||
| ^
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
|
@ -1,7 +1,4 @@
|
|||
// revisions: full min
|
||||
#![cfg_attr(full, feature(const_generics))]
|
||||
#![feature(const_generics_defaults)]
|
||||
#![allow(incomplete_features)]
|
||||
|
||||
struct Foo<const N: usize>;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
error: defaults for const parameters are only allowed in `struct`, `enum`, `type`, or `trait` definitions
|
||||
--> $DIR/default-on-impl.rs:8:12
|
||||
--> $DIR/default-on-impl.rs:5:12
|
||||
|
|
||||
LL | impl<const N: usize = 1> Foo<N> {}
|
||||
| ^
|
||||
|
|
@ -1,9 +1,6 @@
|
|||
// aux-build:const_defaulty.rs
|
||||
// check-pass
|
||||
// revisions: full min
|
||||
#![cfg_attr(full, feature(const_generics))]
|
||||
#![feature(const_generics_defaults)]
|
||||
#![allow(incomplete_features)]
|
||||
|
||||
extern crate const_defaulty;
|
||||
use const_defaulty::Defaulted;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
#![feature(const_generics, generic_const_exprs, const_generics_defaults)]
|
||||
#![feature(generic_const_exprs, const_generics_defaults)]
|
||||
#![allow(incomplete_features)]
|
||||
|
||||
struct Foo<const N: usize, const M: usize = { N + 1 }>;
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
error[E0308]: mismatched types
|
||||
--> $DIR/cec-concrete-default.rs:10:5
|
||||
--> $DIR/generic-expr-default-concrete.rs:10:5
|
||||
|
|
||||
LL | Foo::<10, 12>
|
||||
| ^^^^^^^^^^^^^ expected `11_usize`, found `12_usize`
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
#![feature(const_generics, generic_const_exprs, const_generics_defaults)]
|
||||
#![feature(generic_const_exprs, const_generics_defaults)]
|
||||
#![allow(incomplete_features)]
|
||||
|
||||
struct Foo<const N: usize, const M: usize = { N + 1 }>;
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
error[E0308]: mismatched types
|
||||
--> $DIR/cec-generic-default-mismatched-types.rs:12:5
|
||||
--> $DIR/generic-expr-default-mismatched-types.rs:12:5
|
||||
|
|
||||
LL | Foo::<N, { N + 2 }>
|
||||
| ^^^^^^^^^^^^^^^^^^^ expected `{ N + 1 }`, found `{ N + 2 }`
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
#![feature(generic_const_exprs, const_generics, const_generics_defaults)]
|
||||
#![feature(generic_const_exprs, const_generics_defaults)]
|
||||
#![allow(incomplete_features)]
|
||||
|
||||
pub struct Foo<const N: usize, const M: usize = { N + 1 }>;
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
error: unconstrained generic constant
|
||||
--> $DIR/cec-generic-default.rs:5:54
|
||||
--> $DIR/generic-expr-default.rs:5:54
|
||||
|
|
||||
LL | pub fn needs_evaluatable_bound<const N1: usize>() -> Foo<N1> {
|
||||
| ^^^^^^^
|
||||
|
|
@ -7,7 +7,7 @@ LL | pub fn needs_evaluatable_bound<const N1: usize>() -> Foo<N1> {
|
|||
= help: try adding a `where` bound using this expression: `where [(); { N + 1 }]:`
|
||||
|
||||
error: unconstrained generic constant
|
||||
--> $DIR/cec-generic-default.rs:14:58
|
||||
--> $DIR/generic-expr-default.rs:14:58
|
||||
|
|
||||
LL | fn needs_evaluatable_bound_alias<T, const N: usize>() -> FooAlias<N>
|
||||
| ^^^^^^^^^^^
|
||||
|
|
@ -1,11 +1,11 @@
|
|||
error: lifetime parameters must be declared prior to const parameters
|
||||
--> $DIR/intermixed-lifetime.rs:7:28
|
||||
--> $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:10:37
|
||||
--> $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>`
|
||||
|
|
|
|||
|
|
@ -1,11 +1,11 @@
|
|||
error: lifetime parameters must be declared prior to const parameters
|
||||
--> $DIR/intermixed-lifetime.rs:7:28
|
||||
--> $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:10:37
|
||||
--> $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>`
|
||||
|
|
|
|||
|
|
@ -1,8 +1,6 @@
|
|||
// Checks that lifetimes cannot be interspersed between consts and types.
|
||||
// revisions: full min
|
||||
#![cfg_attr(full, feature(const_generics))]
|
||||
#![feature(const_generics_defaults)]
|
||||
#![allow(incomplete_features)]
|
||||
|
||||
struct Foo<const N: usize, 'a, T = u32>(&'a (), T);
|
||||
//~^ Error lifetime parameters must be declared prior to const parameters
|
||||
|
|
|
|||
|
|
@ -1,58 +0,0 @@
|
|||
error[E0308]: mismatched types
|
||||
--> $DIR/mismatch.rs:12:28
|
||||
|
|
||||
LL | let e: Example::<13> = ();
|
||||
| ------------- ^^ expected struct `Example`, found `()`
|
||||
| |
|
||||
| expected due to this
|
||||
|
|
||||
= note: expected struct `Example`
|
||||
found unit type `()`
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/mismatch.rs:15:34
|
||||
|
|
||||
LL | let e: Example2::<u32, 13> = ();
|
||||
| ------------------- ^^ expected struct `Example2`, found `()`
|
||||
| |
|
||||
| expected due to this
|
||||
|
|
||||
= note: expected struct `Example2`
|
||||
found unit type `()`
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/mismatch.rs:18:34
|
||||
|
|
||||
LL | let e: Example3::<13, u32> = ();
|
||||
| ------------------- ^^ expected struct `Example3`, found `()`
|
||||
| |
|
||||
| expected due to this
|
||||
|
|
||||
= note: expected struct `Example3`
|
||||
found unit type `()`
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/mismatch.rs:21:28
|
||||
|
|
||||
LL | let e: Example3::<7> = ();
|
||||
| ------------- ^^ expected struct `Example3`, found `()`
|
||||
| |
|
||||
| expected due to this
|
||||
|
|
||||
= note: expected struct `Example3<7_usize>`
|
||||
found unit type `()`
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/mismatch.rs:24:28
|
||||
|
|
||||
LL | let e: Example4::<7> = ();
|
||||
| ------------- ^^ expected struct `Example4`, found `()`
|
||||
| |
|
||||
| expected due to this
|
||||
|
|
||||
= note: expected struct `Example4<7_usize>`
|
||||
found unit type `()`
|
||||
|
||||
error: aborting due to 5 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0308`.
|
||||
|
|
@ -1,7 +1,4 @@
|
|||
// revisions: full min
|
||||
#![cfg_attr(full, feature(const_generics))]
|
||||
#![feature(const_generics_defaults)]
|
||||
#![allow(incomplete_features)]
|
||||
|
||||
pub struct Example<const N: usize=13>;
|
||||
pub struct Example2<T=u32, const N: usize=13>(T);
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
error[E0308]: mismatched types
|
||||
--> $DIR/mismatch.rs:12:28
|
||||
--> $DIR/mismatch.rs:9: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:15:34
|
||||
--> $DIR/mismatch.rs:12: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:18:34
|
||||
--> $DIR/mismatch.rs:15: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:21:28
|
||||
--> $DIR/mismatch.rs:18: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:24:28
|
||||
--> $DIR/mismatch.rs:21:28
|
||||
|
|
||||
LL | let e: Example4::<7> = ();
|
||||
| ------------- ^^ expected struct `Example4`, found `()`
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
error: type parameters must be declared prior to const parameters
|
||||
--> $DIR/needs-feature.rs:9:26
|
||||
--> $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>`
|
||||
|
|
|
|||
|
|
@ -1,8 +0,0 @@
|
|||
error: type parameters must be declared prior to const parameters
|
||||
--> $DIR/needs-feature.rs:9: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,10 +1,8 @@
|
|||
//[full] run-pass
|
||||
// Verifies that having generic parameters after constants is not permitted without the
|
||||
// `const_generics` feature.
|
||||
// `const_generics_defaults` feature.
|
||||
// revisions: min full
|
||||
|
||||
#![cfg_attr(full, feature(const_generics))]
|
||||
#![cfg_attr(full, allow(incomplete_features))]
|
||||
#![cfg_attr(full, feature(const_generics_defaults))]
|
||||
|
||||
struct A<const N: usize, T=u32>(T);
|
||||
//[min]~^ ERROR type parameters must be declared prior
|
||||
|
|
|
|||
|
|
@ -1,9 +1,6 @@
|
|||
// run-pass
|
||||
// Checks that type param defaults are allowed after const params.
|
||||
// revisions: full min
|
||||
#![cfg_attr(full, feature(const_generics))]
|
||||
#![feature(const_generics_defaults)]
|
||||
#![allow(incomplete_features)]
|
||||
#![allow(dead_code)]
|
||||
|
||||
struct FixedOutput<'a, const N: usize, T=u32> {
|
||||
|
|
|
|||
|
|
@ -1,8 +1,5 @@
|
|||
// check-pass
|
||||
// revisions: full min
|
||||
#![cfg_attr(full, feature(const_generics))]
|
||||
#![feature(const_generics_defaults)]
|
||||
#![allow(incomplete_features)]
|
||||
|
||||
struct N;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,8 +0,0 @@
|
|||
error: generic parameters with a default must be trailing
|
||||
--> $DIR/wrong-order.rs:6:10
|
||||
|
|
||||
LL | struct A<T = u32, const N: usize> {
|
||||
| ^
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
|
@ -1,7 +1,4 @@
|
|||
// revisions: full min
|
||||
#![cfg_attr(full, feature(const_generics))]
|
||||
#![feature(const_generics_defaults)]
|
||||
#![allow(incomplete_features)]
|
||||
|
||||
struct A<T = u32, const N: usize> {
|
||||
//~^ ERROR generic parameters with a default must be trailing
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
error: generic parameters with a default must be trailing
|
||||
--> $DIR/wrong-order.rs:6:10
|
||||
--> $DIR/wrong-order.rs:3:10
|
||||
|
|
||||
LL | struct A<T = u32, const N: usize> {
|
||||
| ^
|
||||
|
|
@ -1,13 +0,0 @@
|
|||
// Check that deriving debug on struct with const is permitted.
|
||||
// run-pass
|
||||
// revisions: full min
|
||||
|
||||
#![cfg_attr(full, feature(const_generics))]
|
||||
#![cfg_attr(full, allow(incomplete_features))]
|
||||
|
||||
#[derive(Debug)]
|
||||
struct X<const N: usize> {
|
||||
a: [u32; N],
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
|
@ -1,11 +0,0 @@
|
|||
error: `[usize; 1]` is forbidden as the type of a const generic parameter
|
||||
--> $DIR/different_byref.rs:7:23
|
||||
|
|
||||
LL | struct Const<const V: [usize; 1]> {}
|
||||
| ^^^^^^^^^^
|
||||
|
|
||||
= note: the only supported types are integers, `bool` and `char`
|
||||
= help: more complex types are supported with `#![feature(const_generics)]`
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue