@@ -14,7 +14,7 @@ use rustc::hir::def_id::{DefId};
14
14
use rustc:: infer:: { InferCtxt } ;
15
15
use rustc:: ty:: { self , TyCtxt , ParamEnv } ;
16
16
use rustc:: ty:: maps:: Providers ;
17
- use rustc:: mir:: { AssertMessage , BasicBlock , BorrowKind , Location , Lvalue } ;
17
+ use rustc:: mir:: { AssertMessage , BasicBlock , BorrowKind , Location , Lvalue , Local } ;
18
18
use rustc:: mir:: { Mir , Mutability , Operand , Projection , ProjectionElem , Rvalue } ;
19
19
use rustc:: mir:: { Statement , StatementKind , Terminator , TerminatorKind } ;
20
20
use rustc:: mir:: transform:: { MirSource } ;
@@ -1061,11 +1061,7 @@ impl<'c, 'b, 'a: 'b+'c, 'gcx, 'tcx: 'a> MirBorrowckCtxt<'c, 'b, 'a, 'gcx, 'tcx>
1061
1061
fn append_lvalue_to_string ( & self , lvalue : & Lvalue , buf : & mut String , autoderef : Option < bool > ) {
1062
1062
match * lvalue {
1063
1063
Lvalue :: Local ( local) => {
1064
- let local = & self . mir . local_decls [ local] ;
1065
- match local. name {
1066
- Some ( name) => buf. push_str ( & format ! ( "{}" , name) ) ,
1067
- None => buf. push_str ( "_" ) ,
1068
- }
1064
+ self . append_local_to_string ( local, buf, "_" ) ;
1069
1065
}
1070
1066
Lvalue :: Static ( ref static_) => {
1071
1067
buf. push_str ( & format ! ( "{}" , & self . tcx. item_name( static_. def_id) ) ) ;
@@ -1102,7 +1098,7 @@ impl<'c, 'b, 'a: 'b+'c, 'gcx, 'tcx: 'a> MirBorrowckCtxt<'c, 'b, 'a, 'gcx, 'tcx>
1102
1098
self . append_lvalue_to_string ( & proj. base , buf, Some ( autoderef) ) ;
1103
1099
if let Some ( index) = index_operand {
1104
1100
buf. push_str ( "[" ) ;
1105
- self . append_lvalue_to_string ( & Lvalue :: Local ( index) , buf, None ) ;
1101
+ self . append_local_to_string ( index, buf, ".." ) ;
1106
1102
buf. push_str ( "]" ) ;
1107
1103
} else {
1108
1104
buf. push_str ( & suffix) ;
@@ -1111,6 +1107,16 @@ impl<'c, 'b, 'a: 'b+'c, 'gcx, 'tcx: 'a> MirBorrowckCtxt<'c, 'b, 'a, 'gcx, 'tcx>
1111
1107
}
1112
1108
}
1113
1109
1110
+ // Appends end-user visible description of the `local` lvalue to `buf`. If `local` doesn't have
1111
+ // a name, then `none_string` is appended instead
1112
+ fn append_local_to_string ( & self , local_index : Local , buf : & mut String , none_string : & str ) {
1113
+ let local = & self . mir . local_decls [ local_index] ;
1114
+ match local. name {
1115
+ Some ( name) => buf. push_str ( & format ! ( "{}" , name) ) ,
1116
+ None => buf. push_str ( none_string)
1117
+ }
1118
+ }
1119
+
1114
1120
// End-user visible description of the `field_index`nth field of `base`
1115
1121
fn describe_field ( & self , base : & Lvalue , field_index : usize ) -> String {
1116
1122
match * base {
0 commit comments