33//! This module provides facilities to record item correspondence of various kinds, as well as a
44//! map used to temporarily match up unsorted item sequences' elements by name.
55
6- use rustc:: {
7- hir:: {
8- def:: { Export , Res } ,
9- def_id:: { CrateNum , DefId } ,
10- HirId ,
11- } ,
6+ use rustc_ast:: ast:: Name ;
7+ use rustc_hir:: {
8+ def:: Res ,
9+ def_id:: { CrateNum , DefId } ,
10+ HirId ,
11+ } ;
12+ use rustc_middle:: {
13+ hir:: exports:: Export ,
1214 ty:: { AssocKind , GenericParamDef , GenericParamDefKind } ,
1315} ;
1416use std:: collections:: { BTreeSet , HashMap , HashSet , VecDeque } ;
1517use std:: hash:: { Hash , Hasher } ;
16- use syntax:: ast:: Name ;
1718
1819/// A description of an item found in an inherent impl.
1920#[ derive( Debug , PartialEq ) ]
@@ -40,6 +41,7 @@ fn assert_inherent_entry_members_impl_eq() {
4041 assert_impl_eq :: < Name > ( ) ;
4142}
4243
44+ #[ allow( clippy:: derive_hash_xor_eq) ]
4345impl Hash for InherentEntry {
4446 fn hash < H : Hasher > ( & self , hasher : & mut H ) {
4547 self . parent_def_id . hash ( hasher) ;
@@ -111,14 +113,19 @@ impl IdMapping {
111113
112114 /// Register two exports representing the same item across versions.
113115 pub fn add_export ( & mut self , old : Res , new : Res ) -> bool {
114- let old_def_id = old. def_id ( ) ;
116+ let ( old_def_id, new_def_id) =
117+ if let ( Some ( old_def_id) , Some ( new_def_id) ) = ( old. opt_def_id ( ) , new. opt_def_id ( ) ) {
118+ ( old_def_id, new_def_id)
119+ } else {
120+ return false ;
121+ } ;
115122
116123 if !self . in_old_crate ( old_def_id) || self . toplevel_mapping . contains_key ( & old_def_id) {
117124 return false ;
118125 }
119126
120127 self . toplevel_mapping . insert ( old_def_id, ( old, new) ) ;
121- self . reverse_mapping . insert ( new . def_id ( ) , old_def_id) ;
128+ self . reverse_mapping . insert ( new_def_id , old_def_id) ;
122129
123130 true
124131 }
@@ -343,8 +350,8 @@ pub struct NameMapping {
343350impl NameMapping {
344351 /// Insert a single export in the appropriate map, at the appropriate position.
345352 fn insert ( & mut self , item : Export < HirId > , old : bool ) {
346- use rustc :: hir :: def:: DefKind :: * ;
347- use rustc :: hir :: def:: Res :: * ;
353+ use rustc_hir :: def:: DefKind :: * ;
354+ use rustc_hir :: def:: Res :: * ;
348355
349356 let map = match item. res {
350357 Def ( kind, _) => match kind {
@@ -366,7 +373,7 @@ impl NameMapping {
366373 ConstParam |
367374 Static |
368375 Ctor ( _, _) |
369- Method |
376+ AssocFn |
370377 AssocConst => Some ( & mut self . value_map ) ,
371378 Macro ( _) => Some ( & mut self . macro_map ) ,
372379 } ,
0 commit comments