@@ -59,7 +59,6 @@ use std::hash::{Hash, Hasher};
5959use std:: fmt;
6060use std:: mem;
6161use std:: ops:: { Deref , Bound } ;
62- use std:: ptr;
6362use std:: iter;
6463use std:: sync:: mpsc;
6564use std:: sync:: Arc ;
@@ -171,7 +170,7 @@ impl<'gcx: 'tcx, 'tcx> CtxtInterners<'tcx> {
171170
172171 // Make sure we don't end up with inference
173172 // types/regions in the global interner
174- if ptr :: eq ( local, global) {
173+ if ptr_eq ( local, global) {
175174 bug ! ( "Attempted to intern `{:?}` which contains \
176175 inference types/regions in the global type context",
177176 & ty_struct) ;
@@ -1163,7 +1162,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
11631162
11641163 /// Returns `true` if self is the same as self.global_tcx().
11651164 fn is_global ( self ) -> bool {
1166- ptr :: eq ( self . interners , & self . global_interners )
1165+ ptr_eq ( self . interners , & self . global_interners )
11671166 }
11681167
11691168 /// 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 {
18191818}
18201819
18211820pub mod tls {
1822- use super :: { GlobalCtxt , TyCtxt } ;
1821+ use super :: { GlobalCtxt , TyCtxt , ptr_eq } ;
18231822
18241823 use std:: fmt;
18251824 use std:: mem;
18261825 use std:: marker:: PhantomData ;
1827- use std:: ptr;
18281826 use syntax_pos;
18291827 use crate :: ty:: query;
18301828 use errors:: { Diagnostic , TRACK_DIAGNOSTICS } ;
@@ -2067,7 +2065,7 @@ pub mod tls {
20672065 {
20682066 with_context ( |context| {
20692067 unsafe {
2070- assert ! ( ptr :: eq ( context. tcx. gcx, tcx. gcx) ) ;
2068+ assert ! ( ptr_eq ( context. tcx. gcx, tcx. gcx) ) ;
20712069 let context: & ImplicitCtxt < ' _ , ' _ , ' _ > = mem:: transmute ( context) ;
20722070 f ( context)
20732071 }
@@ -2085,8 +2083,8 @@ pub mod tls {
20852083 {
20862084 with_context ( |context| {
20872085 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) ) ;
20902088 let context: & ImplicitCtxt < ' _ , ' _ , ' _ > = mem:: transmute ( context) ;
20912089 f ( context)
20922090 }
@@ -2993,6 +2991,12 @@ impl<T, R, E> InternIteratorElement<T, R> for Result<T, E> {
29932991 }
29942992}
29952993
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+
29963000pub fn provide ( providers : & mut ty:: query:: Providers < ' _ > ) {
29973001 providers. in_scope_traits_map = |tcx, id| tcx. gcx . trait_map . get ( & id) . cloned ( ) ;
29983002 providers. module_exports = |tcx, id| tcx. gcx . export_map . get ( & id) . cloned ( ) ;
0 commit comments