Commit af356d6
authored
Rollup merge of rust-lang#132031 - slanterns:rc_default, r=ibraheemdev
Optimize `Rc<T>::default`
The missing piece of rust-lang#131460.
Also refactored `Arc<T>::default` by using a safe `NonNull::from(Box::leak(_))` to replace the unnecessarily unsafe call to `NonNull::new_unchecked(Box::into_raw(_))`. The remaining unsafety is coming from `[Rc|Arc]::from_inner`, which is safe from the construction of `[Rc|Arc]Inner`.File tree
3 files changed
+32
-8
lines changed- library/alloc/src
- tests/codegen
3 files changed
+32
-8
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2312 | 2312 | | |
2313 | 2313 | | |
2314 | 2314 | | |
2315 | | - | |
| 2315 | + | |
| 2316 | + | |
| 2317 | + | |
| 2318 | + | |
| 2319 | + | |
| 2320 | + | |
| 2321 | + | |
| 2322 | + | |
| 2323 | + | |
| 2324 | + | |
2316 | 2325 | | |
2317 | 2326 | | |
2318 | 2327 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3447 | 3447 | | |
3448 | 3448 | | |
3449 | 3449 | | |
3450 | | - | |
3451 | | - | |
3452 | | - | |
3453 | | - | |
3454 | | - | |
3455 | | - | |
3456 | | - | |
| 3450 | + | |
| 3451 | + | |
| 3452 | + | |
| 3453 | + | |
| 3454 | + | |
| 3455 | + | |
| 3456 | + | |
| 3457 | + | |
| 3458 | + | |
| 3459 | + | |
3457 | 3460 | | |
3458 | 3461 | | |
3459 | 3462 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
| 2 | + | |
2 | 3 | | |
3 | 4 | | |
4 | 5 | | |
5 | 6 | | |
6 | 7 | | |
| 8 | + | |
7 | 9 | | |
8 | 10 | | |
9 | 11 | | |
| |||
16 | 18 | | |
17 | 19 | | |
18 | 20 | | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
19 | 31 | | |
20 | 32 | | |
21 | 33 | | |
| |||
0 commit comments