diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2023-12-06 21:52:32 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-12-06 21:52:32 +0100 |
| commit | cf78a79020d4f04ceeed755db2d28ee99baad683 (patch) | |
| tree | 1a35fce725a90e9dc965df7c3107108961321bc9 /compiler/rustc_middle/src | |
| parent | 1b391d4ae46e48bac50fc8817c631b2f57c8e307 (diff) | |
| parent | 92bf40ffe30832ba459e50d6f51d9e9a1cde9cd2 (diff) | |
| download | rust-cf78a79020d4f04ceeed755db2d28ee99baad683.tar.gz rust-cf78a79020d4f04ceeed755db2d28ee99baad683.zip | |
Rollup merge of #118660 - cuviper:alloc_str, r=petrochenkov
rustc_arena: add `alloc_str` Two places called `from_utf8_unchecked` for strings from `alloc_slice`, and one's SAFETY comment said this was for lack of `alloc_str` -- so let's just add that instead!
Diffstat (limited to 'compiler/rustc_middle/src')
| -rw-r--r-- | compiler/rustc_middle/src/ty/mod.rs | 4 |
1 files changed, 1 insertions, 3 deletions
diff --git a/compiler/rustc_middle/src/ty/mod.rs b/compiler/rustc_middle/src/ty/mod.rs index 9feda4d205e..bedb8050e6b 100644 --- a/compiler/rustc_middle/src/ty/mod.rs +++ b/compiler/rustc_middle/src/ty/mod.rs @@ -2614,9 +2614,7 @@ pub struct SymbolName<'tcx> { impl<'tcx> SymbolName<'tcx> { pub fn new(tcx: TyCtxt<'tcx>, name: &str) -> SymbolName<'tcx> { - SymbolName { - name: unsafe { str::from_utf8_unchecked(tcx.arena.alloc_slice(name.as_bytes())) }, - } + SymbolName { name: tcx.arena.alloc_str(name) } } } |
