The Wayback Machine - https://web.archive.org/web/20201226183846/https://github.com/rust-lang/rust/pull/73858/
Skip to content
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

Make more primitive integer methods const #73858

Merged
merged 6 commits into from Jul 27, 2020
Merged

Conversation

@tspiteri
Copy link
Contributor

@tspiteri tspiteri commented Jun 29, 2020

Now that #72437 has been merged and const_if_match is stable, these methods can be stabilized const. The methods are grouped in commits according to feature names:

  • const_nonzero_int_methods
    • NonZero*::new
  • some const_checked_int_methods
    • {i*,u*}::checked_add
    • {i*,u*}::checked_sub
    • {i*,u*}::checked_mul
    • {i*,u*}::checked_neg
    • {i*,u*}::checked_shl
    • {i*,u*}::checked_shr
    • i*::checked_abs
  • const_saturating_int_methods
    • {i*,u*}::saturating_add
    • {i*,u*}::saturating_sub
    • {i*,u*}::saturating_mul
    • i*::saturating_neg
    • i*::saturating_abs
  • const_int_sign
    • i*::signum
  • const_ascii_ctype_on_intrinsics
    • {char,u8}::is_ascii_alphabetic
    • {char,u8}::is_ascii_uppercase
    • {char,u8}::is_ascii_lowercase
    • {char,u8}::is_ascii_alphanumeric
    • {char,u8}::is_ascii_digit
    • {char,u8}::is_ascii_hexdigit
    • {char,u8}::is_ascii_punctuation
    • {char,u8}::is_ascii_graphic
    • {char,u8}::is_ascii_whitespace
    • {char,u8}::is_ascii_control
@rust-highfive
Copy link
Collaborator

@rust-highfive rust-highfive commented Jun 29, 2020

r? @LukasKalbertodt

(rust_highfive has picked a reviewer for you, use r? to override)

@rust-highfive

This comment has been hidden.

@tspiteri tspiteri force-pushed the tspiteri:const-methods branch from f3348bd to 2672feb Jun 29, 2020
@rust-highfive

This comment has been hidden.

@tspiteri tspiteri force-pushed the tspiteri:const-methods branch from 2672feb to bfd5fde Jun 29, 2020
@rust-highfive

This comment has been hidden.

@tspiteri tspiteri force-pushed the tspiteri:const-methods branch from bfd5fde to 2a84e31 Jun 29, 2020
@LukasKalbertodt
Copy link
Member

@LukasKalbertodt LukasKalbertodt commented Jun 29, 2020

I can't start FCPs, some pseudo-random reassignment:

r? @SimonSapin

@LukasKalbertodt
Copy link
Member

@LukasKalbertodt LukasKalbertodt commented Jun 29, 2020

But I can already ping @rust-lang/wg-const-eval

@Amanieu
Copy link
Contributor

@Amanieu Amanieu commented Jul 17, 2020

@rfcbot fcp merge

@rfcbot
Copy link

@rfcbot rfcbot commented Jul 17, 2020

Team member @Amanieu has proposed to merge this. The next step is review by the rest of the tagged team members:

No concerns currently listed.

Once a majority of reviewers approve (and at most 2 approvals are outstanding), this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up!

See this document for info about what commands tagged team members can give me.

@rfcbot
Copy link

@rfcbot rfcbot commented Jul 17, 2020

🔔 This is now entering its final comment period, as per the review above. 🔔

@Dylan-DPC Dylan-DPC modified the milestones: 1.46, 1.47 Jul 18, 2020
@tspiteri
Copy link
Contributor Author

@tspiteri tspiteri commented Jul 22, 2020

Since this missed the 1.46 train, should I push a commit changing the rustc_const_stable(since) field from "1.46.0" to "1.47.0" and removing the bootstrap allow_internal_unstable(const_if_match)?

@oli-obk
Copy link
Contributor

@oli-obk oli-obk commented Jul 22, 2020

Jup, that would be great!

@rfcbot
Copy link

@rfcbot rfcbot commented Jul 27, 2020

The final comment period, with a disposition to merge, as per the review above, is now complete.

