diff options
| author | Yuki Okushi <jtitor@2k36.org> | 2021-11-19 02:22:57 +0900 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-11-19 02:22:57 +0900 |
| commit | 77c985f76564f4d47897b3488f5a609f6a89f3ec (patch) | |
| tree | 371410deff33bd2b8b1da49a5962fa160780ae5d /compiler/rustc_mir_transform/src/coverage/graph.rs | |
| parent | 3e97d9bd972e138b0aaf8fc697cdb8d181f43a1a (diff) | |
| parent | 573a00e3f9207a3be67921e1046cab95150b4ab4 (diff) | |
| download | rust-77c985f76564f4d47897b3488f5a609f6a89f3ec.tar.gz rust-77c985f76564f4d47897b3488f5a609f6a89f3ec.zip | |
Rollup merge of #90607 - WaffleLapkin:const_str_from_utf8, r=oli-obk
Make slice->str conversion and related functions `const`
This PR marks the following APIs as `const`:
```rust
// core::str
pub const fn from_utf8(v: &[u8]) -> Result<&str, Utf8Error>;
pub const fn from_utf8_mut(v: &mut [u8]) -> Result<&mut str, Utf8Error>;
pub const unsafe fn from_utf8_unchecked_mut(v: &mut [u8]) -> &mut str;
impl Utf8Error {
pub const fn valid_up_to(&self) -> usize;
pub const fn error_len(&self) -> Option<usize>;
}
```
Everything but `from_utf8_unchecked_mut` uses `const_str_from_utf8` feature gate, `from_utf8_unchecked_mut` uses `const_str_from_utf8_unchecked_mut` feature gate.
---
I'm not sure why `from_utf8_unchecked_mut` was left out being non-`const`, considering that `from_utf8_unchecked` is not only `const`, but **`const` stable**.
---
r? ```@oli-obk``` (performance-only `const_eval_select` use)
Diffstat (limited to 'compiler/rustc_mir_transform/src/coverage/graph.rs')
0 files changed, 0 insertions, 0 deletions
