File tree 3 files changed +17
-9
lines changed
3 files changed +17
-9
lines changed Original file line number Diff line number Diff line change @@ -313,17 +313,15 @@ pub type GenericBounds = Vec<GenericBound>;
313
313
pub enum ParamKindOrd {
314
314
Lifetime ,
315
315
Type ,
316
- Const ,
317
- ConstUnordered ,
316
+ Const { unordered : bool } ,
318
317
}
319
318
320
319
impl fmt:: Display for ParamKindOrd {
321
320
fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
322
321
match self {
323
322
ParamKindOrd :: Lifetime => "lifetime" . fmt ( f) ,
324
323
ParamKindOrd :: Type => "type" . fmt ( f) ,
325
- ParamKindOrd :: Const => "const" . fmt ( f) ,
326
- ParamKindOrd :: ConstUnordered => "const" . fmt ( f) ,
324
+ ParamKindOrd :: Const { .. } => "const" . fmt ( f) ,
327
325
}
328
326
}
329
327
}
Original file line number Diff line number Diff line change @@ -735,7 +735,7 @@ fn validate_generic_param_order<'a>(
735
735
}
736
736
let max_param = & mut max_param;
737
737
match max_param {
738
- Some ( ParamKindOrd :: ConstUnordered ) if kind != ParamKindOrd :: Lifetime => ( ) ,
738
+ Some ( ParamKindOrd :: Const { unordered : true } ) if kind != ParamKindOrd :: Lifetime => ( ) ,
739
739
Some ( max_param) if * max_param > kind => {
740
740
let entry = out_of_order. entry ( kind) . or_insert ( ( * max_param, vec ! [ ] ) ) ;
741
741
entry. 1 . push ( span) ;
@@ -1159,7 +1159,11 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
1159
1159
GenericParamKind :: Type { default : _ } => ( ParamKindOrd :: Type , ident) ,
1160
1160
GenericParamKind :: Const { ref ty, kw_span : _ } => {
1161
1161
let ty = pprust:: ty_to_string ( ty) ;
1162
- ( ParamKindOrd :: Const , Some ( format ! ( "const {}: {}" , param. ident, ty) ) )
1162
+ let unordered = self . session . features_untracked ( ) . const_generics ;
1163
+ (
1164
+ ParamKindOrd :: Const { unordered } ,
1165
+ Some ( format ! ( "const {}: {}" , param. ident, ty) ) ,
1166
+ )
1163
1167
}
1164
1168
} ;
1165
1169
( kind, Some ( & * param. bounds ) , param. ident . span , ident)
Original file line number Diff line number Diff line change @@ -489,18 +489,19 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
489
489
kind,
490
490
) ;
491
491
492
+ let unordered = sess. features_untracked ( ) . const_generics ;
492
493
let kind_ord = match kind {
493
494
"lifetime" => ParamKindOrd :: Lifetime ,
494
495
"type" => ParamKindOrd :: Type ,
495
- "constant" => ParamKindOrd :: Const ,
496
+ "constant" => ParamKindOrd :: Const { unordered } ,
496
497
// It's more concise to match on the string representation, though it means
497
498
// the match is non-exhaustive.
498
499
_ => bug ! ( "invalid generic parameter kind {}" , kind) ,
499
500
} ;
500
501
let arg_ord = match arg {
501
502
GenericArg :: Lifetime ( _) => ParamKindOrd :: Lifetime ,
502
503
GenericArg :: Type ( _) => ParamKindOrd :: Type ,
503
- GenericArg :: Const ( _) => ParamKindOrd :: Const ,
504
+ GenericArg :: Const ( _) => ParamKindOrd :: Const { unordered } ,
504
505
} ;
505
506
506
507
// This note will be true as long as generic parameters are strictly ordered by their kind.
@@ -672,7 +673,12 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
672
673
ParamKindOrd :: Type
673
674
}
674
675
GenericParamDefKind :: Const => {
675
- ParamKindOrd :: Const
676
+ ParamKindOrd :: Const {
677
+ unordered : tcx
678
+ . sess
679
+ . features_untracked ( )
680
+ . const_generics ,
681
+ }
676
682
}
677
683
} ,
678
684
param,
You can’t perform that action at this time.
0 commit comments