@@ -83,12 +83,12 @@ pub struct Session {
8383 pub plugin_attributes : RefCell < Vec < ( String , AttributeType ) > > ,
8484 pub crate_types : RefCell < Vec < config:: CrateType > > ,
8585 pub dependency_formats : RefCell < dependency_format:: Dependencies > ,
86- /// The crate_disambiguator is constructed out of all the `-C metadata`
86+ /// The crate_disambiguator is constructed out of all the `-C metadata`
8787 /// arguments passed to the compiler. Its value together with the crate-name
8888 /// forms a unique global identifier for the crate. It is used to allow
8989 /// multiple crates with the same name to coexist. See the
9090 /// trans::back::symbol_names module for more information.
91- pub crate_disambiguator : RefCell < Option < Fingerprint > > ,
91+ pub crate_disambiguator : RefCell < Option < CrateDisambiguator > > ,
9292 pub features : RefCell < feature_gate:: Features > ,
9393
9494 /// The maximum recursion limit for potentially infinitely recursive
@@ -165,9 +165,9 @@ enum DiagnosticBuilderMethod {
165165}
166166
167167impl Session {
168- pub fn local_crate_disambiguator ( & self ) -> Fingerprint {
168+ pub fn local_crate_disambiguator ( & self ) -> CrateDisambiguator {
169169 match * self . crate_disambiguator . borrow ( ) {
170- Some ( sym ) => sym ,
170+ Some ( value ) => value ,
171171 None => bug ! ( "accessing disambiguator before initialization" ) ,
172172 }
173173 }
@@ -471,16 +471,17 @@ impl Session {
471471
472472 /// Returns the symbol name for the registrar function,
473473 /// given the crate Svh and the function DefIndex.
474- pub fn generate_plugin_registrar_symbol ( & self , disambiguator : Fingerprint ,
474+ pub fn generate_plugin_registrar_symbol ( & self , disambiguator : CrateDisambiguator ,
475475 index : DefIndex )
476476 -> String {
477- format ! ( "__rustc_plugin_registrar__{}_{}" , disambiguator. to_hex( ) ,
477+ format ! ( "__rustc_plugin_registrar__{}_{}" , disambiguator. to_fingerprint ( ) . to_hex( ) ,
478478 index. as_usize( ) )
479479 }
480480
481- pub fn generate_derive_registrar_symbol ( & self , disambiguator : Fingerprint , index : DefIndex )
481+ pub fn generate_derive_registrar_symbol ( & self , disambiguator : CrateDisambiguator ,
482+ index : DefIndex )
482483 -> String {
483- format ! ( "__rustc_derive_registrar__{}_{}" , disambiguator. to_hex( ) ,
484+ format ! ( "__rustc_derive_registrar__{}_{}" , disambiguator. to_fingerprint ( ) . to_hex( ) ,
484485 index. as_usize( ) )
485486 }
486487
@@ -841,6 +842,26 @@ pub fn build_session_(sopts: config::Options,
841842 sess
842843}
843844
845+ /// Hash value constructed out of all the `-C metadata` arguments passed to the
846+ /// compiler. Together with the crate-name forms a unique global identifier for
847+ /// the crate.
848+ #[ derive( Eq , PartialEq , Ord , PartialOrd , Hash , Debug , Clone , Copy , RustcEncodable , RustcDecodable ) ]
849+ pub struct CrateDisambiguator ( Fingerprint ) ;
850+
851+ impl CrateDisambiguator {
852+ pub fn to_fingerprint ( self ) -> Fingerprint {
853+ self . 0
854+ }
855+ }
856+
857+ impl From < Fingerprint > for CrateDisambiguator {
858+ fn from ( fingerprint : Fingerprint ) -> CrateDisambiguator {
859+ CrateDisambiguator ( fingerprint)
860+ }
861+ }
862+
863+ impl_stable_hash_for ! ( tuple_struct CrateDisambiguator { fingerprint } ) ;
864+
844865/// Holds data on the current incremental compilation session, if there is one.
845866#[ derive( Debug ) ]
846867pub enum IncrCompSession {
0 commit comments