Skip to content

Commit

Permalink
Revved rust from 1.62.1 to 1.67.1
Browse files Browse the repository at this point in the history
- 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 <jason.heath@progress.com>
  • Loading branch information
Jason Heath committed Mar 2, 2023
1 parent ee5cd3e commit d5846bb
Show file tree
Hide file tree
Showing 73 changed files with 282 additions and 280 deletions.
2 changes: 1 addition & 1 deletion .rustfmt.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ unstable_features = true

# stable options
edition = "2018"
fn_args_layout = "Tall"
fn_params_layout = "Tall"
force_explicit_abi = true
format_code_in_doc_comments = true
hard_tabs = false
Expand Down
4 changes: 2 additions & 2 deletions components/builder-api-client/src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ impl BuilderAPIClient {
let resp = self.maybe_add_authz(rb, token).send().await?;
let resp = response::ok_if(resp, &[StatusCode::OK]).await?;

fs::create_dir_all(&dst_path)?;
fs::create_dir_all(dst_path)?;
let file_name = response::get_header(&resp, X_FILENAME)?;
let dst_file_path = dst_path.join(file_name);
let w = AtomicWriter::new_with_permissions(&dst_file_path, permissions)?;
Expand Down Expand Up @@ -1609,7 +1609,7 @@ mod tests {
(range, (range + step).min(last))
};
let filtered_range = filtered[start..=end].iter()
.map(|s| get_test_ident(**s))
.map(|s| get_test_ident(s))
.collect::<Vec<_>>();
let result = PackageResults { range_start: start as isize,
range_end: end as isize,
Expand Down
2 changes: 1 addition & 1 deletion components/butterfly/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,6 @@ impl Client {
{
let bytes = rumor.write_to_bytes()?;
let wire_msg = message::generate_wire(bytes, self.ring_key.as_ref())?;
self.socket.send(&wire_msg, 0).map_err(Error::ZmqSendError)
self.socket.send(wire_msg, 0).map_err(Error::ZmqSendError)
}
}
2 changes: 1 addition & 1 deletion components/butterfly/src/member.rs
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ impl Default for Member {
}

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

impl<'a> From<&'a Member> for RumorKey {
Expand Down
8 changes: 4 additions & 4 deletions components/butterfly/src/protocol/swim.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ mod tests {

#[test]
fn health_values_are_title_case() {
assert_eq!(serde_json::to_value(&Health::Alive).unwrap(), "Alive");
assert_eq!(serde_json::to_value(&Health::Suspect).unwrap(), "Suspect");
assert_eq!(serde_json::to_value(&Health::Confirmed).unwrap(),
assert_eq!(serde_json::to_value(Health::Alive).unwrap(), "Alive");
assert_eq!(serde_json::to_value(Health::Suspect).unwrap(), "Suspect");
assert_eq!(serde_json::to_value(Health::Confirmed).unwrap(),
"Confirmed");
assert_eq!(serde_json::to_value(&Health::Departed).unwrap(), "Departed");
assert_eq!(serde_json::to_value(Health::Departed).unwrap(), "Departed");
}
}
2 changes: 1 addition & 1 deletion components/butterfly/src/rumor/dat_file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ impl DatFile {
{
let mut bytes_read = 0;
let mut size_buf = [0; 8];
let mut rumor_buf: Vec<u8> = vec![];
let mut rumor_buf: Vec<u8> = vec![0; 8];

loop {
if bytes_read >= offset {
Expand Down
2 changes: 1 addition & 1 deletion components/butterfly/src/rumor/heat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ pub(crate) mod sync {
.collect();

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

// We don't need the heat anymore, just return the rumors.
rumor_heat.into_iter().map(|(k, _)| k).collect()
Expand Down
2 changes: 1 addition & 1 deletion components/butterfly/src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -748,7 +748,7 @@ impl Server {
rumor_heat.lock_rhw().purge(member_id_to_depart);
rumor_heat.lock_rhw()
.start_hot_rumor(RumorKey::new(RumorType::Member,
&*member_id_to_depart,
member_id_to_depart,
""));
}
}
Expand Down
6 changes: 3 additions & 3 deletions components/butterfly/src/server/incarnation_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ mod tests {
"The path {:?} shouldn't exist, but it does",
path);

let i = IncarnationStore::new(&path);
let i = IncarnationStore::new(path);
assert!(i.load().is_err());
}

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

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

assert!(path.exists());

let mut i = IncarnationStore::new(&path);
let mut i = IncarnationStore::new(path);
assert!(i.initialize().is_err());
}
}
2 changes: 1 addition & 1 deletion components/common/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ pub fn is_toml_file(val: &str) -> bool {
}

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

Expand Down
4 changes: 2 additions & 2 deletions components/common/src/cli_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ impl CliConfig {
}

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

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

/// Save the `CliConfig` to disk
pub fn save(&self) -> Result<(), Error> {
fs::create_dir_all(&*CLI_CONFIG_PATH_PARENT)?;
fs::create_dir_all(*CLI_CONFIG_PATH_PARENT)?;
let raw = toml::ser::to_string(self)?;
debug!("Raw config toml:\n---\n{}\n---", &raw);
fs::write(&*CLI_CONFIG_PATH, raw)?;
Expand Down
10 changes: 5 additions & 5 deletions components/common/src/owning_refs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ unsafe impl<'a, T: ?Sized> StableAddress for StableMutexGuard<'a, T> {}
impl<T: ?Sized> Deref for StableMutexGuard<'_, T> {
type Target = T;

fn deref(&self) -> &T { &*self.0 }
fn deref(&self) -> &T { &self.0 }
}

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

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

fn deref(&self) -> &T { &*self.0 }
fn deref(&self) -> &T { &self.0 }
}

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

fn deref(&self) -> &T { &*self.0 }
fn deref(&self) -> &T { &self.0 }
}

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

impl<'a, T> From<RwLockWriteGuard<'a, T>> for StableRwLockWriteGuard<'a, T> {
Expand Down
12 changes: 6 additions & 6 deletions components/common/src/templating.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,15 @@ pub async fn compile_for_package_install(package: &PackageInstall,
cfg_renderer.compile(&pkg.name, &pkg, &pkg.svc_config_install_path, &ctx)?;

if let Some(ref hook) = InstallHook::load(&pkg.name,
&fs::svc_hooks_path(&pkg.name),
&package.installed_path.join("hooks"),
fs::svc_hooks_path(&pkg.name),
package.installed_path.join("hooks"),
feature_flags)
{
hook.compile(&pkg.name, &ctx)?;
};
if let Some(ref hook) = UninstallHook::load(&pkg.name,
&fs::svc_hooks_path(&pkg.name),
&package.installed_path.join("hooks"),
fs::svc_hooks_path(&pkg.name),
package.installed_path.join("hooks"),
feature_flags)
{
hook.compile(&pkg.name, &ctx)?;
Expand Down Expand Up @@ -218,8 +218,8 @@ mod test {
pub fn toml_to_json(value: toml::Value) -> serde_json::Value {
match value {
toml::Value::String(s) => serde_json::Value::String(s),
toml::Value::Integer(i) => serde_json::Value::from(i as i64),
toml::Value::Float(i) => serde_json::Value::from(i as f64),
toml::Value::Integer(i) => serde_json::Value::from(i),
toml::Value::Float(i) => serde_json::Value::from(i),
toml::Value::Boolean(b) => serde_json::Value::Bool(b),
toml::Value::Datetime(s) => serde_json::Value::String(s.to_string()),
toml::Value::Array(a) => toml_vec_to_json(a),
Expand Down
16 changes: 8 additions & 8 deletions components/common/src/templating/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ impl Cfg {
/// exports.
pub fn to_exported(&self, pkg: &Pkg) -> Result<toml::value::Table> {
let mut map = toml::value::Table::default();
let cfg = toml::Value::try_from(&self).expect("Cfg -> TOML conversion");
let cfg = toml::Value::try_from(self).expect("Cfg -> TOML conversion");
for (key, path) in pkg.exports.iter() {
let mut curr = &cfg;
let mut found = false;
Expand Down Expand Up @@ -229,7 +229,7 @@ impl Cfg {
T2: AsRef<Path>
{
let filename = file.as_ref();
let path = dir.as_ref().join(&filename);
let path = dir.as_ref().join(filename);
let mut file = match File::open(&path) {
Ok(file) => file,
Err(e) => {
Expand Down Expand Up @@ -429,7 +429,7 @@ impl CfgRenderer {
for template in self.0.get_templates().keys() {
let compiled = self.0.render(template, ctx)?;
let compiled_hash = Blake2bHash::from_bytes(&compiled);
let cfg_dest = render_path.as_ref().join(&template);
let cfg_dest = render_path.as_ref().join(template);
let file_hash = match Blake2bHash::from_file(&cfg_dest) {
Ok(file_hash) => Some(file_hash),
Err(e) => {
Expand Down Expand Up @@ -536,7 +536,7 @@ fn set_permissions(path: &Path, user: &str, group: &str) -> hcore::error::Result
} else {
CONFIG_PERMISSIONS
};
posix_perm::set_permissions(&path, permissions)
posix_perm::set_permissions(path, permissions)
}

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

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

if !dir.exists() {
std::fs::create_dir_all(&dir)?;
std::fs::create_dir_all(dir)?;
for anc in dir.ancestors().take_while(|&d| d != root) {
set_permissions(anc, user, group)?;
}
Expand Down Expand Up @@ -967,7 +967,7 @@ mod test {
package_name: &str,
input_config: &str,
expected_config_as_toml: &str) {
env::set_var(env_key, &input_config);
env::set_var(env_key, input_config);

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

env::set_var(key, &config);
env::set_var(key, config);

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

Expand Down
4 changes: 2 additions & 2 deletions components/common/src/templating/helpers/each_alive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ impl HelperDef for EachAliveHelper {
let local_path_root = value.path_root()
.map(|p| format!("{}/{}", rc.get_path(), p));
let rendered = match (value.value().is_truthy(), value.value()) {
(true, &Json::Array(ref list)) => {
(true, Json::Array(list)) => {
let alive_members: Vec<Json> = list.iter()
.filter_map(|m| {
m.as_object().and_then(|m| {
Expand Down Expand Up @@ -55,7 +55,7 @@ impl HelperDef for EachAliveHelper {
}
Ok(())
}
(true, &Json::Object(ref obj)) => {
(true, Json::Object(obj)) => {
let mut first: bool = true;
if !obj.contains_key("alive") || !obj["alive"].as_bool().unwrap() {
return Ok(());
Expand Down
Loading

0 comments on commit d5846bb

Please sign in to comment.