Commit 9f2ad0a
authored
Rollup merge of rust-lang#90009 - woppopo:const_from_more, r=dtolnay
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>File tree
19 files changed
+103
-27
lines changed- library/core
- src
- array
- char
- convert
- num
- ptr
- sync
- task
- tests
19 files changed
+103
-27
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
125 | 125 | | |
126 | 126 | | |
127 | 127 | | |
128 | | - | |
| 128 | + | |
| 129 | + | |
129 | 130 | | |
130 | 131 | | |
131 | 132 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
308 | 308 | | |
309 | 309 | | |
310 | 310 | | |
311 | | - | |
| 311 | + | |
| 312 | + | |
312 | 313 | | |
313 | 314 | | |
314 | 315 | | |
| |||
1236 | 1237 | | |
1237 | 1238 | | |
1238 | 1239 | | |
1239 | | - | |
| 1240 | + | |
| 1241 | + | |
1240 | 1242 | | |
1241 | 1243 | | |
1242 | 1244 | | |
| |||
1976 | 1978 | | |
1977 | 1979 | | |
1978 | 1980 | | |
1979 | | - | |
| 1981 | + | |
| 1982 | + | |
1980 | 1983 | | |
1981 | 1984 | | |
1982 | 1985 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
97 | 97 | | |
98 | 98 | | |
99 | 99 | | |
100 | | - | |
| 100 | + | |
| 101 | + | |
101 | 102 | | |
102 | 103 | | |
103 | 104 | | |
| |||
116 | 117 | | |
117 | 118 | | |
118 | 119 | | |
119 | | - | |
| 120 | + | |
| 121 | + | |
120 | 122 | | |
121 | 123 | | |
122 | 124 | | |
| |||
137 | 139 | | |
138 | 140 | | |
139 | 141 | | |
140 | | - | |
| 142 | + | |
| 143 | + | |
141 | 144 | | |
142 | 145 | | |
143 | 146 | | |
| |||
176 | 179 | | |
177 | 180 | | |
178 | 181 | | |
179 | | - | |
| 182 | + | |
| 183 | + | |
180 | 184 | | |
181 | 185 | | |
182 | 186 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
545 | 545 | | |
546 | 546 | | |
547 | 547 | | |
548 | | - | |
| 548 | + | |
| 549 | + | |
549 | 550 | | |
550 | 551 | | |
551 | 552 | | |
| |||
560 | 561 | | |
561 | 562 | | |
562 | 563 | | |
563 | | - | |
| 564 | + | |
| 565 | + | |
564 | 566 | | |
565 | 567 | | |
566 | 568 | | |
| |||
726 | 728 | | |
727 | 729 | | |
728 | 730 | | |
729 | | - | |
| 731 | + | |
| 732 | + | |
730 | 733 | | |
731 | 734 | | |
732 | 735 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
74 | 74 | | |
75 | 75 | | |
76 | 76 | | |
77 | | - | |
| 77 | + | |
78 | 78 | | |
79 | 79 | | |
80 | 80 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
29 | 29 | | |
30 | 30 | | |
31 | 31 | | |
32 | | - | |
| 32 | + | |
| 33 | + | |
33 | 34 | | |
34 | 35 | | |
35 | 36 | | |
36 | 37 | | |
37 | 38 | | |
38 | 39 | | |
39 | | - | |
| 40 | + | |
40 | 41 | | |
41 | 42 | | |
42 | 43 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
82 | 82 | | |
83 | 83 | | |
84 | 84 | | |
85 | | - | |
| 85 | + | |
| 86 | + | |
86 | 87 | | |
87 | 88 | | |
88 | 89 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1723 | 1723 | | |
1724 | 1724 | | |
1725 | 1725 | | |
1726 | | - | |
| 1726 | + | |
| 1727 | + | |
1727 | 1728 | | |
1728 | 1729 | | |
1729 | 1730 | | |
| |||
1739 | 1740 | | |
1740 | 1741 | | |
1741 | 1742 | | |
1742 | | - | |
| 1743 | + | |
| 1744 | + | |
1743 | 1745 | | |
1744 | 1746 | | |
1745 | 1747 | | |
| |||
1766 | 1768 | | |
1767 | 1769 | | |
1768 | 1770 | | |
1769 | | - | |
| 1771 | + | |
| 1772 | + | |
1770 | 1773 | | |
1771 | 1774 | | |
1772 | 1775 | | |
| |||
2052 | 2055 | | |
2053 | 2056 | | |
2054 | 2057 | | |
2055 | | - | |
| 2058 | + | |
2056 | 2059 | | |
2057 | 2060 | | |
2058 | 2061 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
698 | 698 | | |
699 | 699 | | |
700 | 700 | | |
701 | | - | |
| 701 | + | |
| 702 | + | |
702 | 703 | | |
703 | 704 | | |
704 | 705 | | |
| |||
708 | 709 | | |
709 | 710 | | |
710 | 711 | | |
711 | | - | |
| 712 | + | |
| 713 | + | |
712 | 714 | | |
713 | 715 | | |
714 | 716 | | |
| |||
717 | 719 | | |
718 | 720 | | |
719 | 721 | | |
720 | | - | |
| 722 | + | |
| 723 | + | |
721 | 724 | | |
722 | 725 | | |
723 | 726 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
176 | 176 | | |
177 | 177 | | |
178 | 178 | | |
179 | | - | |
| 179 | + | |
180 | 180 | | |
181 | 181 | | |
182 | 182 | | |
| |||
0 commit comments