Skip to content

Commit

Permalink
Apply clippy suggestions
Browse files Browse the repository at this point in the history
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
  • Loading branch information
boozook and github-actions[bot] authored May 28, 2024
1 parent c9ac85f commit 9c72320
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 42 deletions.
1 change: 0 additions & 1 deletion cargo/src/build/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ use crate::utils::cargo::CompileKindExt;
use crate::utils::path::AsRelativeTo;
use crate::utils::workspace::PossibleTargets;

use crate::utils::cargo::build_plan as plan;

pub mod rustflags;

Expand Down
18 changes: 9 additions & 9 deletions support/build/src/metadata/format.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ impl MetadataSource for Metadata {

fn manifest(&self) -> impl ManifestSourceOptExt { &self.inner.manifest }

fn bins<'t>(&'t self) -> &'t [Self::TargetManifest] { self.inner.bins.as_slice() }
fn examples<'t>(&'t self) -> &'t [Self::TargetManifest] { self.inner.examples.as_slice() }
fn bins(&self) -> &[Self::TargetManifest] { self.inner.bins.as_slice() }
fn examples(&self) -> &[Self::TargetManifest] { self.inner.examples.as_slice() }

fn bin_targets(&self) -> impl IntoIterator<Item = &str> { self.inner.bins.iter().map(|o| o.target.as_str()) }
fn example_targets(&self) -> impl IntoIterator<Item = &str> {
Expand Down Expand Up @@ -202,7 +202,7 @@ impl<'t, S> Cob<'t> for Manifest<S> where S: Cob<'t> {
launch_sound_path: self.launch_sound_path.as_ref().map(Cob::as_borrow),
content_warning: self.content_warning.as_ref().map(Cob::as_borrow),
content_warning2: self.content_warning2.as_ref().map(Cob::as_borrow),
build_number: self.build_number.clone() }
build_number: self.build_number }
}
}

Expand Down Expand Up @@ -241,7 +241,7 @@ impl IntoOwned<Manifest<<str as ToOwned>::Owned>> for Manifest<Cow<'_, str>> {
launch_sound_path: self.launch_sound_path.map(|s| s.into_owned()),
content_warning: self.content_warning.map(|s| s.into_owned()),
content_warning2: self.content_warning2.map(|s| s.into_owned()),
build_number: self.build_number.clone() }
build_number: self.build_number }
}
}

Expand All @@ -256,7 +256,7 @@ impl<S> Manifest<S> where S: ToOwned {
launch_sound_path: self.launch_sound_path.map(|s| s.to_owned()),
content_warning: self.content_warning.map(|s| s.to_owned()),
content_warning2: self.content_warning2.map(|s| s.to_owned()),
build_number: self.build_number.clone() }
build_number: self.build_number }
}
}

Expand Down Expand Up @@ -373,7 +373,7 @@ impl std::fmt::Display for ExtraValue {
}

impl From<bool> for ExtraValue {
fn from(value: bool) -> Self { Self::Boolean(value.into()) }
fn from(value: bool) -> Self { Self::Boolean(value) }
}
impl From<i64> for ExtraValue {
fn from(value: i64) -> Self { Self::Int(value) }
Expand Down Expand Up @@ -417,7 +417,7 @@ impl<S> ManifestSourceOpt for Manifest<S> where S: Deref<Target = str> {
fn launch_sound_path(&self) -> Option<&str> { self.launch_sound_path.as_deref() }
fn content_warning(&self) -> Option<&str> { self.content_warning.as_deref() }
fn content_warning2(&self) -> Option<&str> { self.content_warning2.as_deref() }
fn build_number(&self) -> Option<usize> { self.build_number.clone() }
fn build_number(&self) -> Option<usize> { self.build_number }
}

impl<T: ManifestSourceOpt> ManifestSourceOpt for Ext<T> {
Expand Down Expand Up @@ -483,7 +483,7 @@ impl<'s, T: ManifestSourceOpt, S: From<&'s str>> From<&'s T> for Manifest<S> {
launch_sound_path: source.launch_sound_path().map(Into::into),
content_warning: source.content_warning().map(Into::into),
content_warning2: source.content_warning2().map(Into::into),
build_number: source.build_number().clone() }
build_number: source.build_number() }
}
}

Expand Down Expand Up @@ -870,7 +870,7 @@ mod tests {
#[test]
fn options_assets_deps() {
// default is false
assert_eq!(false, AssetsOptions::default_dependencies());
assert!(!AssetsOptions::default_dependencies());
let src = r#" [assets] "#;
let m = toml::from_str::<Options>(src).unwrap();
assert_matches!(
Expand Down
60 changes: 28 additions & 32 deletions support/build/src/metadata/source.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,12 @@ pub trait CrateInfoSource {
log::debug!("target not found: {}", target);
None
}
} else {
if let Some(man) = root.bin(target) {
Some(base.override_with_extra(man).into_owned())
} else {
log::debug!("target not found: {}", target);
None
}
}
} else if let Some(man) = root.bin(target) {
Some(base.override_with_extra(man).into_owned())
} else {
log::debug!("target not found: {}", target);
None
}
} else {
Some(base.into_owned())
}
Expand All @@ -98,14 +96,14 @@ pub trait MetadataSource {

fn manifest(&self) -> impl ManifestSourceOptExt;

fn bins<'t>(&'t self) -> &'t [Self::TargetManifest];
fn examples<'t>(&'t self) -> &'t [Self::TargetManifest];
fn bins(&self) -> &[Self::TargetManifest];
fn examples(&self) -> &[Self::TargetManifest];

