@@ -279,7 +279,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
279
279
self . check_pat_tuple_struct ( pat, qpath, subpats, ddpos, expected, pat_info)
280
280
}
281
281
PatKind :: Path ( ref qpath) => {
282
- self . check_pat_path ( pat, qpath, path_res. unwrap ( ) , expected, ti)
282
+ self . check_pat_path ( pat. hir_id , pat . span , qpath, path_res. unwrap ( ) , expected, ti)
283
283
}
284
284
PatKind :: Struct ( ref qpath, fields, has_rest_pat) => {
285
285
self . check_pat_struct ( pat, qpath, fields, has_rest_pat, expected, pat_info)
@@ -1053,7 +1053,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
1053
1053
1054
1054
fn check_pat_path (
1055
1055
& self ,
1056
- pat : & Pat < ' tcx > ,
1056
+ hir_id : HirId ,
1057
+ span : Span ,
1057
1058
qpath : & hir:: QPath < ' _ > ,
1058
1059
path_resolution : ( Res , Option < LoweredTy < ' tcx > > , & ' tcx [ hir:: PathSegment < ' tcx > ] ) ,
1059
1060
expected : Ty < ' tcx > ,
@@ -1072,8 +1073,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
1072
1073
}
1073
1074
Res :: Def ( DefKind :: AssocFn | DefKind :: Ctor ( _, CtorKind :: Fn ) | DefKind :: Variant , _) => {
1074
1075
let expected = "unit struct, unit variant or constant" ;
1075
- let e =
1076
- report_unexpected_variant_res ( tcx, res, None , qpath, pat. span , E0533 , expected) ;
1076
+ let e = report_unexpected_variant_res ( tcx, res, None , qpath, span, E0533 , expected) ;
1077
1077
return Ty :: new_error ( tcx, e) ;
1078
1078
}
1079
1079
Res :: SelfCtor ( def_id) => {
@@ -1088,7 +1088,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
1088
1088
res,
1089
1089
None ,
1090
1090
qpath,
1091
- pat . span ,
1091
+ span,
1092
1092
E0533 ,
1093
1093
"unit struct" ,
1094
1094
) ;
@@ -1107,11 +1107,11 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
1107
1107
1108
1108
// Type-check the path.
1109
1109
let ( pat_ty, pat_res) =
1110
- self . instantiate_value_path ( segments, opt_ty, res, pat . span , pat . span , pat . hir_id ) ;
1110
+ self . instantiate_value_path ( segments, opt_ty, res, span, span, hir_id) ;
1111
1111
if let Err ( err) =
1112
- self . demand_suptype_with_origin ( & self . pattern_cause ( ti, pat . span ) , expected, pat_ty)
1112
+ self . demand_suptype_with_origin ( & self . pattern_cause ( ti, span) , expected, pat_ty)
1113
1113
{
1114
- self . emit_bad_pat_path ( err, pat , res, pat_res, pat_ty, segments) ;
1114
+ self . emit_bad_pat_path ( err, hir_id , span , res, pat_res, pat_ty, segments) ;
1115
1115
}
1116
1116
pat_ty
1117
1117
}
@@ -1154,13 +1154,13 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
1154
1154
fn emit_bad_pat_path (
1155
1155
& self ,
1156
1156
mut e : Diag < ' _ > ,
1157
- pat : & hir:: Pat < ' tcx > ,
1157
+ hir_id : HirId ,
1158
+ pat_span : Span ,
1158
1159
res : Res ,
1159
1160
pat_res : Res ,
1160
1161
pat_ty : Ty < ' tcx > ,
1161
1162
segments : & ' tcx [ hir:: PathSegment < ' tcx > ] ,
1162
1163
) {
1163
- let pat_span = pat. span ;
1164
1164
if let Some ( span) = self . tcx . hir ( ) . res_span ( pat_res) {
1165
1165
e. span_label ( span, format ! ( "{} defined here" , res. descr( ) ) ) ;
1166
1166
if let [ hir:: PathSegment { ident, .. } ] = & * segments {
@@ -1173,7 +1173,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
1173
1173
res. descr( ) ,
1174
1174
) ,
1175
1175
) ;
1176
- match self . tcx . parent_hir_node ( pat . hir_id ) {
1176
+ match self . tcx . parent_hir_node ( hir_id) {
1177
1177
hir:: Node :: PatField ( ..) => {
1178
1178
e. span_suggestion_verbose (
1179
1179
ident. span . shrink_to_hi ( ) ,
0 commit comments