Skip to content

Commit 25f605a

Browse files
committed
typeck/pat.rs: extract error_field_already_bound.
1 parent 729fbeb commit 25f605a

File tree

1 file changed

+12
-8
lines changed
  • src/librustc_typeck/check

1 file changed

+12
-8
lines changed

src/librustc_typeck/check/pat.rs

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -774,14 +774,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
774774
let ident = tcx.adjust_ident(field.ident, variant.def_id);
775775
let field_ty = match used_fields.entry(ident) {
776776
Occupied(occupied) => {
777-
struct_span_err!(tcx.sess, span, E0025,
778-
"field `{}` bound multiple times \
779-
in the pattern",
780-
field.ident)
781-
.span_label(span,
782-
format!("multiple uses of `{}` in pattern", field.ident))
783-
.span_label(*occupied.get(), format!("first use of `{}`", field.ident))
784-
.emit();
777+
self.error_field_already_bound(span, field.ident, *occupied.get());
785778
no_field_errors = false;
786779
tcx.types.err
787780
}
@@ -912,6 +905,17 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
912905
no_field_errors
913906
}
914907

908+
fn error_field_already_bound(&self, span: Span, ident: ast::Ident, other_field: Span) {
909+
struct_span_err!(
910+
self.tcx.sess, span, E0025,
911+
"field `{}` bound multiple times in the pattern",
912+
ident
913+
)
914+
.span_label(span, format!("multiple uses of `{}` in pattern", ident))
915+
.span_label(other_field, format!("first use of `{}`", ident))
916+
.emit();
917+
}
918+
915919
fn check_pat_box(
916920
&self,
917921
span: Span,

0 commit comments

Comments
 (0)