@@ -182,52 +182,40 @@ impl<'tcx> GotocCtx<'tcx> {
182
182
self . current_fn . as_ref ( ) . map ( |x| self . symbol_name ( x. instance ) )
183
183
}
184
184
185
- /// Pretty name including crate path and trait information. For example:
186
- /// boxtrait_fail::<Concrete as Trait>::increment
187
- /// Generated from the fn instance to insert into/lookup in the symbol table.
188
- /// TODO: internal unit tests https://github.com/model-checking/rmc/issues/172
189
- pub fn pretty_name_from_instance ( & self , instance : Instance < ' tcx > ) -> String {
190
- format ! (
191
- "{}::{}" ,
192
- self . tcx. crate_name( instance. def_id( ) . krate) ,
193
- with_no_trimmed_paths( || instance. to_string( ) )
194
- )
195
- }
196
-
197
185
/// For the vtable field name, we need exactly the dyn trait name and the function
198
186
/// name. The table itself already is scoped by the object type.
199
187
/// Example: ::Shape::vol
200
188
/// Note: this is _not_ the same name for top-level entry into the symbol table,
201
- /// which does need more crate and type information. For now, the symbol table
202
- /// name is from the pretty_name_from_instance function above.
189
+ /// which does need more crate/type information and uses the full symbol_name(...)
203
190
pub fn vtable_field_name ( & self , def_id : DefId ) -> String {
204
191
// `to_string_no_crate_verbose` is from Rust proper, we use it here because it
205
192
// always includes the dyn trait name and function name.
206
193
// Tracking a less brittle solution here: https://github.com/model-checking/rmc/issues/187
207
194
self . tcx . def_path ( def_id) . to_string_no_crate_verbose ( )
208
195
}
209
196
210
- /// a human readable name in rust for reference
211
- pub fn instance_name ( & self , instance : Instance < ' tcx > ) -> String {
197
+ /// A human readable name in Rust for reference, should not be used as a key.
198
+ pub fn readable_instance_name ( & self , instance : Instance < ' tcx > ) -> String {
212
199
with_no_trimmed_paths ( || self . tcx . def_path_str ( instance. def_id ( ) ) )
213
200
}
214
201
215
- /// the actual function name used in the symbol table
202
+ /// The actual function name used in the symbol table
216
203
pub fn symbol_name ( & self , instance : Instance < ' tcx > ) -> String {
217
204
let llvm_mangled = self . tcx . symbol_name ( instance) . name . to_string ( ) ;
218
205
debug ! (
219
206
"finding function name for instance: {}, debug: {:?}, name: {}, symbol: {}, demangle: {}" ,
220
207
instance,
221
208
instance,
222
- self . instance_name ( instance) ,
209
+ self . readable_instance_name ( instance) ,
223
210
llvm_mangled,
224
211
rustc_demangle:: demangle( & llvm_mangled) . to_string( )
225
212
) ;
226
213
227
- let pretty = self . pretty_name_from_instance ( instance) ;
214
+ let pretty = self . readable_instance_name ( instance) ;
228
215
229
- // make main function a special case for easy CBMC entry
230
- if pretty. ends_with ( "::main" ) {
216
+ // Make main function a special case for easy CBMC entry
217
+ // TODO: probably need to edit for https://github.com/model-checking/rmc/issues/169
218
+ if pretty == "main" {
231
219
"main" . to_string ( )
232
220
} else {
233
221
// TODO: llvm mangled string is not very readable. one way to tackle this is to
@@ -460,6 +448,7 @@ impl<'tcx> GotocCtx<'tcx> {
460
448
& fn_name,
461
449
Type :: code ( vec ! [ ] , Type :: constructor ( ) ) ,
462
450
Some ( Stmt :: block ( vec ! [ body] , Location :: none ( ) ) ) , //TODO is this block needed?
451
+ None ,
463
452
Location :: none ( ) ,
464
453
)
465
454
. with_is_file_local ( true )
0 commit comments