]> git.lizzy.rs Git - rust.git/blobdiff - src/types.rs
Merge pull request #3401 from topecongiro/rustcap
[rust.git] / src / types.rs
index 2bbf1ba9f22d2f61a2a46288ba680aa703eaa53d..10b46959136e65c7386b66d6981a3fe1e1d4e0b2 100644 (file)
@@ -40,7 +40,7 @@ pub enum PathContext {
 
 // Does not wrap on simple segments.
 pub fn rewrite_path(
-    context: &RewriteContext,
+    context: &RewriteContext<'_>,
     path_context: PathContext,
     qself: Option<&ast::QSelf>,
     path: &ast::Path,
@@ -103,7 +103,7 @@ fn rewrite_path_segments<'a, I>(
     iter: I,
     mut span_lo: BytePos,
     span_hi: BytePos,
-    context: &RewriteContext,
+    context: &RewriteContext<'_>,
     shape: Shape,
 ) -> Option<String>
 where
@@ -148,10 +148,11 @@ pub enum SegmentParam<'a> {
 }
 
 impl<'a> SegmentParam<'a> {
-    fn from_generic_arg(arg: &ast::GenericArg) -> SegmentParam {
+    fn from_generic_arg(arg: &ast::GenericArg) -> SegmentParam<'_> {
         match arg {
             ast::GenericArg::Lifetime(ref lt) => SegmentParam::LifeTime(lt),
             ast::GenericArg::Type(ref ty) => SegmentParam::Type(ty),
+            ast::GenericArg::Const(..) => unreachable!(), // FIXME(#3336)
         }
     }
 }
