mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-03 15:15:24 +00:00
Fix mir CString lowering not respecting the extra 0 byte for length calc
This commit is contained in:
parent
4b577e2bc8
commit
eab295cc73
1 changed files with 4 additions and 2 deletions
|
@ -1121,11 +1121,13 @@ impl<'ctx> MirLowerCtx<'ctx> {
|
|||
}
|
||||
hir_def::hir::Literal::CString(b) => {
|
||||
let b = b.as_bytes();
|
||||
let bytes = b.iter().copied().chain(iter::once(0)).collect::<Vec<_>>();
|
||||
|
||||
let mut data = Vec::with_capacity(mem::size_of::<usize>() * 2);
|
||||
data.extend(0usize.to_le_bytes());
|
||||
data.extend(b.len().to_le_bytes());
|
||||
data.extend(bytes.len().to_le_bytes());
|
||||
let mut mm = MemoryMap::default();
|
||||
mm.insert(0, b.iter().copied().chain(iter::once(0)).collect::<Vec<_>>());
|
||||
mm.insert(0, bytes);
|
||||
return Ok(Operand::from_concrete_const(data, mm, ty));
|
||||
}
|
||||
hir_def::hir::Literal::ByteString(b) => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue