Fix a bunch of "needless borrow" warnings on nightly

It looks like, despite a few false starts, they've got this warning
right; there weren't any false positives.
This commit is contained in:
Nick Mathewson 2022-11-18 10:12:05 -05:00
parent e8701b1e9e
commit d51162e55b
10 changed files with 17 additions and 17 deletions

View File

@ -490,7 +490,7 @@ mod test {
"www.example.com:8000",
);
check(
&TorAddr::from(("www.example.com", 8000)).unwrap(),
TorAddr::from(("www.example.com", 8000)).unwrap(),
"www.example.com:8000",
);
check("[2001:db8::0042]:9001".to_owned(), "[2001:db8::42]:9001");

View File

@ -615,7 +615,7 @@ mod test {
let example = uncomment_example_settings(example_file);
let example: toml::Value = toml::from_str(&example).unwrap();
// dbg!(&example);
let example = serde_json::to_value(&example).unwrap();
let example = serde_json::to_value(example).unwrap();
// dbg!(&example);
// "Exhaustive" taxonomy of the recognized configuration keys
@ -626,8 +626,8 @@ mod test {
// I'm not sure this is quite perfect but it is pretty good,
// and has found a number of un-exampled config keys.
let exhausts = [
serde_json::to_value(&TorClientConfig::builder()).unwrap(),
serde_json::to_value(&ArtiConfig::builder()).unwrap(),
serde_json::to_value(TorClientConfig::builder()).unwrap(),
serde_json::to_value(ArtiConfig::builder()).unwrap(),
];
#[derive(Default, Debug)]

View File

@ -482,7 +482,7 @@ world = \"nonsense\"
let xd = td.path().join("nonexistent.d/");
std::fs::create_dir(&d).unwrap();
std::fs::write(&cf, EX_TOML).unwrap();
std::fs::write(&df, EX2_TOML).unwrap();
std::fs::write(df, EX2_TOML).unwrap();
std::fs::write(d.join("not-toml"), "SYNTAX ERROR").unwrap();
let files = vec![

View File

@ -149,7 +149,7 @@ fn setup() -> (TempDir, Bdm, R, M, BridgeKey, rusqlite::Connection) {
let store = Arc::new(Mutex::new(Box::new(store) as _));
let sql_path = db_tmp_dir.path().join("db.sql");
let conn = rusqlite::Connection::open(&sql_path).unwrap();
let conn = rusqlite::Connection::open(sql_path).unwrap();
let bdm = BridgeDescMgr::<R, M>::new_internal(
runtime.clone(),

View File

@ -404,7 +404,7 @@ impl Store for SqliteStore {
if let Some(row) = rows.next()? {
let meta = cmeta_from_row(row)?;
let fname: String = row.get(5)?;
let text = self.read_blob(&fname)?;
let text = self.read_blob(fname)?;
Ok(Some((text, meta)))
} else {
Ok(None)
@ -978,7 +978,7 @@ pub(crate) mod test {
pub(crate) fn new_empty() -> Result<(TempDir, SqliteStore)> {
let tmp_dir = tempdir().unwrap();
let sql_path = tmp_dir.path().join("db.sql");
let conn = rusqlite::Connection::open(&sql_path)?;
let conn = rusqlite::Connection::open(sql_path)?;
let blob_dir = fs_mistrust::Mistrust::builder()
.dangerously_trust_everyone()
.build()

View File

@ -267,7 +267,7 @@ impl PublicKey {
pub fn to_rsa_identity(&self) -> RsaIdentity {
use crate::d::Sha1;
use digest::Digest;
let id = Sha1::digest(&self.to_der()).into();
let id = Sha1::digest(self.to_der()).into();
RsaIdentity { id }
}
}

View File

@ -58,7 +58,7 @@ impl<'a, K: Keyword> TokVal<'a, K> {
/// Return the Item for this value, if there is exactly one.
fn singleton(&self) -> Option<&Item<'a, K>> {
match &*self.0 {
&[ref x] => Some(x),
[x] => Some(x),
_ => None,
}
}

View File

@ -344,7 +344,7 @@ mod test {
assert_eq!(store.try_lock()?, LockStatus::NewlyAcquired);
let fname = statedir.join("numbat.toml");
let fname2 = statedir.join("quoll.json");
std::fs::write(&fname, "we no longer use toml files.").unwrap();
std::fs::write(fname, "we no longer use toml files.").unwrap();
std::fs::write(&fname2, "{}").unwrap();
// Make the store directory read-only and make sure that we can't delete from it.
@ -358,7 +358,7 @@ mod test {
assert_eq!(lst.len(), 3); // We can't remove the file, but we didn't freak out. Great!
// Try failing to read a mode-0 file.
std::fs::set_permissions(&statedir, rw_dir).unwrap();
std::fs::set_permissions(&fname2, unusable).unwrap();
std::fs::set_permissions(fname2, unusable).unwrap();
let h: Result<Option<HashMap<String, u32>>> = store.load("quoll");
assert!(h.is_err());

View File

@ -122,7 +122,7 @@ mod test {
let fname1 = dir.path().join("quokka");
let now = SystemTime::now();
std::fs::write(&fname1, "hello world").unwrap();
std::fs::write(fname1, "hello world").unwrap();
let mut r = std::fs::read_dir(dir.path()).unwrap();
let ent = r.next().unwrap().unwrap();
@ -136,10 +136,10 @@ mod test {
let now = SystemTime::now();
let fname1 = dir.path().join("quokka.toml");
std::fs::write(&fname1, "hello world").unwrap();
std::fs::write(fname1, "hello world").unwrap();
let fname2 = dir.path().join("wombat.json");
std::fs::write(&fname2, "greetings").unwrap();
std::fs::write(fname2, "greetings").unwrap();
let removable_now = files_to_delete(dir.path(), now);
assert!(removable_now.is_empty());

View File

@ -359,8 +359,8 @@ mod tests {
fn make_fake_ephem_key(bytes: &[u8]) -> EphemeralSecret {
assert_eq!(bytes.len(), 32);
let mut rng = FakePRNG::new(bytes);
EphemeralSecret::new(&mut rng)
let rng = FakePRNG::new(bytes);
EphemeralSecret::new(rng)
}
#[test]