@@ -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)
@@ -1045,7 +1045,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
1045
1045
1046
1046
fn check_pat_path (
1047
1047
& self ,
1048
- pat : & Pat < ' tcx > ,
1048
+ hir_id : HirId ,
1049
+ span : Span ,
1049
1050
qpath : & hir:: QPath < ' _ > ,
1050
1051
path_resolution : ( Res , Option < LoweredTy < ' tcx > > , & ' tcx [ hir:: PathSegment < ' tcx > ] ) ,
1051
1052
expected : Ty < ' tcx > ,
@@ -1064,8 +1065,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
1064
1065
}
1065
1066
Res :: Def ( DefKind :: AssocFn | DefKind :: Ctor ( _, CtorKind :: Fn ) | DefKind :: Variant , _) => {
1066
1067
let expected = "unit struct, unit variant or constant" ;
1067
- let e =
1068
- report_unexpected_variant_res ( tcx, res, None , qpath, pat. span , E0533 , expected) ;
1068
+ let e = report_unexpected_variant_res ( tcx, res, None , qpath, span, E0533 , expected) ;
1069
1069
return Ty :: new_error ( tcx, e) ;
1070
1070
}
1071
1071
Res :: SelfCtor ( def_id) => {
@@ -1080,7 +1080,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
1080
1080
res,
1081
1081
None ,
1082
1082
qpath,
1083
- pat . span ,
1083
+ span,
1084
1084
E0533 ,
1085
1085
"unit struct" ,
1086
1086
) ;
@@ -1099,11 +1099,11 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
1099
1099
1100
1100
// Type-check the path.
1101
1101
let ( pat_ty, pat_res) =
1102
- self . instantiate_value_path ( segments, opt_ty, res, pat . span , pat . span , pat . hir_id ) ;
1102
+ self . instantiate_value_path ( segments, opt_ty, res, span, span, hir_id) ;
1103
1103
if let Err ( err) =
1104
- self . demand_suptype_with_origin ( & self . pattern_cause ( ti, pat . span ) , expected, pat_ty)
1104
+ self . demand_suptype_with_origin ( & self . pattern_cause ( ti, span) , expected, pat_ty)
1105
1105
{
1106
- self . emit_bad_pat_path ( err, pat , res, pat_res, pat_ty, segments) ;
1106
+ self . emit_bad_pat_path ( err, hir_id , span , res, pat_res, pat_ty, segments) ;
1107
1107
}
1108
1108
pat_ty
1109
1109
}
@@ -1146,13 +1146,13 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
1146
1146
fn emit_bad_pat_path (
1147
1147
& self ,
1148
1148
mut e : Diag < ' _ > ,
1149
- pat : & hir:: Pat < ' tcx > ,
1149
+ hir_id : HirId ,
1150
+ pat_span : Span ,
1150
1151
res : Res ,
1151
1152
pat_res : Res ,
1152
1153
pat_ty : Ty < ' tcx > ,
1153
1154
segments : & ' tcx [ hir:: PathSegment < ' tcx > ] ,
1154
1155
) {
1155
- let pat_span = pat. span ;
1156
1156
if let Some ( span) = self . tcx . hir ( ) . res_span ( pat_res) {
1157
1157
e. span_label ( span, format ! ( "{} defined here" , res. descr( ) ) ) ;
1158
1158
if let [ hir:: PathSegment { ident, .. } ] = & * segments {
@@ -1165,7 +1165,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
1165
1165
res. descr( ) ,
1166
1166
) ,
1167
1167
) ;
1168
- match self . tcx . parent_hir_node ( pat . hir_id ) {
1168
+ match self . tcx . parent_hir_node ( hir_id) {
1169
1169
hir:: Node :: PatField ( ..) => {
1170
1170
e. span_suggestion_verbose (
1171
1171
ident. span . shrink_to_hi ( ) ,
0 commit comments