allow unordered const/ty params if any cg feature is active

This commit is contained in:
lcnr 2021-08-26 21:12:02 +02:00
parent 0c28e028b6
commit 4747cbb3bb
4 changed files with 4 additions and 6 deletions

View File

@ -332,8 +332,8 @@ pub type GenericBounds = Vec<GenericBound>;
pub enum ParamKindOrd {
Lifetime,
Type,
// `unordered` is only `true` if `sess.has_features().const_generics_defaults`
// is active. Specifically, if it's only `min_const_generics`, it will still require
// `unordered` is only `true` if `sess.unordered_const_ty_params()`
// returns true. Specifically, if it's only `min_const_generics`, it will still require
// ordering consts after types.
Const { unordered: bool },
// `Infer` is not actually constructed directly from the AST, but is implicitly constructed

View File

@ -1351,7 +1351,7 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
}
fn visit_generics(&mut self, generics: &'a Generics) {
let cg_defaults = self.session.features_untracked().const_generics_defaults;
let cg_defaults = self.session.features_untracked().unordered_const_ty_params();
let mut prev_param_default = None;
for param in &generics.params {

View File

@ -71,7 +71,7 @@ macro_rules! declare_features {
}
pub fn unordered_const_ty_params(&self) -> bool {
self.const_generics_defaults
self.const_generics_defaults || self.generic_const_exprs || self.const_param_types
}
/// Some features are known to be incomplete and using them is likely to have

View File

@ -3,8 +3,6 @@ error: generic parameters with a default must be trailing
|
LL | struct Bar<T = [u8; N], const N: usize>(T);
| ^
|
= note: using type defaults and const parameters in the same parameter list is currently not permitted
error[E0128]: generic parameters with a default cannot use forward declared identifiers
--> $DIR/params-in-ct-in-ty-param-lazy-norm.rs:8:21