@@ -774,14 +774,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
774
774
let ident = tcx. adjust_ident ( field. ident , variant. def_id ) ;
775
775
let field_ty = match used_fields. entry ( ident) {
776
776
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 ( ) ) ;
785
778
no_field_errors = false ;
786
779
tcx. types . err
787
780
}
@@ -912,6 +905,17 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
912
905
no_field_errors
913
906
}
914
907
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
+
915
919
fn check_pat_box (
916
920
& self ,
917
921
span : Span ,
0 commit comments