Commit graph

910 commits

Author SHA1 Message Date
Thom Chiovoloni
783a7dc8ed Mark leading_trailing_ones with tracking issue 57969 2020-01-15 08:31:24 -08:00
Thom Chiovoloni
6a7a69bde9 Add {leading,trailing}_ones to primitive int types 2020-01-12 14:07:31 -08:00
Mazdak Farrokhzad
5ea69781f4
Rollup merge of #67966 - popzxc:core-std-matches, r=Centril
Use matches macro in libcore and libstd

This PR replaces matches like

```rust
match var {
    value => true,
    _ => false,
}
```

with use of `matches!` macro.

r? @Centril
2020-01-09 00:22:10 +01:00
Mazdak Farrokhzad
11f0013378
Rollup merge of #67884 - anp:allow-unused-const-attr, r=oli-obk
Fix incremental builds of core by allowing unused attribute.

I *think* that the same problem as in https://github.com/rust-lang/rust/issues/65023 was introduced by https://github.com/rust-lang/rust/pull/67657. This works around the current incrcomp issue with these attributes by allowing it here. This resolves the near-term issue for me, at least.
2020-01-09 00:22:08 +01:00
Igor Aleksanov
f720469fd0 Use matches macro in libcore and libstd 2020-01-08 07:10:28 +03:00
Lzu Tao
c7dbf5ad54 Use Self instead of $type 2020-01-06 04:33:31 +00:00
Adam Perry
3458aba0f9 Fix incremental builds of core by allowing unused attribute.
The same problem as in https://github.com/rust-lang/rust/issues/65023 was
introduced by https://github.com/rust-lang/rust/pull/67657. This works
around the current incrcomp issue with these attributes by allowing it
here.
2020-01-04 18:20:52 -08:00
jumbatm
525cd2d7c1 Re-add comment about behaviour of inline. 2020-01-05 08:01:32 +10:00
jumbatm
ae002c1d84 Also remove const-hack for abs 2020-01-04 08:42:22 +10:00
Dylan DPC
2c64475069
Rollup merge of #67430 - tspiteri:minus-inf, r=Dylan-DPC
doc: minus (U+2212) instead of dash (U+002D) for negative infinity

The documentation for [`f32::NEG_INFINITY`](https://doc.rust-lang.org/std/f32/constant.NEG_INFINITY.html) contains “-∞” with a dash instead of a minus sign, “−∞” with a proper minus sign looks better with the used Source Serif Pro font. Similarly for [`f64::NEG_INFINITY`](https://doc.rust-lang.org/std/f64/constant.NEG_INFINITY.html).
2019-12-31 18:14:01 +05:30
Yuki Okushi
047a4bb432
Rollup merge of #67657 - jumbatm:cleanup-const-hack, r=oli-obk
Clean up const-hack PRs now that const if / match exist.

Closes #67627.

Cleans up these merged PRs tagged with `const-hack`:

- #63810
- #63786
- #61635
- #58044

reverting their contents to have the match or if expressions they originally contained.

r? @oli-obk

There's one more PR in those tagged with `const-hack` that originally wasn't merged (#65107). Reading the thread, it looks like it was originally closed because the `const-hack` for the checked arithmetic non-negligibly hurt performance, and because there was no way to manipulate the returned Option at compile time anyway (with neither const if nor const match). Would you like me to add these changes to the changes from this PR here too, now that we have the necessary features?
2019-12-30 14:07:50 +09:00
jumbatm
91c2f78b50 Clean up const-hack from #58044 2019-12-27 23:21:32 +10:00
jumbatm
282635f2db Clean up const-hack from #61635 2019-12-27 23:21:32 +10:00
jumbatm
8c494866be Clean up const-hack from #63786 2019-12-27 23:21:32 +10:00
Matthew Kraai
21e636f188 Remove redundant link texts 2019-12-26 05:04:46 -08:00
Ohad Ravid
811bdeee00 Show value for consts in the documentation 2019-12-24 10:10:36 +01:00
Mark Rousskov
a06baa56b9 Format the world 2019-12-22 17:42:47 -05:00
Ross MacArthur
f7256d28d1
Require issue = "none" over issue = "0" in unstable attributes 2019-12-21 13:16:18 +02:00
Trevor Spiteri
d1a3518e30 doc: minus (U+2212) instead of dash (U+002D) for negative infinity 2019-12-19 17:57:08 +01:00
Mark Rousskov
82184440ec Propagate cfg bootstrap 2019-12-18 12:16:19 -05:00
Lzu Tao
7bf55f4aa5 use Self alias in place of macros 2019-12-15 13:55:10 +00:00
Mazdak Farrokhzad
e5c34411f9
Rollup merge of #67305 - kappa:patch-1, r=jonas-schievink
Doc typo
2019-12-15 05:57:28 +01:00
Alex Kapranoff
d0008baebd
Doc typo 2019-12-14 17:12:40 -08:00
bors
6f829840f7 Auto merge of #67224 - nikomatsakis:revert-stabilization-of-never-type, r=centril
Revert stabilization of never type

Fixes https://github.com/rust-lang/rust/issues/66757

I decided to keep the separate `never-type-fallback` feature gate, but tried to otherwise revert https://github.com/rust-lang/rust/pull/65355. Seemed pretty clean.

( cc @Centril, author of #65355, you may want to check this over briefly )
2019-12-14 22:02:59 +00:00
Niko Matsakis
d286113024 Revert "Stabilize the never_type, written !."
This reverts commit 15c30ddd69.
2019-12-14 09:01:09 -05:00
Niko Matsakis
ca8154861e Revert "Redefine core::convert::Infallible as !."
This reverts commit 089229a193.
2019-12-14 09:00:49 -05:00
Oliver Scherer
5e17e39881 Require stable/unstable annotations for the constness of all stable functions with a const modifier 2019-12-13 11:27:02 +01:00
bors
8960acf023 Auto merge of #66277 - peter-wilkins:impl-from-wider-non-zeros, r=SimonSapin
From<NonZero*> impls for wider NonZero types

Closes: https://github.com/rust-lang/rust/issues/66291
2019-12-10 10:11:37 +00:00
Peter
8f6a06285e move from non zero impls to libcore/convert/num.rs 2019-12-08 23:49:30 +00:00
David Tolnay
c737169fe5
Format libcore with rustfmt (including tests and benches) 2019-12-06 20:20:51 -08:00
Simon Sapin
a213ff8299 Move numeric From and TryFrom impls to libcore/convert/num.rs
This makes `libcore/num/mod.rs` slightly smaller. It’s still 4911 lines and not easy to navigate. This doesn’t change any public API.
2019-12-06 14:00:45 +01:00
Simon Sapin
cba479f75c Add {f32,f64}::approx_unchecked_to<Int> unsafe methods
As discussed in https://github.com/rust-lang/rust/issues/10184

Currently, casting a floating point number to an integer with `as` is Undefined Behavior if the value is out of range. `-Z saturating-float-casts` fixes this soundness hole by making `as` “saturate” to the maximum or minimum value of the integer type (or zero for `NaN`), but has measurable negative performance impact in some benchmarks. There is some consensus in that thread for enabling saturation by default anyway, but provide an `unsafe fn` alternative for users who know through some other mean that their values are in range.
2019-12-06 14:01:05 +01:00
David Tolnay
d353a4c267
Make dec2flt_table compatible with rustfmt 2019-11-29 20:17:09 -08:00
Ohad Ravid
85a468b8cf Clarify {f32,f64}::EPSILON docs 2019-11-28 13:49:58 +01:00
Tyler Mandry
4c51d58de0
Rollup merge of #66769 - fusion-engineering-forks:tau-constant, r=dtolnay
Add core::{f32,f64}::consts::TAU.

### **`τ`**
2019-11-27 15:28:47 -06:00
David Tolnay
95e00bfed8
Format libcore with rustfmt
This commit applies rustfmt with default settings to files in
src/libcore *that are not involved in any currently open PR* to minimize
merge conflicts. The list of files involved in open PRs was determined
by querying GitHub's GraphQL API with this script:
https://gist.github.com/dtolnay/aa9c34993dc051a4f344d1b10e4487e8

With the list of files from the script in `outstanding_files`, the
relevant commands were:

    $ find src/libcore -name '*.rs' | xargs rustfmt --edition=2018
    $ rg libcore outstanding_files | xargs git checkout --

Repeating this process several months apart should get us coverage of
most of the rest of libcore.
2019-11-26 23:02:11 -08:00
Mara Bos
d220ed4fd7 Add tracking issue number. 2019-11-26 16:32:46 +01:00
Mara Bos
fd9b986bfe Add core::{f32,f64}::consts::TAU. 2019-11-26 16:32:46 +01:00
Mazdak Farrokhzad
089229a193 Redefine core::convert::Infallible as !. 2019-11-21 14:55:33 +01:00
Mazdak Farrokhzad
15c30ddd69 Stabilize the never_type, written !. 2019-11-21 14:55:32 +01:00
Peter
947772fc31 update version metadata 2019-11-12 11:48:05 +00:00
Peter
9f88273f3d add NonZeroU16 -> NonZeroUsize and NonZeroI16 -> NonZeroIsize 2019-11-11 11:57:02 +00:00
Peter
ae2b192fdd remove irrelevant Safety section 2019-11-10 18:08:17 +00:00
Peter
7bf66d97b6 From<NonZero*> impls for wider NonZero types
issue: https://github.com/rust-lang/rust/issues/66196
2019-11-10 17:28:45 +00:00
Alexander Nye
619f057dae remove vestigial comments referring to defunct numeric trait hierarchy
see also https://github.com/rust-lang/rust/pull/23104/files
2019-11-08 13:51:07 -08:00
Oliver Scherer
02f9167f94 Have tidy ensure that we document all unsafe blocks in libcore 2019-11-06 11:04:42 +01:00
Lzu Tao
7b72c2831c Stabilize float_to_from_bytes feature 2019-10-31 16:13:28 +00:00
Mateusz Mikuła
dffc1b3282 Apply clippy::useless_let_if_seq suggestion 2019-10-22 19:14:22 +02:00
Mazdak Farrokhzad
a160258927
Rollup merge of #65092 - tspiteri:const-is-pow2, r=oli-obk
make is_power_of_two a const function

This makes `is_power_of_two` a const function by using `&` instead of short-circuiting `&&`; Rust supports bitwise `&` for `bool` and short-circuiting is not required in the existing expression.

I don't think this needs a const-hack label as I don't find the changed code less readable, if anything I prefer that it is clearer that short circuiting is not used.

@oli-obk
2019-10-21 22:00:47 +02:00
Trevor Spiteri
d689c709ea improve readability of is_power_of_two 2019-10-21 15:35:54 +02:00