@@ -5,7 +5,6 @@ use core::ops::ControlFlow;
55
66use hir:: { ExprKind , Param } ;
77use rustc_abi:: FieldIdx ;
8- use rustc_data_structures:: fx:: FxHashMap ;
98use rustc_errors:: { Applicability , Diag } ;
109use rustc_hir:: intravisit:: Visitor ;
1110use rustc_hir:: { self as hir, BindingMode , ByRef , Node } ;
@@ -923,8 +922,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
923922 }
924923 }
925924
926- /// When modifying a binding from inside of an `Fn` closure, point at the binding definition
927- /// and suggest using an `std::sync` type that would allow the code to compile.
925+ /// When modifying a binding from inside of an `Fn` closure, point at the binding definition.
928926 fn point_at_binding_outside_closure (
929927 & self ,
930928 err : & mut Diag < ' _ > ,
@@ -956,31 +954,6 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
956954 && let hir:: def:: Res :: Local ( hir_id) = path. res
957955 && let hir:: Node :: Pat ( pat) = self . infcx . tcx . hir_node ( hir_id)
958956 {
959- let hir = self . infcx . tcx . hir ( ) ;
960- let def_id = hir. enclosing_body_owner ( self . mir_hir_id ( ) ) ;
961- let typeck_results = self . infcx . tcx . typeck ( def_id) ;
962- let ty = typeck_results. node_type_opt ( expr. hir_id ) ;
963- if let Some ( ty) = ty {
964- let mutex = format ! ( "std::sync::atomic::Mutex<{ty}>" ) ;
965- let mutex = mutex. as_str ( ) ;
966- let suggestions: FxHashMap < _ , _ > = [
967- ( self . infcx . tcx . types . isize , "std::sync::atomic::AtomicIsize" ) ,
968- ( self . infcx . tcx . types . usize , "std::sync::atomic::AtomicUsize" ) ,
969- ( self . infcx . tcx . types . i64 , "std::sync::atomic::AtomicI64" ) ,
970- ( self . infcx . tcx . types . u64 , "std::sync::atomic::AtomicU64" ) ,
971- ( self . infcx . tcx . types . i32 , "std::sync::atomic::AtomicI32" ) ,
972- ( self . infcx . tcx . types . u32 , "std::sync::atomic::AtomicU32" ) ,
973- ( self . infcx . tcx . types . i16 , "std::sync::atomic::AtomicI16" ) ,
974- ( self . infcx . tcx . types . u16 , "std::sync::atomic::AtomicU16" ) ,
975- ( self . infcx . tcx . types . i8 , "std::sync::atomic::AtomicI8" ) ,
976- ( self . infcx . tcx . types . u8 , "std::sync::atomic::AtomicU8" ) ,
977- ( self . infcx . tcx . types . bool , "std::sync::atomic::AtomicBool" ) ,
978- ]
979- . into_iter ( )
980- . collect ( ) ;
981- let ty = suggestions. get ( & ty) . unwrap_or ( & mutex) ;
982- err. help ( format ! ( "consider using `{ty}` instead, which allows for multiple threads to access and modify the value" ) ) ;
983- }
984957 let name = upvar. to_string ( self . infcx . tcx ) ;
985958 err. span_label (
986959 pat. span ,
0 commit comments