@@ -23,7 +23,7 @@ use std::mem;
2323use std:: ops;
2424use syntax:: abi;
2525use syntax:: ast:: { self , Name } ;
26- use syntax:: parse:: token:: keywords;
26+ use syntax:: parse:: token:: { keywords, InternedString } ;
2727
2828use serialize:: { Decodable , Decoder , Encodable , Encoder } ;
2929
@@ -440,12 +440,6 @@ pub struct ProjectionTy<'tcx> {
440440 pub item_name : Name ,
441441}
442442
443- impl < ' tcx > ProjectionTy < ' tcx > {
444- pub fn sort_key ( & self ) -> ( DefId , Name ) {
445- ( self . trait_ref . def_id , self . item_name )
446- }
447- }
448-
449443#[ derive( Clone , PartialEq , Eq , Hash , Debug ) ]
450444pub struct BareFnTy < ' tcx > {
451445 pub unsafety : hir:: Unsafety ,
@@ -738,8 +732,17 @@ impl<'a, 'tcx, 'gcx> PolyExistentialProjection<'tcx> {
738732 self . 0 . item_name // safe to skip the binder to access a name
739733 }
740734
741- pub fn sort_key ( & self ) -> ( DefId , Name ) {
742- ( self . 0 . trait_ref . def_id , self . 0 . item_name )
735+ pub fn sort_key ( & self , tcx : TyCtxt < ' a , ' gcx , ' tcx > ) -> ( u64 , InternedString ) {
736+ // We want something here that is stable across crate boundaries.
737+ // The DefId isn't but the `deterministic_hash` of the corresponding
738+ // DefPath is.
739+ let trait_def = tcx. lookup_trait_def ( self . 0 . trait_ref . def_id ) ;
740+ let def_path_hash = trait_def. def_path_hash ;
741+
742+ // An `ast::Name` is also not stable (it's just an index into an
743+ // interning table), so map to the corresponding `InternedString`.
744+ let item_name = self . 0 . item_name . as_str ( ) ;
745+ ( def_path_hash, item_name)
743746 }
744747
745748 pub fn with_self_ty ( & self , tcx : TyCtxt < ' a , ' gcx , ' tcx > ,
0 commit comments