@@ -360,6 +360,7 @@ enum GenericPosition {
360
360
}
361
361
362
362
fn validate_generics_order < ' a > (
363
+ sess : & Session ,
363
364
handler : & errors:: Handler ,
364
365
generics : impl Iterator <
365
366
Item = (
@@ -426,7 +427,11 @@ fn validate_generics_order<'a>(
426
427
if let GenericPosition :: Param = pos {
427
428
err. span_suggestion (
428
429
span,
429
- & format ! ( "reorder the {}s: lifetimes, then types, then consts" , pos_str) ,
430
+ & format ! (
431
+ "reorder the {}s: lifetimes, then types{}" ,
432
+ pos_str,
433
+ if sess. features_untracked( ) . const_generics { ", then consts" } else { "" } ,
434
+ ) ,
430
435
ordered_params. clone ( ) ,
431
436
Applicability :: MachineApplicable ,
432
437
) ;
@@ -709,13 +714,19 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
709
714
match * generic_args {
710
715
GenericArgs :: AngleBracketed ( ref data) => {
711
716
walk_list ! ( self , visit_generic_arg, & data. args) ;
712
- validate_generics_order ( self . err_handler ( ) , data. args . iter ( ) . map ( |arg| {
713
- ( match arg {
714
- GenericArg :: Lifetime ( ..) => ParamKindOrd :: Lifetime ,
715
- GenericArg :: Type ( ..) => ParamKindOrd :: Type ,
716
- GenericArg :: Const ( ..) => ParamKindOrd :: Const ,
717
- } , None , arg. span ( ) , None )
718
- } ) , GenericPosition :: Arg , generic_args. span ( ) ) ;
717
+ validate_generics_order (
718
+ self . session ,
719
+ self . err_handler ( ) ,
720
+ data. args . iter ( ) . map ( |arg| {
721
+ ( match arg {
722
+ GenericArg :: Lifetime ( ..) => ParamKindOrd :: Lifetime ,
723
+ GenericArg :: Type ( ..) => ParamKindOrd :: Type ,
724
+ GenericArg :: Const ( ..) => ParamKindOrd :: Const ,
725
+ } , None , arg. span ( ) , None )
726
+ } ) ,
727
+ GenericPosition :: Arg ,
728
+ generic_args. span ( ) ,
729
+ ) ;
719
730
720
731
// Type bindings such as `Item=impl Debug` in `Iterator<Item=Debug>`
721
732
// are allowed to contain nested `impl Trait`.
@@ -748,18 +759,24 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
748
759
}
749
760
}
750
761
751
- validate_generics_order ( self . err_handler ( ) , generics. params . iter ( ) . map ( |param| {
752
- let ident = Some ( param. ident . to_string ( ) ) ;
753
- let ( kind, ident) = match & param. kind {
754
- GenericParamKind :: Lifetime { .. } => ( ParamKindOrd :: Lifetime , ident) ,
755
- GenericParamKind :: Type { .. } => ( ParamKindOrd :: Type , ident) ,
756
- GenericParamKind :: Const { ref ty } => {
757
- let ty = pprust:: ty_to_string ( ty) ;
758
- ( ParamKindOrd :: Const , Some ( format ! ( "const {}: {}" , param. ident, ty) ) )
759
- }
760
- } ;
761
- ( kind, Some ( & * param. bounds ) , param. ident . span , ident)
762
- } ) , GenericPosition :: Param , generics. span ) ;
762
+ validate_generics_order (
763
+ self . session ,
764
+ self . err_handler ( ) ,
765
+ generics. params . iter ( ) . map ( |param| {
766
+ let ident = Some ( param. ident . to_string ( ) ) ;
767
+ let ( kind, ident) = match & param. kind {
768
+ GenericParamKind :: Lifetime { .. } => ( ParamKindOrd :: Lifetime , ident) ,
769
+ GenericParamKind :: Type { .. } => ( ParamKindOrd :: Type , ident) ,
770
+ GenericParamKind :: Const { ref ty } => {
771
+ let ty = pprust:: ty_to_string ( ty) ;
772
+ ( ParamKindOrd :: Const , Some ( format ! ( "const {}: {}" , param. ident, ty) ) )
773
+ }
774
+ } ;
775
+ ( kind, Some ( & * param. bounds ) , param. ident . span , ident)
776
+ } ) ,
777
+ GenericPosition :: Param ,
778
+ generics. span ,
779
+ ) ;
763
780
764
781
for predicate in & generics. where_clause . predicates {
765
782
if let WherePredicate :: EqPredicate ( ref predicate) = * predicate {
0 commit comments