Rustup to rustc 1.35.0-nightly (87a436377 2019-03-03)

This commit is contained in:
bjorn3 2019-03-04 18:57:09 +01:00
parent 2ce5387b7c
commit c2095c4afe
3 changed files with 33 additions and 167 deletions

View File

@ -1,166 +0,0 @@
From a84d00b816c1b771f3990ad5f7ba78981ab9c151 Mon Sep 17 00:00:00 2001
From: bjorn3 <bjorn3@users.noreply.github.com>
Date: Wed, 13 Feb 2019 14:54:20 +0100
Subject: [PATCH] Workaround missing saturating_{add,sub} intrinsic impl
---
src/libcore/num/mod.rs | 94 --------------------------------------------------
1 file changed, 94 deletions(-)
diff --git a/src/libcore/num/mod.rs b/src/libcore/num/mod.rs
index 4871b2e..5d5cd61 100644
--- a/src/libcore/num/mod.rs
+++ b/src/libcore/num/mod.rs
@@ -880,7 +880,6 @@ $EndFeature, "
```"),
#[stable(feature = "rust1", since = "1.0.0")]
#[inline]
- #[cfg(stage0)]
pub fn saturating_add(self, rhs: Self) -> Self {
match self.checked_add(rhs) {
Some(x) => x,
@@ -892,30 +891,6 @@ $EndFeature, "
}
doc_comment! {
- concat!("Saturating integer addition. Computes `self + rhs`, saturating at the numeric
-bounds instead of overflowing.
-
-# Examples
-
-Basic usage:
-
-```
-", $Feature, "assert_eq!(100", stringify!($SelfT), ".saturating_add(1), 101);
-assert_eq!(", stringify!($SelfT), "::max_value().saturating_add(100), ", stringify!($SelfT),
-"::max_value());",
-$EndFeature, "
-```"),
-
- #[stable(feature = "rust1", since = "1.0.0")]
- #[rustc_const_unstable(feature = "const_saturating_int_methods")]
- #[inline]
- #[cfg(not(stage0))]
- pub const fn saturating_add(self, rhs: Self) -> Self {
- intrinsics::saturating_add(self, rhs)
- }
- }
-
- doc_comment! {
concat!("Saturating integer subtraction. Computes `self - rhs`, saturating at the
numeric bounds instead of overflowing.
@@ -931,7 +906,6 @@ $EndFeature, "
```"),
#[stable(feature = "rust1", since = "1.0.0")]
#[inline]
- #[cfg(stage0)]
pub fn saturating_sub(self, rhs: Self) -> Self {
match self.checked_sub(rhs) {
Some(x) => x,
@@ -942,29 +916,6 @@ $EndFeature, "
}
doc_comment! {
- concat!("Saturating integer subtraction. Computes `self - rhs`, saturating at the
-numeric bounds instead of overflowing.
-
-# Examples
-
-Basic usage:
-
-```
-", $Feature, "assert_eq!(100", stringify!($SelfT), ".saturating_sub(127), -27);
-assert_eq!(", stringify!($SelfT), "::min_value().saturating_sub(100), ", stringify!($SelfT),
-"::min_value());",
-$EndFeature, "
-```"),
- #[stable(feature = "rust1", since = "1.0.0")]
- #[rustc_const_unstable(feature = "const_saturating_int_methods")]
- #[inline]
- #[cfg(not(stage0))]
- pub const fn saturating_sub(self, rhs: Self) -> Self {
- intrinsics::saturating_sub(self, rhs)
- }
- }
-
- doc_comment! {
concat!("Saturating integer multiplication. Computes `self * rhs`, saturating at the
numeric bounds instead of overflowing.
@@ -2779,7 +2730,6 @@ assert_eq!(200u8.saturating_add(127), 255);", $EndFeature, "
```"),
#[stable(feature = "rust1", since = "1.0.0")]
#[inline]
- #[cfg(stage0)]
pub fn saturating_add(self, rhs: Self) -> Self {
match self.checked_add(rhs) {
Some(x) => x,
@@ -2789,28 +2739,6 @@ assert_eq!(200u8.saturating_add(127), 255);", $EndFeature, "
}
doc_comment! {
- concat!("Saturating integer addition. Computes `self + rhs`, saturating at
-the numeric bounds instead of overflowing.
-
-# Examples
-
-Basic usage:
-
-```
-", $Feature, "assert_eq!(100", stringify!($SelfT), ".saturating_add(1), 101);
-assert_eq!(200u8.saturating_add(127), 255);", $EndFeature, "
-```"),
-
- #[stable(feature = "rust1", since = "1.0.0")]
- #[rustc_const_unstable(feature = "const_saturating_int_methods")]
- #[inline]
- #[cfg(not(stage0))]
- pub const fn saturating_add(self, rhs: Self) -> Self {
- intrinsics::saturating_add(self, rhs)
- }
- }
-
- doc_comment! {
concat!("Saturating integer subtraction. Computes `self - rhs`, saturating
at the numeric bounds instead of overflowing.
@@ -2824,7 +2752,6 @@ assert_eq!(13", stringify!($SelfT), ".saturating_sub(127), 0);", $EndFeature, "
```"),
#[stable(feature = "rust1", since = "1.0.0")]
#[inline]
- #[cfg(stage0)]
pub fn saturating_sub(self, rhs: Self) -> Self {
match self.checked_sub(rhs) {
Some(x) => x,
@@ -2834,27 +2761,6 @@ assert_eq!(13", stringify!($SelfT), ".saturating_sub(127), 0);", $EndFeature, "
}
doc_comment! {
- concat!("Saturating integer subtraction. Computes `self - rhs`, saturating
-at the numeric bounds instead of overflowing.
-
-# Examples
-
-Basic usage:
-
-```
-", $Feature, "assert_eq!(100", stringify!($SelfT), ".saturating_sub(27), 73);
-assert_eq!(13", stringify!($SelfT), ".saturating_sub(127), 0);", $EndFeature, "
-```"),
- #[stable(feature = "rust1", since = "1.0.0")]
- #[rustc_const_unstable(feature = "const_saturating_int_methods")]
- #[inline]
- #[cfg(not(stage0))]
- pub const fn saturating_sub(self, rhs: Self) -> Self {
- intrinsics::saturating_sub(self, rhs)
- }
- }
-
- doc_comment! {
concat!("Saturating integer multiplication. Computes `self * rhs`,
saturating at the numeric bounds instead of overflowing.
--
2.11.0

View File

@ -515,7 +515,8 @@ fn trans_stmt<'a, 'tcx: 'a>(
_ => bug!("Trying to ReifyFnPointer on non FnDef {:?}", ty),
}
}
Rvalue::Cast(CastKind::UnsafeFnPointer, operand, ty) => {
Rvalue::Cast(CastKind::UnsafeFnPointer, operand, ty)
| Rvalue::Cast(CastKind::MutToConstPointer, operand, ty) => {
let operand = trans_operand(fx, operand);
let layout = fx.layout_of(ty);
lval.write_cvalue(fx, operand.unchecked_cast_to(layout));

View File

@ -192,6 +192,7 @@ pub fn codegen_intrinsic_call<'a, 'tcx: 'a>(
ret.write_cvalue(fx, type_id);
};
_ if intrinsic.starts_with("unchecked_") || intrinsic == "exact_div", (c x, c y) {
// FIXME trap on overflow
let bin_op = match intrinsic {
"unchecked_div" | "exact_div" => BinOp::Div,
"unchecked_rem" => BinOp::Rem,
@ -278,6 +279,36 @@ pub fn codegen_intrinsic_call<'a, 'tcx: 'a>(
};
ret.write_cvalue(fx, res);
};
_ if intrinsic.starts_with("saturating_"), <T> (c x, c y) {
// FIXME implement saturating behavior
assert_eq!(x.layout().ty, y.layout().ty);
let bin_op = match intrinsic {
"saturating_add" => BinOp::Add,
"saturating_sub" => BinOp::Sub,
"saturating_mul" => BinOp::Mul,
_ => unimplemented!("intrinsic {}", intrinsic),
};
let res = match T.sty {
ty::Uint(_) => crate::base::trans_int_binop(
fx,
bin_op,
x,
y,
ret.layout().ty,
false,
),
ty::Int(_) => crate::base::trans_int_binop(
fx,
bin_op,
x,
y,
ret.layout().ty,
true,
),
_ => panic!(),
};
ret.write_cvalue(fx, res);
};
rotate_left, <T>(v x, v y) {
let layout = fx.layout_of(T);
let res = fx.bcx.ins().rotl(x, y);