mirror of
https://github.com/topjohnwu/cxx.git
synced 2025-02-17 06:37:33 +00:00
Resolve manual_let_else clippy lint
warning: this could be rewritten as `let...else` --> gen/build/src/cargo.rs:54:13 | 54 | / let k = match k.to_str() { 55 | | Some(k) => k, 56 | | None => continue, 57 | | }; | |______________^ help: consider writing: `let Some(k) = k.to_str() else { continue };` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#manual_let_else = note: `-W clippy::manual-let-else` implied by `-W clippy::pedantic` = help: to override `-W clippy::pedantic` add `#[allow(clippy::manual_let_else)]` warning: this could be rewritten as `let...else` --> gen/build/src/cargo.rs:58:13 | 58 | / let v = match v.into_string() { 59 | | Ok(v) => v, 60 | | Err(_) => continue, 61 | | }; | |______________^ help: consider writing: `let Ok(v) = v.into_string() else { continue };` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#manual_let_else warning: this could be rewritten as `let...else` --> gen/build/src/lib.rs:437:5 | 437 | / let mut entries = match fs::read_dir(src) { 438 | | Ok(entries) => entries, 439 | | Err(_) => return, 440 | | }; | |______^ help: consider writing: `let Ok(mut entries) = fs::read_dir(src) else { return };` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#manual_let_else warning: this could be rewritten as `let...else` --> gen/build/src/out.rs:160:5 | 160 | / let relative_path = match abstractly_relativize_symlink(original, link) { 161 | | Some(relative_path) => relative_path, 162 | | None => return original.to_path_buf(), 163 | | }; | |______^ help: consider writing: `let Some(relative_path) = abstractly_relativize_symlink(original, link) else { return original.to_path_buf() };` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#manual_let_else warning: this could be rewritten as `let...else` --> syntax/check.rs:558:9 | 558 | / let resolve = match cx.types.try_resolve(&receiver.ty) { 559 | | Some(resolve) => resolve, 560 | | None => return, 561 | | }; | |__________^ help: consider writing: `let Some(resolve) = cx.types.try_resolve(&receiver.ty) else { return };` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#manual_let_else = note: `-W clippy::manual-let-else` implied by `-W clippy::pedantic` = help: to override `-W clippy::pedantic` add `#[allow(clippy::manual_let_else)]` warning: this could be rewritten as `let...else` --> syntax/parse.rs:439:5 | 439 | / let name = match &abi.name { 440 | | Some(name) => name, 441 | | None => { 442 | | return Err(Error::new_spanned( ... | 446 | | } 447 | | }; | |______^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#manual_let_else help: consider writing | 439 ~ let Some(name) = &abi.name else { 440 + return Err(Error::new_spanned( 441 + abi, 442 + "ABI name is required, extern \"C++\" or extern \"Rust\"", 443 + )); 444 + }; | warning: this could be rewritten as `let...else` --> syntax/parse.rs:1332:5 | 1332 | / let len_expr = if let Expr::Lit(lit) = &ty.len { 1333 | | lit 1334 | | } else { 1335 | | let msg = "unsupported expression, array length must be an integer literal"; 1336 | | return Err(Error::new_spanned(&ty.len, msg)); 1337 | | }; | |______^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#manual_let_else help: consider writing | 1332 ~ let Expr::Lit(len_expr) = &ty.len else { 1333 + let msg = "unsupported expression, array length must be an integer literal"; 1334 + return Err(Error::new_spanned(&ty.len, msg)); 1335 + }; | warning: this could be rewritten as `let...else` --> syntax/report.rs:24:9 | 24 | / let mut all_errors = match iter.next() { 25 | | Some(err) => err, 26 | | None => return Ok(()), 27 | | }; | |__________^ help: consider writing: `let Some(mut all_errors) = iter.next() else { return Ok(()) };` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#manual_let_else warning: this could be rewritten as `let...else` --> syntax/types.rs:174:13 | 174 | / let impl_key = match ty.impl_key() { 175 | | Some(impl_key) => impl_key, 176 | | None => continue, 177 | | }; | |______________^ help: consider writing: `let Some(impl_key) = ty.impl_key() else { continue };` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#manual_let_else
This commit is contained in:
parent
3ea1e9f654
commit
1565becf8d
@ -51,13 +51,11 @@ impl CargoEnv {
|
||||
let mut features = Set::new();
|
||||
let mut cfgs = Map::new();
|
||||
for (k, v) in env::vars_os() {
|
||||
let k = match k.to_str() {
|
||||
Some(k) => k,
|
||||
None => continue,
|
||||
let Some(k) = k.to_str() else {
|
||||
continue;
|
||||
};
|
||||
let v = match v.into_string() {
|
||||
Ok(v) => v,
|
||||
Err(_) => continue,
|
||||
let Ok(v) = v.into_string() else {
|
||||
continue;
|
||||
};
|
||||
if let Some(feature_name) = k.strip_prefix(CARGO_FEATURE_PREFIX) {
|
||||
let feature_name = Name(feature_name.to_owned());
|
||||
|
@ -58,7 +58,6 @@
|
||||
clippy::inherent_to_string,
|
||||
clippy::into_iter_without_iter,
|
||||
clippy::items_after_statements,
|
||||
clippy::manual_let_else,
|
||||
clippy::match_bool,
|
||||
clippy::match_on_vec_items,
|
||||
clippy::match_same_arms,
|
||||
@ -435,9 +434,8 @@ fn best_effort_copy_headers(src: &Path, dst: &Path, max_depth: usize) {
|
||||
use std::fs;
|
||||
|
||||
let mut dst_created = false;
|
||||
let mut entries = match fs::read_dir(src) {
|
||||
Ok(entries) => entries,
|
||||
Err(_) => return,
|
||||
let Ok(mut entries) = fs::read_dir(src) else {
|
||||
return;
|
||||
};
|
||||
|
||||
while let Some(Ok(entry)) = entries.next() {
|
||||
|
@ -157,9 +157,8 @@ fn best_effort_relativize_symlink(original: impl AsRef<Path>, link: impl AsRef<P
|
||||
let original = original.as_ref();
|
||||
let link = link.as_ref();
|
||||
|
||||
let relative_path = match abstractly_relativize_symlink(original, link) {
|
||||
Some(relative_path) => relative_path,
|
||||
None => return original.to_path_buf(),
|
||||
let Some(relative_path) = abstractly_relativize_symlink(original, link) else {
|
||||
return original.to_path_buf();
|
||||
};
|
||||
|
||||
// Sometimes "a/b/../c" refers to a different canonical location than "a/c".
|
||||
|
@ -20,7 +20,6 @@
|
||||
clippy::inherent_to_string,
|
||||
clippy::into_iter_without_iter,
|
||||
clippy::items_after_statements,
|
||||
clippy::manual_let_else,
|
||||
clippy::match_bool,
|
||||
clippy::match_on_vec_items,
|
||||
clippy::match_same_arms,
|
||||
|
@ -9,7 +9,6 @@
|
||||
clippy::into_iter_without_iter,
|
||||
clippy::items_after_statements,
|
||||
clippy::large_enum_variant,
|
||||
clippy::manual_let_else,
|
||||
clippy::match_bool,
|
||||
clippy::match_same_arms,
|
||||
clippy::module_name_repetitions,
|
||||
|
@ -555,9 +555,8 @@ fn check_mut_return_restriction(cx: &mut Check, efn: &ExternFn) {
|
||||
if receiver.mutable {
|
||||
return;
|
||||
}
|
||||
let resolve = match cx.types.try_resolve(&receiver.ty) {
|
||||
Some(resolve) => resolve,
|
||||
None => return,
|
||||
let Some(resolve) = cx.types.try_resolve(&receiver.ty) else {
|
||||
return;
|
||||
};
|
||||
if !resolve.generics.lifetimes.is_empty() {
|
||||
return;
|
||||
|
@ -436,14 +436,11 @@ fn parse_foreign_mod(
|
||||
}
|
||||
|
||||
fn parse_lang(abi: &Abi) -> Result<Lang> {
|
||||
let name = match &abi.name {
|
||||
Some(name) => name,
|
||||
None => {
|
||||
return Err(Error::new_spanned(
|
||||
abi,
|
||||
"ABI name is required, extern \"C++\" or extern \"Rust\"",
|
||||
));
|
||||
}
|
||||
let Some(name) = &abi.name else {
|
||||
return Err(Error::new_spanned(
|
||||
abi,
|
||||
"ABI name is required, extern \"C++\" or extern \"Rust\"",
|
||||
));
|
||||
};
|
||||
|
||||
match name.value().as_str() {
|
||||
@ -1329,16 +1326,12 @@ fn parse_type_path(ty: &TypePath) -> Result<Type> {
|
||||
fn parse_type_array(ty: &TypeArray) -> Result<Type> {
|
||||
let inner = parse_type(&ty.elem)?;
|
||||
|
||||
let len_expr = if let Expr::Lit(lit) = &ty.len {
|
||||
lit
|
||||
} else {
|
||||
let Expr::Lit(len_expr) = &ty.len else {
|
||||
let msg = "unsupported expression, array length must be an integer literal";
|
||||
return Err(Error::new_spanned(&ty.len, msg));
|
||||
};
|
||||
|
||||
let len_token = if let Lit::Int(int) = &len_expr.lit {
|
||||
int.clone()
|
||||
} else {
|
||||
let Lit::Int(len_token) = &len_expr.lit else {
|
||||
let msg = "array length must be an integer literal";
|
||||
return Err(Error::new_spanned(len_expr, msg));
|
||||
};
|
||||
@ -1357,7 +1350,7 @@ fn parse_type_array(ty: &TypeArray) -> Result<Type> {
|
||||
inner,
|
||||
semi_token,
|
||||
len,
|
||||
len_token,
|
||||
len_token: len_token.clone(),
|
||||
})))
|
||||
}
|
||||
|
||||
|
@ -21,9 +21,8 @@ impl Errors {
|
||||
|
||||
pub(crate) fn propagate(&mut self) -> Result<()> {
|
||||
let mut iter = self.errors.drain(..);
|
||||
let mut all_errors = match iter.next() {
|
||||
Some(err) => err,
|
||||
None => return Ok(()),
|
||||
let Some(mut all_errors) = iter.next() else {
|
||||
return Ok(());
|
||||
};
|
||||
for err in iter {
|
||||
all_errors.combine(err);
|
||||
|
@ -171,9 +171,8 @@ impl<'a> Types<'a> {
|
||||
}
|
||||
|
||||
for ty in &all {
|
||||
let impl_key = match ty.impl_key() {
|
||||
Some(impl_key) => impl_key,
|
||||
None => continue,
|
||||
let Some(impl_key) = ty.impl_key() else {
|
||||
continue;
|
||||
};
|
||||
let implicit_impl = match impl_key {
|
||||
ImplKey::RustBox(ident)
|
||||
|
Loading…
x
Reference in New Issue
Block a user