As the automated representative of the governance process, I would like to thank the author for their work and everyone else who contributed.

The RFC will be merged soon.

@oli-obk
Copy link
Contributor

@oli-obk oli-obk commented Jul 27, 2020

@bors r+

@bors
Copy link
Contributor

@bors bors commented Jul 27, 2020

📌 Commit d6cf128 has been approved by oli-obk

@bors
Copy link
Contributor

@bors bors commented Jul 27, 2020

Testing commit d6cf128 with merge 84ed779...

bors added a commit to rust-lang-ci/rust that referenced this pull request Jul 27, 2020
Make more primitive integer methods const

Now that rust-lang#72437 has been merged and `const_if_match` is stable, these methods can be stabilized const. The methods are grouped in commits according to feature names:

* `const_nonzero_int_methods`
    - `NonZero*::new`
* some `const_checked_int_methods`
    - `{i*,u*}::checked_add`
    - `{i*,u*}::checked_sub`
    - `{i*,u*}::checked_mul`
    - `{i*,u*}::checked_neg`
    - `{i*,u*}::checked_shl`
    - `{i*,u*}::checked_shr`
    - `i*::checked_abs`
* `const_saturating_int_methods`
    - `{i*,u*}::saturating_add`
    - `{i*,u*}::saturating_sub`
    - `{i*,u*}::saturating_mul`
    - `i*::saturating_neg`
    - `i*::saturating_abs`
* `const_int_sign`
    - `i*::signum`
* `const_ascii_ctype_on_intrinsics`
    - `{char,u8}::is_ascii_alphabetic`
    - `{char,u8}::is_ascii_uppercase`
    - `{char,u8}::is_ascii_lowercase`
    - `{char,u8}::is_ascii_alphanumeric`
    - `{char,u8}::is_ascii_digit`
    - `{char,u8}::is_ascii_hexdigit`
    - `{char,u8}::is_ascii_punctuation`
    - `{char,u8}::is_ascii_graphic`
    - `{char,u8}::is_ascii_whitespace`
    - `{char,u8}::is_ascii_control`
@Manishearth
Copy link
Member

@Manishearth Manishearth commented Jul 27, 2020

@bors retry yield

bors added a commit to rust-lang-ci/rust that referenced this pull request Jul 27, 2020
…arth

Rollup of 4 pull requests

Successful merges:

 - rust-lang#73858 (Make more primitive integer methods const)
 - rust-lang#74487 (Forbid generic parameters in anon consts inside of type defaults)
 - rust-lang#74803 (rustbuild: fix bad usage of UNIX exec() in rustc wrapper)
 - rust-lang#74822 (More ensure stack to avoid segfault with increased `recursion_limit`)

Failed merges:

