diff options
| author | Josh Stone <jistone@redhat.com> | 2023-12-05 17:33:16 -0800 |
|---|---|---|
| committer | Josh Stone <jistone@redhat.com> | 2023-12-05 17:52:51 -0800 |
| commit | 92bf40ffe30832ba459e50d6f51d9e9a1cde9cd2 (patch) | |
| tree | 01aedd7ed5c6ecb573001d096ea472d873243ad0 /compiler/rustc_middle/src | |
| parent | e9013ac0e402ef449c5d00251d687289599137df (diff) | |
| download | rust-92bf40ffe30832ba459e50d6f51d9e9a1cde9cd2.tar.gz rust-92bf40ffe30832ba459e50d6f51d9e9a1cde9cd2.zip | |
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) } } } |
