@@ -21,11 +21,11 @@ use crate::gotoc::cbmc::goto_program::{
2121use crate :: gotoc:: cbmc:: utils:: aggr_name;
2222use crate :: gotoc:: cbmc:: { MachineModel , RoundingMode } ;
2323use crate :: gotoc:: mir_to_goto:: overrides:: { type_and_fn_hooks, GotocHooks , GotocTypeHooks } ;
24+ use crate :: gotoc:: mir_to_goto:: utils:: full_crate_name;
2425use rustc_data_structures:: owning_ref:: OwningRef ;
2526use rustc_data_structures:: rustc_erase_owner;
2627use rustc_data_structures:: stable_map:: FxHashMap ;
2728use rustc_data_structures:: sync:: MetadataRef ;
28- use rustc_hir:: def_id:: LOCAL_CRATE ;
2929use rustc_middle:: middle:: cstore:: MetadataLoader ;
3030use rustc_middle:: mir:: interpret:: Allocation ;
3131use rustc_middle:: ty:: layout:: { HasParamEnv , HasTyCtxt , TyAndLayout } ;
@@ -43,6 +43,8 @@ pub struct GotocCtx<'tcx> {
4343 pub symbol_table : SymbolTable ,
4444 pub hooks : GotocHooks < ' tcx > ,
4545 pub type_hooks : GotocTypeHooks < ' tcx > ,
46+ /// the full crate name, including versioning info
47+ pub full_crate_name : String ,
4648 /// a global counter for generating unique names for global variables
4749 pub global_var_count : u64 ,
4850 /// map a global allocation to a name in the symbol table
@@ -61,6 +63,7 @@ impl<'tcx> GotocCtx<'tcx> {
6163 symbol_table,
6264 hooks : fhks,
6365 type_hooks : thks,
66+ full_crate_name : full_crate_name ( tcx) ,
6467 global_var_count : 0 ,
6568 alloc_map : FxHashMap :: default ( ) ,
6669 current_fn : None ,
@@ -70,10 +73,6 @@ impl<'tcx> GotocCtx<'tcx> {
7073
7174/// Getters
7275impl < ' tcx > GotocCtx < ' tcx > {
73- pub fn crate_name ( & self ) -> String {
74- self . tcx . crate_name ( LOCAL_CRATE ) . to_string ( )
75- }
76-
7776 pub fn current_fn ( & self ) -> & CurrentFnCtx < ' tcx > {
7877 self . current_fn . as_ref ( ) . unwrap ( )
7978 }
@@ -225,7 +224,7 @@ impl<'tcx> GotocCtx<'tcx> {
225224 pub fn next_global_name ( & mut self ) -> String {
226225 let c = self . global_var_count ;
227226 self . global_var_count += 1 ;
228- format ! ( "{}::global::{}::" , self . tcx . crate_name ( LOCAL_CRATE ) , c)
227+ format ! ( "{}::global::{}::" , self . full_crate_name ( ) , c)
229228 }
230229}
231230
0 commit comments