@@ -17,6 +17,7 @@ use Resolver;
17
17
use { names_to_string, module_to_string} ;
18
18
use { resolve_error, ResolutionError } ;
19
19
20
+ use rustc_data_structures:: ptr_key:: PtrKey ;
20
21
use rustc:: ty;
21
22
use rustc:: lint:: builtin:: BuiltinLintDiagnostics ;
22
23
use 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;
33
34
use syntax_pos:: Span ;
34
35
35
36
use std:: cell:: { Cell , RefCell } ;
36
- use std:: mem;
37
+ use std:: { mem, ptr } ;
37
38
38
39
/// Contains data for specific types of import directives.
39
40
#[ derive( Clone , Debug ) ]
@@ -105,8 +106,8 @@ impl<'a> ImportDirective<'a> {
105
106
/// Records information about the resolution of a name in a namespace of a module.
106
107
pub struct NameResolution < ' a > {
107
108
/// 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 > > > ,
110
111
/// The least shadowable known binding for this name, or None if there are no known bindings.
111
112
pub binding : Option < & ' a NameBinding < ' a > > ,
112
113
shadowed_glob : Option < & ' a NameBinding < ' a > > ,
@@ -192,7 +193,6 @@ impl<'a> Resolver<'a> {
192
193
// Check if one of single imports can still define the name,
193
194
// if it can then our result is not determined and can be invalidated.
194
195
for single_import in & resolution. single_imports {
195
- let single_import = unsafe { & * * single_import } ;
196
196
if !self . is_accessible ( single_import. vis . get ( ) ) {
197
197
continue ;
198
198
}
@@ -291,7 +291,7 @@ impl<'a> Resolver<'a> {
291
291
SingleImport { target, type_ns_only, .. } => {
292
292
self . per_ns ( |this, ns| if !type_ns_only || ns == TypeNS {
293
293
let mut resolution = this. resolution ( current_module, target, ns) . borrow_mut ( ) ;
294
- resolution. single_imports . insert ( directive) ;
294
+ resolution. single_imports . insert ( PtrKey ( directive) ) ;
295
295
} ) ;
296
296
}
297
297
// We don't add prelude imports to the globs since they only affect lexical scopes,
@@ -398,7 +398,7 @@ impl<'a> Resolver<'a> {
398
398
_ if old_binding. is_some ( ) => return t,
399
399
None => return t,
400
400
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,
402
402
_ => ( binding, t) ,
403
403
}
404
404
}
@@ -583,7 +583,7 @@ impl<'a, 'b:'a> ImportResolver<'a, 'b> {
583
583
Err ( Undetermined ) => indeterminate = true ,
584
584
Err ( Determined ) => {
585
585
this. update_resolution ( parent, target, ns, |_, resolution| {
586
- resolution. single_imports . remove ( & ( directive as * const _ ) ) ;
586
+ resolution. single_imports . remove ( & PtrKey ( directive) ) ;
587
587
} ) ;
588
588
}
589
589
Ok ( binding) if !binding. is_importable ( ) => {
@@ -916,7 +916,7 @@ impl<'a, 'b:'a> ImportResolver<'a, 'b> {
916
916
917
917
let mut reexports = Vec :: new ( ) ;
918
918
let mut exported_macro_names = FxHashMap ( ) ;
919
- if module as * const _ == self . graph_root as * const _ {
919
+ if ptr :: eq ( module, self . graph_root ) {
920
920
let macro_exports = mem:: replace ( & mut self . macro_exports , Vec :: new ( ) ) ;
921
921
for export in macro_exports. into_iter ( ) . rev ( ) {
922
922
if let Some ( later_span) = exported_macro_names. insert ( export. ident . modern ( ) ,
0 commit comments