@@ -59,7 +59,6 @@ use std::hash::{Hash, Hasher};
59
59
use std:: fmt;
60
60
use std:: mem;
61
61
use std:: ops:: { Deref , Bound } ;
62
- use std:: ptr;
63
62
use std:: iter;
64
63
use std:: sync:: mpsc;
65
64
use std:: sync:: Arc ;
@@ -171,7 +170,7 @@ impl<'gcx: 'tcx, 'tcx> CtxtInterners<'tcx> {
171
170
172
171
// Make sure we don't end up with inference
173
172
// types/regions in the global interner
174
- if ptr :: eq ( local, global) {
173
+ if ptr_eq ( local, global) {
175
174
bug ! ( "Attempted to intern `{:?}` which contains \
176
175
inference types/regions in the global type context",
177
176
& ty_struct) ;
@@ -1163,7 +1162,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
1163
1162
1164
1163
/// Returns `true` if self is the same as self.global_tcx().
1165
1164
fn is_global ( self ) -> bool {
1166
- ptr :: eq ( self . interners , & self . global_interners )
1165
+ ptr_eq ( self . interners , & self . global_interners )
1167
1166
}
1168
1167
1169
1168
/// Creates a type context and call the closure with a `TyCtxt` reference
@@ -1819,12 +1818,11 @@ impl<'a, 'tcx> Lift<'tcx> for &'a mir::interpret::Allocation {
1819
1818
}
1820
1819
1821
1820
pub mod tls {
1822
- use super :: { GlobalCtxt , TyCtxt } ;
1821
+ use super :: { GlobalCtxt , TyCtxt , ptr_eq } ;
1823
1822
1824
1823
use std:: fmt;
1825
1824
use std:: mem;
1826
1825
use std:: marker:: PhantomData ;
1827
- use std:: ptr;
1828
1826
use syntax_pos;
1829
1827
use crate :: ty:: query;
1830
1828
use errors:: { Diagnostic , TRACK_DIAGNOSTICS } ;
@@ -2067,7 +2065,7 @@ pub mod tls {
2067
2065
{
2068
2066
with_context ( |context| {
2069
2067
unsafe {
2070
- assert ! ( ptr :: eq ( context. tcx. gcx, tcx. gcx) ) ;
2068
+ assert ! ( ptr_eq ( context. tcx. gcx, tcx. gcx) ) ;
2071
2069
let context: & ImplicitCtxt < ' _ , ' _ , ' _ > = mem:: transmute ( context) ;
2072
2070
f ( context)
2073
2071
}
@@ -2085,8 +2083,8 @@ pub mod tls {
2085
2083
{
2086
2084
with_context ( |context| {
2087
2085
unsafe {
2088
- assert ! ( ptr :: eq ( context. tcx. gcx, tcx. gcx) ) ;
2089
- assert ! ( ptr :: eq ( context. tcx. interners, tcx. interners) ) ;
2086
+ assert ! ( ptr_eq ( context. tcx. gcx, tcx. gcx) ) ;
2087
+ assert ! ( ptr_eq ( context. tcx. interners, tcx. interners) ) ;
2090
2088
let context: & ImplicitCtxt < ' _ , ' _ , ' _ > = mem:: transmute ( context) ;
2091
2089
f ( context)
2092
2090
}
@@ -2993,6 +2991,12 @@ impl<T, R, E> InternIteratorElement<T, R> for Result<T, E> {
2993
2991
}
2994
2992
}
2995
2993
2994
+ // We are comparing types with different invariant lifetimes, so `ptr::eq`
2995
+ // won't work for us.
2996
+ fn ptr_eq < T , U > ( t : * const T , u : * const U ) -> bool {
2997
+ t as * const ( ) == u as * const ( )
2998
+ }
2999
+
2996
3000
pub fn provide ( providers : & mut ty:: query:: Providers < ' _ > ) {
2997
3001
providers. in_scope_traits_map = |tcx, id| tcx. gcx . trait_map . get ( & id) . cloned ( ) ;
2998
3002
providers. module_exports = |tcx, id| tcx. gcx . export_map . get ( & id) . cloned ( ) ;
0 commit comments