Commit Graph

467 Commits

Author SHA1 Message Date
Patrick McCarter
17998961d4 Refactor const saturating intrinsics emulation and add unstable feature attribute #58030 2019-02-07 13:12:17 -05:00
Patrick McCarter
0efb8e4d73 Allow const assignment for int saturating_sub() for #58030 2019-02-06 16:15:17 -05:00
Patrick McCarter
9204497c29 Allow const assignment for int saturating_add() calls for #58030 2019-02-05 15:36:31 -05:00
Nikita Popov
4a4186e4d1 Use LLVM intrinsics for saturating add/sub 2019-01-29 22:32:13 +01:00
Mark Rousskov
b7f030e114 Bump bootstrap compiler to 1.33 beta 2019-01-26 08:02:08 -07:00
Jewoo Lee
b12aa4fb6e Stabilize no_panic_pow 2019-01-24 13:38:46 +09:00
Simon Sapin
9be4c76910 Add signed num::NonZeroI* types
Multiple people have asked for them, in
https://github.com/rust-lang/rust/issues/49137.
Given that the unsigned ones already exist,
they are very easy to add and not an additional maintenance burden.
2019-01-17 17:32:55 +01:00
Pietro Albini
d158ef64e8 Revert "Auto merge of #57670 - rust-lang:beta-next, r=Mark-Simulacrum"
This reverts commit 722b4d6959, reversing
changes made to 956dba47d3.
2019-01-17 10:48:10 +01:00
Pietro Albini
b54a00accd allow unused warnings related to rustc_layout_scalar_valid_range_start 2019-01-16 18:20:08 +01:00
Mazdak Farrokhzad
2b234f61c6 const stabilize . 2019-01-13 04:00:03 +01:00
Mazdak Farrokhzad
2760f87e3a const-stabilize const_int_ops + reverse_bits 2018-12-31 16:11:03 +01:00
Mazdak Farrokhzad
50152d24ca now that some intrisics are safe, use that fact. 2018-12-31 04:11:46 +01:00
Mazdak Farrokhzad
eb0597ae83 stabilize const_int_sign 2018-12-31 03:36:46 +01:00
Mazdak Farrokhzad
e258489eae stabilize const_int_rotate 2018-12-31 03:36:46 +01:00
Mazdak Farrokhzad
7e7c337aef stabilize const_int_wrapping. 2018-12-31 03:36:46 +01:00
dylan_DPC
d11a58b676 Make the getter for NonZero types into a const fn 2018-12-28 16:58:55 +05:30
Simon Sapin
7a09115280 Remove the private generic NonZero<T> wrapper type.
Instead, use `#[rustc_layout_scalar_valid_range_start(1)]` directly
on relevant libcore types.
2018-12-26 20:54:10 +01:00
Mark Rousskov
2a663555dd Remove licenses 2018-12-25 21:08:33 -07:00
Nicole Mazzuca
455bc95317 fix nits 2018-12-20 01:37:20 -08:00
David Tolnay
66bb34c3ab Update src/libcore/num/mod.rs
Co-Authored-By: ubsan <npmazzuca@gmail.com>
2018-12-20 01:34:31 -08:00
Nicole Mazzuca
e36b62873f rename div_euc -> div_euclid, and mod_euc -> rem_euclid
logic is written up in https://github.com/rust-lang/rust/issues/49048

Also, update the documentation slightly
2018-12-17 16:41:48 -08:00
Mazdak Farrokhzad
a777754c4d Rollup merge of #56855 - nikic:remove-cttz-hack, r=nagisa
Remove u8 cttz hack

This issue has since been fixed in LLVM: 1886c8e29a

Furthermore this code doesn't actually work, because the 8 literal does not match the $BITS provided from the macro invocation, so effectively this was just dead code. Ref #43024.

What LLVM does is still not ideal for CPUs that only have bsf but not tzcnt, will create a patch for that later.

r? @nagisa
2018-12-16 14:08:37 +01:00
Mazdak Farrokhzad
3552499010 Rollup merge of #56706 - oli-obk:const_unsafe_fn, r=Centril
Make `const unsafe fn` bodies `unsafe`

r? @Centril

Updated for tracking issue discussion https://github.com/rust-lang/rust/issues/55607#issuecomment-445882296
2018-12-16 14:08:22 +01:00
Nikita Popov
c0ed771382 Remove u8 cttz hack
This issue has since been fixed in LLVM:
1886c8e29a

Furthermore this doesn't actually work, because the "8" literal does
not match the $BITS provided from the macro invocation, so effectively
this code was not being used anyway...
2018-12-15 17:26:18 +01:00
Alex Crichton
cf47a19305 Bump to 1.33.0
* Update bootstrap compiler
* Update version to 1.33.0
* Remove some `#[cfg(stage0)]` annotations

