Skip to content

Commit

Permalink
~fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
boozook committed Jul 12, 2024
1 parent b6017b4 commit ef8cd7f
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 64 deletions.
103 changes: 51 additions & 52 deletions cargo/src/build/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -209,54 +209,54 @@ pub fn build(cfg: &Config, tree: &MetaDeps) -> CargoResult<Vec<BuildProduct>> {

let mut crate_types_cache = BTreeMap::new();

let removed = roots.extract_if(|root| {
let tk = root.node().target().kind();
let ck = root.node().unit().platform;

log::trace!(" check {} {}", tk.description(), match ck {
CompileKind::Host => "host",
CompileKind::Target(ref kind) => kind.short_name(),
});

if reserved_roots.contains(root) {
log::trace!(" excluding, reserved root");
return true;
}

{
use cargo::core::TargetKind as Tk;
if executable && !matches!(tk, Tk::Bin | Tk::ExampleBin) {
log::trace!(" excluding, is not executable");
return true;
}
}

let target = targets_cache.entry(*root)
.or_insert_with(|| target_for_root(root));

let ct =
determine_crate_types(cfg, art, target, tk.clone(), ck).collect::<Vec<_>>();

let is_good =
art.filenames.len() == ct.len() && !ct.iter().any(|(_, ct)| ct.is_none());
if is_good {
// save resolved crate-types:
let ct = ct.into_iter()
.filter_map(|(p, ct)| ct.map(|ct| (p.to_owned(), ct)));
crate_types_cache.extend(ct);
}

need_remove_roots && !is_good
})
.inspect(|r| {
let p = r.package_id().name();
let t = r.node().target().name.as_str();
log::trace!(" excluded: {p}::{t} {:?}", match r.node().unit().platform {
CompileKind::Host => "host",
CompileKind::Target(ref kind) => kind.short_name(),
})
})
.count();
let removed =
roots.extract_if(|root| {
let tk = root.node().target().kind();
let ck = root.node().unit().platform;

log::trace!(" check {} {}", tk.description(), match ck {
CompileKind::Host => "host",
CompileKind::Target(ref kind) => kind.short_name(),
});

if reserved_roots.contains(root) {
log::trace!(" excluding, reserved root");
return true;
}

{
use cargo::core::TargetKind as Tk;
if executable && !matches!(tk, Tk::Bin | Tk::ExampleBin) {
log::trace!(" excluding, is not executable");
return true;
}
}

let target = targets_cache.entry(*root)
.or_insert_with(|| target_for_root(root));

let ct = determine_crate_types(cfg, art, target, tk.clone(), ck).collect::<Vec<_>>();

let is_good =
art.filenames.len() == ct.len() && !ct.iter().any(|(_, ct)| ct.is_none());
if is_good {
// save resolved crate-types:
let ct = ct.into_iter()
.filter_map(|(p, ct)| ct.map(|ct| (p.to_owned(), ct)));
crate_types_cache.extend(ct);
}

need_remove_roots && !is_good
})
.inspect(|r| {
let p = r.package_id().name();
let t = r.node().target().name.as_str();
log::trace!(" excluded: {p}::{t} {:?}", match r.node().unit().platform {
CompileKind::Host => "host",
CompileKind::Target(ref kind) => kind.short_name(),
})
})
.count();

if removed > 0 {
log::trace!(" excluded: {removed}, now roots: {}", roots.len());
Expand Down Expand Up @@ -335,11 +335,10 @@ pub fn build(cfg: &Config, tree: &MetaDeps) -> CargoResult<Vec<BuildProduct>> {
})
.collect::<BTreeSet<_>>();

let ck_exact =
ck_name.iter().copied().find(|ck| {
comps.iter()
let ck_exact = ck_name.iter().copied().find(|ck| {
comps.iter()
.all(|(_num, first)| matches!(first, Some(s) if *s == *ck))
});
});

let removed = if let Some(ck) = ck_exact {
roots.extract_if(|root| {
Expand Down
16 changes: 8 additions & 8 deletions support/device/src/mount/win.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ pub mod unmount {
fn unmount_blocking(&self) -> Result<(), Error> {
#[cfg(feature = "eject")]
let res = unmount_eject(&self).or_else(|err| {
winapi::unmount(self.letter).map_err(|err2| Error::chain(err2, [err]))
});
winapi::unmount(self.letter).map_err(|err2| Error::chain(err2, [err]))
});
#[cfg(not(feature = "eject"))]
let res = winapi::unmount(self.letter);

Expand Down Expand Up @@ -92,12 +92,12 @@ pub mod unmount {

#[cfg(feature = "eject")]
let fut = lazy(|_| unmount_eject(&self)).or_else(|err| {
lazy(|_| {
winapi::unmount(self.letter).map_err(|err2| {
Error::chain(err2, [err])
})
})
});
lazy(|_| {
winapi::unmount(self.letter).map_err(|err2| {
Error::chain(err2, [err])
})
})
});
#[cfg(not(feature = "eject"))]
let fut = lazy(|_| winapi::unmount(self.letter));

Expand Down
9 changes: 5 additions & 4 deletions support/device/src/usb/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -294,10 +294,11 @@ impl Interface {
// TODO: attach data to the pool
let written = comp.data.actual_length();
let data = comp.data.reuse();
let s = std::str::from_utf8(&data).map(Cow::Borrowed)
.unwrap_or_else(|_| {
Cow::Owned(hex::encode_upper(&data))
});
let s =
std::str::from_utf8(&data).map(Cow::Borrowed)
.unwrap_or_else(|_| {
Cow::Owned(hex::encode_upper(&data))
});
trace!("sent, resp: ({written}) '{s}'");
comp.status.map(|_| written)
})
Expand Down

0 comments on commit ef8cd7f

Please sign in to comment.