Commit 4d840a6
authored
Rollup merge of rust-lang#91823 - woppopo:const_ptr_as_ref, r=lcnr
Make `PTR::as_ref` and similar methods `const`.
Tracking issue: rust-lang#91822
Feature gate: `#![feature(const_ptr_as_ref)]`
```rust
// core::ptr
impl<T: ?Sized> *const T {
pub const unsafe fn as_ref<'a>(self) -> Option<&'a T>;
pub const unsafe fn as_uninit_ref<'a>(self) -> Option<&'a MaybeUninit<T>>
where
T: Sized;
pub const unsafe fn as_uninit_slice<'a>(self) -> Option<&'a [MaybeUninit<T>]>;
}
impl<T: ?Sized> *mut T {
pub const unsafe fn as_ref<'a>(self) -> Option<&'a T>;
pub const unsafe fn as_uninit_ref<'a>(self) -> Option<&'a MaybeUninit<T>>
where
T: Sized;
pub const unsafe fn as_mut<'a>(self) -> Option<&'a mut T>;
pub const unsafe fn as_uninit_mut<'a>(self) -> Option<&'a mut MaybeUninit<T>>
where
T: Sized;
pub const unsafe fn as_uninit_slice<'a>(self) -> Option<&'a [MaybeUninit<T>]>;
pub const unsafe fn as_uninit_slice_mut<'a>(self) -> Option<&'a mut [MaybeUninit<T>]>;
}
impl<T: Sized> NonNull<T> {
pub const unsafe fn as_uninit_ref<'a>(&self) -> &'a MaybeUninit<T>;
pub const unsafe fn as_uninit_mut<'a>(&mut self) -> &'a mut MaybeUninit<T>;
}
impl<T: ?Sized> NonNull<T> {
pub const unsafe fn as_ref<'a>(&self) -> &'a T;
pub const unsafe fn as_mut<'a>(&mut self) -> &'a mut T;
pub const unsafe fn as_uninit_slice<'a>(&self) -> &'a [MaybeUninit<T>];
pub const unsafe fn as_uninit_slice_mut<'a>(&self) -> &'a mut [MaybeUninit<T>];
}
```3 files changed
+30
-15
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
163 | 163 | | |
164 | 164 | | |
165 | 165 | | |
| 166 | + | |
166 | 167 | | |
167 | | - | |
| 168 | + | |
168 | 169 | | |
169 | 170 | | |
170 | 171 | | |
| |||
211 | 212 | | |
212 | 213 | | |
213 | 214 | | |
214 | | - | |
| 215 | + | |
| 216 | + | |
215 | 217 | | |
216 | 218 | | |
217 | 219 | | |
| |||
1068 | 1070 | | |
1069 | 1071 | | |
1070 | 1072 | | |
1071 | | - | |
| 1073 | + | |
| 1074 | + | |
1072 | 1075 | | |
1073 | 1076 | | |
1074 | 1077 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
166 | 166 | | |
167 | 167 | | |
168 | 168 | | |
| 169 | + | |
169 | 170 | | |
170 | | - | |
| 171 | + | |
171 | 172 | | |
172 | 173 | | |
173 | 174 | | |
| |||
217 | 218 | | |
218 | 219 | | |
219 | 220 | | |
220 | | - | |
| 221 | + | |
| 222 | + | |
221 | 223 | | |
222 | 224 | | |
223 | 225 | | |
| |||
411 | 413 | | |
412 | 414 | | |
413 | 415 | | |
| 416 | + | |
414 | 417 | | |
415 | | - | |
| 418 | + | |
416 | 419 | | |
417 | 420 | | |
418 | 421 | | |
| |||
446 | 449 | | |
447 | 450 | | |
448 | 451 | | |
449 | | - | |
| 452 | + | |
| 453 | + | |
450 | 454 | | |
451 | 455 | | |
452 | 456 | | |
| |||
1335 | 1339 | | |
1336 | 1340 | | |
1337 | 1341 | | |
1338 | | - | |
| 1342 | + | |
| 1343 | + | |
1339 | 1344 | | |
1340 | 1345 | | |
1341 | 1346 | | |
| |||
1386 | 1391 | | |
1387 | 1392 | | |
1388 | 1393 | | |
1389 | | - | |
| 1394 | + | |
| 1395 | + | |
1390 | 1396 | | |
1391 | 1397 | | |
1392 | 1398 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
122 | 122 | | |
123 | 123 | | |
124 | 124 | | |
125 | | - | |
| 125 | + | |
| 126 | + | |
126 | 127 | | |
127 | 128 | | |
128 | 129 | | |
| |||
155 | 156 | | |
156 | 157 | | |
157 | 158 | | |
158 | | - | |
| 159 | + | |
| 160 | + | |
159 | 161 | | |
160 | 162 | | |
161 | 163 | | |
| |||
316 | 318 | | |
317 | 319 | | |
318 | 320 | | |
| 321 | + | |
319 | 322 | | |
320 | 323 | | |
321 | | - | |
| 324 | + | |
322 | 325 | | |
323 | 326 | | |
324 | 327 | | |
| |||
366 | 369 | | |
367 | 370 | | |
368 | 371 | | |
| 372 | + | |
369 | 373 | | |
370 | 374 | | |
371 | | - | |
| 375 | + | |
372 | 376 | | |
373 | 377 | | |
374 | 378 | | |
| |||
534 | 538 | | |
535 | 539 | | |
536 | 540 | | |
537 | | - | |
| 541 | + | |
| 542 | + | |
538 | 543 | | |
539 | 544 | | |
540 | 545 | | |
| |||
596 | 601 | | |
597 | 602 | | |
598 | 603 | | |
599 | | - | |
| 604 | + | |
| 605 | + | |
600 | 606 | | |
601 | 607 | | |
602 | 608 | | |
| |||
0 commit comments