@@ -254,7 +254,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
254
254
self . check_pat_tuple_struct ( pat, qpath, subpats, ddpos, expected, pat_info)
255
255
}
256
256
PatKind :: Path ( ref qpath) => {
257
- self . check_pat_path ( pat, qpath, path_res. unwrap ( ) , expected, ti)
257
+ self . check_pat_path ( pat. hir_id , pat . span , qpath, path_res. unwrap ( ) , expected, ti)
258
258
}
259
259
PatKind :: Struct ( ref qpath, fields, has_rest_pat) => {
260
260
self . check_pat_struct ( pat, qpath, fields, has_rest_pat, expected, pat_info)
@@ -1020,7 +1020,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
1020
1020
1021
1021
fn check_pat_path (
1022
1022
& self ,
1023
- pat : & Pat < ' tcx > ,
1023
+ hir_id : HirId ,
1024
+ span : Span ,
1024
1025
qpath : & hir:: QPath < ' _ > ,
1025
1026
path_resolution : ( Res , Option < LoweredTy < ' tcx > > , & ' tcx [ hir:: PathSegment < ' tcx > ] ) ,
1026
1027
expected : Ty < ' tcx > ,
@@ -1039,8 +1040,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
1039
1040
}
1040
1041
Res :: Def ( DefKind :: AssocFn | DefKind :: Ctor ( _, CtorKind :: Fn ) | DefKind :: Variant , _) => {
1041
1042
let expected = "unit struct, unit variant or constant" ;
1042
- let e =
1043
- report_unexpected_variant_res ( tcx, res, None , qpath, pat. span , E0533 , expected) ;
1043
+ let e = report_unexpected_variant_res ( tcx, res, None , qpath, span, E0533 , expected) ;
1044
1044
return Ty :: new_error ( tcx, e) ;
1045
1045
}
1046
1046
Res :: SelfCtor ( def_id) => {
@@ -1055,7 +1055,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
1055
1055
res,
1056
1056
None ,
1057
1057
qpath,
1058
- pat . span ,
1058
+ span,
1059
1059
E0533 ,
1060
1060
"unit struct" ,
1061
1061
) ;
@@ -1074,11 +1074,11 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
1074
1074
1075
1075
// Type-check the path.
1076
1076
let ( pat_ty, pat_res) =
1077
- self . instantiate_value_path ( segments, opt_ty, res, pat . span , pat . span , pat . hir_id ) ;
1077
+ self . instantiate_value_path ( segments, opt_ty, res, span, span, hir_id) ;
1078
1078
if let Err ( err) =
1079
- self . demand_suptype_with_origin ( & self . pattern_cause ( ti, pat . span ) , expected, pat_ty)
1079
+ self . demand_suptype_with_origin ( & self . pattern_cause ( ti, span) , expected, pat_ty)
1080
1080
{
1081
- self . emit_bad_pat_path ( err, pat , res, pat_res, pat_ty, segments) ;
1081
+ self . emit_bad_pat_path ( err, hir_id , span , res, pat_res, pat_ty, segments) ;
1082
1082
}
1083
1083
pat_ty
1084
1084
}
@@ -1121,13 +1121,13 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
1121
1121
fn emit_bad_pat_path (
1122
1122
& self ,
1123
1123
mut e : Diag < ' _ > ,
1124
- pat : & hir:: Pat < ' tcx > ,
1124
+ hir_id : HirId ,
1125
+ pat_span : Span ,
1125
1126
res : Res ,
1126
1127
pat_res : Res ,
1127
1128
pat_ty : Ty < ' tcx > ,
1128
1129
segments : & ' tcx [ hir:: PathSegment < ' tcx > ] ,
1129
1130
) {
1130
- let pat_span = pat. span ;
1131
1131
if let Some ( span) = self . tcx . hir ( ) . res_span ( pat_res) {
1132
1132
e. span_label ( span, format ! ( "{} defined here" , res. descr( ) ) ) ;
1133
1133
if let [ hir:: PathSegment { ident, .. } ] = & * segments {
@@ -1140,7 +1140,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
1140
1140
res. descr( ) ,
1141
1141
) ,
1142
1142
) ;
1143
- match self . tcx . parent_hir_node ( pat . hir_id ) {
1143
+ match self . tcx . parent_hir_node ( hir_id) {
1144
1144
hir:: Node :: PatField ( ..) => {
1145
1145
e. span_suggestion_verbose (
1146
1146
ident. span . shrink_to_hi ( ) ,
0 commit comments