@@ -17,6 +17,7 @@ use Resolver;
1717use { names_to_string, module_to_string} ;
1818use { resolve_error, ResolutionError } ;
1919
20+ use rustc_data_structures:: ptr_key:: PtrKey ;
2021use rustc:: ty;
2122use rustc:: lint:: builtin:: BuiltinLintDiagnostics ;
2223use rustc:: lint:: builtin:: { DUPLICATE_MACRO_EXPORTS , PUB_USE_OF_PRIVATE_EXTERN_CRATE } ;
@@ -33,7 +34,7 @@ use syntax::util::lev_distance::find_best_match_for_name;
3334use syntax_pos:: Span ;
3435
3536use std:: cell:: { Cell , RefCell } ;
36- use std:: mem;
37+ use std:: { mem, ptr } ;
3738
3839/// Contains data for specific types of import directives.
3940#[ derive( Clone , Debug ) ]
@@ -105,8 +106,8 @@ impl<'a> ImportDirective<'a> {
105106/// Records information about the resolution of a name in a namespace of a module.
106107pub struct NameResolution < ' a > {
107108 /// Single imports that may define the name in the namespace.
108- /// Import directives are arena-allocated, so it's ok to use pointers as keys, they are stable .
109- single_imports : FxHashSet < * const ImportDirective < ' a > > ,
109+ /// Import directives are arena-allocated, so it's ok to use pointers as keys.
110+ single_imports : FxHashSet < PtrKey < ' a , ImportDirective < ' a > > > ,
110111 /// The least shadowable known binding for this name, or None if there are no known bindings.
111112 pub binding : Option < & ' a NameBinding < ' a > > ,
112113 shadowed_glob : Option < & ' a NameBinding < ' a > > ,
@@ -192,7 +193,6 @@ impl<'a> Resolver<'a> {
192193 // Check if one of single imports can still define the name,
193194 // if it can then our result is not determined and can be invalidated.
194195 for single_import in & resolution. single_imports {
195- let single_import = unsafe { & * * single_import } ;
196196 if !self . is_accessible ( single_import. vis . get ( ) ) {
197197 continue ;
198198 }
@@ -291,7 +291,7 @@ impl<'a> Resolver<'a> {
291291 SingleImport { target, type_ns_only, .. } => {
292292 self . per_ns ( |this, ns| if !type_ns_only || ns == TypeNS {
293293 let mut resolution = this. resolution ( current_module, target, ns) . borrow_mut ( ) ;
294- resolution. single_imports . insert ( directive) ;
294+ resolution. single_imports . insert ( PtrKey ( directive) ) ;
295295 } ) ;
296296 }
297297 // We don't add prelude imports to the globs since they only affect lexical scopes,
@@ -398,7 +398,7 @@ impl<'a> Resolver<'a> {
398398 _ if old_binding. is_some ( ) => return t,
399399 None => return t,
400400 Some ( binding) => match old_binding {
401- Some ( old_binding) if old_binding as * const _ == binding as * const _ => return t,
401+ Some ( old_binding) if ptr :: eq ( old_binding, binding) => return t,
402402 _ => ( binding, t) ,
403403 }
404404 }
@@ -583,7 +583,7 @@ impl<'a, 'b:'a> ImportResolver<'a, 'b> {
583583 Err ( Undetermined ) => indeterminate = true ,
584584 Err ( Determined ) => {
585585 this. update_resolution ( parent, target, ns, |_, resolution| {
586- resolution. single_imports . remove ( & ( directive as * const _ ) ) ;
586+ resolution. single_imports . remove ( & PtrKey ( directive) ) ;
587587 } ) ;
588588 }
589589 Ok ( binding) if !binding. is_importable ( ) => {
@@ -916,7 +916,7 @@ impl<'a, 'b:'a> ImportResolver<'a, 'b> {
916916
917917 let mut reexports = Vec :: new ( ) ;
918918 let mut exported_macro_names = FxHashMap ( ) ;
919- if module as * const _ == self . graph_root as * const _ {
919+ if ptr :: eq ( module, self . graph_root ) {
920920 let macro_exports = mem:: replace ( & mut self . macro_exports , Vec :: new ( ) ) ;
921921 for export in macro_exports. into_iter ( ) . rev ( ) {
922922 if let Some ( later_span) = exported_macro_names. insert ( export. ident . modern ( ) ,
0 commit comments