]> git.lizzy.rs Git - rust.git/commitdiff
code fixes for error code use warning
authorgaurikholkar <f2013002@goa.bits-pilani.ac.in>
Thu, 29 Jun 2017 13:35:09 +0000 (06:35 -0700)
committergaurikholkar <f2013002@goa.bits-pilani.ac.in>
Thu, 29 Jun 2017 13:37:18 +0000 (06:37 -0700)
src/librustc/infer/error_reporting/named_anon_conflict.rs

index 21f8a04be0a6adb7fc5714d62fec026fb4c9a3e8..ccbc5cdb862f98eb96f26880a857b7091d3cbef9 100644 (file)
@@ -131,29 +131,23 @@ pub fn try_report_named_anon_conflict(&self, error: &RegionResolutionError<'tcx>
             return false;
         }
 
-        if let Some(simple_name) = arg.pat.simple_name() {
-            struct_span_err!(self.tcx.sess,
-                             span,
-                             E0621,
-                             "explicit lifetime required in the type of `{}`",
-                             simple_name)
-                    .span_label(arg.pat.span,
-                                format!("consider changing the type of `{}` to `{}`",
-                                        simple_name,
-                                        new_ty))
-                    .span_label(span, format!("lifetime `{}` required", named))
-                    .emit();
-
+        let (error_var, span_label_var) = if let Some(simple_name) = arg.pat.simple_name() {
+            (format!("the type of `{}`", simple_name), format!("the type of `{}`", simple_name))
         } else {
-            struct_span_err!(self.tcx.sess,
-                             span,
-                             E0621,
-                             "explicit lifetime required in parameter type")
-                    .span_label(arg.pat.span,
-                                format!("consider changing type to `{}`", new_ty))
-                    .span_label(span, format!("lifetime `{}` required", named))
-                    .emit();
-        }
+            (format!("parameter type"), format!("type"))
+        };
+
+
+        struct_span_err!(self.tcx.sess,
+                         span,
+                         E0621,
+                         "explicit lifetime required in {}",
+                         error_var)
+                .span_label(arg.pat.span,
+                            format!("consider changing {} to `{}`", span_label_var, new_ty))
+                .span_label(span, format!("lifetime `{}` required", named))
+                .emit();
+
         return true;
 
     }