@@ -15,7 +15,7 @@ use rustc_middle::ty::error::{ExpectedFound, TypeError};
1515use rustc_middle:: ty:: fold:: BottomUpFolder ;
1616use rustc_middle:: ty:: print:: with_no_trimmed_paths;
1717use rustc_middle:: ty:: { self , Article , AssocItem , Ty , TypeAndMut , TypeFoldable } ;
18- use rustc_span:: symbol:: { sym, Symbol } ;
18+ use rustc_span:: symbol:: sym;
1919use rustc_span:: { BytePos , Span , DUMMY_SP } ;
2020use rustc_trait_selection:: infer:: InferCtxtExt as _;
2121use rustc_trait_selection:: traits:: ObligationCause ;
@@ -997,7 +997,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
997997 . collect ( ) ;
998998
999999 let suggestions_for = |variant : & _ , ctor_kind, field_name| {
1000- let prefix = match self . maybe_get_struct_pattern_shorthand_field ( expr) {
1000+ let prefix = match self . tcx . hir ( ) . maybe_get_struct_pattern_shorthand_field ( expr) {
10011001 Some ( ident) => format ! ( "{ident}: " ) ,
10021002 None => String :: new ( ) ,
10031003 } ;
@@ -1240,39 +1240,6 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
12401240 }
12411241 }
12421242
1243- pub ( crate ) fn maybe_get_struct_pattern_shorthand_field (
1244- & self ,
1245- expr : & hir:: Expr < ' _ > ,
1246- ) -> Option < Symbol > {
1247- let hir = self . tcx . hir ( ) ;
1248- let local = match expr {
1249- hir:: Expr {
1250- kind :
1251- hir:: ExprKind :: Path ( hir:: QPath :: Resolved (
1252- None ,
1253- hir:: Path {
1254- res : hir:: def:: Res :: Local ( _) ,
1255- segments : [ hir:: PathSegment { ident, .. } ] ,
1256- ..
1257- } ,
1258- ) ) ,
1259- ..
1260- } => Some ( ident) ,
1261- _ => None ,
1262- } ?;
1263-
1264- match hir. find_parent ( expr. hir_id ) ? {
1265- Node :: ExprField ( field) => {
1266- if field. ident . name == local. name && field. is_shorthand {
1267- return Some ( local. name ) ;
1268- }
1269- }
1270- _ => { }
1271- }
1272-
1273- None
1274- }
1275-
12761243 /// If the given `HirId` corresponds to a block with a trailing expression, return that expression
12771244 pub ( crate ) fn maybe_get_block_expr (
12781245 & self ,
@@ -1467,7 +1434,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
14671434 ) ) ;
14681435 }
14691436
1470- let prefix = match self . maybe_get_struct_pattern_shorthand_field ( expr) {
1437+ let prefix = match self . tcx . hir ( ) . maybe_get_struct_pattern_shorthand_field ( expr) {
14711438 Some ( ident) => format ! ( "{ident}: " ) ,
14721439 None => String :: new ( ) ,
14731440 } ;
@@ -1661,7 +1628,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
16611628 )
16621629 } ;
16631630
1664- let prefix = match self . maybe_get_struct_pattern_shorthand_field ( expr) {
1631+ let prefix = match self . tcx . hir ( ) . maybe_get_struct_pattern_shorthand_field ( expr) {
16651632 Some ( ident) => format ! ( "{ident}: " ) ,
16661633 None => String :: new ( ) ,
16671634 } ;
0 commit comments