@@ -59,6 +59,7 @@ 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;
62
63
use std:: iter;
63
64
use std:: sync:: mpsc;
64
65
use std:: sync:: Arc ;
@@ -168,7 +169,7 @@ impl<'gcx: 'tcx, 'tcx> CtxtInterners<'tcx> {
168
169
169
170
// Make sure we don't end up with inference
170
171
// types/regions in the global interner
171
- if local as * const _ as usize == global as * const _ as usize {
172
+ if ptr :: eq ( local, global) {
172
173
bug ! ( "Attempted to intern `{:?}` which contains \
173
174
inference types/regions in the global type context",
174
175
& ty_struct) ;
@@ -1125,9 +1126,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
1125
1126
1126
1127
/// Returns true if self is the same as self.global_tcx().
1127
1128
fn is_global ( self ) -> bool {
1128
- let local = self . interners as * const _ ;
1129
- let global = & self . global_interners as * const _ ;
1130
- local as usize == global as usize
1129
+ ptr:: eq ( self . interners , & self . global_interners )
1131
1130
}
1132
1131
1133
1132
/// Create a type context and call the closure with a `TyCtxt` reference
@@ -1777,6 +1776,7 @@ pub mod tls {
1777
1776
use std:: fmt;
1778
1777
use std:: mem;
1779
1778
use std:: marker:: PhantomData ;
1779
+ use std:: ptr;
1780
1780
use syntax_pos;
1781
1781
use ty:: query;
1782
1782
use errors:: { Diagnostic , TRACK_DIAGNOSTICS } ;
@@ -2011,8 +2011,7 @@ pub mod tls {
2011
2011
{
2012
2012
with_context ( |context| {
2013
2013
unsafe {
2014
- let gcx = tcx. gcx as * const _ as usize ;
2015
- assert ! ( context. tcx. gcx as * const _ as usize == gcx) ;
2014
+ assert ! ( ptr:: eq( context. tcx. gcx, tcx. gcx) ) ;
2016
2015
let context: & ImplicitCtxt < ' _ , ' _ , ' _ > = mem:: transmute ( context) ;
2017
2016
f ( context)
2018
2017
}
@@ -2030,10 +2029,8 @@ pub mod tls {
2030
2029
{
2031
2030
with_context ( |context| {
2032
2031
unsafe {
2033
- let gcx = tcx. gcx as * const _ as usize ;
2034
- let interners = tcx. interners as * const _ as usize ;
2035
- assert ! ( context. tcx. gcx as * const _ as usize == gcx) ;
2036
- assert ! ( context. tcx. interners as * const _ as usize == interners) ;
2032
+ assert ! ( ptr:: eq( context. tcx. gcx, tcx. gcx) ) ;
2033
+ assert ! ( ptr:: eq( context. tcx. interners, tcx. interners) ) ;
2037
2034
let context: & ImplicitCtxt < ' _ , ' _ , ' _ > = mem:: transmute ( context) ;
2038
2035
f ( context)
2039
2036
}
0 commit comments