r? @ghost
@bors bors merged commit 7864c3f into rust-lang:master Jul 27, 2020
15 of 16 checks passed
15 of 16 checks passed
PR (mingw-check, ubuntu-latest-xl)
Details
PR (x86_64-gnu-llvm-8, ubuntu-latest-xl)
Details
PR (x86_64-gnu-tools, 1, ubuntu-latest-xl)
Details
try
Details
auto
Details
auto-fallible
Details
master
Details
bors build finished
Details
bors build finished
Details
bors build finished
Details
bors build finished
Details
homu Testing commit d6cf128b45b4e7b370357b9497d68426719b0d5a with merge 84ed7797312f8dcc3aa46eca665088d6cc492651...
Details
pr Build #20200722.10 succeeded
Details
pr (Linux mingw-check) Linux mingw-check succeeded
Details
pr (Linux x86_64-gnu-llvm-8) Linux x86_64-gnu-llvm-8 succeeded
Details
pr (Linux x86_64-gnu-tools) Linux x86_64-gnu-tools succeeded
Details
@tspiteri tspiteri deleted the tspiteri:const-methods branch Jul 27, 2020
bnjbvr added a commit to bnjbvr/staticvec that referenced this pull request Jul 28, 2020
- following landing of rust-lang/rust#73858,
the `const_saturing_int_methods` feature is in a weird nonexisting
state (stabilized in a future Rust version), so remove it from the list
to unblock compilation.
- also remove other const features that have stabilized in the
meanwhile to avoid compiler warnings.
bnjbvr added a commit to bnjbvr/staticvec that referenced this pull request Jul 31, 2020
- following landing of rust-lang/rust#73858,
the `const_saturing_int_methods` feature is in a weird nonexisting
state (stabilized in a future Rust version), so remove it from the list
to unblock compilation.
- also remove other const features that have stabilized in the
meanwhile to avoid compiler warnings.
yvt added a commit to yvt/r3 that referenced this pull request Aug 14, 2020
The feature `const_saturating_int_methods` used by `staticvec` 0.10.1
has been stabilized by <rust-lang/rust#73858>.
yvt added a commit to yvt/r3 that referenced this pull request Aug 14, 2020
`const_saturating_int_methods` has been stabilized by
<rust-lang/rust#73858>.
@tspiteri tspiteri mentioned this pull request Sep 10, 2020
59 of 59 tasks complete
netbsd-srcmastr pushed a commit to NetBSD/pkgsrc that referenced this pull request Nov 13, 2020
Pkgsrc changes:
 * Remove patches now integrated upstream, many related to SunOS / Illumos.
 * The LLVM fix for powerpc is also now integrated upstream.
 * Adapt those patches where the source has moved or parts are integrated.
 * The randomness patches no longer applies, and I could not find
   where those files went...
 * Provide a separate bootstrap for NetBSD/powerpc 9.0, since apparently
   the C++ ABI is different from 8.0.  Yes, this appears to be specific to
   the NetBSD powerpc ports.

Upstream changes:

Version 1.47.0 (2020-10-08)
==========================

Language
--------
- [Closures will now warn when not used.][74869]

Compiler
--------
- [Stabilized the `-C control-flow-guard` codegen option][73893], which enables
  [Control Flow Guard][1.47.0-cfg] for Windows platforms, and is ignored on
  other platforms.
