9

Github various const parameter defaults improvements by lcnr · Pull Request #842...

 3 years ago
source link: https://github.com/rust-lang/rust/pull/84299
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

Copy link

Contributor

lcnr commented on Apr 18

edited

Actually resolve names in const parameter defaults, fixing struct Foo<const N: usize = { usize::MAX }>.


Split generic parameter ban rib for types and consts, allowing

#![feature(const_generics_defaults)]
struct Q;
struct Foo<T = Q, const Q: usize = 3>(T);

Remove the type/const ordering restriction if const_generics_defaults is active, even if const_generics is not. allowing us to stabilize and test const param defaults separately.


Check well formedness of const parameter defaults, eagerly emitting an error for struct Foo<const N: usize = { 0 - 1 }>


Do not forbid const parameters in param defaults, allowing struct Foo<const N: usize, T = [u8; N]>(T) and struct Foo<const N: usize, const M: usize = N>. Note that this should not change anything which is stabilized, as on stable, type parameters must be in front of const parameters, which means that type parameter defaults are only allowed if no const parameters exist.

We still forbid generic parameters inside of const param types.

r? @varkor @petrochenkov


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK