1
Fork 0

Avoid naming variables str

This renames variables named `str` to other names, to make sure `str`
always refers to a type.

It's confusing to read code where `str` (or another standard type name)
is used as an identifier. It also produces misleading syntax
highlighting.
This commit is contained in:
Josh Triplett 2025-01-07 14:12:07 +02:00
parent fb546ee09b
commit bb6bbfa13f
10 changed files with 34 additions and 34 deletions

View file

@ -704,8 +704,8 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
pub fn read_str(&self, mplace: &MPlaceTy<'tcx, M::Provenance>) -> InterpResult<'tcx, &str> {
let len = mplace.len(self)?;
let bytes = self.read_bytes_ptr_strip_provenance(mplace.ptr(), Size::from_bytes(len))?;
let str = std::str::from_utf8(bytes).map_err(|err| err_ub!(InvalidStr(err)))?;
interp_ok(str)
let s = std::str::from_utf8(bytes).map_err(|err| err_ub!(InvalidStr(err)))?;
interp_ok(s)
}
/// Read from a local of the current frame. Convenience method for [`InterpCx::local_at_frame_to_op`].

View file

@ -1017,9 +1017,9 @@ where
/// This is allocated in immutable global memory and deduplicated.
pub fn allocate_str_dedup(
&mut self,
str: &str,
s: &str,
) -> InterpResult<'tcx, MPlaceTy<'tcx, M::Provenance>> {
let bytes = str.as_bytes();
let bytes = s.as_bytes();
let ptr = self.allocate_bytes_dedup(bytes)?;
// Create length metadata for the string.