@@ -60,7 +60,9 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
60
60
. cannot_act_on_uninitialized_variable (
61
61
span,
62
62
desired_action. as_noun ( ) ,
63
- & self . describe_place_with_options ( place, IncludingDowncast ( true ) ) . unwrap_or ( "_" . to_owned ( ) ) ,
63
+ & self
64
+ . describe_place_with_options ( place, IncludingDowncast ( true ) )
65
+ . unwrap_or ( "_" . to_owned ( ) ) ,
64
66
Origin :: Mir ,
65
67
)
66
68
. span_label ( span, format ! ( "use of possibly uninitialized {}" , item_msg) )
@@ -79,7 +81,10 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
79
81
let mut is_loop_move = false ;
80
82
for moi in & mois {
81
83
let move_msg = "" ; //FIXME: add " (into closure)"
82
- let move_span = self . mir . source_info ( self . move_data . moves [ * * moi] . source ) . span ;
84
+ let move_span = self
85
+ . mir
86
+ . source_info ( self . move_data . moves [ * * moi] . source )
87
+ . span ;
83
88
if span == move_span {
84
89
err. span_label (
85
90
span,
@@ -120,7 +125,9 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
120
125
let place = & self . move_data . move_paths [ mpi] . place ;
121
126
122
127
if let Some ( ty) = self . retrieve_type_for_place ( place) {
123
- let note_msg = match self . describe_place_with_options ( place, IncludingDowncast ( true ) ) {
128
+ let note_msg = match self
129
+ . describe_place_with_options ( place, IncludingDowncast ( true ) )
130
+ {
124
131
Some ( name) => format ! ( "`{}`" , name) ,
125
132
None => "value" . to_owned ( ) ,
126
133
} ;
@@ -649,8 +656,10 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
649
656
let local_decl = & self . mir . local_decls [ * local] ;
650
657
if let Some ( name) = local_decl. name {
651
658
if local_decl. can_be_made_mutable ( ) {
652
- err. span_label ( local_decl. source_info . span ,
653
- format ! ( "consider changing this to `mut {}`" , name) ) ;
659
+ err. span_label (
660
+ local_decl. source_info . span ,
661
+ format ! ( "consider changing this to `mut {}`" , name) ,
662
+ ) ;
654
663
}
655
664
}
656
665
}
@@ -672,7 +681,11 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
672
681
// place is a temporary for instance, None will be returned.
673
682
// `IncludingDowncast` parameter makes the function return `Err` if `ProjectionElem` is
674
683
// `Downcast` and `IncludingDowncast` is true
675
- pub ( super ) fn describe_place_with_options ( & self , place : & Place < ' tcx > , including_downcast : IncludingDowncast ) -> Option < String > {
684
+ pub ( super ) fn describe_place_with_options (
685
+ & self ,
686
+ place : & Place < ' tcx > ,
687
+ including_downcast : IncludingDowncast ,
688
+ ) -> Option < String > {
676
689
let mut buf = String :: new ( ) ;
677
690
match self . append_place_to_string ( place, & mut buf, false , & including_downcast) {
678
691
Ok ( ( ) ) => Some ( buf) ,
@@ -708,15 +721,30 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
708
721
}
709
722
} else {
710
723
if autoderef {
711
- self . append_place_to_string ( & proj. base , buf, autoderef, & including_downcast) ?;
724
+ self . append_place_to_string (
725
+ & proj. base ,
726
+ buf,
727
+ autoderef,
728
+ & including_downcast,
729
+ ) ?;
712
730
} else {
713
731
buf. push_str ( & "*" ) ;
714
- self . append_place_to_string ( & proj. base , buf, autoderef, & including_downcast) ?;
732
+ self . append_place_to_string (
733
+ & proj. base ,
734
+ buf,
735
+ autoderef,
736
+ & including_downcast,
737
+ ) ?;
715
738
}
716
739
}
717
740
}
718
741
ProjectionElem :: Downcast ( ..) => {
719
- self . append_place_to_string ( & proj. base , buf, autoderef, & including_downcast) ?;
742
+ self . append_place_to_string (
743
+ & proj. base ,
744
+ buf,
745
+ autoderef,
746
+ & including_downcast,
747
+ ) ?;
720
748
if including_downcast. 0 {
721
749
return Err ( ( ) ) ;
722
750
}
@@ -730,14 +758,24 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
730
758
buf. push_str ( & name) ;
731
759
} else {
732
760
let field_name = self . describe_field ( & proj. base , field) ;
733
- self . append_place_to_string ( & proj. base , buf, autoderef, & including_downcast) ?;
761
+ self . append_place_to_string (
762
+ & proj. base ,
763
+ buf,
764
+ autoderef,
765
+ & including_downcast,
766
+ ) ?;
734
767
buf. push_str ( & format ! ( ".{}" , field_name) ) ;
735
768
}
736
769
}
737
770
ProjectionElem :: Index ( index) => {
738
771
autoderef = true ;
739
772
740
- self . append_place_to_string ( & proj. base , buf, autoderef, & including_downcast) ?;
773
+ self . append_place_to_string (
774
+ & proj. base ,
775
+ buf,
776
+ autoderef,
777
+ & including_downcast,
778
+ ) ?;
741
779
buf. push_str ( "[" ) ;
742
780
if let Err ( _) = self . append_local_to_string ( index, buf) {
743
781
buf. push_str ( ".." ) ;
@@ -749,7 +787,12 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
749
787
// Since it isn't possible to borrow an element on a particular index and
750
788
// then use another while the borrow is held, don't output indices details
751
789
// to avoid confusing the end-user
752
- self . append_place_to_string ( & proj. base , buf, autoderef, & including_downcast) ?;
790
+ self . append_place_to_string (
791
+ & proj. base ,
792
+ buf,
793
+ autoderef,
794
+ & including_downcast,
795
+ ) ?;
753
796
buf. push_str ( & "[..]" ) ;
754
797
}
755
798
} ;
0 commit comments