From 5be4fa864af439cb18fe9bff4297e229f2879c73 Mon Sep 17 00:00:00 2001 From: gaurikholkar Date: Thu, 29 Jun 2017 06:35:09 -0700 Subject: [PATCH] code fixes for error code use warning --- .../error_reporting/named_anon_conflict.rs | 38 ++++++++----------- 1 file changed, 16 insertions(+), 22 deletions(-) diff --git a/src/librustc/infer/error_reporting/named_anon_conflict.rs b/src/librustc/infer/error_reporting/named_anon_conflict.rs index 21f8a04be0a..ccbc5cdb862 100644 --- a/src/librustc/infer/error_reporting/named_anon_conflict.rs +++ b/src/librustc/infer/error_reporting/named_anon_conflict.rs @@ -131,29 +131,23 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, '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; }