Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bump rust to 1.85.0 and fix clippy #9626

Draft
wants to merge 12 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions .expeditor/scripts/verify/run_cargo_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,17 @@ if ${BUILDKITE:-false}; then
fi

# TODO: these should be in a shared script?
sudo hab pkg install core/zeromq
sudo hab pkg install core/protobuf
sudo hab pkg install core/rust/"$toolchain"
sudo -E hab pkg install core/zeromq
sudo -E hab pkg install core/protobuf
sudo -E hab pkg install core/rust/"$toolchain"
export LIBZMQ_PREFIX
LIBZMQ_PREFIX=$(hab pkg path core/zeromq)
# now include zeromq and gcc so they exist in the runtime library path when cargo test is run
export LD_LIBRARY_PATH
LD_LIBRARY_PATH="$(hab pkg path core/gcc)/lib:$(hab pkg path core/zeromq)/lib"
eval "$(hab pkg env core/rust/"$toolchain"):$PATH"
LD_LIBRARY_PATH="$(hab pkg path core/gcc-base)/lib64:$(hab pkg path core/zeromq)/lib"
old_path=$PATH
eval "$(hab pkg env core/rust/"$toolchain")"
export PATH=$PATH:$old_path

export PROTOC_NO_VENDOR=1
export PROTOC
Expand Down
8 changes: 5 additions & 3 deletions .expeditor/scripts/verify/run_clippy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ rustup component add --toolchain "$toolchain" clippy

# TODO: these should be in a shared script?
install_hab_pkg core/zeromq core/protobuf core/patchelf
sudo hab pkg install core/rust/"$toolchain"
sudo -E hab pkg install core/rust/"$toolchain"

# Yes, this is terrible but we need the clippy binary to run under our glibc.
# This became an issue with the latest refresh and can likely be dropped in
Expand All @@ -31,8 +31,10 @@ export LIBZMQ_PREFIX
LIBZMQ_PREFIX=$(hab pkg path core/zeromq)
# now include zeromq so it exists in the runtime library path when cargo test is run
export LD_LIBRARY_PATH
LD_LIBRARY_PATH="$(hab pkg path core/gcc)/lib:$(hab pkg path core/zeromq)/lib"
eval "$(hab pkg env core/rust/"$toolchain"):$PATH"
LD_LIBRARY_PATH="$(hab pkg path core/gcc-base)/lib64:$(hab pkg path core/zeromq)/lib"
old_path=$PATH
eval "$(hab pkg env core/rust/"$toolchain")"
export PATH=$PATH:$old_path

export PROTOC_NO_VENDOR=1
export PROTOC
Expand Down
2 changes: 1 addition & 1 deletion .expeditor/scripts/verify/shared.sh
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ install_hab_pkg() {
installed_pkgs=$(hab pkg list "$ident")

if [[ -z $installed_pkgs ]]; then
sudo hab pkg install "$ident"
sudo -E hab pkg install "$ident"
else
echo "$ident already installed"
fi
Expand Down
15 changes: 6 additions & 9 deletions .expeditor/verify.pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -195,15 +195,12 @@ steps:
- label: "[unit] :linux: common"
command:
- .expeditor/scripts/verify/run_cargo_test.sh common
agents:
queue: 'default-privileged'
plugins:
docker#v3.3.0:
always-pull: true
user: "buildkite-agent"
group: "buildkite-agent"
image: "chefes/buildkite"
privileged: true
expeditor:
executor:
linux:
single-use: true
user: "buildkite-agent"
group: "buildkite-agent"
timeout_in_minutes: 10
retry:
automatic:
Expand Down
1 change: 1 addition & 0 deletions components/builder-api-client/src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1581,6 +1581,7 @@ mod tests {
release: None, }
}

#[allow(clippy::type_complexity)]
fn seach_generator<'a>(
data: &'a [&str],
step: usize)
Expand Down
1 change: 0 additions & 1 deletion components/butterfly/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
///
/// Generated code is deposited in `OUT_DIR` and automatically
/// `include!`-ed in our Rust modules, per standard Prost practice.

