Implement binop eq and ne for fat ptr's

This commit is contained in:
bjorn3 2018-09-25 18:35:05 +02:00
parent b11cb572dc
commit 889150a4f9
3 changed files with 36 additions and 93 deletions

View File

@ -1,68 +0,0 @@
From 8838226899913c8636fa00f4dfbc7497c685abc5 Mon Sep 17 00:00:00 2001
From: bjorn3 <bjorn3@users.noreply.github.com>
Date: Thu, 20 Sep 2018 18:16:25 +0200
Subject: [PATCH] Disable future and task modules, because they contain unsized
types
---
src/libcore/lib.rs | 4 +++-
src/libcore/option.rs | 4 +++-
2 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/src/libcore/lib.rs b/src/libcore/lib.rs
index 09f5035..f129254 100644
--- a/src/libcore/lib.rs
+++ b/src/libcore/lib.rs
@@ -194,7 +194,7 @@ pub mod cell;
pub mod char;
pub mod panic;
pub mod panicking;
-pub mod pin;
+//pub mod pin;
pub mod iter;
pub mod option;
pub mod raw;
@@ -209,9 +209,11 @@ pub mod time;
pub mod unicode;
+/*
/* Async */
pub mod future;
pub mod task;
+*/
/* Heap memory allocator trait */
#[allow(missing_docs)]
diff --git a/src/libcore/option.rs b/src/libcore/option.rs
index 58bf6be..902d38f 100644
--- a/src/libcore/option.rs
+++ b/src/libcore/option.rs
@@ -147,7 +147,7 @@
use iter::{FromIterator, FusedIterator, TrustedLen};
use {hint, mem, ops::{self, Deref}};
-use pin::Pin;
+//use pin::Pin;
// Note that this is not a lang item per se, but it has a hidden dependency on
// `Iterator`, which is one. The compiler assumes that the `next` method of
@@ -271,6 +271,7 @@ impl<T> Option<T> {
}
+ /*
/// Converts from `Pin<&Option<T>>` to `Option<Pin<&T>>`
#[inline]
#[unstable(feature = "pin", issue = "49150")]
@@ -288,6 +289,7 @@ impl<T> Option<T> {
Pin::get_mut_unchecked(self).as_mut().map(|x| Pin::new_unchecked(x))
}
}
+ */
/////////////////////////////////////////////////////////////////////////
// Getting to contained values
--
2.11.0

View File

@ -968,38 +968,49 @@ fn trans_ptr_binop<'a, 'tcx: 'a>(
bin_op: BinOp,
lhs: CValue<'tcx>,
rhs: CValue<'tcx>,
ty: Ty<'tcx>,
ret_ty: Ty<'tcx>,
) -> CValue<'tcx> {
match lhs.layout().ty.sty {
ty::RawPtr(TypeAndMut { ty, mutbl: _ }) => {
if !ty.is_sized(fx.tcx.at(DUMMY_SP), ParamEnv::reveal_all()) {
unimpl!("Unsized values are not yet implemented");
if ty.is_sized(fx.tcx.at(DUMMY_SP), ParamEnv::reveal_all()) {
binop_match! {
fx, bin_op, false, lhs, rhs, ret_ty, "ptr";
Add (_) bug;
Sub (_) bug;
Mul (_) bug;
Div (_) bug;
Rem (_) bug;
BitXor (_) bug;
BitAnd (_) bug;
BitOr (_) bug;
Shl (_) bug;
Shr (_) bug;
Eq (_) icmp(Equal);
Lt (_) icmp(UnsignedLessThan);
Le (_) icmp(UnsignedLessThanOrEqual);
Ne (_) icmp(NotEqual);
Ge (_) icmp(UnsignedGreaterThanOrEqual);
Gt (_) icmp(UnsignedGreaterThan);
Offset (_) iadd;
}
} else {
let lhs = lhs.load_value_pair(fx).0;
let rhs = rhs.load_value_pair(fx).0;
let res = match bin_op {
BinOp::Eq => fx.bcx.ins().icmp(IntCC::Equal, lhs, rhs),
BinOp::Ne => fx.bcx.ins().icmp(IntCC::NotEqual, lhs, rhs),
_ => unimplemented!("trans_ptr_binop({:?}, <fat ptr>, <fat ptr>) not implemented", bin_op),
};
assert_eq!(fx.tcx.types.bool, ret_ty);
let ret_layout = fx.layout_of(ret_ty);
CValue::ByVal(fx.bcx.ins().bint(types::I8, res), ret_layout)
}
}
_ => bug!("trans_ptr_binop on non ptr"),
}
binop_match! {
fx, bin_op, false, lhs, rhs, ty, "ptr";
Add (_) bug;
Sub (_) bug;
Mul (_) bug;
Div (_) bug;
Rem (_) bug;
BitXor (_) bug;
BitAnd (_) bug;
BitOr (_) bug;
Shl (_) bug;
Shr (_) bug;
Eq (_) icmp(Equal);
Lt (_) icmp(UnsignedLessThan);
Le (_) icmp(UnsignedLessThanOrEqual);
Ne (_) icmp(NotEqual);
Ge (_) icmp(UnsignedGreaterThanOrEqual);
Gt (_) icmp(UnsignedGreaterThan);
Offset (_) iadd;
}
}
pub fn trans_place<'a, 'tcx: 'a>(