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

Rollup of 8 pull requests #74724

Merged
merged 28 commits into from
Jul 24, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
6813c1c
revise RwLock, which is derived from the wasm implementation
stlankes Jun 3, 2020
3acc3ef
minor changes to pass the format check
stlankes Jun 3, 2020
beb1b1f
reorder crates to pass the format check
stlankes Jun 4, 2020
f9c6091
remove some compiler warnings
stlankes Jun 26, 2020
6925ebd
use latest version of hermit-abi
stlankes Jul 6, 2020
711a680
Optimize away BitAnd and BitOr when possible
xldenis Jul 18, 2020
c276334
add RegionName::span
SNCPlay42 Jul 21, 2020
51af5af
extract RegionNameHighlight
SNCPlay42 Jul 22, 2020
601518e
change returns to RegionNameHighlight
SNCPlay42 Jul 22, 2020
723ea90
rename functions
SNCPlay42 Jul 22, 2020
b56f5b9
clean up give_name_if_anonymous_region_appears_in_arguments
SNCPlay42 Jul 22, 2020
a7450b7
decouple highlight_if_we_cannot_match_hir_ty
SNCPlay42 Jul 22, 2020
ebb4aba
move highlight_if_we_can_match_hir_ty call
SNCPlay42 Jul 22, 2020
8a776ee
rename arguments to highlight_if_we_can_match_hir_ty
SNCPlay42 Jul 22, 2020
ef74e50
Rearrange the pipeline of `pow` to gain efficiency
Neutron3529 Jul 15, 2020
e46219c
Downgrade glibc to 2.11.1 for ppc, ppc64 and s390x
Jul 22, 2020
5a5846f
delay_span_bug instead of silent ignore
Mark-Simulacrum Jul 23, 2020
bae1e03
fixed error reporting for mismatched traits
ayrtonm Jul 23, 2020
b75ed4f
added a test case for reporting mismatched traits
ayrtonm Jul 24, 2020
b56ea88
Add a system for creating diffs across multiple mir optimizations.
oli-obk Jul 24, 2020
dfedb84
Rollup merge of #72954 - hermitcore:rwlock, r=dtolnay
Manishearth Jul 24, 2020
3226d72
Rollup merge of #74367 - Neutron3529:patch-1, r=nagisa
Manishearth Jul 24, 2020
e59effe
Rollup merge of #74491 - xldenis:constant-binop-opt, r=oli-obk
Manishearth Jul 24, 2020
a4024ba
Rollup merge of #74639 - msirringhaus:master, r=cuviper
Manishearth Jul 24, 2020
ceaef73
Rollup merge of #74661 - SNCPlay42:lifetime-names-refactor, r=estebank
Manishearth Jul 24, 2020
db83a21
Rollup merge of #74692 - Mark-Simulacrum:delay-bug, r=pnkfelix
Manishearth Jul 24, 2020
7f24c7d
Rollup merge of #74698 - ayrtonm:handle-traitref-mismatch, r=estebank
Manishearth Jul 24, 2020
5d1d94e
Rollup merge of #74715 - oli-obk:mir_pass_diff, r=wesleywiser
Manishearth Jul 24, 2020
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
4 changes: 2 additions & 2 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1242,9 +1242,9 @@ dependencies = [

[[package]]
name = "hermit-abi"
version = "0.1.14"
version = "0.1.15"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b9586eedd4ce6b3c498bc3b4dd92fc9f11166aa908a914071953768066c67909"
checksum = "3deed196b6e7f9e44a2ae8d94225d80302d81208b1bb673fd21fe634645c85a9"
dependencies = [
"compiler_builtins",
"libc",
Expand Down
6 changes: 3 additions & 3 deletions src/ci/docker/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ For targets: `powerpc-unknown-linux-gnu`
- Target options > Emit assembly for CPU = powerpc -- pure 32-bit PowerPC
- Operating System > Target OS = linux
- Operating System > Linux kernel version = 2.6.32.68 -- ~RHEL6 kernel
- C-library > glibc version = 2.12.2 -- ~RHEL6 glibc
- C-library > glibc version = 2.11.1 -- ~SLE11-SP4 glibc
- C compiler > gcc version = 5.2.0
- C compiler > C++ = ENABLE -- to cross compile LLVM

Expand All @@ -255,7 +255,7 @@ For targets: `powerpc64-unknown-linux-gnu`
- Target options > Tune for CPU = power6 -- (+)
- Operating System > Target OS = linux
- Operating System > Linux kernel version = 2.6.32.68 -- ~RHEL6 kernel
- C-library > glibc version = 2.12.2 -- ~RHEL6 glibc
- C-library > glibc version = 2.11.1 -- ~SLE11-SP4 glibc
- C compiler > gcc version = 5.2.0
- C compiler > C++ = ENABLE -- to cross compile LLVM

Expand All @@ -272,7 +272,7 @@ For targets: `s390x-unknown-linux-gnu`
- Target options > Bitness = 64-bit
- Operating System > Target OS = linux
- Operating System > Linux kernel version = 2.6.32.68 -- ~RHEL6 kernel
- C-library > glibc version = 2.12.2 -- ~RHEL6 glibc
- C-library > glibc version = 2.11.1 -- ~SLE11-SP4 glibc
- C compiler > gcc version = 5.2.0
- C compiler > gcc extra config = --with-arch=z10 -- LLVM's minimum support
- C compiler > C++ = ENABLE -- to cross compile LLVM
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ CT_BINUTILS_EXTRA_CONFIG_ARRAY=""
# C-library
#
CT_LIBC="glibc"
CT_LIBC_VERSION="2.12.2"
CT_LIBC_VERSION="2.11.1"
CT_LIBC_glibc=y
# CT_LIBC_musl is not set
# CT_LIBC_uClibc is not set
Expand All @@ -309,9 +309,9 @@ CT_THREADS="nptl"
# CT_LIBC_GLIBC_V_2_14_1 is not set
# CT_LIBC_GLIBC_V_2_14 is not set
# CT_LIBC_GLIBC_V_2_13 is not set
CT_LIBC_GLIBC_V_2_12_2=y
# CT_LIBC_GLIBC_V_2_12_2 is not set
# CT_LIBC_GLIBC_V_2_12_1 is not set
# CT_LIBC_GLIBC_V_2_11_1 is not set
CT_LIBC_GLIBC_V_2_11_1=y
# CT_LIBC_GLIBC_V_2_11 is not set
# CT_LIBC_GLIBC_V_2_10_1 is not set
# CT_LIBC_GLIBC_V_2_9 is not set
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ CT_BINUTILS_EXTRA_CONFIG_ARRAY=""
# C-library
#
CT_LIBC="glibc"
CT_LIBC_VERSION="2.12.2"
CT_LIBC_VERSION="2.11.1"
CT_LIBC_glibc=y
# CT_LIBC_musl is not set
# CT_LIBC_uClibc is not set
Expand All @@ -309,9 +309,9 @@ CT_THREADS="nptl"
# CT_LIBC_GLIBC_V_2_14_1 is not set
# CT_LIBC_GLIBC_V_2_14 is not set
# CT_LIBC_GLIBC_V_2_13 is not set
CT_LIBC_GLIBC_V_2_12_2=y
# CT_LIBC_GLIBC_V_2_12_2 is not set
# CT_LIBC_GLIBC_V_2_12_1 is not set
# CT_LIBC_GLIBC_V_2_11_1 is not set
CT_LIBC_GLIBC_V_2_11_1=y
# CT_LIBC_GLIBC_V_2_11 is not set
# CT_LIBC_GLIBC_V_2_10_1 is not set
# CT_LIBC_GLIBC_V_2_9 is not set
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ CT_BINUTILS_EXTRA_CONFIG_ARRAY=""
# C-library
#
CT_LIBC="glibc"
CT_LIBC_VERSION="2.12.2"
CT_LIBC_VERSION="2.11.1"
CT_LIBC_glibc=y
# CT_LIBC_musl is not set
# CT_LIBC_uClibc is not set
Expand All @@ -289,9 +289,9 @@ CT_THREADS="nptl"
# CT_LIBC_GLIBC_V_2_14_1 is not set
# CT_LIBC_GLIBC_V_2_14 is not set
# CT_LIBC_GLIBC_V_2_13 is not set
CT_LIBC_GLIBC_V_2_12_2=y
# CT_LIBC_GLIBC_V_2_12_2 is not set
# CT_LIBC_GLIBC_V_2_12_1 is not set
# CT_LIBC_GLIBC_V_2_11_1 is not set
CT_LIBC_GLIBC_V_2_11_1=y
# CT_LIBC_GLIBC_V_2_11 is not set
# CT_LIBC_GLIBC_V_2_10_1 is not set
# CT_LIBC_GLIBC_V_2_9 is not set
Expand Down
87 changes: 44 additions & 43 deletions src/libcore/num/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1095,6 +1095,9 @@ $EndFeature, "
without modifying the original"]
#[inline]
pub const fn checked_pow(self, mut exp: u32) -> Option<Self> {
if exp == 0 {
return Some(1);
}
let mut base = self;
let mut acc: Self = 1;

Expand All @@ -1105,15 +1108,11 @@ $EndFeature, "
exp /= 2;
base = try_opt!(base.checked_mul(base));
}

// since exp!=0, finally the exp must be 1.
// Deal with the final bit of the exponent separately, since
// squaring the base afterwards is not necessary and may cause a
// needless overflow.
if exp == 1 {
acc = try_opt!(acc.checked_mul(base));
}

Some(acc)
Some(try_opt!(acc.checked_mul(base)))
}
}

