Auto merge of #84299 - lcnr:const-generics-defaults-name-res, r=varkor
various const parameter defaults improvements 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 ```rust #![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`
This commit is contained in:
commit
58bdb08947
45 changed files with 385 additions and 217 deletions
|
@ -63,6 +63,10 @@ macro_rules! declare_features {
|
|||
_ => panic!("`{}` was not listed in `declare_features`", feature),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn unordered_const_ty_params(&self) -> bool {
|
||||
self.const_generics || self.const_generics_defaults
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue