Skip to content

Commit

Permalink
code fixes for error code use warning
Browse files Browse the repository at this point in the history
  • Loading branch information
gaurikholkar committed Jun 29, 2017
1 parent 5841021 commit 5be4fa8
Showing 1 changed file with 16 additions and 22 deletions.
38 changes: 16 additions & 22 deletions src/librustc/infer/error_reporting/named_anon_conflict.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

}
Expand Down

0 comments on commit 5be4fa8

Please sign in to comment.