File tree Expand file tree Collapse file tree 3 files changed +17
-9
lines changed Expand file tree Collapse file tree 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>;
313313pub enum ParamKindOrd {
314314 Lifetime ,
315315 Type ,
316- Const ,
317- ConstUnordered ,
316+ Const { unordered : bool } ,
318317}
319318
320319impl fmt:: Display for ParamKindOrd {
321320 fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
322321 match self {
323322 ParamKindOrd :: Lifetime => "lifetime" . fmt ( f) ,
324323 ParamKindOrd :: Type => "type" . fmt ( f) ,
325- ParamKindOrd :: Const => "const" . fmt ( f) ,
326- ParamKindOrd :: ConstUnordered => "const" . fmt ( f) ,
324+ ParamKindOrd :: Const { .. } => "const" . fmt ( f) ,
327325 }
328326 }
329327}
Original file line number Diff line number Diff line change @@ -735,7 +735,7 @@ fn validate_generic_param_order<'a>(
735735 }
736736 let max_param = & mut max_param;
737737 match max_param {
738- Some ( ParamKindOrd :: ConstUnordered ) if kind != ParamKindOrd :: Lifetime => ( ) ,
738+ Some ( ParamKindOrd :: Const { unordered : true } ) if kind != ParamKindOrd :: Lifetime => ( ) ,
739739 Some ( max_param) if * max_param > kind => {
740740 let entry = out_of_order. entry ( kind) . or_insert ( ( * max_param, vec ! [ ] ) ) ;
741741 entry. 1 . push ( span) ;
@@ -1159,7 +1159,11 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
11591159 GenericParamKind :: Type { default : _ } => ( ParamKindOrd :: Type , ident) ,
11601160 GenericParamKind :: Const { ref ty, kw_span : _ } => {
11611161 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+ )
11631167 }
11641168 } ;
11651169 ( 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 {
489489 kind,
490490 ) ;
491491
492+ let unordered = sess. features_untracked ( ) . const_generics ;
492493 let kind_ord = match kind {
493494 "lifetime" => ParamKindOrd :: Lifetime ,
494495 "type" => ParamKindOrd :: Type ,
495- "constant" => ParamKindOrd :: Const ,
496+ "constant" => ParamKindOrd :: Const { unordered } ,
496497 // It's more concise to match on the string representation, though it means
497498 // the match is non-exhaustive.
498499 _ => bug ! ( "invalid generic parameter kind {}" , kind) ,
499500 } ;
500501 let arg_ord = match arg {
501502 GenericArg :: Lifetime ( _) => ParamKindOrd :: Lifetime ,
502503 GenericArg :: Type ( _) => ParamKindOrd :: Type ,
503- GenericArg :: Const ( _) => ParamKindOrd :: Const ,
504+ GenericArg :: Const ( _) => ParamKindOrd :: Const { unordered } ,
504505 } ;
505506
506507 // 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 {
672673 ParamKindOrd :: Type
673674 }
674675 GenericParamDefKind :: Const => {
675- ParamKindOrd :: Const
676+ ParamKindOrd :: Const {
677+ unordered : tcx
678+ . sess
679+ . features_untracked ( )
680+ . const_generics ,
681+ }
676682 }
677683 } ,
678684 param,
You can’t perform that action at this time.
0 commit comments