Skip to content

Commit 5be4fa8

Browse files
committed
code fixes for error code use warning
1 parent 5841021 commit 5be4fa8

File tree

1 file changed

+16
-22
lines changed

1 file changed

+16
-22
lines changed

src/librustc/infer/error_reporting/named_anon_conflict.rs

Lines changed: 16 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -131,29 +131,23 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
131131
return false;
132132
}
133133

134-
if let Some(simple_name) = arg.pat.simple_name() {
135-
struct_span_err!(self.tcx.sess,
136-
span,
137-
E0621,
138-
"explicit lifetime required in the type of `{}`",
139-
simple_name)
140-
.span_label(arg.pat.span,
141-
format!("consider changing the type of `{}` to `{}`",
142-
simple_name,
143-
new_ty))
144-
.span_label(span, format!("lifetime `{}` required", named))
145-
.emit();
146-
134+
let (error_var, span_label_var) = if let Some(simple_name) = arg.pat.simple_name() {
135+
(format!("the type of `{}`", simple_name), format!("the type of `{}`", simple_name))
147136
} else {
148-
struct_span_err!(self.tcx.sess,
149-
span,
150-
E0621,
151-
"explicit lifetime required in parameter type")
152-
.span_label(arg.pat.span,
153-
format!("consider changing type to `{}`", new_ty))
154-
.span_label(span, format!("lifetime `{}` required", named))
155-
.emit();
156-
}
137+
(format!("parameter type"), format!("type"))
138+
};
139+
140+
141+
struct_span_err!(self.tcx.sess,
142+
span,
143+
E0621,
144+
"explicit lifetime required in {}",
145+
error_var)
146+
.span_label(arg.pat.span,
147+
format!("consider changing {} to `{}`", span_label_var, new_ty))
148+
.span_label(span, format!("lifetime `{}` required", named))
149+
.emit();
150+
157151
return true;
158152

159153
}

0 commit comments

Comments
 (0)