@@ -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) ;
@@ -1135,9 +1136,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
1135
1136
1136
1137
/// Returns true if self is the same as self.global_tcx().
1137
1138
fn is_global ( self ) -> bool {
1138
- let local = self . interners as * const _ ;
1139
- let global = & self . global_interners as * const _ ;
1140
- local as usize == global as usize
1139
+ ptr:: eq ( self . interners , & self . global_interners )
1141
1140
}
1142
1141
1143
1142
/// Create a type context and call the closure with a `TyCtxt` reference
@@ -1787,6 +1786,7 @@ pub mod tls {
1787
1786
use std:: fmt;
1788
1787
use std:: mem;
1789
1788
use std:: marker:: PhantomData ;
1789
+ use std:: ptr;
1790
1790
use syntax_pos;
1791
1791
use ty:: query;
1792
1792
use errors:: { Diagnostic , TRACK_DIAGNOSTICS } ;
@@ -2021,8 +2021,7 @@ pub mod tls {
2021
2021
{
2022
2022
with_context ( |context| {
2023
2023
unsafe {
2024
- let gcx = tcx. gcx as * const _ as usize ;
2025
- assert ! ( context. tcx. gcx as * const _ as usize == gcx) ;
2024
+ assert ! ( ptr:: eq( context. tcx. gcx, tcx. gcx) ) ;
2026
2025
let context: & ImplicitCtxt < ' _ , ' _ , ' _ > = mem:: transmute ( context) ;
2027
2026
f ( context)
2028
2027
}
@@ -2040,10 +2039,8 @@ pub mod tls {
2040
2039
{
2041
2040
with_context ( |context| {
2042
2041
unsafe {
2043
- let gcx = tcx. gcx as * const _ as usize ;
2044
- let interners = tcx. interners as * const _ as usize ;
2045
- assert ! ( context. tcx. gcx as * const _ as usize == gcx) ;
2046
- assert ! ( context. tcx. interners as * const _ as usize == interners) ;
2042
+ assert ! ( ptr:: eq( context. tcx. gcx, tcx. gcx) ) ;
2043
+ assert ! ( ptr:: eq( context. tcx. interners, tcx. interners) ) ;
2047
2044
let context: & ImplicitCtxt < ' _ , ' _ , ' _ > = mem:: transmute ( context) ;
2048
2045
f ( context)
2049
2046
}
0 commit comments