Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use ptr::eq where applicable #57547

Merged
merged 1 commit into from
Jan 13, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 7 additions & 10 deletions src/librustc/ty/context.rs
Original file line number Diff line number Diff line change
@@ -59,6 +59,7 @@ use std::hash::{Hash, Hasher};
use std::fmt;
use std::mem;
use std::ops::{Deref, Bound};
use std::ptr;
use std::iter;
use std::sync::mpsc;
use std::sync::Arc;
@@ -168,7 +169,7 @@ impl<'gcx: 'tcx, 'tcx> CtxtInterners<'tcx> {

// Make sure we don't end up with inference
// types/regions in the global interner
if local as *const _ as usize == global as *const _ as usize {
if ptr::eq(local, global) {
bug!("Attempted to intern `{:?}` which contains \
inference types/regions in the global type context",
&ty_struct);
@@ -1125,9 +1126,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {

/// Returns true if self is the same as self.global_tcx().
fn is_global(self) -> bool {
let local = self.interners as *const _;
let global = &self.global_interners as *const _;
local as usize == global as usize
ptr::eq(self.interners, &self.global_interners)
}

/// Create a type context and call the closure with a `TyCtxt` reference
@@ -1777,6 +1776,7 @@ pub mod tls {
use std::fmt;
use std::mem;
use std::marker::PhantomData;
use std::ptr;
use syntax_pos;
use ty::query;
use errors::{Diagnostic, TRACK_DIAGNOSTICS};
@@ -2011,8 +2011,7 @@ pub mod tls {
{
with_context(|context| {
unsafe {
let gcx = tcx.gcx as *const _ as usize;
assert!(context.tcx.gcx as *const _ as usize == gcx);
assert!(ptr::eq(context.tcx.gcx, tcx.gcx));
let context: &ImplicitCtxt<'_, '_, '_> = mem::transmute(context);
f(context)
}
@@ -2030,10 +2029,8 @@ pub mod tls {
{
with_context(|context| {
unsafe {
let gcx = tcx.gcx as *const _ as usize;
let interners = tcx.interners as *const _ as usize;
assert!(context.tcx.gcx as *const _ as usize == gcx);
assert!(context.tcx.interners as *const _ as usize == interners);
assert!(ptr::eq(context.tcx.gcx, tcx.gcx));
assert!(ptr::eq(context.tcx.interners, tcx.interners));
let context: &ImplicitCtxt<'_, '_, '_> = mem::transmute(context);
f(context)
}
2 changes: 1 addition & 1 deletion src/librustc_codegen_llvm/debuginfo/metadata.rs
Original file line number Diff line number Diff line change
@@ -47,7 +47,7 @@ use syntax_pos::{self, Span, FileName};

impl PartialEq for llvm::Metadata {
fn eq(&self, other: &Self) -> bool {
self as *const _ == other as *const _
ptr::eq(self, other)
}
}

3 changes: 2 additions & 1 deletion src/librustc_codegen_llvm/type_.rs
Original file line number Diff line number Diff line change
@@ -20,12 +20,13 @@ use abi::{LlvmType, FnTypeExt};

use std::fmt;
use std::cell::RefCell;
use std::ptr;

use libc::c_uint;

impl PartialEq for Type {
fn eq(&self, other: &Self) -> bool {
self as *const _ == other as *const _
ptr::eq(self, other)
}
}

3 changes: 2 additions & 1 deletion src/librustc_codegen_llvm/value.rs
Original file line number Diff line number Diff line change
@@ -4,10 +4,11 @@ use llvm;

use std::fmt;
use std::hash::{Hash, Hasher};
use std::ptr;

impl PartialEq for Value {
fn eq(&self, other: &Self) -> bool {
self as *const _ == other as *const _
ptr::eq(self, other)
}
}