@@ -17,7 +17,7 @@ use rustc_middle::mir::interpret::Allocation;
17
17
use rustc_middle:: mir:: { BasicBlock , Body , HasLocalDecls , Local , Operand , Place , Rvalue } ;
18
18
use rustc_middle:: ty:: layout:: { HasParamEnv , HasTyCtxt , TyAndLayout } ;
19
19
use rustc_middle:: ty:: print:: with_no_trimmed_paths;
20
- use rustc_middle:: ty:: { self , Instance , Ty , TyCtxt , TypeFoldable } ;
20
+ use rustc_middle:: ty:: { self , Binder , Instance , TraitRef , Ty , TyCtxt , TypeFoldable } ;
21
21
use rustc_target:: abi:: { HasDataLayout , LayoutOf , TargetDataLayout } ;
22
22
use rustc_target:: spec:: Target ;
23
23
use std:: iter;
@@ -186,10 +186,35 @@ impl<'tcx> GotocCtx<'tcx> {
186
186
self . current_fn . as_ref ( ) . map ( |x| self . symbol_name ( x. instance ) )
187
187
}
188
188
189
- /// a path to the def id. the difference from [instance_name] is that it does not consider generics.
190
- pub fn pretty_name ( & self , did : DefId ) -> String {
191
- let def_path = self . tcx . def_path ( did) ;
192
- format ! ( "{}{}" , self . tcx. crate_name( did. krate) , def_path. to_string_no_crate_verbose( ) )
189
+ /// Pretty name including crate path and trait information. For example:
190
+ /// boxtrait_fail::<Concrete as Trait>::increment
191
+ /// Generated from the fn instance to insert _into_ the symbol table.
192
+ /// Must match the format of pretty_name_from_dynamic_object.
193
+ /// TODO: internal unit tests https://github.com/model-checking/rmc/issues/172
194
+ pub fn pretty_name_from_instance ( & self , instance : Instance < ' tcx > ) -> String {
195
+ format ! (
196
+ "{}::{}" ,
197
+ self . tcx. crate_name( instance. def_id( ) . krate) ,
198
+ with_no_trimmed_paths( || instance. to_string( ) )
199
+ )
200
+ }
201
+
202
+ /// Pretty name including crate path and trait information. For example:
203
+ /// boxtrait_fail::<Concrete as Trait>::increment
204
+ /// Generated from the dynamic object type for _lookup_ from the symbol table.
205
+ /// Must match the format of pretty_name_from_instance.
206
+ pub fn pretty_name_from_dynamic_object (
207
+ & self ,
208
+ def_id : DefId ,
209
+ trait_ref_t : Binder < ' _ , TraitRef < ' tcx > > ,
210
+ ) -> String {
211
+ let normalized_object_type_name = self . normalized_name_of_dynamic_object_type ( trait_ref_t) ;
212
+ format ! (
213
+ "{}::{}::{}" ,
214
+ self . tcx. crate_name( def_id. krate) ,
215
+ normalized_object_type_name,
216
+ self . tcx. item_name( def_id)
217
+ )
193
218
}
194
219
195
220
/// a human readable name in rust for reference
@@ -208,8 +233,8 @@ impl<'tcx> GotocCtx<'tcx> {
208
233
llvm_mangled,
209
234
rustc_demangle:: demangle( & llvm_mangled) . to_string( )
210
235
) ;
211
- let did = instance . def . def_id ( ) ;
212
- let pretty = self . pretty_name ( did ) ;
236
+
237
+ let pretty = self . pretty_name_from_instance ( instance ) ;
213
238
214
239
// make main function a special case for easy CBMC entry
215
240
if pretty. ends_with ( "::main" ) {
0 commit comments