Expand Down Expand Up @@ -1622,6 +1621,9 @@ $EndFeature, "
without modifying the original"]
#[inline]
pub const fn wrapping_pow(self, mut exp: u32) -> Self {
if exp == 0 {
return 1;
}
let mut base = self;
let mut acc: Self = 1;

Expand All @@ -1633,14 +1635,11 @@ $EndFeature, "
base = base.wrapping_mul(base);
}

// since exp!=0, finally the exp must be 1.
// Deal with the final bit of the exponent separately, since
// squaring the base afterwards is not necessary and may cause a
// needless overflow.
if exp == 1 {
acc = acc.wrapping_mul(base);
}

acc
acc.wrapping_mul(base)
}
}

Expand Down Expand Up @@ -1989,6 +1988,9 @@ $EndFeature, "
without modifying the original"]
#[inline]
pub const fn overflowing_pow(self, mut exp: u32) -> (Self, bool) {
if exp == 0 {
return (1,false);
}
let mut base = self;
let mut acc: Self = 1;
let mut overflown = false;
Expand All @@ -2007,16 +2009,13 @@ $EndFeature, "
overflown |= r.1;
}

// since exp!=0, finally the exp must be 1.
// Deal with the final bit of the exponent separately, since
// squaring the base afterwards is not necessary and may cause a
// needless overflow.
if exp == 1 {
r = acc.overflowing_mul(base);
acc = r.0;
overflown |= r.1;
}