Actually updating the version number is blocked on updating Cargo
2018-12-12 08:09:26 -08:00
Oliver Scherer
8d0b64f16d Make const unsafe fn bodies unsafe 2018-12-11 10:27:00 +01:00
Alexander Regueiro
ee89c088b0 Various minor/cosmetic improvements to code 2018-12-07 23:53:34 +00:00
Oliver Scherer
02b22323f1 Make sure the initialization of constrained int range newtypes is unsafe 2018-12-04 10:17:36 +01:00
kennytm
45aaaa70bb Rollup merge of #56355 - Zoxc:inline-things, r=michaelwoerister
Add inline attributes and add unit to CommonTypes
2018-12-01 02:03:51 +08:00
kennytm
f7c407eb8b Rollup merge of #56216 - SimonSapin:array-tryfrom-slice, r=withoutboats
Add TryFrom<&[T]> for [T; $N] where T: Copy

`TryFrom<&[T]> for &[T; $N]` (note *reference* to an array) already exists, but not needing to dereference makes type inference easier for example when using `u32::from_be_bytes`.

Also add doc examples doing just that.
2018-12-01 01:53:15 +08:00
John Kåre Alsaker
4cce4ffdef Add inline attributes and add unit to CommonTypes 2018-11-29 22:11:02 +01:00
bors
423291f14b Auto merge of #55705 - ethanboxx:master, r=SimonSapin
Make `ParseIntError` and `IntErrorKind` fully public

Why would you write nice error types if I can't read them?

# Why

It can be useful to use `match` with errors produced when parsing strings to int. This would be useful for the `.err_match()` function in my [new crate](https://crates.io/crates/read_input).

---
I could also do this for `ParseFloatError` if people think it is a good idea.
I am new around hear so please tell me if I am getting anything wrong.
2018-11-26 01:46:18 +00:00
Simon Sapin
057e6d3a35 Add TryFrom<&[T]> for [T; $N] where T: Copy
`TryFrom<&[T]> for &[T; $N]` (note *reference* to an array) already exists,
but not needing to dereference makes type inference easier
for example when using `u32::from_be_bytes`.

Also add doc examples doing just that.
2018-11-25 22:34:59 +01:00
Ethan Brierley
121e5e806e fix missing borrow 2018-11-25 19:44:09 +00:00
Ethan Brierley
07b97a486f Use a reference rather than take ownership 2018-11-25 19:31:35 +00:00
Simon Sapin
68a26ec647 Stabilize the int_to_from_bytes feature
Fixes #52963
2018-11-25 08:29:01 +01:00
Pietro Albini
0f1c1eb480 Rollup merge of #55828 - oli-obk:promotion_strikes_again, r=eddyb
Add missing `rustc_promotable` attribute to unsigned `min_value` and `max_value`

cc @pnkfelix

fixes #55806
2018-11-11 00:21:23 +01:00
Oliver Scherer
f4c9dd55d6 Add missing rustc_promotable attribute to unsigned min_value and max_value 2018-11-09 17:55:24 +01:00
Ethan Brierley
51e1f5560d add unstable attribute 2018-11-07 08:48:37 +00:00
Ethan Brierley
d0bac148f7 Fix incorrect documentation 2018-11-07 08:38:34 +00:00
Ethan Brierley
11ee29a813 Use method rather than public field 2018-11-07 08:35:28 +00:00
Ethan Brierley
f1a593d116 Document kind field 2018-11-06 09:29:24 +00:00
Ethan Brierley
3dc56b7d9c Fix mistake in my markdown 2018-11-06 08:37:25 +00:00
Ethan Brierley
c3f0c9419e Add very useful documentation 2018-11-06 08:34:30 +00:00
Ethan Brierley
b60efc1574 Continue to try to make travis happy by adding a issue number 2018-11-05 21:57:19 +00:00
Ethan Brierley
420e6413c6 break line to keep travis_fold:start:tidy happy 2018-11-05 21:37:10 +00:00
Ethan Brierley
3b0fc3c309 Add useful attributes 2018-11-05 21:22:45 +00:00
Ethan Brierley
2d1cd9ae80 Make ParseIntError and IntErrorKind fully public 2018-11-05 17:23:34 +00:00
Nikita Popov
4c40ff6a24 Implement rotate using funnel shift on LLVM >= 7
Implement the rotate_left and rotate_right operations using
llvm.fshl and llvm.fshr if they are available (LLVM >= 7).

Originally I wanted to expose the funnel_shift_left and
funnel_shift_right intrinsics and implement rotate_left and
rotate_right on top of them. However, emulation of funnel
shifts requires emitting a conditional to check for zero shift
amount, which is not necessary for rotates. I was uncomfortable
doing that here, as I don't want to rely on LLVM to optimize
away that conditional (and for variable rotates, I'm not sure it
can). We should revisit that question when we raise our minimum
version requirement to LLVM 7 and don't need emulation code
anymore.
2018-11-03 23:50:55 +01:00
Alex Crichton
d0060d72e5 Bump nightly to 1.32.0
* Also update the bootstrap compiler
* Update cargo to 1.32.0
* Clean out stage0 annotations
2018-10-31 11:53:50 -07:00