8000 Rollup of 9 pull requests by Dylan-DPC-zz · Pull Request #72747 · rust-lang/rust · GitHub
[go: up one dir, main page]

Skip to content

Rollup of 9 pull requests #72747

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

Merged
merged 35 commits into from
May 29, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
34b5118
Suggest using std::mem::drop function instead of explicit destructor …
stanislav-tkach May 20, 2020
a9199de
Merge spans for the suggestion
stanislav-tkach May 22, 2020
68bab3e
Add total_cmp to f32 and f64, plus tests
golddranks May 22, 2020
b6eec22
Fix typo in src/libcore/num/f32.rs
golddranks May 25, 2020
d6650e0
Fix typo in src/libcore/num/f32.rs
golddranks May 25, 2020
bd68de8
remove unneeded and unidiomatic must_use
golddranks May 25, 2020
6973fd7
Add bit twiddling
golddranks May 25, 2020
8bc31ff
Fix the same typos again orz
golddranks May 25, 2020
c3dc8c4
Rename upvar_list to closure_captures
May 25, 2020
66da735
Add tracing issue for total_cmp
golddranks May 26, 2020
ca722b9
Add test for #56445
JohnTitor May 25, 2020
125f0ab
Add test for #68532
JohnTitor May 25, 2020
4b87f97
Add test for #70121
JohnTitor May 25, 2020
6315d0c
Add test for #71042
JohnTitor May 26, 2020
6ddbef1
Simplify suggestion
stanislav-tkach May 26, 2020
822ad87
Add Peekable::next_if
jyn514 May 18, 2020
42a4f5a
Fix grammar in liballoc raw_vec
pickfire May 28, 2020
813ce7a
`SocketAddr(V4|V6)?`::Display now correctly pads its content
Lucretiel May 20, 2020
defbd84
Added fast-path, tests
Lucretiel May 20, 2020
06a97a0
Clarify comment message & MAX_LENGTH const
Lucretiel May 22, 2020
12c03db
Add missing empty line in E0619 explanation
GuillaumeGomez May 29, 2020
3f13d97
liveness: Log information about used variables
tmiasko May 20, 2020
b3342b4
liveness: Remove unused clean_exit_var
tmiasko May 21, 2020
7c63014
liveness: Remove unused fallthrough_ln
tmiasko May 21, 2020
74fcbfb
liveness: Include upvars in the analysis
tmiasko May 21, 2020
4dc5661
liveness: Warn about unused captured variables
tmiasko May 22, 2020
cbcc4c4
Rollup merge of #72310 - jyn514:peekable-next-if, r=dtolnay
Dylan-DPC May 29, 2020
9c1f203
Rollup merge of #72383 - DarkEld3r:issue-72322, r=matthewjasper
Dylan-DPC May 29, 2020
8bce240
Rollup merge of #72398 - Lucretiel:ip-socket-display, r=Mark-Simulacrum
Dylan-DPC May 29, 2020
9ef6227
Rollup merge of #72465 - tmiasko:liveness-upvars, r=nikomatsakis
Dylan-DPC May 29, 2020
c09f0eb
Rollup merge of #72568 - golddranks:add_total_cmp_to_floats, r=sfackler
Dylan-DPC May 29, 2020
89cb4d7
Rollup merge of #72572 - JohnTitor:add-tests, r=matthewjasper
Dylan-DPC May 29, 2020
ed80e8e
Rollup merge of #72591 - sexxi-goose:rename_upvar_list-to-closure_cap…
Dylan-DPC May 29, 2020
510793b
Rollup merge of #72701 - pickfire:patch-1, r=Mark-Simulacrum
Dylan-DPC May 29, 2020
180a92c
Rollup merge of #72731 - GuillaumeGomez:cleanup-e0619, r=Dylan-DPC
Dylan-DPC May 29, 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
Prev Previous commit
Next Next commit
Add bit twiddling
  • Loading branch information
golddranks committed May 25, 2020
commit 6973fd716b51b01debf39edd8e43f0059be3d053
18 changes: 10 additions & 8 deletions src/libcore/num/f32.rs
Original file line number Diff line number Diff line change
Expand Up @@ -857,7 +857,7 @@ impl f32 {
let mut left = self.to_bits() as i32;
let mut right = other.to_bits() as i32;

// In case of negatives, flip all the bits except the sign
// In case of negatives, flip all the bits expect the sign
// to achieve a similar layout as two's complement integers
//
// Why does this work? IEEE 754 floats consist of three fields:
Expand All @@ -872,13 +872,15 @@ impl f32 {
// To easily compare the floats as signed integers, we need to
// flip the exponent and mantissa bits in case of negative numbers.
// We effectively convert the numbers to "two's complement" form.
if left < 0 {
// i32::MAX corresponds the bit pattern of "all ones except for the sign bit"
left ^= i32::MAX
};
if right < 0 {
right ^= i32::MAX
};
//
// To do the flipping, we construct a mask and XOR against it.
// We branchlessly calculate an "all-ones expect for the sign bit"
// mask from negative-signed values: right shifting sign-extends
// the integer, so we "fill" the mask with sign bits, and then
// convert to unsigned to push one more zero bit.
// On positive values, the mask is all zeros, so it's a no-op.
left ^= (((left >> 31) as u32) >> 1) as i32;
right ^= (((right >> 31) as u32) >> 1) as i32;

left.cmp(&right)
}
Expand Down
16 changes: 9 additions & 7 deletions src/libcore/num/f64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -886,13 +886,15 @@ impl f64 {
// To easily compare the floats as signed integers, we need to
// flip the exponent and mantissa bits in case of negative numbers.
// We effectively convert the numbers to "two's complement" form.
if left < 0 {
// i64::MAX corresponds the bit pattern of "all ones expect for the sign bit"
left ^= i64::MAX
};
if right < 0 {
right ^= i64::MAX
};
//
// To do the flipping, we construct a mask and XOR against it.
// We branchlessly calculate an "all-ones expect for the sign bit"
// mask from negative-signed values: right shifting sign-extends
// the integer, so we "fill" the mask with sign bits, and then
// convert to unsigned to push one more zero bit.
// On positive values, the mask is all zeros, so it's a no-op.
left ^= (((left >> 63) as u64) >> 1) as i64;
right ^= (((right >> 63) as u64) >> 1) as i64;

left.cmp(&right)
}
Expand Down
0