diff options
| author | Josh Triplett <josh@joshtriplett.org> | 2025-01-07 14:12:07 +0200 |
|---|---|---|
| committer | Josh Triplett <josh@joshtriplett.org> | 2025-01-07 14:30:02 +0200 |
| commit | bb6bbfa13f97e6ef30ecd63c835c99cf7762bd6e (patch) | |
| tree | 72903e70f117fddc546a875d4fff4285c11c00d1 /compiler/rustc_const_eval/src | |
| parent | fb546ee09b226bc4dd4b712d35a372d923c4fa54 (diff) | |
| download | rust-bb6bbfa13f97e6ef30ecd63c835c99cf7762bd6e.tar.gz rust-bb6bbfa13f97e6ef30ecd63c835c99cf7762bd6e.zip | |
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.
Diffstat (limited to 'compiler/rustc_const_eval/src')
| -rw-r--r-- | compiler/rustc_const_eval/src/interpret/operand.rs | 4 | ||||
| -rw-r--r-- | compiler/rustc_const_eval/src/interpret/place.rs | 4 |
2 files changed, 4 insertions, 4 deletions
diff --git a/compiler/rustc_const_eval/src/interpret/operand.rs b/compiler/rustc_const_eval/src/interpret/operand.rs index b861ffb6110..5d905cff1f2 100644 --- a/compiler/rustc_const_eval/src/interpret/operand.rs +++ b/compiler/rustc_const_eval/src/interpret/operand.rs @@ -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`]. diff --git a/compiler/rustc_const_eval/src/interpret/place.rs b/compiler/rustc_const_eval/src/interpret/place.rs index 0d974071619..c97922ac132 100644 --- a/compiler/rustc_const_eval/src/interpret/place.rs +++ b/compiler/rustc_const_eval/src/interpret/place.rs @@ -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. |
