We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent b120ca9 commit 79a6cffCopy full SHA for 79a6cff
compiler/rustc_span/src/symbol.rs
@@ -2591,11 +2591,8 @@ impl StringArena {
2591
let len = u32::from_ne_bytes(region[idx as usize..idx as usize + 4].try_into().unwrap());
2592
let data = ®ion[idx as usize + 4..][..len as usize];
2593
2594
- // SAFETY: We (in theory) could be passed a random `idx` into the memory region, so we need
2595
- // to re-check that the region is actually UTF-8 before returning. If it is, then it is safe
2596
- // to return &str, though it might not be a *useful* &str due to having near-random
2597
- // contents.
2598
- std::str::from_utf8(data).unwrap()
+ // FIXME: hopefully we got passed an accurate index.
+ unsafe { std::str::from_utf8_unchecked(data) }
2599
}
2600
2601
0 commit comments