Dylan DPC
c261ff1a77
Rollup merge of #68984 - ecstatic-morse:const-u8-is-ascii, r=sfackler
...
Make `u8::is_ascii` a stable `const fn`
`char::is_ascii` was already stabilized as `const fn` in #55278 , so there is no reason for `u8::is_ascii` to go through an unstable period.
cc @rust-lang/libs
2020-02-22 18:42:59 +05:30
Dylan DPC
d96951f554
Rollup merge of #68978 - ecstatic-morse:const-int-pow, r=oli-obk
...
Make integer exponentiation methods unstably const
cc #53718
This makes the following inherent methods on integer primitives into unstable `const fn`:
- `pow`
- `checked_pow`
- `wrapping_pow`
- `overflowing_pow`
- `saturating_pow`
- `next_power_of_two`
- `checked_next_power_of_two`
- `wrapping_next_power_of_two`
Only two changes were made to the implementation of these methods. First, I had to switch from the `?` operator, which is not yet implemented in a const context, to a `try_opt` macro. Second, `next_power_of_two` was using `ops::Add::add` (see the first commit) to "get overflow checks", so I switched to `#[rustc_inherit_overflow_checks]`. I'm not quite sure why the attribute wasn't used in the first place.
2020-02-20 10:49:12 +01:00
LeSeulArtichaut
2ae493a767
Stabilize {f32, f64}::{LOG2_10, LOG10_2}
2020-02-16 18:53:02 +01:00
Dylan DPC
6e1b75b7e1
Rollup merge of #68986 - ecstatic-morse:const-ascii-ctype, r=Centril
...
Make ASCII ctype functions unstably const
Makes the following inherent methods on `u8` and `char` unstable `const fn`:
* `is_ascii_alphabetic`
* `is_ascii_uppercase`
* `is_ascii_lowercase`
* `is_ascii_alphanumeric`
* `is_ascii_digit`
* `is_ascii_hexdigit`
* `is_ascii_punctuation`
* `is_ascii_graphic`
* `is_ascii_whitespace`
* `is_ascii_control`
cc #68983
2020-02-10 17:28:59 +01:00
Dylan MacKenzie
f6d4720f26
Make u8::is_ascii a stable const fn
...
`char::is_ascii` is already a stable `const fn`, so there is no reason
for `u8::is_ascii` to be unstable.
2020-02-08 21:29:32 -08:00
Dylan MacKenzie
a9212b8e93
Make the ASCII ctype inherent methods const
2020-02-08 21:29:25 -08:00
Dylan MacKenzie
269bf89865
Make integer power methods const
2020-02-08 17:19:09 -08:00
Dylan MacKenzie
2afa99379d
Use bespoke macro instead of ? inside const fns
2020-02-08 17:18:13 -08:00
Dylan MacKenzie
c981d67b50
[!] Use rustc_inherit_overflow_checks in next_power_of_two
...
I believe the previous code was calling `ops::Add::add` instead of the
`+` operator to get this behavior.
2020-02-08 17:16:43 -08:00
Dylan MacKenzie
0b20ce97f7
Make num::NonZeroX::new an unstable const fn
2020-02-08 16:02:20 -08:00
Dylan MacKenzie
09160d1b84
Use consistent feature naming
2020-02-04 20:36:18 -08:00
Dylan MacKenzie
dda015aebc
Make saturating arithmetic using intrinsics const
2020-02-04 11:04:04 -08:00
Dylan MacKenzie
526304da16
Make checked division const
2020-02-04 11:04:04 -08:00
Dylan MacKenzie
b46d1d2718
Make wrapping arithmetic const
...
Co-Authored-By: 9999years <rbt@sent.as>
2020-02-04 11:04:04 -08:00
Dylan MacKenzie
b422a19c43
Make saturating_mul a const fn
...
Co-Authored-By: 9999years <rbt@sent.as>
2020-02-04 11:04:04 -08:00
Dylan MacKenzie
de52a541d5
Make overflowing arithmetic const
...
Co-Authored-By: 9999years <rbt@sent.as>
2020-02-04 11:04:03 -08:00
Dylan MacKenzie
37c141885a
Make checked arithmetic besides division const
...
Co-Authored-By: 9999years <rbt@sent.as>
2020-02-04 11:04:03 -08:00
Dylan MacKenzie
d9e3d2a531
Make euclidean division const
...
Co-Authored-By: 9999years <rbt@sent.as>
2020-02-04 11:04:03 -08:00
bors
c4071d0919
Auto merge of #68325 - faern:move-numeric-consts-to-associated-consts-step1, r=LukasKalbertodt
...
Move numeric consts to associated consts step1
A subset of #67913 . Implements the first step of RFC https://github.com/rust-lang/rfcs/pull/2700
This PR adds the new constants as unstable constants and defines the old ones in terms of the new ones. Then fix a tiny bit of code that started having naming collisions because of the new assoc consts.
Removed a test that did not seem relevant any longer. Since doing just `u8::MIN` should now indeed be valid.
2020-01-30 08:55:07 +00:00
LeSeulArtichaut
684bd50148
Document From implementation for NonZero nums
2020-01-29 17:49:38 +01:00
Linus Färnstrand
002c7897a6
Unlock assoc_int_consts in documentation examples using it
2020-01-23 20:55:06 +01:00
Linus Färnstrand
9d257579fc
Fix some float operations to work together with the assoc consts
2020-01-23 20:55:06 +01:00
Linus Färnstrand
22dcfa1d8d
Add relevant associated constants to the float types
2020-01-23 20:55:06 +01:00
Linus Färnstrand
b5ff8064a4
Add MIN/MAX associated constants to the integer types
2020-01-23 20:55:06 +01:00
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