- [Upgraded to LLVM 11.][73526]
- [Added tier 3\* support for the `thumbv4t-none-eabi` target.][74419]
- [Upgrade the FreeBSD toolchain to version 11.4][75204]
- [`RUST_BACKTRACE`'s output is now more compact.][75048]

\* Refer to Rust's [platform support page][forge-platform-support] for more
information on Rust's tiered platform support.

Libraries
---------
- [`CStr` now implements `Index<RangeFrom<usize>>`.][74021]
- [Traits in `std`/`core` are now implemented for arrays of any length, not just
  those of length less than 33.][74060]
- [`ops::RangeFull` and `ops::Range` now implement Default.][73197]
- [`panic::Location` now implements `Copy`, `Clone`, `Eq`, `Hash`, `Ord`,
  `PartialEq`, and `PartialOrd`.][73583]

Stabilized APIs
---------------
- [`Ident::new_raw`]
- [`Range::is_empty`]
- [`RangeInclusive::is_empty`]
- [`Result::as_deref`]
- [`Result::as_deref_mut`]
- [`Vec::leak`]
- [`pointer::offset_from`]
- [`f32::TAU`]
- [`f64::TAU`]

The following previously stable APIs have now been made const.

- [The `new` method for all `NonZero` integers.][73858]
- [The `checked_add`,`checked_sub`,`checked_mul`,`checked_neg`, `checked_shl`,
  `checked_shr`, `saturating_add`, `saturating_sub`, and `saturating_mul`
  methods for all integers.][73858]
- [The `checked_abs`, `saturating_abs`, `saturating_neg`, and `signum`  for all
  signed integers.][73858]
- [The `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`, and
  `is_ascii_control` methods for `char` and `u8`.][73858]

Cargo
-----
- [`build-dependencies` are now built with opt-level 0 by default.][cargo/8500]
  You can override this by setting the following in your `Cargo.toml`.
  ```toml
  [profile.release.build-override]
  opt-level = 3
  ```
- [`cargo-help` will now display man pages for commands rather just the
  `--help` text.][cargo/8456]
- [`cargo-metadata` now emits a `test` field indicating if a target has
  tests enabled.][cargo/8478]
- [`workspace.default-members` now respects `workspace.exclude`.][cargo/8485]
- [`cargo-publish` will now use an alternative registry by default if it's the
  only registry specified in `package.publish`.][cargo/8571]

Misc
----
- [Added a help button beside Rustdoc's searchbar that explains rustdoc's
  type based search.][75366]
- [Added the Ayu theme to rustdoc.][71237]

Compatibility Notes
-------------------
- [Bumped the minimum supported Emscripten version to 1.39.20.][75716]
- [Fixed a regression parsing `{} && false` in tail expressions.][74650]
- [Added changes to how proc-macros are expanded in `macro_rules!` that should
  help to preserve more span information.][73084] These changes may cause
  compiliation errors if your macro was unhygenic or didn't correctly handle
  `Delimiter::None`.
- [Moved support for the CloudABI target to tier 3.][75568]
- [`linux-gnu` targets now require minimum kernel 2.6.32 and glibc 2.11.][74163]

Internal Only
--------
- [Improved default settings for bootstrapping in `x.py`.][73964]
  You can read details about this change in the ["Changes to `x.py`
  defaults"](https://blog.rust-lang.org/inside-rust/2020/08/30/changes-to-x-py-defaults.html)
  post on the Inside Rust blog.

- [Added the `rustc-docs` component.][75560] This allows you to install
  and read the documentation for the compiler internal APIs. (Currently only
  available for `x86_64-unknown-linux-gnu`.)

[1.47.0-cfg]: https://docs.microsoft.com/en-us/windows/win32/secbp/control-flow-guard
[76980]: rust-lang/rust#76980
[75048]: rust-lang/rust#75048
[74163]: rust-lang/rust#74163
[71237]: rust-lang/rust#71237
[74869]: rust-lang/rust#74869
[73858]: rust-lang/rust#73858
[75716]: rust-lang/rust#75716
[75908]: rust-lang/rust#75908
[75516]: rust-lang/rust#75516
[75560]: rust-lang/rust#75560
[75568]: rust-lang/rust#75568
[75366]: rust-lang/rust#75366
[75204]: rust-lang/rust#75204
[74650]: rust-lang/rust#74650
[74419]: rust-lang/rust#74419
[73964]: rust-lang/rust#73964
[74021]: rust-lang/rust#74021
[74060]: rust-lang/rust#74060
[73893]: rust-lang/rust#73893
[73526]: rust-lang/rust#73526
[73583]: rust-lang/rust#73583
[73084]: rust-lang/rust#73084
[73197]: rust-lang/rust#73197
[72488]: rust-lang/rust#72488
[cargo/8456]: rust-lang/cargo#8456
[cargo/8478]: rust-lang/cargo#8478
[cargo/8485]: rust-lang/cargo#8485
[cargo/8500]: rust-lang/cargo#8500
[cargo/8571]: rust-lang/cargo#8571
[`Ident::new_raw`]:  https://doc.rust-lang.org/nightly/proc_macro/struct.Ident.html#method.new_raw
[`Range::is_empty`]: https://doc.rust-lang.org/nightly/std/ops/struct.Range.html#method.is_empty
[`RangeInclusive::is_empty`]: https://doc.rust-lang.org/nightly/std/ops/struct.RangeInclusive.html#method.is_empty
[`Result::as_deref_mut`]: https://doc.rust-lang.org/nightly/std/result/enum.Result.html#method.as_deref_mut
[`Result::as_deref`]: https://doc.rust-lang.org/nightly/std/result/enum.Result.html#method.as_deref
[`TypeId::of`]: https://doc.rust-lang.org/nightly/std/any/struct.TypeId.html#method.of
[`Vec::leak`]: https://doc.rust-lang.org/nightly/std/vec/struct.Vec.html#method.leak
[`f32::TAU`]: https://doc.rust-lang.org/nightly/std/f32/consts/constant.TAU.html
[`f64::TAU`]: https://doc.rust-lang.org/nightly/std/f64/consts/constant.TAU.html
[`pointer::offset_from`]: https://doc.rust-lang.org/nightly/std/primitive.pointer.html#method.offset_from
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.