Commit Graph

534 Commits

Author SHA1 Message Date
Marcel Hellwig
ce30d4e1b9 replaced nonzeroparseerror with regular interror 2019-02-27 18:37:35 +01:00
Simon Heath
5dce719520 Vastly simplify TryFrom docs. 2019-02-27 16:03:11 +01:00
Simon Heath
60cf413a20 Incorporated review changes. 2019-02-27 16:03:11 +01:00
Simon Heath
c1d1c6731c Fix a bunch of heckin' trailing whitespace 2019-02-27 16:02:25 +01:00
Simon Heath
12532277d5 Add basic docs to integer TryFrom impl macros.
They're not as good as `From` 'cause they don't stringify
the types and generate examples and so on, but it's a start.
2019-02-27 16:02:25 +01:00
Tobias Bucher
998896c036 Clarify rotate_{left,right} docs
I wondered what the `<<!` operator is although the exclamation mark was
only the end of the sentence.
2019-02-26 16:10:28 +01:00
bors
00aae71f50 Auto merge of #58302 - SimonSapin:tryfrom, r=alexcrichton
Stabilize TryFrom and TryInto with a convert::Infallible empty enum

This is the plan proposed in https://github.com/rust-lang/rust/issues/33417#issuecomment-423073898
2019-02-25 20:24:10 +00:00
Marcel Hellwig
36bcbc352d Add FromStr impl for NonZero types 2019-02-25 07:09:16 +01:00
kennytm
a1a17f5c66 Rollup merge of #58044 - Lokathor:lokathor, r=alexcrichton
Make overflowing and wrapping negation const

Remember that the signed and unsigned versions are slightly different here, so there's four functions made const instead of just two.
2019-02-20 12:01:58 +08:00
Simon Sapin
c80a8f51dc Stabilize TryFrom and TryInto 2019-02-13 18:00:18 +01:00
Simon Sapin
2f7120397f Use convert::Infallible instead of never in the blanket TryFrom impl 2019-02-13 18:00:18 +01:00
bors
b244f61b77 Auto merge of #58341 - alexreg:cosmetic-2-doc-comments, r=steveklabnik
Cosmetic improvements to doc comments

This has been factored out from https://github.com/rust-lang/rust/pull/58036 to only include changes to documentation comments (throughout the rustc codebase).

r? @steveklabnik

Once you're happy with this, maybe we could get it through with r=1, so it doesn't constantly get invalidated? (I'm not sure this will be an issue, but just in case...) Anyway, thanks for your advice so far!
2019-02-12 19:09:24 +00:00
Alexander Regueiro
99ed06eb88 libs: doc comments 2019-02-10 23:57:25 +00:00
Patrick McCarter
da13fbda5e Add unstable feature attribute for unsigned const saturating add/sub intrinsics #58030 2019-02-07 13:46:20 -05:00
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
Lokathor
481b354c97 Simplify the overflowing_neg expression 2019-02-01 18:43:32 -07:00
Lokathor
26a354065c Don't know why I wasn't using self properly there 2019-02-01 01:50:11 -07:00
Lokathor
2f5d2455a4 Make overflowing and wrapping negation const
Remember that the signed and unsigned versions are slightly different here, so there's four functions made const instead of just two.
2019-02-01 01:31:52 -07: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