File tree 24 files changed +154
-52
lines changed
src/test/ui/const-generics
24 files changed +154
-52
lines changed Original file line number Diff line number Diff line change 1
1
error: type parameters with a default must be trailing
2
- --> $DIR/wrong-order.rs:3 :10
2
+ --> $DIR/wrong-order.rs:5 :10
3
3
|
4
4
LL | struct A<T = u32, const N: usize> {
5
5
| ^
6
6
|
7
7
= note: using type defaults and const parameters in the same parameter list is currently not permitted
8
8
9
9
warning: the feature `const_generics` is incomplete and may not be safe to use and/or cause compiler crashes
10
- --> $DIR/wrong-order.rs:1:12
10
+ --> $DIR/wrong-order.rs:2:27
11
11
|
12
- LL | #![feature(const_generics)]
13
- | ^^^^^^^^^^^^^^
12
+ LL | #![cfg_attr(full, feature(const_generics) )]
13
+ | ^^^^^^^^^^^^^^
14
14
|
15
15
= note: `#[warn(incomplete_features)]` on by default
16
16
= note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information
Original file line number Diff line number Diff line change
1
+ error: type parameters with a default must be trailing
2
+ --> $DIR/wrong-order.rs:5:10
3
+ |
4
+ LL | struct A<T = u32, const N: usize> {
5
+ | ^
6
+ |
7
+ = note: using type defaults and const parameters in the same parameter list is currently not permitted
8
+
9
+ error: aborting due to previous error
10
+
Original file line number Diff line number Diff line change 1
- #![ feature( const_generics) ] //~ WARN the feature `const_generics` is incomplete
1
+ // revisions: full min
2
+ #![ cfg_attr( full, feature( const_generics) ) ] //[full]~WARN the feature `const_generics` is incomplete
3
+ #![ cfg_attr( min, feature( min_const_generics) ) ]
2
4
3
5
struct A < T = u32 , const N : usize > {
4
6
//~^ ERROR type parameters with a default must be trailing
Original file line number Diff line number Diff line change 1
1
warning: the feature `const_generics` is incomplete and may not be safe to use and/or cause compiler crashes
2
- --> $DIR/issue-56445.rs:3:12
2
+ --> $DIR/issue-56445.rs:3:27
3
3
|
4
- LL | #![feature(const_generics)]
5
- | ^^^^^^^^^^^^^^
4
+ LL | #![cfg_attr(full, feature(const_generics) )]
5
+ | ^^^^^^^^^^^^^^
6
6
|
7
7
= note: `#[warn(incomplete_features)]` on by default
8
8
= note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information
Original file line number Diff line number Diff line change
1
+ error[E0771]: use of non-static lifetime `'a` in const generic
2
+ --> $DIR/issue-56445.rs:9:26
3
+ |
4
+ LL | struct Bug<'a, const S: &'a str>(PhantomData<&'a ()>);
5
+ | ^^
6
+ |
7
+ = note: for more information, see issue #74052 <https://github.com/rust-lang/rust/issues/74052>
8
+
9
+ error: using `&'static str` as const generic parameters is forbidden
10
+ --> $DIR/issue-56445.rs:9:25
11
+ |
12
+ LL | struct Bug<'a, const S: &'a str>(PhantomData<&'a ()>);
13
+ | ^^^^^^^
14
+ |
15
+ = note: the only supported types are integers, `bool` and `char`
16
+ = note: more complex types are supported with `#[feature(const_generics)]`
17
+
18
+ error: aborting due to 2 previous errors
19
+
20
+ For more information about this error, try `rustc --explain E0771`.
Original file line number Diff line number Diff line change 1
1
// Regression test for https://github.com/rust-lang/rust/issues/56445#issuecomment-518402995.
2
-
3
- #![ feature( const_generics) ]
4
- //~^ WARN: the feature `const_generics` is incomplete
2
+ // revisions: full min
3
+ #![ cfg_attr ( full , feature( const_generics) ) ] //[full]~WARN the feature `const_generics` is incomplete
4
+ #! [ cfg_attr ( min , feature( min_const_generics ) ) ]
5
5
#![ crate_type = "lib" ]
6
6
7
7
use std:: marker:: PhantomData ;
8
8
9
9
struct Bug < ' a , const S : & ' a str > ( PhantomData < & ' a ( ) > ) ;
10
10
//~^ ERROR: use of non-static lifetime `'a` in const generic
11
+ //[min]~| ERROR: using `&'static str` as const
11
12
12
13
impl Bug < ' _ , "" > { }
Original file line number Diff line number Diff line change 1
1
warning: the feature `const_generics` is incomplete and may not be safe to use and/or cause compiler crashes
2
- --> $DIR/issue-61336-1 .rs:1:12
2
+ --> $DIR/issue-60818-struct-constructors .rs:3:27
3
3
|
4
- LL | #![feature(const_generics)]
5
- | ^^^^^^^^^^^^^^
4
+ LL | #![cfg_attr(full, feature(const_generics) )]
5
+ | ^^^^^^^^^^^^^^
6
6
|
7
7
= note: `#[warn(incomplete_features)]` on by default
8
8
= note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information
Original file line number Diff line number Diff line change 1
1
// check-pass
2
-
3
- #![ feature( const_generics) ]
4
- //~^ WARN the feature `const_generics` is incomplete
2
+ // revisions: full min
3
+ #![ cfg_attr ( full , feature( const_generics) ) ] //[full]~WARN the feature `const_generics` is incomplete
4
+ #! [ cfg_attr ( min , feature( min_const_generics ) ) ]
5
5
6
6
struct Generic < const V : usize > ;
7
7
Original file line number Diff line number Diff line change 1
1
warning: the feature `const_generics` is incomplete and may not be safe to use and/or cause compiler crashes
2
- --> $DIR/issue-60818-struct-constructors .rs:3:12
2
+ --> $DIR/issue-61336-1 .rs:3:27
3
3
|
4
- LL | #![feature(const_generics)]
5
- | ^^^^^^^^^^^^^^
4
+ LL | #![cfg_attr(full, feature(const_generics) )]
5
+ | ^^^^^^^^^^^^^^
6
6
|
7
7
= note: `#[warn(incomplete_features)]` on by default
8
8
= note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information
Original file line number Diff line number Diff line change 1
- #![ feature( const_generics) ]
2
- //~^ WARN the feature `const_generics` is incomplete
3
-
4
1
// build-pass
2
+ // revisions: full min
3
+ #![ cfg_attr( full, feature( const_generics) ) ] //[full]~WARN the feature `const_generics` is incomplete
4
+ #![ cfg_attr( min, feature( min_const_generics) ) ]
5
5
6
6
fn f < T : Copy , const N : usize > ( x : T ) -> [ T ; N ] {
7
7
[ x; N ]
Original file line number Diff line number Diff line change 1
1
warning: the feature `const_generics` is incomplete and may not be safe to use and/or cause compiler crashes
2
- --> $DIR/issue-61336-2.rs:1:12
2
+ --> $DIR/issue-61336-2.rs:2:27
3
3
|
4
- LL | #![feature(const_generics)]
5
- | ^^^^^^^^^^^^^^
4
+ LL | #![cfg_attr(full, feature(const_generics) )]
5
+ | ^^^^^^^^^^^^^^
6
6
|
7
7
= note: `#[warn(incomplete_features)]` on by default
8
8
= note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information
9
9
10
10
error[E0277]: the trait bound `T: std::marker::Copy` is not satisfied
11
- --> $DIR/issue-61336-2.rs:9 :5
11
+ --> $DIR/issue-61336-2.rs:10 :5
12
12
|
13
13
LL | [x; { N }]
14
14
| ^^^^^^^^^^ the trait `std::marker::Copy` is not implemented for `T`
Original file line number Diff line number Diff line change
1
+ error[E0277]: the trait bound `T: std::marker::Copy` is not satisfied
2
+ --> $DIR/issue-61336-2.rs:10:5
3
+ |
4
+ LL | [x; { N }]
5
+ | ^^^^^^^^^^ the trait `std::marker::Copy` is not implemented for `T`
6
+ |
7
+ = note: the `Copy` trait is required because the repeated element will be copied
8
+ help: consider restricting type parameter `T`
9
+ |
10
+ LL | fn g<T: std::marker::Copy, const N: usize>(x: T) -> [T; N] {
11
+ | ^^^^^^^^^^^^^^^^^^^
12
+
13
+ error: aborting due to previous error
14
+
15
+ For more information about this error, try `rustc --explain E0277`.
Original file line number Diff line number Diff line change 1
- #![ feature( const_generics) ]
2
- //~^ WARN the feature `const_generics` is incomplete
1
+ // revisions: full min
2
+ #![ cfg_attr( full, feature( const_generics) ) ] //[full]~WARN the feature `const_generics` is incomplete
3
+ #![ cfg_attr( min, feature( min_const_generics) ) ]
3
4
4
5
fn f < T : Copy , const N : usize > ( x : T ) -> [ T ; N ] {
5
6
[ x; { N } ]
Original file line number Diff line number Diff line change
1
+ warning: the feature `const_generics` is incomplete and may not be safe to use and/or cause compiler crashes
2
+ --> $DIR/issue-61336.rs:2:27
3
+ |
4
+ LL | #![cfg_attr(full, feature(const_generics))]
5
+ | ^^^^^^^^^^^^^^
6
+ |
7
+ = note: `#[warn(incomplete_features)]` on by default
8
+ = note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information
9
+
10
+ error[E0277]: the trait bound `T: std::marker::Copy` is not satisfied
11
+ --> $DIR/issue-61336.rs:10:5
12
+ |
13
+ LL | [x; N]
14
+ | ^^^^^^ the trait `std::marker::Copy` is not implemented for `T`
15
+ |
16
+ = note: the `Copy` trait is required because the repeated element will be copied
17
+ help: consider restricting type parameter `T`
18
+ |
19
+ LL | fn g<T: std::marker::Copy, const N: usize>(x: T) -> [T; N] {
20
+ | ^^^^^^^^^^^^^^^^^^^
21
+
22
+ error: aborting due to previous error; 1 warning emitted
23
+
24
+ For more information about this error, try `rustc --explain E0277`.
Original file line number Diff line number Diff line change
1
+ error[E0277]: the trait bound `T: std::marker::Copy` is not satisfied
2
+ --> $DIR/issue-61336.rs:10:5
3
+ |
4
+ LL | [x; N]
5
+ | ^^^^^^ the trait `std::marker::Copy` is not implemented for `T`
6
+ |
7
+ = note: the `Copy` trait is required because the repeated element will be copied
8
+ help: consider restricting type parameter `T`
9
+ |
10
+ LL | fn g<T: std::marker::Copy, const N: usize>(x: T) -> [T; N] {
11
+ | ^^^^^^^^^^^^^^^^^^^
12
+
13
+ error: aborting due to previous error
14
+
15
+ For more information about this error, try `rustc --explain E0277`.
Original file line number Diff line number Diff line change 1
- #![ feature( const_generics) ]
2
- //~^ WARN the feature `const_generics` is incomplete
1
+ // revisions: full min
2
+ #![ cfg_attr( full, feature( const_generics) ) ] //[full]~WARN the feature `const_generics` is incomplete
3
+ #![ cfg_attr( min, feature( min_const_generics) ) ]
3
4
4
5
fn f < T : Copy , const N : usize > ( x : T ) -> [ T ; N ] {
5
6
[ x; N ]
Original file line number Diff line number Diff line change 1
1
warning: the feature `const_generics` is incomplete and may not be safe to use and/or cause compiler crashes
2
- --> $DIR/issue-61432 .rs:3:12
2
+ --> $DIR/issue-61422 .rs:3:27
3
3
|
4
- LL | #![feature(const_generics)]
5
- | ^^^^^^^^^^^^^^
4
+ LL | #![cfg_attr(full, feature(const_generics) )]
5
+ | ^^^^^^^^^^^^^^
6
6
|
7
7
= note: `#[warn(incomplete_features)]` on by default
8
8
= note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information
Original file line number Diff line number Diff line change 1
1
// check-pass
2
-
3
- #![ feature( const_generics) ]
4
- //~^ WARN the feature `const_generics` is incomplete
2
+ // revisions: full min
3
+ #![ cfg_attr ( full , feature( const_generics) ) ] //[full]~WARN the feature `const_generics` is incomplete
4
+ #! [ cfg_attr ( min , feature( min_const_generics ) ) ]
5
5
6
6
use std:: mem;
7
7
Original file line number Diff line number Diff line change 1
1
warning: the feature `const_generics` is incomplete and may not be safe to use and/or cause compiler crashes
2
- --> $DIR/issue-61422 .rs:3:12
2
+ --> $DIR/issue-61432 .rs:3:27
3
3
|
4
- LL | #![feature(const_generics)]
5
- | ^^^^^^^^^^^^^^
4
+ LL | #![cfg_attr(full, feature(const_generics) )]
5
+ | ^^^^^^^^^^^^^^
6
6
|
7
7
= note: `#[warn(incomplete_features)]` on by default
8
8
= note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information
Original file line number Diff line number Diff line change 1
1
// run-pass
2
-
3
- #![ feature( const_generics) ]
4
- //~^ WARN the feature `const_generics` is incomplete
2
+ // revisions: full min
3
+ #![ cfg_attr ( full , feature( const_generics) ) ] //[full]~WARN the feature `const_generics` is incomplete
4
+ #! [ cfg_attr ( min , feature( min_const_generics ) ) ]
5
5
6
6
fn promote < const N : i32 > ( ) {
7
7
// works:
Original file line number Diff line number Diff line change 1
1
warning: the feature `const_generics` is incomplete and may not be safe to use and/or cause compiler crashes
2
- --> $DIR/issue-61747.rs:1:12
2
+ --> $DIR/issue-61747.rs:2:27
3
3
|
4
- LL | #![feature(const_generics)]
5
- | ^^^^^^^^^^^^^^
4
+ LL | #![cfg_attr(full, feature(const_generics) )]
5
+ | ^^^^^^^^^^^^^^
6
6
|
7
7
= note: `#[warn(incomplete_features)]` on by default
8
8
= note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information
9
9
10
10
error: constant expression depends on a generic parameter
11
- --> $DIR/issue-61747.rs:7 :23
11
+ --> $DIR/issue-61747.rs:8 :23
12
12
|
13
13
LL | fn successor() -> Const<{C + 1}> {
14
14
| ^^^^^^^^^^^^^^
Original file line number Diff line number Diff line change
1
+ error: generic parameters must not be used inside of non trivial constant values
2
+ --> $DIR/issue-61747.rs:8:30
3
+ |
4
+ LL | fn successor() -> Const<{C + 1}> {
5
+ | ^ non-trivial anonymous constants must not depend on the parameter `C`
6
+ |
7
+ = help: it is currently only allowed to use either `C` or `{ C }` as generic constants
8
+
9
+ error: aborting due to previous error
10
+
Original file line number Diff line number Diff line change 1
- #![ feature( const_generics) ]
2
- //~^ WARN the feature `const_generics` is incomplete
1
+ // revisions: full min
2
+ #![ cfg_attr( full, feature( const_generics) ) ] //[full]~WARN the feature `const_generics` is incomplete
3
+ #![ cfg_attr( min, feature( min_const_generics) ) ]
3
4
4
5
struct Const < const N : usize > ;
5
6
6
7
impl < const C : usize > Const < { C } > {
7
8
fn successor ( ) -> Const < { C + 1 } > {
8
- //~^ ERROR constant expression depends on a generic parameter
9
+ //[full]~^ ERROR constant expression depends on a generic parameter
10
+ //[min]~^^ ERROR generic parameters must not be used
9
11
Const
10
12
}
11
13
}
Original file line number Diff line number Diff line change 1
1
// run-pass
2
- #![ feature( const_generics) ]
2
+ // revisions: full min
3
+ #![ cfg_attr( full, feature( const_generics) ) ]
4
+ #![ cfg_attr( min, feature( min_const_generics) ) ]
3
5
#![ allow( incomplete_features) ]
4
- #![ feature( const_fn) ]
5
6
6
7
struct Foo ;
7
8
You can’t perform that action at this time.
0 commit comments