Skip to content

Commit d5846bb

Browse files
author
Jason Heath
committed
Revved rust from 1.62.1 to 1.67.1
- Address Clippy warnings while upgrading from 1.62.1 to 1.67.1 - A fix for the change in signal masking introduced in rust-lang/rust#101077 - Changes to address an instance of https://rust-lang.github.io/rust-clippy/master/index.html\#result_large_err Signed-off-by: Jason Heath <[email protected]>
1 parent ee5cd3e commit d5846bb

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

73 files changed

+282
-280
lines changed

.rustfmt.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ unstable_features = true
66

77
# stable options
88
edition = "2018"
9-
fn_args_layout = "Tall"
9+
fn_params_layout = "Tall"
1010
force_explicit_abi = true
1111
format_code_in_doc_comments = true
1212
hard_tabs = false

components/builder-api-client/src/builder.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ impl BuilderAPIClient {
190190
let resp = self.maybe_add_authz(rb, token).send().await?;
191191
let resp = response::ok_if(resp, &[StatusCode::OK]).await?;
192192

193-
fs::create_dir_all(&dst_path)?;
193+
fs::create_dir_all(dst_path)?;
194194
let file_name = response::get_header(&resp, X_FILENAME)?;
195195
let dst_file_path = dst_path.join(file_name);
196196
let w = AtomicWriter::new_with_permissions(&dst_file_path, permissions)?;
@@ -1609,7 +1609,7 @@ mod tests {
16091609
(range, (range + step).min(last))
16101610
};
16111611
let filtered_range = filtered[start..=end].iter()
1612-
.map(|s| get_test_ident(**s))
1612+
.map(|s| get_test_ident(s))
16131613
.collect::<Vec<_>>();
16141614
let result = PackageResults { range_start: start as isize,
16151615
range_end: end as isize,

components/butterfly/src/client.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,6 @@ impl Client {
8181
{
8282
let bytes = rumor.write_to_bytes()?;
8383
let wire_msg = message::generate_wire(bytes, self.ring_key.as_ref())?;
84-
self.socket.send(&wire_msg, 0).map_err(Error::ZmqSendError)
84+
self.socket.send(wire_msg, 0).map_err(Error::ZmqSendError)
8585
}
8686
}

components/butterfly/src/member.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ impl Default for Member {
174174
}
175175

176176
impl From<Member> for RumorKey {
177-
fn from(member: Member) -> RumorKey { RumorKey::new(RumorType::Member, &member.id, "") }
177+
fn from(member: Member) -> RumorKey { RumorKey::new(RumorType::Member, member.id, "") }
178178
}
179179

180180
impl<'a> From<&'a Member> for RumorKey {

components/butterfly/src/protocol/swim.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@ mod tests {
2424

2525
#[test]
2626
fn health_values_are_title_case() {
27-
assert_eq!(serde_json::to_value(&Health::Alive).unwrap(), "Alive");
28-
assert_eq!(serde_json::to_value(&Health::Suspect).unwrap(), "Suspect");
29-
assert_eq!(serde_json::to_value(&Health::Confirmed).unwrap(),
27+
assert_eq!(serde_json::to_value(Health::Alive).unwrap(), "Alive");
28+
assert_eq!(serde_json::to_value(Health::Suspect).unwrap(), "Suspect");
29+
assert_eq!(serde_json::to_value(Health::Confirmed).unwrap(),
3030
"Confirmed");
31-
assert_eq!(serde_json::to_value(&Health::Departed).unwrap(), "Departed");
31+
assert_eq!(serde_json::to_value(Health::Departed).unwrap(), "Departed");
3232
}
3333
}

components/butterfly/src/rumor/dat_file.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,7 @@ impl DatFile {
368368
{
369369
let mut bytes_read = 0;
370370
let mut size_buf = [0; 8];
371-
let mut rumor_buf: Vec<u8> = vec![];
371+
let mut rumor_buf: Vec<u8> = vec![0; 8];
372372

373373
loop {
374374
if bytes_read >= offset {

components/butterfly/src/rumor/heat.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ pub(crate) mod sync {
7575
.collect();
7676

7777
// Reverse sorting by heat; 0s come last!
78-
rumor_heat.sort_by(|&(_, ref h1), &(_, ref h2)| h2.cmp(h1));
78+
rumor_heat.sort_by(|(_, h1), (_, h2)| h2.cmp(h1));
7979

8080
// We don't need the heat anymore, just return the rumors.
8181
rumor_heat.into_iter().map(|(k, _)| k).collect()

components/butterfly/src/server.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -748,7 +748,7 @@ impl Server {
748748
rumor_heat.lock_rhw().purge(member_id_to_depart);
749749
rumor_heat.lock_rhw()
750750
.start_hot_rumor(RumorKey::new(RumorType::Member,
751-
&*member_id_to_depart,
751+
member_id_to_depart,
752752
""));
753753
}
754754
}

components/butterfly/src/server/incarnation_store.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ mod tests {
9797
"The path {:?} shouldn't exist, but it does",
9898
path);
9999

100-
let i = IncarnationStore::new(&path);
100+
let i = IncarnationStore::new(path);
101101
assert!(i.load().is_err());
102102
}
103103

@@ -155,13 +155,13 @@ mod tests {
155155
let tempfile = Temp::new_file().expect("Could not create temp file");
156156
let path = tempfile.as_ref();
157157

158-
let mut buffer = File::create(&path).expect("could not create file");
158+
let mut buffer = File::create(path).expect("could not create file");
159159
buffer.write_all(b"this, also, is not a u64")
160160
.expect("could not write file");
161161

162162
assert!(path.exists());
163163

164-
let mut i = IncarnationStore::new(&path);
164+
let mut i = IncarnationStore::new(path);
165165
assert!(i.initialize().is_err());
166166
}
167167
}

components/common/src/cli.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ pub fn is_toml_file(val: &str) -> bool {
6161
}
6262

6363
pub fn file_into_idents(path: &str) -> Result<Vec<PackageIdent>, habitat_core::error::Error> {
64-
let s = std::fs::read_to_string(&path).map_err(|_| {
64+
let s = std::fs::read_to_string(path).map_err(|_| {
6565
habitat_core::error::Error::FileNotFound(format!("Could not open file {}", path))
6666
})?;
6767

components/common/src/cli_config.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ impl CliConfig {
6464
}
6565

6666
/// Get a reference to the `CliConfig` cached at startup
67-
pub fn cache() -> &'static Self { &*CACHED_CLI_CONFIG }
67+
pub fn cache() -> &'static Self { &CACHED_CLI_CONFIG }
6868

6969
/// Load an up to date `CliConfig` from disk
7070
pub fn load() -> Result<Self, Error> {
@@ -79,7 +79,7 @@ impl CliConfig {
7979

8080
/// Save the `CliConfig` to disk
8181
pub fn save(&self) -> Result<(), Error> {
82-
fs::create_dir_all(&*CLI_CONFIG_PATH_PARENT)?;
82+
fs::create_dir_all(*CLI_CONFIG_PATH_PARENT)?;
8383
let raw = toml::ser::to_string(self)?;
8484
debug!("Raw config toml:\n---\n{}\n---", &raw);
8585
fs::write(&*CLI_CONFIG_PATH, raw)?;

components/common/src/owning_refs.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@ unsafe impl<'a, T: ?Sized> StableAddress for StableMutexGuard<'a, T> {}
1515
impl<T: ?Sized> Deref for StableMutexGuard<'_, T> {
1616
type Target = T;
1717

18-
fn deref(&self) -> &T { &*self.0 }
18+
fn deref(&self) -> &T { &self.0 }
1919
}
2020

2121
impl<T: ?Sized> DerefMut for StableMutexGuard<'_, T> {
22-
fn deref_mut(&mut self) -> &mut T { &mut *self.0 }
22+
fn deref_mut(&mut self) -> &mut T { &mut self.0 }
2323
}
2424

2525
impl<'a, T> From<MutexGuard<'a, T>> for StableMutexGuard<'a, T> {
@@ -35,7 +35,7 @@ unsafe impl<'a, T: ?Sized> StableAddress for StableRwLockReadGuard<'a, T> {}
3535
impl<T: ?Sized> Deref for StableRwLockReadGuard<'_, T> {
3636
type Target = T;
3737

38-
fn deref(&self) -> &T { &*self.0 }
38+
fn deref(&self) -> &T { &self.0 }
3939
}
4040

4141
impl<'a, T> From<RwLockReadGuard<'a, T>> for StableRwLockReadGuard<'a, T> {
@@ -51,11 +51,11 @@ unsafe impl<'a, T: ?Sized> StableAddress for StableRwLockWriteGuard<'a, T> {}
5151
impl<T: ?Sized> Deref for StableRwLockWriteGuard<'_, T> {
5252
type Target = T;
5353

54-
fn deref(&self) -> &T { &*self.0 }
54+
fn deref(&self) -> &T { &self.0 }
5555
}
5656

5757
impl<T: ?Sized> DerefMut for StableRwLockWriteGuard<'_, T> {
58-
fn deref_mut(&mut self) -> &mut T { &mut *self.0 }
58+
fn deref_mut(&mut self) -> &mut T { &mut self.0 }
5959
}
6060

6161
impl<'a, T> From<RwLockWriteGuard<'a, T>> for StableRwLockWriteGuard<'a, T> {

components/common/src/templating.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -50,15 +50,15 @@ pub async fn compile_for_package_install(package: &PackageInstall,
5050
cfg_renderer.compile(&pkg.name, &pkg, &pkg.svc_config_install_path, &ctx)?;
5151

5252
if let Some(ref hook) = InstallHook::load(&pkg.name,
53-
&fs::svc_hooks_path(&pkg.name),
54-
&package.installed_path.join("hooks"),
53+
fs::svc_hooks_path(&pkg.name),
54+
package.installed_path.join("hooks"),
5555
feature_flags)
5656
{
5757
hook.compile(&pkg.name, &ctx)?;
5858
};
5959
if let Some(ref hook) = UninstallHook::load(&pkg.name,
60-
&fs::svc_hooks_path(&pkg.name),
61-
&package.installed_path.join("hooks"),
60+
fs::svc_hooks_path(&pkg.name),
61+
package.installed_path.join("hooks"),
6262
feature_flags)
6363
{
6464
hook.compile(&pkg.name, &ctx)?;
@@ -218,8 +218,8 @@ mod test {
218218
pub fn toml_to_json(value: toml::Value) -> serde_json::Value {
219219
match value {
220220
toml::Value::String(s) => serde_json::Value::String(s),
221-
toml::Value::Integer(i) => serde_json::Value::from(i as i64),
222-
toml::Value::Float(i) => serde_json::Value::from(i as f64),
221+
toml::Value::Integer(i) => serde_json::Value::from(i),
222+
toml::Value::Float(i) => serde_json::Value::from(i),
223223
toml::Value::Boolean(b) => serde_json::Value::Bool(b),
224224
toml::Value::Datetime(s) => serde_json::Value::String(s.to_string()),
225225
toml::Value::Array(a) => toml_vec_to_json(a),

components/common/src/templating/config.rs

+8-8
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ impl Cfg {
198198
/// exports.
199199
pub fn to_exported(&self, pkg: &Pkg) -> Result<toml::value::Table> {
200200
let mut map = toml::value::Table::default();
201-
let cfg = toml::Value::try_from(&self).expect("Cfg -> TOML conversion");
201+
let cfg = toml::Value::try_from(self).expect("Cfg -> TOML conversion");
202202
for (key, path) in pkg.exports.iter() {
203203
let mut curr = &cfg;
204204
let mut found = false;
@@ -229,7 +229,7 @@ impl Cfg {
229229
T2: AsRef<Path>
230230
{
231231
let filename = file.as_ref();
232-
let path = dir.as_ref().join(&filename);
232+
let path = dir.as_ref().join(filename);
233233
let mut file = match File::open(&path) {
234234
Ok(file) => file,
235235
Err(e) => {
@@ -429,7 +429,7 @@ impl CfgRenderer {
429429
for template in self.0.get_templates().keys() {
430430
let compiled = self.0.render(template, ctx)?;
431431
let compiled_hash = Blake2bHash::from_bytes(&compiled);
432-
let cfg_dest = render_path.as_ref().join(&template);
432+
let cfg_dest = render_path.as_ref().join(template);
433433
let file_hash = match Blake2bHash::from_file(&cfg_dest) {
434434
Ok(file_hash) => Some(file_hash),
435435
Err(e) => {
@@ -536,7 +536,7 @@ fn set_permissions(path: &Path, user: &str, group: &str) -> hcore::error::Result
536536
} else {
537537
CONFIG_PERMISSIONS
538538
};
539-
posix_perm::set_permissions(&path, permissions)
539+
posix_perm::set_permissions(path, permissions)
540540
}
541541

542542
#[cfg(windows)]
@@ -585,12 +585,12 @@ fn ensure_directory_structure(root: &Path, file: &Path, user: &str, group: &str)
585585
// that `root` exists, so that we don't create arbitrary directory
586586
// structures on disk
587587
assert!(root.is_dir());
588-
assert!(file.starts_with(&root));
588+
assert!(file.starts_with(root));
589589

590590
let dir = file.parent().unwrap();
591591

592592
if !dir.exists() {
593-
std::fs::create_dir_all(&dir)?;
593+
std::fs::create_dir_all(dir)?;
594594
for anc in dir.ancestors().take_while(|&d| d != root) {
595595
set_permissions(anc, user, group)?;
596596
}
@@ -967,7 +967,7 @@ mod test {
967967
package_name: &str,
968968
input_config: &str,
969969
expected_config_as_toml: &str) {
970-
env::set_var(env_key, &input_config);
970+
env::set_var(env_key, input_config);
971971

972972
let expected = toml_from_str(expected_config_as_toml);
973973
let result = Cfg::load_environment(package_name);
@@ -1006,7 +1006,7 @@ mod test {
10061006
let key = "HAB_TESTING_TRASH";
10071007
let config = "{\"port: 1234 what even is this!!!!?! =";
10081008

1009-
env::set_var(key, &config);
1009+
env::set_var(key, config);
10101010

10111011
let result = Cfg::load_environment("testing-trash");
10121012

components/common/src/templating/helpers/each_alive.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ impl HelperDef for EachAliveHelper {
2222
let local_path_root = value.path_root()
2323
.map(|p| format!("{}/{}", rc.get_path(), p));
2424
let rendered = match (value.value().is_truthy(), value.value()) {
25-
(true, &Json::Array(ref list)) => {
25+
(true, Json::Array(list)) => {
2626
let alive_members: Vec<Json> = list.iter()
2727
.filter_map(|m| {
2828
m.as_object().and_then(|m| {
@@ -55,7 +55,7 @@ impl HelperDef for EachAliveHelper {
5555
}
5656
Ok(())
5757
}
58-
(true, &Json::Object(ref obj)) => {
58+
(true, Json::Object(obj)) => {
5959
let mut first: bool = true;
6060
if !obj.contains_key("alive") || !obj["alive"].as_bool().unwrap() {
6161
return Ok(());

0 commit comments

Comments
 (0)