@@ -1711,31 +1711,25 @@ impl<'a> State<'a> {
1711
1711
}
1712
1712
} ;
1713
1713
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
1726
1720
}
1727
- }
1728
- if !elide_lifetimes {
1721
+ } ) ;
1722
+
1723
+ if nonelided_generic_args {
1729
1724
start_or_comma ( self ) ?;
1730
1725
self . commasep ( Inconsistent , & generic_args. args , |s, generic_arg| {
1731
1726
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 ( ( ) ) ,
1733
1729
GenericArg :: Type ( ty) => s. print_type ( ty) ,
1730
+ GenericArg :: Const ( ct) => s. print_anon_const ( & ct. value ) ,
1734
1731
}
1735
1732
} ) ?;
1736
- } else if !types. is_empty ( ) {
1737
- start_or_comma ( self ) ?;
1738
- self . commasep ( Inconsistent , & types, |s, ty| s. print_type ( & ty) ) ?;
1739
1733
}
1740
1734
1741
1735
// FIXME(eddyb) This would leak into error messages, e.g.:
@@ -2106,7 +2100,12 @@ impl<'a> State<'a> {
2106
2100
}
2107
2101
2108
2102
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
+
2109
2107
self . print_ident ( param. name . ident ( ) ) ?;
2108
+
2110
2109
match param. kind {
2111
2110
GenericParamKind :: Lifetime { .. } => {
2112
2111
let mut sep = ":" ;
@@ -2133,6 +2132,10 @@ impl<'a> State<'a> {
2133
2132
_ => Ok ( ( ) ) ,
2134
2133
}
2135
2134
}
2135
+ GenericParamKind :: Const { ref ty } => {
2136
+ self . word_space ( ":" ) ?;
2137
+ self . print_type ( ty)
2138
+ }
2136
2139
}
2137
2140
}
2138
2141
0 commit comments