(acc, overflown)
r = acc.overflowing_mul(base);
r.1 |= overflown;
r
}
}

Expand All @@ -2040,6 +2039,9 @@ $EndFeature, "
#[inline]
#[rustc_inherit_overflow_checks]
pub const fn pow(self, mut exp: u32) -> Self {
if exp == 0 {
return 1;
}
let mut base = self;
let mut acc = 1;

Expand All @@ -2051,14 +2053,11 @@ $EndFeature, "
base = base * base;
}

// since exp!=0, finally the exp must be 1.
// Deal with the final bit of the exponent separately, since
// squaring the base afterwards is not necessary and may cause a
// needless overflow.
if exp == 1 {
acc = acc * base;
}

acc
acc * base
}
}

Expand Down Expand Up @@ -3295,6 +3294,9 @@ assert_eq!(", stringify!($SelfT), "::MAX.checked_pow(2), None);", $EndFeature, "
without modifying the original"]
#[inline]
pub const fn checked_pow(self, mut exp: u32) -> Option<Self> {
if exp == 0 {
return Some(1);
}
let mut base = self;
let mut acc: Self = 1;

Expand All @@ -3306,14 +3308,12 @@ assert_eq!(", stringify!($SelfT), "::MAX.checked_pow(2), None);", $EndFeature, "
base = try_opt!(base.checked_mul(base));
}

// since exp!=0, finally the exp must be 1.
// Deal with the final bit of the exponent separately, since
// squaring the base afterwards is not necessary and may cause a
// needless overflow.
if exp == 1 {
acc = try_opt!(acc.checked_mul(base));
}

Some(acc)
Some(try_opt!(acc.checked_mul(base)))
}
}

Expand Down Expand Up @@ -3704,6 +3704,9 @@ assert_eq!(3u8.wrapping_pow(6), 217);", $EndFeature, "
without modifying the original"]
#[inline]
pub const fn wrapping_pow(self, mut exp: u32) -> Self {
if exp == 0 {
return 1;
}
let mut base = self;
let mut acc: Self = 1;

Expand All @@ -3715,14 +3718,11 @@ assert_eq!(3u8.wrapping_pow(6), 217);", $EndFeature, "
base = base.wrapping_mul(base);
}

