Skip to content

Commit

Permalink
Unify single-char and multi-char CStrUnit::Char handling.
Browse files Browse the repository at this point in the history
The two cases are equivalent. C string literals aren't common so there
is no performance need here.
  • Loading branch information
nnethercote committed Dec 12, 2023
1 parent 29c5158 commit a50efe2
Showing 1 changed file with 0 additions and 1 deletion.
1 change: 0 additions & 1 deletion compiler/rustc_ast/src/util/literal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,6 @@ impl LitKind {
error = Err(LitError::NulInCStr(span));
}
Ok(CStrUnit::Byte(b)) => buf.push(b),
Ok(CStrUnit::Char(c)) if c.len_utf8() == 1 => buf.push(c as u8),
Ok(CStrUnit::Char(c)) => {
buf.extend_from_slice(c.encode_utf8(&mut [0; 4]).as_bytes())
}
Expand Down

0 comments on commit a50efe2

Please sign in to comment.