@@ -45,12 +45,12 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
4545 let item_msg;
4646 let reason;
4747 let mut opt_source = None ;
48- let access_place_desc = self . describe_place ( access_place. as_ref ( ) ) ;
48+ let access_place_desc = self . describe_any_place ( access_place. as_ref ( ) ) ;
4949 debug ! ( "report_mutability_error: access_place_desc={:?}" , access_place_desc) ;
5050
5151 match the_place_err {
5252 PlaceRef { local, projection : [ ] } => {
53- item_msg = format ! ( "`{}`" , access_place_desc. unwrap ( ) ) ;
53+ item_msg = access_place_desc;
5454 if access_place. as_local ( ) . is_some ( ) {
5555 reason = ", as it is not declared as mutable" . to_string ( ) ;
5656 } else {
@@ -83,7 +83,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
8383 // If we deref an immutable ref then the suggestion here doesn't help.
8484 return ;
8585 } else {
86- item_msg = format ! ( "`{}`" , access_place_desc. unwrap ( ) ) ;
86+ item_msg = access_place_desc;
8787 if self . is_upvar_field_projection ( access_place. as_ref ( ) ) . is_some ( ) {
8888 reason = ", as it is not declared as mutable" . to_string ( ) ;
8989 } else {
@@ -96,17 +96,17 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
9696 PlaceRef { local, projection : [ ProjectionElem :: Deref ] }
9797 if self . body . local_decls [ local] . is_ref_for_guard ( ) =>
9898 {
99- item_msg = format ! ( "`{}`" , access_place_desc. unwrap ( ) ) ;
99+ item_msg = access_place_desc;
100100 reason = ", as it is immutable for the pattern guard" . to_string ( ) ;
101101 }
102102 PlaceRef { local, projection : [ ProjectionElem :: Deref ] }
103103 if self . body . local_decls [ local] . is_ref_to_static ( ) =>
104104 {
105105 if access_place. projection . len ( ) == 1 {
106- item_msg = format ! ( "immutable static item `{}` " , access_place_desc. unwrap ( ) ) ;
106+ item_msg = format ! ( "immutable static item {} " , access_place_desc) ;
107107 reason = String :: new ( ) ;
108108 } else {
109- item_msg = format ! ( "`{}`" , access_place_desc. unwrap ( ) ) ;
109+ item_msg = access_place_desc;
110110 let local_info = & self . body . local_decls [ local] . local_info ;
111111 if let Some ( box LocalInfo :: StaticRef { def_id, .. } ) = * local_info {
112112 let static_name = & self . infcx . tcx . item_name ( def_id) ;
@@ -121,7 +121,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
121121 && proj_base. is_empty ( )
122122 && !self . upvars . is_empty ( )
123123 {
124- item_msg = format ! ( "`{}`" , access_place_desc. unwrap ( ) ) ;
124+ item_msg = access_place_desc;
125125 debug_assert ! (
126126 self . body. local_decls[ ty:: CAPTURE_STRUCT_LOCAL ] . ty. is_region_ptr( )
127127 ) ;
@@ -147,7 +147,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
147147 } ) ;
148148 let pointer_type = source. describe_for_immutable_place ( self . infcx . tcx ) ;
149149 opt_source = Some ( source) ;
150- if let Some ( desc) = access_place_desc {
150+ if let Some ( desc) = self . describe_place ( access_place . as_ref ( ) ) {
151151 item_msg = format ! ( "`{}`" , desc) ;
152152 reason = match error_access {
153153 AccessKind :: Mutate => format ! ( ", which is behind {}" , pointer_type) ,
0 commit comments