@@ -1711,31 +1711,25 @@ impl<'a> State<'a> {
17111711 }
17121712 } ;
17131713
1714- let mut types = vec ! [ ] ;
1715- let mut elide_lifetimes = true ;
1716- for arg in & generic_args. args {
1717- match arg {
1718- GenericArg :: Lifetime ( lt) => {
1719- if !lt. is_elided ( ) {
1720- elide_lifetimes = false ;
1721- }
1722- }
1723- GenericArg :: Type ( ty) => {
1724- types. push ( ty) ;
1725- }
1714+ let mut nonelided_generic_args: bool = false ;
1715+ let elide_lifetimes = generic_args. args . iter ( ) . all ( |arg| match arg {
1716+ GenericArg :: Lifetime ( lt) => lt. is_elided ( ) ,
1717+ _ => {
1718+ nonelided_generic_args = true ;
1719+ true
17261720 }
1727- }
1728- if !elide_lifetimes {
1721+ } ) ;
1722+
1723+ if nonelided_generic_args {
17291724 start_or_comma ( self ) ?;
17301725 self . commasep ( Inconsistent , & generic_args. args , |s, generic_arg| {
17311726 match generic_arg {
1732- GenericArg :: Lifetime ( lt) => s. print_lifetime ( lt) ,
1727+ GenericArg :: Lifetime ( lt) if !elide_lifetimes => s. print_lifetime ( lt) ,
1728+ GenericArg :: Lifetime ( _) => Ok ( ( ) ) ,
17331729 GenericArg :: Type ( ty) => s. print_type ( ty) ,
1730+ GenericArg :: Const ( ct) => s. print_anon_const ( & ct. value ) ,
17341731 }
17351732 } ) ?;
1736- } else if !types. is_empty ( ) {
1737- start_or_comma ( self ) ?;
1738- self . commasep ( Inconsistent , & types, |s, ty| s. print_type ( & ty) ) ?;
17391733 }
17401734
17411735 // FIXME(eddyb) This would leak into error messages, e.g.:
@@ -2106,7 +2100,12 @@ impl<'a> State<'a> {
21062100 }
21072101
21082102 pub fn print_generic_param ( & mut self , param : & GenericParam ) -> io:: Result < ( ) > {
2103+ if let GenericParamKind :: Const { .. } = param. kind {
2104+ self . word_space ( "const" ) ?;
2105+ }
2106+
21092107 self . print_ident ( param. name . ident ( ) ) ?;
2108+
21102109 match param. kind {
21112110 GenericParamKind :: Lifetime { .. } => {
21122111 let mut sep = ":" ;
@@ -2133,6 +2132,10 @@ impl<'a> State<'a> {
21332132 _ => Ok ( ( ) ) ,
21342133 }
21352134 }
2135+ GenericParamKind :: Const { ref ty } => {
2136+ self . word_space ( ":" ) ?;
2137+ self . print_type ( ty)
2138+ }
21362139 }
21372140 }
21382141
0 commit comments