@@ -167,7 +168,7 @@ fn span(&self) -> Span {
 }
 
 impl<'a> Rewrite for SegmentParam<'a> {
-    fn rewrite(&self, context: &RewriteContext, shape: Shape) -> Option<String> {
+    fn rewrite(&self, context: &RewriteContext<'_>, shape: Shape) -> Option<String> {
         match *self {
             SegmentParam::LifeTime(lt) => lt.rewrite(context, shape),
             SegmentParam::Type(ty) => ty.rewrite(context, shape),
@@ -204,7 +205,7 @@ fn rewrite_segment(
     segment: &ast::PathSegment,
     span_lo: &mut BytePos,
     span_hi: BytePos,
-    context: &RewriteContext,
+    context: &RewriteContext<'_>,
     shape: Shape,
 ) -> Option<String> {
     let mut result = String::with_capacity(128);
@@ -285,7 +286,7 @@ fn format_function_type<'a, I>(
     output: &FunctionRetTy,
     variadic: bool,
     span: Span,
-    context: &RewriteContext,
+    context: &RewriteContext<'_>,
     shape: Shape,
 ) -> Option<String>
 where
@@ -410,7 +411,7 @@ enum ArgumentKind<T>
     }
 }
 
-fn type_bound_colon(context: &RewriteContext) -> &'static str {
+fn type_bound_colon(context: &RewriteContext<'_>) -> &'static str {
     colon_spaces(
         context.config.space_before_colon(),
         context.config.space_after_colon(),
@@ -418,7 +419,7 @@ fn type_bound_colon(context: &RewriteContext) -> &'static str {
 }
 
 impl Rewrite for ast::WherePredicate {
-    fn rewrite(&self, context: &RewriteContext, shape: Shape) -> Option<String> {
+    fn rewrite(&self, context: &RewriteContext<'_>, shape: Shape) -> Option<String> {
         // FIXME: dead spans?
         let result = match *self {
             ast::WherePredicate::BoundPredicate(ast::WhereBoundPredicate {
@@ -459,10 +460,11 @@ fn rewrite(&self, context: &RewriteContext, shape: Shape) -> Option<String> {
 }
 
 impl Rewrite for ast::GenericArg {
-    fn rewrite(&self, context: &RewriteContext, shape: Shape) -> Option<String> {
+    fn rewrite(&self, context: &RewriteContext<'_>, shape: Shape) -> Option<String> {
         match *self {
             ast::GenericArg::Lifetime(ref lt) => lt.rewrite(context, shape),
             ast::GenericArg::Type(ref ty) => ty.rewrite(context, shape),
+            ast::GenericArg::Const(..) => unreachable!(), // FIXME(#3336)
         }
     }
 }
@@ -470,7 +472,7 @@ fn rewrite(&self, context: &RewriteContext, shape: Shape) -> Option<String> {
 fn rewrite_bounded_lifetime(
     lt: &ast::Lifetime,
     bounds: &[ast::GenericBound],
-    context: &RewriteContext,
+    context: &RewriteContext<'_>,
     shape: Shape,
 ) -> Option<String> {
     let result = lt.rewrite(context, shape)?;
@@ -491,13 +493,13 @@ fn rewrite_bounded_lifetime(
 }
 
 impl Rewrite for ast::Lifetime {
-    fn rewrite(&self, context: &RewriteContext, _: Shape) -> Option<String> {
+    fn rewrite(&self, context: &RewriteContext<'_>, _: Shape) -> Option<String> {
         Some(rewrite_ident(context, self.ident).to_owned())
     }
 }
 
 impl Rewrite for ast::GenericBound {
-    fn rewrite(&self, context: &RewriteContext, shape: Shape) -> Option<String> {
+    fn rewrite(&self, context: &RewriteContext<'_>, shape: Shape) -> Option<String> {
         match *self {
             ast::GenericBound::Trait(ref poly_trait_ref, trait_bound_modifier) => {
                 let snippet = context.snippet(self.span());
@@ -516,7 +518,7 @@ fn rewrite(&self, context: &RewriteContext, shape: Shape) -> Option<String> {
 }
 
 impl Rewrite for ast::GenericBounds {
-    fn rewrite(&self, context: &RewriteContext, shape: Shape) -> Option<String> {
+    fn rewrite(&self, context: &RewriteContext<'_>, shape: Shape) -> Option<String> {
         if self.is_empty() {
             return Some(String::new());
         }
@@ -526,7 +528,7 @@ fn rewrite(&self, context: &RewriteContext, shape: Shape) -> Option<String> {
 }
 
 impl Rewrite for ast::GenericParam {
-    fn rewrite(&self, context: &RewriteContext, shape: Shape) -> Option<String> {
+    fn rewrite(&self, context: &RewriteContext<'_>, shape: Shape) -> Option<String> {
         let mut result = String::with_capacity(128);
         // FIXME: If there are more than one attributes, this will force multiline.
         match self.attrs.rewrite(context, shape) {
@@ -558,7 +560,7 @@ fn rewrite(&self, context: &RewriteContext, shape: Shape) -> Option<String> {
 }
 
 impl Rewrite for ast::PolyTraitRef {
-    fn rewrite(&self, context: &RewriteContext, shape: Shape) -> Option<String> {
+    fn rewrite(&self, context: &RewriteContext<'_>, shape: Shape) -> Option<String> {
         if let Some(lifetime_str) =
             rewrite_lifetime_param(context, shape, &self.bound_generic_params)
         {
@@ -576,13 +578,13 @@ fn rewrite(&self, context: &RewriteContext, shape: Shape) -> Option<String> {
 }
 
 impl Rewrite for ast::TraitRef {
-    fn rewrite(&self, context: &RewriteContext, shape: Shape) -> Option<String> {
+    fn rewrite(&self, context: &RewriteContext<'_>, shape: Shape) -> Option<String> {
         rewrite_path(context, PathContext::Type, None, &self.path, shape)
     }
 }
 
 impl Rewrite for ast::Ty {
-    fn rewrite(&self, context: &RewriteContext, shape: Shape) -> Option<String> {
+    fn rewrite(&self, context: &RewriteContext<'_>, shape: Shape) -> Option<String> {
         match self.node {
             ast::TyKind::TraitObject(ref bounds, tobj_syntax) => {
                 // we have to consider 'dyn' keyword is used or not!!!
@@ -695,7 +697,7 @@ fn rewrite(&self, context: &RewriteContext, shape: Shape) -> Option<String> {
 fn rewrite_bare_fn(
     bare_fn: &ast::BareFnTy,
     span: Span,
-    context: &RewriteContext,
+    context: &RewriteContext<'_>,
     shape: Shape,
 ) -> Option<String> {
     debug!("rewrite_bare_fn {:#?}", shape);
@@ -759,7 +761,7 @@ fn is_generic_bounds_in_order(generic_bounds: &[ast::GenericBound]) -> bool {
 }
 
 fn join_bounds(
-    context: &RewriteContext,
+    context: &RewriteContext<'_>,
     shape: Shape,
     items: &[ast::GenericBound],
     need_indent: bool,
@@ -815,7 +817,7 @@ fn join_bounds(
     Some(result)
 }
 
-pub fn can_be_overflowed_type(context: &RewriteContext, ty: &ast::Ty, len: usize) -> bool {
+pub fn can_be_overflowed_type(context: &RewriteContext<'_>, ty: &ast::Ty, len: usize) -> bool {
     match ty.node {
         ast::TyKind::Tup(..) => context.use_block_indent() && len == 1,
         ast::TyKind::Rptr(_, ref mutty) | ast::TyKind::Ptr(ref mutty) => {
@@ -827,7 +829,7 @@ pub fn can_be_overflowed_type(context: &RewriteContext, ty: &ast::Ty, len: usize
 
 /// Returns `None` if there is no `LifetimeDef` in the given generic parameters.
 fn rewrite_lifetime_param(
-    context: &RewriteContext,
+    context: &RewriteContext<'_>,
     shape: Shape,
     generic_params: &[ast::GenericParam],
 ) -> Option<String> {