]> git.lizzy.rs Git - rust.git/commitdiff
Fixes compilation with rust version 2017-12-21
authorBastian Köcher <git@kchr.de>
Fri, 22 Dec 2017 01:52:22 +0000 (02:52 +0100)
committerBastian Köcher <git@kchr.de>
Fri, 22 Dec 2017 01:52:22 +0000 (02:52 +0100)
src/items.rs
src/types.rs

index 66b9d81e163bda52ef8213e1dcd3fe6ffbb84c65..13b4c0e49405a8af95e7b908279a0d4ac4c4ffd5 100644 (file)
@@ -1869,7 +1869,12 @@ fn rewrite_fn_base(
     // A conservative estimation, to goal is to be over all parens in generics
     let args_start = fn_sig
         .generics
-        .ty_params
+        .params
+        .iter()
+        .filter_map(|p| match p {
+            &ast::GenericParam::Type(ref t) => Some(t),
+            _ => None,
+        })
         .last()
         .map_or(lo_after_visibility, |tp| end_typaram(tp));
     let args_end = if fd.inputs.is_empty() {
@@ -2363,15 +2368,22 @@ fn span(&self) -> Span {
         }
     }
 
-    if generics.lifetimes.is_empty() && generics.ty_params.is_empty() {
+    if generics.params.is_empty() {
         return Some(String::new());
     }
 
     let generics_args = generics
-        .lifetimes
+        .params
         .iter()
+        .filter_map(|p| match p {
+            &ast::GenericParam::Lifetime(ref l) => Some(l),
+            _ => None,
+        })
         .map(|lt| GenericsArg::Lifetime(lt))
-        .chain(generics.ty_params.iter().map(|ty| GenericsArg::TyParam(ty)));
+        .chain(generics.params.iter().filter_map(|ty| match ty {
+            &ast::GenericParam::Type(ref ty) => Some(GenericsArg::TyParam(ty)),
+            _ => None,
+        }));
     let items = itemize_list(
         context.codemap,
         generics_args,
index 88f9dba5c3f0c4ccb00b7735081cbf48c58c364d..d07af7376f1791c3390a2ce557369ecd459d72e9 100644 (file)
@@ -413,7 +413,7 @@ fn rewrite(&self, context: &RewriteContext, shape: Shape) -> Option<String> {
         // TODO: dead spans?
         let result = match *self {
             ast::WherePredicate::BoundPredicate(ast::WhereBoundPredicate {
-                ref bound_lifetimes,
+                ref bound_generic_params,
                 ref bounded_ty,
                 ref bounds,
                 ..
@@ -422,9 +422,13 @@ fn rewrite(&self, context: &RewriteContext, shape: Shape) -> Option<String> {
 
                 let colon = type_bound_colon(context);
 
-                if !bound_lifetimes.is_empty() {
-                    let lifetime_str: String = bound_lifetimes
+                if bound_generic_params.iter().filter(|p| p.is_lifetime_param()).count() > 0 {
+                    let lifetime_str: String = bound_generic_params
                         .iter()
+                        .filter_map(|p| match p {
+                            &ast::GenericParam::Lifetime(ref l) => Some(l),
+                            _ => None,
+                        })
                         .map(|lt| lt.rewrite(context, shape))
                         .collect::<Option<Vec<_>>>()?
                         .join(", ");
@@ -590,9 +594,13 @@ fn rewrite(&self, context: &RewriteContext, shape: Shape) -> Option<String> {
 
 impl Rewrite for ast::PolyTraitRef {
     fn rewrite(&self, context: &RewriteContext, shape: Shape) -> Option<String> {
-        if !self.bound_lifetimes.is_empty() {
-            let lifetime_str: String = self.bound_lifetimes
+        if self.bound_generic_params.iter().filter(|p| p.is_lifetime_param()).count() > 0 {
+            let lifetime_str: String = self.bound_generic_params
                 .iter()
+                .filter_map(|p| match p {
+                    &ast::GenericParam::Lifetime(ref l) => Some(l),
+                    _ => None,
+                })
                 .map(|lt| lt.rewrite(context, shape))
                 .collect::<Option<Vec<_>>>()?
                 .join(", ");
@@ -746,14 +754,18 @@ fn rewrite_bare_fn(
 ) -> Option<String> {
     let mut result = String::with_capacity(128);
 
-    if !bare_fn.lifetimes.is_empty() {
+    if bare_fn.generic_params.iter().filter(|p| p.is_lifetime_param()).count() > 0 {
         result.push_str("for<");
         // 6 = "for<> ".len(), 4 = "for<".
         // This doesn't work out so nicely for mutliline situation with lots of
         // rightward drift. If that is a problem, we could use the list stuff.
         result.push_str(&bare_fn
-            .lifetimes
+            .generic_params
             .iter()
+            .filter_map(|p| match p {
+                &ast::GenericParam::Lifetime(ref l) => Some(l),
+                _ => None,
+            })
             .map(|l| {
                 l.rewrite(
                     context,