Skip to content

Commit a94d1d0

Browse files
committed
Auto merge of #12351 - ehuss:let-else-fmt, r=weihanglo
Rustfmt with latest nightly. The latest nightly introduced a new version of rustfmt which handles let-else formatting. These should be compatible with stable formatting.
2 parents 694a579 + 43c253e commit a94d1d0

File tree

6 files changed

+45
-21
lines changed

6 files changed

+45
-21
lines changed

crates/xtask-stale-label/src/main.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ fn main() {
3434

3535
for (label, value) in autolabel.iter() {
3636
let Some(trigger_files) = value.get("trigger_files") else {
37-
continue
37+
continue;
3838
};
3939
let trigger_files = trigger_files.as_array().expect("an array");
4040
let missing_files: Vec<_> = trigger_files

src/cargo/sources/git/known_hosts.rs

+13-5
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ pub fn certificate_check(
141141
let Some(host_key) = cert.as_hostkey() else {
142142
// Return passthrough for TLS X509 certificates to use whatever validation
143143
// was done in git2.
144-
return Ok(CertificateCheckStatus::CertificatePassthrough)
144+
return Ok(CertificateCheckStatus::CertificatePassthrough);
145145
};
146146
// If a nonstandard port is in use, check for that first.
147147
// The fallback to check without a port is handled in the HostKeyNotFound handler.
@@ -611,10 +611,18 @@ impl KnownHost {
611611
}
612612

613613
fn hashed_hostname_matches(host: &str, hashed: &str) -> bool {
614-
let Some((b64_salt, b64_host)) = hashed.split_once('|') else { return false; };
615-
let Ok(salt) = STANDARD.decode(b64_salt) else { return false; };
616-
let Ok(hashed_host) = STANDARD.decode(b64_host) else { return false; };
617-
let Ok(mut mac) = hmac::Hmac::<sha1::Sha1>::new_from_slice(&salt) else { return false; };
614+
let Some((b64_salt, b64_host)) = hashed.split_once('|') else {
615+
return false;
616+
};
617+
let Ok(salt) = STANDARD.decode(b64_salt) else {
618+
return false;
619+
};
620+
let Ok(hashed_host) = STANDARD.decode(b64_host) else {
621+
return false;
622+
};
623+
let Ok(mut mac) = hmac::Hmac::<sha1::Sha1>::new_from_slice(&salt) else {
624+
return false;
625+
};
618626
mac.update(host.as_bytes());
619627
let result = mac.finalize().into_bytes();
620628
hashed_host == &result[..]

src/cargo/sources/registry/http_remote.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -808,7 +808,9 @@ impl<'cfg> Downloads<'cfg> {
808808
/// Updates the state of the progress bar for downloads.
809809
fn tick(&self) -> CargoResult<()> {
810810
let mut progress = self.progress.borrow_mut();
811-
let Some(progress) = progress.as_mut() else { return Ok(()); };
811+
let Some(progress) = progress.as_mut() else {
812+
return Ok(());
813+
};
812814

813815
// Since the sparse protocol discovers dependencies as it goes,
814816
// it's not possible to get an accurate progress indication.

src/cargo/util/auth/asymmetric.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,8 @@ pub fn public_token_from_credential(
7373
source_id: &SourceId,
7474
mutation: Option<&'_ Mutation<'_>>,
7575
) -> CargoResult<Secret<String>> {
76-
let RegistryCredentialConfig::AsymmetricKey((secret_key, secret_key_subject)) = credential else {
76+
let RegistryCredentialConfig::AsymmetricKey((secret_key, secret_key_subject)) = credential
77+
else {
7778
anyhow::bail!("credential must be an asymmetric secret key")
7879
};
7980

src/cargo/util/toml/embedded.rs

+20-11
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,11 @@ impl DocFragment {
207207
let syn::Meta::NameValue(nv) = &attr.meta else {
208208
anyhow::bail!("unsupported attr meta for {:?}", attr.meta.path())
209209
};
210-
let syn::Expr::Lit(syn::ExprLit { lit: syn::Lit::Str(lit), .. }) = &nv.value else {
210+
let syn::Expr::Lit(syn::ExprLit {
211+
lit: syn::Lit::Str(lit),
212+
..
213+
}) = &nv.value
214+
else {
211215
anyhow::bail!("only string literals are supported")
212216
};
213217
Ok(Self {
@@ -373,16 +377,21 @@ fn unindent_doc_fragments(docs: &mut [DocFragment]) {
373377
let Some(min_indent) = docs
374378
.iter()
375379
.map(|fragment| {
376-
fragment.doc.as_str().lines().fold(usize::MAX, |min_indent, line| {
377-
if line.chars().all(|c| c.is_whitespace()) {
378-
min_indent
379-
} else {
380-
// Compare against either space or tab, ignoring whether they are
381-
// mixed or not.
382-
let whitespace = line.chars().take_while(|c| *c == ' ' || *c == '\t').count();
383-
min_indent.min(whitespace)
384-
}
385-
})
380+
fragment
381+
.doc
382+
.as_str()
383+
.lines()
384+
.fold(usize::MAX, |min_indent, line| {
385+
if line.chars().all(|c| c.is_whitespace()) {
386+
min_indent
387+
} else {
388+
// Compare against either space or tab, ignoring whether they are
389+
// mixed or not.
390+
let whitespace =
391+
line.chars().take_while(|c| *c == ' ' || *c == '\t').count();
392+
min_indent.min(whitespace)
393+
}
394+
})
386395
})
387396
.min()
388397
else {

src/cargo/util/toml/mod.rs

+6-2
Original file line numberDiff line numberDiff line change
@@ -2835,7 +2835,9 @@ fn parse_unstable_lints<T: Deserialize<'static>>(
28352835
config: &Config,
28362836
warnings: &mut Vec<String>,
28372837
) -> CargoResult<Option<T>> {
2838-
let Some(lints) = lints else { return Ok(None); };
2838+
let Some(lints) = lints else {
2839+
return Ok(None);
2840+
};
28392841

28402842
if !config.cli_unstable().lints {
28412843
warn_for_lint_feature(config, warnings);
@@ -2878,7 +2880,9 @@ switch to nightly channel you can pass
28782880
}
28792881

28802882
fn verify_lints(lints: Option<TomlLints>) -> CargoResult<Option<TomlLints>> {
2881-
let Some(lints) = lints else { return Ok(None); };
2883+
let Some(lints) = lints else {
2884+
return Ok(None);
2885+
};
28822886

28832887
for (tool, lints) in &lints {
28842888
let supported = ["rust", "clippy", "rustdoc"];

0 commit comments

Comments
 (0)