fn bin<'t>(&'t self, target: &'_ str) -> Option<&'t Self::TargetManifest> {
self.bins().into_iter().find(|b| b.target() == target)
self.bins().iter().find(|b| b.target() == target)
}
fn example<'t>(&'t self, target: &'_ str) -> Option<&'t Self::TargetManifest> {
self.examples().into_iter().find(|b| b.target() == target)
self.examples().iter().find(|b| b.target() == target)
}

fn bin_targets(&self) -> impl IntoIterator<Item = &str>;
Expand All @@ -115,10 +113,10 @@ pub trait MetadataSource {
}

fn bins_iter(&self) -> Option<impl Iterator<Item = &Self::TargetManifest>> {
(!self.bins().is_empty()).then_some(self.bins().into_iter())
(!self.bins().is_empty()).then_some(self.bins().iter())
}
fn examples_iter(&self) -> Option<impl Iterator<Item = &Self::TargetManifest>> {
(!self.examples().is_empty()).then_some(self.examples().into_iter())
(!self.examples().is_empty()).then_some(self.examples().iter())
}

fn all_targets_iter(&self) -> impl Iterator<Item = &Self::TargetManifest> {
Expand Down Expand Up @@ -150,14 +148,12 @@ pub trait MetadataSource {
} else {
None
}
} else {
if let Some(target) = self.bin(target) {
let trg = base.override_with_extra_ref(target);
Some(trg.into_owned())
} else {
None
}
}
} else if let Some(target) = self.bin(target) {
let trg = base.override_with_extra_ref(target);
Some(trg.into_owned())
} else {
None
}
}

fn manifest_for_target_any(&self, target: &str) -> Option<impl ManifestSourceOptExt> {
Expand All @@ -176,8 +172,8 @@ impl<T: MetadataSource> MetadataSource for &T {

fn manifest(&self) -> impl ManifestSourceOptExt { (*self).manifest() }

fn bins<'t>(&'t self) -> &'t [Self::TargetManifest] { <T as MetadataSource>::bins(*self) }
fn examples<'t>(&'t self) -> &'t [Self::TargetManifest] { <T as MetadataSource>::examples(*self) }
fn bins(&self) -> &[Self::TargetManifest] { <T as MetadataSource>::bins(*self) }
fn examples(&self) -> &[Self::TargetManifest] { <T as MetadataSource>::examples(*self) }

fn bin_targets(&self) -> impl IntoIterator<Item = &str> { (*self).bin_targets() }
fn example_targets(&self) -> impl IntoIterator<Item = &str> { (*self).example_targets() }
Expand Down Expand Up @@ -294,14 +290,14 @@ pub trait ManifestSourceOptExt: ManifestSourceOpt {
impl<T: ManifestSource> ManifestSourceOpt for T {
const MAY_BE_INCOMPLETE: bool = false;
fn name(&self) -> Option<&str> { Some(ManifestSource::name(self)) }
fn version(&self) -> Option<&str> { Some(ManifestSource::version(self).as_ref()) }
fn author(&self) -> Option<&str> { Some(ManifestSource::author(self).as_ref()) }
fn bundle_id(&self) -> Option<&str> { Some(ManifestSource::bundle_id(self).as_ref()) }
fn description(&self) -> Option<&str> { Some(ManifestSource::description(self).as_ref()) }
fn image_path(&self) -> Option<&str> { Some(ManifestSource::image_path(self).as_ref()) }
fn launch_sound_path(&self) -> Option<&str> { Some(ManifestSource::launch_sound_path(self).as_ref()) }
fn content_warning(&self) -> Option<&str> { Some(ManifestSource::content_warning(self).as_ref()) }
fn content_warning2(&self) -> Option<&str> { Some(ManifestSource::content_warning2(self).as_ref()) }
fn version(&self) -> Option<&str> { Some(ManifestSource::version(self)) }
fn author(&self) -> Option<&str> { Some(ManifestSource::author(self)) }
fn bundle_id(&self) -> Option<&str> { Some(ManifestSource::bundle_id(self)) }
fn description(&self) -> Option<&str> { Some(ManifestSource::description(self)) }
fn image_path(&self) -> Option<&str> { Some(ManifestSource::image_path(self)) }
fn launch_sound_path(&self) -> Option<&str> { Some(ManifestSource::launch_sound_path(self)) }
fn content_warning(&self) -> Option<&str> { Some(ManifestSource::content_warning(self)) }
fn content_warning2(&self) -> Option<&str> { Some(ManifestSource::content_warning2(self)) }
fn build_number(&self) -> Option<usize> { ManifestSource::build_number(self) }
}

Expand Down

0 comments on commit 9c72320

Please sign in to comment.