-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of #74654 - lcnr:default-no-more, r=varkor
require type defaults to be after const generic parameters From current discussions it seems like the goal here is for type and const parameters to be unordered and allow things like `struct Foo<const N: usize, T = u32>(T)` and `struct Foo<T, const N: usize = 7>` this way. Note: This means that using `min_const_generics` it will not be possible for an adt to have both type defaults and const parameters. closes #70471 r? @varkor @eddyb
- Loading branch information
Showing
3 changed files
with
46 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#![feature(const_generics)] //~ WARN the feature `const_generics` is incomplete | ||
|
||
struct A<T = u32, const N: usize> { | ||
//~^ ERROR type parameters with a default must be trailing | ||
arg: T, | ||
} | ||
|
||
fn main() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
error: type parameters with a default must be trailing | ||
--> $DIR/wrong-order.rs:3:10 | ||
| | ||
LL | struct A<T = u32, const N: usize> { | ||
| ^ | ||
| | ||
= note: using type defaults and const parameters in the same parameter list is currently not permitted | ||
|
||
warning: the feature `const_generics` is incomplete and may not be safe to use and/or cause compiler crashes | ||
--> $DIR/wrong-order.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: aborting due to previous error; 1 warning emitted | ||
|