// since exp!=0, finally the exp must be 1.
// Deal with the final bit of the exponent separately, since
// squaring the base afterwards is not necessary and may cause a
// needless overflow.
if exp == 1 {
acc = acc.wrapping_mul(base);
}

acc
acc.wrapping_mul(base)
}
}

Expand Down Expand Up @@ -4029,6 +4029,9 @@ assert_eq!(3u8.overflowing_pow(6), (217, true));", $EndFeature, "
without modifying the original"]
#[inline]
pub const fn overflowing_pow(self, mut exp: u32) -> (Self, bool) {
if exp == 0{
return (1,false);
}
let mut base = self;
let mut acc: Self = 1;
let mut overflown = false;
Expand All @@ -4047,16 +4050,14 @@ assert_eq!(3u8.overflowing_pow(6), (217, true));", $EndFeature, "
overflown |= r.1;
}

// since exp!=0, finally the exp must be 1.
// Deal with the final bit of the exponent separately, since
// squaring the base afterwards is not necessary and may cause a
// needless overflow.
if exp == 1 {
r = acc.overflowing_mul(base);
acc = r.0;
overflown |= r.1;
}
r = acc.overflowing_mul(base);
r.1 |= overflown;

(acc, overflown)
r
}
}

Expand All @@ -4077,6 +4078,9 @@ Basic usage:
#[inline]
#[rustc_inherit_overflow_checks]
pub const fn pow(self, mut exp: u32) -> Self {
if exp == 0 {
return 1;
}
let mut base = self;
let mut acc = 1;

Expand All @@ -4088,14 +4092,11 @@ Basic usage:
base = base * base;
}

// since exp!=0, finally the exp must be 1.
// Deal with the final bit of the exponent separately, since
// squaring the base afterwards is not necessary and may cause a
// needless overflow.
if exp == 1 {
acc = acc * base;
}

acc
acc * base
}
}

Expand Down
33 changes: 32 additions & 1 deletion src/libcore/tests/num/int_macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -255,12 +255,43 @@ macro_rules! int_module {
#[test]
fn test_pow() {
let mut r = 2 as $T;

assert_eq!(r.pow(2), 4 as $T);
assert_eq!(r.pow(0), 1 as $T);
assert_eq!(r.wrapping_pow(2), 4 as $T);
assert_eq!(r.wrapping_pow(0), 1 as $T);
assert_eq!(r.checked_pow(2), Some(4 as $T));
assert_eq!(r.checked_pow(0), Some(1 as $T));
assert_eq!(r.overflowing_pow(2), (4 as $T, false));
assert_eq!(r.overflowing_pow(0), (1 as $T, false));
assert_eq!(r.saturating_pow(2), 4 as $T);
assert_eq!(r.saturating_pow(0), 1 as $T);

r = MAX;
// use `^` to represent .pow() with no overflow.
// if itest::MAX == 2^j-1, then itest is a `j` bit int,
// so that `itest::MAX*itest::MAX == 2^(2*j)-2^(j+1)+1`,
// thussaturating_pow the overflowing result is exactly 1.
assert_eq!(r.wrapping_pow(2), 1 as $T);
assert_eq!(r.checked_pow(2), None);
assert_eq!(r.overflowing_pow(2), (1 as $T, true));
assert_eq!(r.saturating_pow(2), MAX);
//test for negative exponent.
r = -2 as $T;
assert_eq!(r.pow(2), 4 as $T);
assert_eq!(r.pow(3), -8 as $T);
assert_eq!(r.pow(0), 1 as $T);
assert_eq!(r.wrapping_pow(2), 4 as $T);
assert_eq!(r.wrapping_pow(3), -8 as $T);
assert_eq!(r.wrapping_pow(0), 1 as $T);
assert_eq!(r.checked_pow(2), Some(4 as $T));
assert_eq!(r.checked_pow(3), Some(-8 as $T));
assert_eq!(r.checked_pow(0), Some(1 as $T));
assert_eq!(r.overflowing_pow(2), (4 as $T, false));
assert_eq!(r.overflowing_pow(3), (-8 as $T, false));
assert_eq!(r.overflowing_pow(0), (1 as $T, false));
assert_eq!(r.saturating_pow(2), 4 as $T);
assert_eq!(r.saturating_pow(3), -8 as $T);
assert_eq!(r.saturating_pow(0), 1 as $T);
}
}
};
Expand Down
Loading