@@ -29,8 +29,6 @@ use rustc_data_structures::indexed_set::IdxSetBuf;
29
29
use rustc_data_structures:: indexed_vec:: Idx ;
30
30
use rustc_data_structures:: small_vec:: SmallVec ;
31
31
32
- use core:: unicode:: property:: Pattern_White_Space ;
33
-
34
32
use std:: rc:: Rc ;
35
33
36
34
use syntax_pos:: Span ;
@@ -46,6 +44,7 @@ use dataflow::{EverInitializedPlaces, MovingOutStatements};
46
44
use dataflow:: { MaybeInitializedPlaces , MaybeUninitializedPlaces } ;
47
45
use util:: borrowck_errors:: { BorrowckErrors , Origin } ;
48
46
use util:: collect_writes:: FindAssignments ;
47
+ use util:: suggest_ref_mut;
49
48
50
49
use self :: borrow_set:: { BorrowData , BorrowSet } ;
51
50
use self :: flows:: Flows ;
@@ -1861,7 +1860,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
1861
1860
ClearCrossCrate :: Set ( mir:: BindingForm :: Var ( mir:: VarBindingForm {
1862
1861
binding_mode : ty:: BindingMode :: BindByReference ( _) ,
1863
1862
..
1864
- } ) ) => suggest_ref_mut ( self . tcx , local_decl) ,
1863
+ } ) ) => suggest_ref_mut ( self . tcx , local_decl. source_info . span ) ,
1865
1864
1866
1865
ClearCrossCrate :: Clear => bug ! ( "saw cleared local state" ) ,
1867
1866
} ;
@@ -1957,22 +1956,6 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
1957
1956
assert_eq ! ( ty_mut. mutbl, hir:: MutImmutable ) ;
1958
1957
( highlight_span, format ! ( "&mut {}" , ty_mut. ty) )
1959
1958
}
1960
-
1961
- fn suggest_ref_mut < ' cx , ' gcx , ' tcx > (
1962
- tcx : TyCtxt < ' cx , ' gcx , ' tcx > ,
1963
- local_decl : & mir:: LocalDecl < ' tcx > ,
1964
- ) -> Option < ( Span , String ) > {
1965
- let hi_span = local_decl. source_info . span ;
1966
- let hi_src = tcx. sess . codemap ( ) . span_to_snippet ( hi_span) . unwrap ( ) ;
1967
- if hi_src. starts_with ( "ref" )
1968
- && hi_src[ "ref" . len ( ) ..] . starts_with ( Pattern_White_Space )
1969
- {
1970
- let suggestion = format ! ( "ref mut{}" , & hi_src[ "ref" . len( ) ..] ) ;
1971
- Some ( ( hi_span, suggestion) )
1972
- } else {
1973
- None
1974
- }
1975
- }
1976
1959
}
1977
1960
1978
1961
/// Adds the place into the used mutable variables set
0 commit comments