Skip to content

Conversation

lilasta
Copy link
Contributor

@lilasta lilasta commented Oct 18, 2021

Adding const to From implementations in the core. rustc_const_unstable attribute is not added to unstable implementations.

Tracking issue: #88674

Done
  • T from T
  • T from !
  • Option<T> from T
  • Option<&T> from &Option<T>
  • Option<&mut T> from &mut Option<T>
  • Cell<T> from T
  • RefCell<T> from T
  • UnsafeCell<T> from T
  • OnceCell<T> from T
  • Poll<T> from T
  • u32 from char
  • u64 from char
  • u128 from char
  • char from u8
  • AtomicBool from bool
  • AtomicPtr<T> from *mut T
  • AtomicI(bits) from i(bits)
  • AtomicU(bits) from u(bits)
  • i(bits) from NonZeroI(bits)
  • u(bits) from NonZeroU(bits)
  • NonNull<T> from Unique<T>
  • NonNull<T> from &T
  • NonNull<T> from &mut T
  • Unique<T> from &mut T
  • Infallible from !
  • TryIntError from !
  • TryIntError from Infallible
  • TryFromSliceError from Infallible
  • FromResidual for Option<T>
Remaining

@rust-highfive
Copy link
Contributor

r? @dtolnay

(rust-highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Oct 18, 2021
Copy link
Member

@dtolnay dtolnay left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice — thanks!

@dtolnay
Copy link
Member

dtolnay commented Oct 18, 2021

@bors r+

@bors
Copy link
Collaborator

bors commented Oct 18, 2021

📌 Commit 7936ecf has been approved by dtolnay

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Oct 18, 2021
GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this pull request Oct 19, 2021
Make more `From` impls `const` (libcore)

Adding `const` to `From` implementations in the core. `rustc_const_unstable` attribute is not added to unstable implementations.

Tracking issue: rust-lang#88674

<details>
<summary>Done</summary><div>

- `T` from `T`
- `T` from `!`
- `Option<T>` from `T`
- `Option<&T>` from `&Option<T>`
- `Option<&mut T>` from `&mut Option<T>`
- `Cell<T>` from `T`
- `RefCell<T>` from `T`
- `UnsafeCell<T>` from `T`
- `OnceCell<T>` from `T`
- `Poll<T>` from `T`
- `u32` from `char`
- `u64` from `char`
- `u128` from `char`
- `char` from `u8`
- `AtomicBool` from `bool`
- `AtomicPtr<T>` from `*mut T`
- `AtomicI(bits)` from `i(bits)`
- `AtomicU(bits)` from `u(bits)`
- `i(bits)` from `NonZeroI(bits)`
- `u(bits)` from `NonZeroU(bits)`
- `NonNull<T>` from `Unique<T>`
- `NonNull<T>` from `&T`
- `NonNull<T>` from `&mut T`
- `Unique<T>` from `&mut T`
- `Infallible` from `!`
- `TryIntError` from `!`
- `TryIntError` from `Infallible`
- `TryFromSliceError` from `Infallible`
- `FromResidual for Option<T>`
</div></details>

<details>
<summary>Remaining</summary><dev>

- `NonZero` from `NonZero`
These can't be made const at this time because these use Into::into.
https://github.com/rust-lang/rust/blob/master/library/core/src/convert/num.rs#L393

- `std`, `alloc`
There may still be many implementations that can be made `const`.
</div></details>
bors added a commit to rust-lang-ci/rust that referenced this pull request Oct 19, 2021
Rollup of 10 pull requests

Successful merges:

 - rust-lang#86479 (Automatic exponential formatting in Debug)
 - rust-lang#87404 (Add support for artifact size profiling)
 - rust-lang#87769 (Alloc features cleanup)
 - rust-lang#88789 (remove unnecessary bound on Zip specialization impl)
 - rust-lang#88860 (Deduplicate panic_fmt)
 - rust-lang#90009 (Make more `From` impls `const` (libcore))
 - rust-lang#90018 (Fix rustdoc UI for very long type names)
 - rust-lang#90025 (Revert rust-lang#86011 to fix an incorrect bound check)
 - rust-lang#90036 (Remove border-bottom from most docblocks.)
 - rust-lang#90060 (Update RELEASES.md)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 9f2ad0a into rust-lang:master Oct 20, 2021
@rustbot rustbot added this to the 1.58.0 milestone Oct 20, 2021
@lilasta lilasta deleted the const_from_more branch December 25, 2021 09:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants