Skip to content

Commit

Permalink
Avoid naming variables str (#15025)
Browse files Browse the repository at this point in the history
This renames variables named `str` to other names, to make sure `str`
always refers to a type.
  • Loading branch information
Rustin170506 authored Jan 7, 2025
2 parents c1febbe + 1fe4591 commit 9438fe3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions src/cargo/util/context/de.rs
Original file line number Diff line number Diff line change
Expand Up @@ -531,11 +531,11 @@ impl<'de, 'gctx> de::MapAccess<'de> for ValueDeserializer<'gctx> {
seed.deserialize(Tuple2Deserializer(1i32, env.as_str()))
}
Definition::Cli(path) => {
let str = path
let s = path
.as_ref()
.map(|p| p.to_string_lossy())
.unwrap_or_default();
seed.deserialize(Tuple2Deserializer(2i32, str))
seed.deserialize(Tuple2Deserializer(2i32, s))
}
}
}
Expand Down
10 changes: 5 additions & 5 deletions src/cargo/util/interning.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,14 +72,14 @@ impl<'a> PartialEq<&'a str> for InternedString {
impl Eq for InternedString {}

impl InternedString {
pub fn new(str: &str) -> InternedString {
InternedString::from_cow(str.into())
pub fn new(s: &str) -> InternedString {
InternedString::from_cow(s.into())
}

fn from_cow<'a>(str: Cow<'a, str>) -> InternedString {
fn from_cow<'a>(cs: Cow<'a, str>) -> InternedString {
let mut cache = interned_storage();
let s = cache.get(str.as_ref()).copied().unwrap_or_else(|| {
let s = str.into_owned().leak();
let s = cache.get(cs.as_ref()).copied().unwrap_or_else(|| {
let s = cs.into_owned().leak();
cache.insert(s);
s
});
Expand Down

0 comments on commit 9438fe3

Please sign in to comment.