fn main() {
let mut config = prost_build::Config::new();
config.type_attribute(".butterfly.newscast.Rumor.payload",
Expand Down
6 changes: 3 additions & 3 deletions components/butterfly/src/member.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ impl FromStr for Incarnation {

struct IncarnationVisitor;

impl<'de> de::Visitor<'de> for IncarnationVisitor {
impl de::Visitor<'_> for IncarnationVisitor {
type Value = Incarnation;

fn expecting(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
Expand Down Expand Up @@ -850,7 +850,7 @@ impl<'a> MemberListProxy<'a> {
pub fn new(m: &'a MemberList) -> Self { MemberListProxy(m) }
}

impl<'a> Serialize for MemberListProxy<'a> {
impl Serialize for MemberListProxy<'_> {
/// # Locking (see locking.md)
/// * `MemberList::entries` (read)
fn serialize<S>(&self, serializer: S) -> result::Result<S::Ok, S::Error>
Expand All @@ -876,7 +876,7 @@ impl<'a> MemberProxy<'a> {
pub fn new(m: &'a Member, h: &'a Health) -> Self { MemberProxy(m, h) }
}

impl<'a> Serialize for MemberProxy<'a> {
impl Serialize for MemberProxy<'_> {
fn serialize<S>(&self, serializer: S) -> result::Result<S::Ok, S::Error>
where S: Serializer
{
Expand Down
20 changes: 10 additions & 10 deletions components/butterfly/src/rumor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ mod storage {
/// lifetime of the service group key.
pub struct ServiceGroupRumors<'sg_key, R>(Option<&'sg_key RumorSubMap<R>>);

impl<'sg_key, R> ServiceGroupRumors<'sg_key, R> {
impl<R> ServiceGroupRumors<'_, R> {
/// Allows iterator access to the rumors in a particular service group:
/// ```
/// # use habitat_butterfly::rumor::{RumorStore,
Expand Down Expand Up @@ -219,7 +219,7 @@ mod storage {
}
}

impl<'a, R: Rumor> IterableGuard<'a, RumorMap<R>> {
impl<R: Rumor> IterableGuard<'_, RumorMap<R>> {
pub fn contains_rumor(&self, rumor: &R) -> bool {
let RumorKey { key, id, .. } = rumor.into();

Expand All @@ -238,23 +238,23 @@ mod storage {
}
}

impl<'a, C: ConstKeyRumor> IterableGuard<'a, RumorMap<C>> {
impl<C: ConstKeyRumor> IterableGuard<'_, RumorMap<C>> {
pub fn contains_id(&self, member_id: &str) -> bool {
self.get(C::const_key())
.map(|rumors| rumors.contains_key(member_id))
.unwrap_or(false)
}
}

impl<'a, E: ElectionRumor> IterableGuard<'a, RumorMap<E>> {
impl<E: ElectionRumor> IterableGuard<'_, RumorMap<E>> {
pub fn get_term(&self, service_group: &str) -> Option<u64> {
self.get(service_group)
.map(|sg| sg.get(E::const_id()).map(ElectionRumor::term))
.unwrap_or(None)
}
}

impl<'a, E: ElectionRumor> IterableGuard<'a, RumorMap<E>> {
impl<E: ElectionRumor> IterableGuard<'_, RumorMap<E>> {
pub fn get_member_id(&self, service_group: &str) -> Option<&str> {
self.get(service_group)
.map(|sg| sg.get(E::const_id()).map(ElectionRumor::member_id))
Expand All @@ -269,7 +269,7 @@ mod storage {
/// let rs: RumorStore<Departure> = RumorStore::default();
/// assert_eq!(rs.lock_rsr().len(), 0);
/// ```
impl<'a, R> std::ops::Deref for IterableGuard<'a, RumorMap<R>> {
impl<R> std::ops::Deref for IterableGuard<'_, RumorMap<R>> {
type Target = RumorMap<R>;

fn deref(&self) -> &Self::Target { &self.0 }
Expand Down Expand Up @@ -374,7 +374,7 @@ mod storage {
pub fn new(r: &'a RumorStore<T>) -> Self { RumorStoreProxy(r) }
}

impl<'a> Serialize for RumorStoreProxy<'a, Departure> {
impl Serialize for RumorStoreProxy<'_, Departure> {
/// # Locking (see locking.md)
/// * `RumorStore::list` (read)
fn serialize<S>(&self, serializer: S) -> result::Result<S::Ok, S::Error>
Expand All @@ -395,7 +395,7 @@ mod storage {
}
}

impl<'a, C: ConstIdRumor> Serialize for RumorStoreProxy<'a, C> {
impl<C: ConstIdRumor> Serialize for RumorStoreProxy<'_, C> {
/// # Locking (see locking.md)
/// * `RumorStore::list` (read)
fn serialize<S>(&self, serializer: S) -> result::Result<S::Ok, S::Error>
Expand All @@ -419,7 +419,7 @@ mod storage {
}
}

impl<'a> Serialize for RumorStoreProxy<'a, Service> {
impl Serialize for RumorStoreProxy<'_, Service> {
/// # Locking (see locking.md)
/// * `RumorStore::list` (read)
fn serialize<S>(&self, serializer: S) -> result::Result<S::Ok, S::Error>
Expand All @@ -436,7 +436,7 @@ mod storage {
}
}

impl<'a> Serialize for RumorStoreProxy<'a, ServiceFile> {
impl Serialize for RumorStoreProxy<'_, ServiceFile> {
/// # Locking (see locking.md)
/// * `RumorStore::list` (read)
fn serialize<S>(&self, serializer: S) -> result::Result<S::Ok, S::Error>
Expand Down
4 changes: 2 additions & 2 deletions components/butterfly/src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -790,7 +790,7 @@ impl Server {
let inserting_new_group_member =
service_store.lock_rsr()
.get(service_group)
.map_or(false, |rumors| !rumors.contains_key(member_id));
.is_some_and(|rumors| !rumors.contains_key(member_id));

if service_store.insert_rsw(service) {
if inserting_new_group_member && !check_quorum(service_group) {
Expand Down Expand Up @@ -1437,7 +1437,7 @@ impl<'a> ServerProxy<'a> {
pub fn new(s: &'a Server) -> Self { ServerProxy(s) }
}

impl<'a> Serialize for ServerProxy<'a> {
impl Serialize for ServerProxy<'_> {
/// # Locking (see locking.md)
/// * `MemberList::entries` (read)
/// * `RumorStore::list` (read)
Expand Down
4 changes: 2 additions & 2 deletions components/butterfly/src/server/outbound.rs
Original file line number Diff line number Diff line change
Expand Up @@ -537,8 +537,8 @@ pub fn ack_mlr_smr_rhw(server: &Server,
addr: SocketAddr,
forward_to: Option<Member>) {
let ack_msg = Ack { membership: vec![],
from: server.myself.lock_smr().to_member(),
forward_to: forward_to.map(Member::from), };
from: server.myself.lock_smr().to_member(),
forward_to };
let swim = populate_membership_rumors_mlr_rhw(server, target, ack_msg);
let bytes = match swim.encode() {
Ok(bytes) => bytes,
Expand Down
7 changes: 2 additions & 5 deletions components/butterfly/tests/common/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -423,11 +423,8 @@ impl SwimNet {
return true;
} else if self.check_rounds(&rounds_in) {
for (i, some_health) in network_health.iter().enumerate() {
match some_health {
Some(ref health) => {
println!("{}: {:?}", i, health);
}
None => {}
if let Some(ref health) = some_health {
println!("{}: {:?}", i, health);
}
}
return false;
Expand Down
3 changes: 1 addition & 2 deletions components/common/src/command/package/install.rs
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,6 @@ impl Default for LocalPackageUsage {
///
/// At the end of this function, the specified package and all its
/// dependencies will be installed on the system.

// TODO (CM): Consider passing in a configured depot client instead of
// product / version... That might make it easier to share with the
// `sup` crate
Expand Down Expand Up @@ -426,7 +425,7 @@ struct InstallTask<'a> {
install_hook_mode: InstallHookMode,
}

impl<'a> InstallTask<'a> {
impl InstallTask<'_> {
/// Install a package from the Depot, based on a given identifier.
///
/// If the identifier is fully-qualified, that specific package
Expand Down
11 changes: 5 additions & 6 deletions components/common/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,7 @@ impl FeatureFlag {
if let Some(val) = env::var_os(env_var) {
if !val.is_empty() {
flags.insert(*feature);
ui.warn(&format!("Enabling feature: {:?}", feature))
.unwrap();
ui.warn(format!("Enabling feature: {:?}", feature)).unwrap();
}
}
}
Expand All @@ -135,10 +134,10 @@ impl FeatureFlag {
ui.warn("Listing feature flags environment variables:")
.unwrap();
for (feature, env_var) in ENV_VARS.iter() {
ui.warn(&format!(" * {:?}: {}={:?}",
feature,
env_var,
env::var_os(env_var).unwrap_or_default()))
ui.warn(format!(" * {:?}: {}={:?}",
feature,
env_var,
env::var_os(env_var).unwrap_or_default()))
.unwrap();
}
}
Expand Down
4 changes: 2 additions & 2 deletions components/common/src/output.rs
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ impl<'a> StructuredOutput<'a> {
// Custom implementation of Serialize to ensure that we can
// appropriately represent both verbose and non-verbose output, a
// behavior which isn't otherwise possible to derive.
impl<'a> Serialize for StructuredOutput<'a> {
impl Serialize for StructuredOutput<'_> {
fn serialize<S>(&self, serializer: S) -> result::Result<S::Ok, S::Error>
where S: Serializer
{
Expand All @@ -219,7 +219,7 @@ impl<'a> Serialize for StructuredOutput<'a> {
}
}

impl<'a> fmt::Display for StructuredOutput<'a> {
impl fmt::Display for StructuredOutput<'_> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let bufwtr = BufferWriter::stdout(self.format.color_choice());
let mut buffer = bufwtr.buffer();
Expand Down
6 changes: 3 additions & 3 deletions components/common/src/owning_refs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use std::ops::{Deref,
// A wrapper around `MutexGuard` needed to implement the `StableAddress` trait to use `OwningRef`
pub struct StableMutexGuard<'a, T: ?Sized>(MutexGuard<'a, T>);

unsafe impl<'a, T: ?Sized> StableAddress for StableMutexGuard<'a, T> {}
unsafe impl<T: ?Sized> StableAddress for StableMutexGuard<'_, T> {}

impl<T: ?Sized> Deref for StableMutexGuard<'_, T> {
type Target = T;
Expand All @@ -30,7 +30,7 @@ impl<'a, T> From<MutexGuard<'a, T>> for StableMutexGuard<'a, T> {
// `OwningRef`
pub struct StableRwLockReadGuard<'a, T: ?Sized>(RwLockReadGuard<'a, T>);

unsafe impl<'a, T: ?Sized> StableAddress for StableRwLockReadGuard<'a, T> {}
unsafe impl<T: ?Sized> StableAddress for StableRwLockReadGuard<'_, T> {}

impl<T: ?Sized> Deref for StableRwLockReadGuard<'_, T> {
type Target = T;
Expand All @@ -46,7 +46,7 @@ impl<'a, T> From<RwLockReadGuard<'a, T>> for StableRwLockReadGuard<'a, T> {
// `OwningRef`
pub struct StableRwLockWriteGuard<'a, T: ?Sized>(RwLockWriteGuard<'a, T>);

unsafe impl<'a, T: ?Sized> StableAddress for StableRwLockWriteGuard<'a, T> {}
unsafe impl<T: ?Sized> StableAddress for StableRwLockWriteGuard<'_, T> {}

impl<T: ?Sized> Deref for StableRwLockWriteGuard<'_, T> {
type Target = T;
Expand Down
4 changes: 2 additions & 2 deletions components/common/src/templating/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -558,11 +558,11 @@ fn load_templates(dir: &Path,
for entry in std::fs::read_dir(dir)?.filter_map(result::Result::ok) {
// We're storing the pathname relative to the input config directory
// as the identifier for the template
let relative_path = context.join(&entry.file_name());
let relative_path = context.join(entry.file_name());
match entry.file_type() {
Ok(file_type) if file_type.is_file() => {
// JW TODO: This error needs improvement. TemplateFileError is too generic.
template.register_template_file(&relative_path.to_string_lossy(), &entry.path())
template.register_template_file(&relative_path.to_string_lossy(), entry.path())
.map_err(Error::TemplateError)?;
}
Ok(file_type) if file_type.is_dir() => {
Expand Down
2 changes: 1 addition & 1 deletion components/common/src/templating/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ impl<'a> Package<'a> {
}
}

impl<'a> Serialize for Package<'a> {
impl Serialize for Package<'_> {
fn serialize<S>(&self, serializer: S) -> result::Result<S::Ok, S::Error>
where S: Serializer
{
Expand Down
6 changes: 3 additions & 3 deletions components/common/src/templating/hooks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ pub trait Hook: fmt::Debug + Sized + Send {
.map(|n| template_path.as_ref().join(n));

let has_template = template.exists();
let has_deprecated_template = deprecated_template.as_ref().map_or(false, |t| t.exists());
let has_deprecated_template = deprecated_template.as_ref().is_some_and(|t| t.exists());

if has_template && file_name == "reload" {
outputln!(preamble package_name, "The '{}' hook has been deprecated. You should use the 'reconfigure' hook instead.",
Expand Down Expand Up @@ -311,8 +311,8 @@ pub trait PackageMaintenanceHookExt: Hook<ExitValue = ExitStatus> + Sync {
let feature_flags = FeatureFlag::from_env(ui);
let package_name = &package.ident.name;
if let Some(ref hook) = Self::load(package_name,
&svc_hooks_path(package_name),
&package.installed_path.join("hooks"),
svc_hooks_path(package_name),
package.installed_path.join("hooks"),
feature_flags)
{
let hook_name = Self::FILE_NAME;
Expand Down
Loading