mirror of
https://github.com/serde-rs/serde.git
synced 2025-12-29 20:50:44 +00:00
Resolve manual_let_else pedantic clippy lint
warning: this could be rewritten as `let...else`
--> serde_derive/src/internals/attr.rs:1460:5
|
1460 | / let string = match get_lit_str(cx, attr_name, meta)? {
1461 | | Some(string) => string,
1462 | | None => return Ok(None),
1463 | | };
| |______^ help: consider writing: `let Some(string) = get_lit_str(cx, attr_name, meta)? else { return Ok(None) };`
|
= 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`
--> serde_derive/src/internals/attr.rs:1482:5
|
1482 | / let string = match get_lit_str(cx, attr_name, meta)? {
1483 | | Some(string) => string,
1484 | | None => return Ok(None),
1485 | | };
| |______^ help: consider writing: `let Some(string) = get_lit_str(cx, attr_name, meta)? else { return Ok(None) };`
|
= 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`
--> serde_derive/src/internals/attr.rs:1505:5
|
1505 | / let string = match get_lit_str2(cx, attr_name, meta_item_name, meta)? {
1506 | | Some(string) => string,
1507 | | None => return Ok(Vec::new()),
1508 | | };
| |______^ help: consider writing: `let Some(string) = get_lit_str2(cx, attr_name, meta_item_name, meta)? else { return Ok(Vec::new()) };`
|
= 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`
--> serde_derive/src/internals/attr.rs:1526:5
|
1526 | / let string = match get_lit_str(cx, attr_name, meta)? {
1527 | | Some(string) => string,
1528 | | None => return Ok(None),
1529 | | };
| |______^ help: consider writing: `let Some(string) = get_lit_str(cx, attr_name, meta)? else { return Ok(None) };`
|
= 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`
--> serde_derive/src/internals/attr.rs:1549:5
|
1549 | / let string = match get_lit_str(cx, BORROW, meta)? {
1550 | | Some(string) => string,
1551 | | None => return Ok(BTreeSet::new()),
1552 | | };
| |______^ help: consider writing: `let Some(string) = get_lit_str(cx, BORROW, meta)? else { return Ok(BTreeSet::new()) };`
|
= 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`
--> serde_derive/src/internals/attr.rs:1621:5
|
1621 | / let seg = match path.segments.last() {
1622 | | Some(seg) => seg,
1623 | | None => {
1624 | | return false;
1625 | | }
1626 | | };
| |______^
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#manual_let_else
help: consider writing
|
1621 ~ let Some(seg) = path.segments.last() else {
1622 + return false;
1623 + };
|
warning: this could be rewritten as `let...else`
--> serde_derive/src/internals/attr.rs:1648:5
|
1648 | / let seg = match path.segments.last() {
1649 | | Some(seg) => seg,
1650 | | None => {
1651 | | return false;
1652 | | }
1653 | | };
| |______^
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#manual_let_else
help: consider writing
|
1648 ~ let Some(seg) = path.segments.last() else {
1649 + return false;
1650 + };
|
warning: this could be rewritten as `let...else`
--> serde_derive/src/internals/ctxt.rs:49:9
|
49 | / let mut combined = match errors.next() {
50 | | Some(first) => first,
51 | | None => return Ok(()),
52 | | };
| |__________^ help: consider writing: `let Some(mut combined) = errors.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`
--> serde_derive/src/de.rs:29:5
|
29 | / let cont = match Container::from_ast(&ctxt, input, Derive::Deserialize, &private...
30 | | Some(cont) => cont,
31 | | None => return Err(ctxt.check().unwrap_err()),
32 | | };
| |______^ help: consider writing: `let Some(cont) = Container::from_ast(&ctxt, input, Derive::Deserialize, &private.ident()) else { return Err(ctxt.check().unwrap_err()) };`
|
= 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`
--> serde_derive/src/ser.rs:16:5
|
16 | / let cont = match Container::from_ast(&ctxt, input, Derive::Serialize, &private.i...
17 | | Some(cont) => cont,
18 | | None => return Err(ctxt.check().unwrap_err()),
19 | | };
| |______^ help: consider writing: `let Some(cont) = Container::from_ast(&ctxt, input, Derive::Serialize, &private.ident()) else { return Err(ctxt.check().unwrap_err()) };`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#manual_let_else
This commit is contained in:
parent
d656b4dd6a
commit
fae23fea97
@ -26,9 +26,9 @@ pub fn expand_derive_deserialize(input: &mut syn::DeriveInput) -> syn::Result<To
|
||||
replace_receiver(input);
|
||||
|
||||
let ctxt = Ctxt::new();
|
||||
let cont = match Container::from_ast(&ctxt, input, Derive::Deserialize, &private.ident()) {
|
||||
Some(cont) => cont,
|
||||
None => return Err(ctxt.check().unwrap_err()),
|
||||
let Some(cont) = Container::from_ast(&ctxt, input, Derive::Deserialize, &private.ident())
|
||||
else {
|
||||
return Err(ctxt.check().unwrap_err());
|
||||
};
|
||||
precondition(&ctxt, &cont);
|
||||
ctxt.check()?;
|
||||
|
||||
@ -1457,9 +1457,8 @@ fn parse_lit_into_path(
|
||||
attr_name: Symbol,
|
||||
meta: &ParseNestedMeta,
|
||||
) -> syn::Result<Option<syn::Path>> {
|
||||
let string = match get_lit_str(cx, attr_name, meta)? {
|
||||
Some(string) => string,
|
||||
None => return Ok(None),
|
||||
let Some(string) = get_lit_str(cx, attr_name, meta)? else {
|
||||
return Ok(None);
|
||||
};
|
||||
|
||||
Ok(match string.parse() {
|
||||
@ -1479,9 +1478,8 @@ fn parse_lit_into_expr_path(
|
||||
attr_name: Symbol,
|
||||
meta: &ParseNestedMeta,
|
||||
) -> syn::Result<Option<syn::ExprPath>> {
|
||||
let string = match get_lit_str(cx, attr_name, meta)? {
|
||||
Some(string) => string,
|
||||
None => return Ok(None),
|
||||
let Some(string) = get_lit_str(cx, attr_name, meta)? else {
|
||||
return Ok(None);
|
||||
};
|
||||
|
||||
Ok(match string.parse() {
|
||||
@ -1502,9 +1500,8 @@ fn parse_lit_into_where(
|
||||
meta_item_name: Symbol,
|
||||
meta: &ParseNestedMeta,
|
||||
) -> syn::Result<Vec<syn::WherePredicate>> {
|
||||
let string = match get_lit_str2(cx, attr_name, meta_item_name, meta)? {
|
||||
Some(string) => string,
|
||||
None => return Ok(Vec::new()),
|
||||
let Some(string) = get_lit_str2(cx, attr_name, meta_item_name, meta)? else {
|
||||
return Ok(Vec::new());
|
||||
};
|
||||
|
||||
Ok(
|
||||
@ -1523,9 +1520,8 @@ fn parse_lit_into_ty(
|
||||
attr_name: Symbol,
|
||||
meta: &ParseNestedMeta,
|
||||
) -> syn::Result<Option<syn::Type>> {
|
||||
let string = match get_lit_str(cx, attr_name, meta)? {
|
||||
Some(string) => string,
|
||||
None => return Ok(None),
|
||||
let Some(string) = get_lit_str(cx, attr_name, meta)? else {
|
||||
return Ok(None);
|
||||
};
|
||||
|
||||
Ok(match string.parse() {
|
||||
@ -1546,9 +1542,8 @@ fn parse_lit_into_lifetimes(
|
||||
cx: &Ctxt,
|
||||
meta: &ParseNestedMeta,
|
||||
) -> syn::Result<BTreeSet<syn::Lifetime>> {
|
||||
let string = match get_lit_str(cx, BORROW, meta)? {
|
||||
Some(string) => string,
|
||||
None => return Ok(BTreeSet::new()),
|
||||
let Some(string) = get_lit_str(cx, BORROW, meta)? else {
|
||||
return Ok(BTreeSet::new());
|
||||
};
|
||||
|
||||
if let Ok(lifetimes) = string.parse_with(|input: ParseStream| {
|
||||
@ -1618,11 +1613,8 @@ fn is_cow(ty: &syn::Type, elem: fn(&syn::Type) -> bool) -> bool {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
let seg = match path.segments.last() {
|
||||
Some(seg) => seg,
|
||||
None => {
|
||||
return false;
|
||||
}
|
||||
let Some(seg) = path.segments.last() else {
|
||||
return false;
|
||||
};
|
||||
let args = match &seg.arguments {
|
||||
syn::PathArguments::AngleBracketed(bracketed) => &bracketed.args,
|
||||
@ -1645,11 +1637,8 @@ fn is_option(ty: &syn::Type, elem: fn(&syn::Type) -> bool) -> bool {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
let seg = match path.segments.last() {
|
||||
Some(seg) => seg,
|
||||
None => {
|
||||
return false;
|
||||
}
|
||||
let Some(seg) = path.segments.last() else {
|
||||
return false;
|
||||
};
|
||||
let args = match &seg.arguments {
|
||||
syn::PathArguments::AngleBracketed(bracketed) => &bracketed.args,
|
||||
|
||||
@ -46,9 +46,8 @@ impl Ctxt {
|
||||
pub fn check(self) -> syn::Result<()> {
|
||||
let mut errors = self.errors.borrow_mut().take().unwrap().into_iter();
|
||||
|
||||
let mut combined = match errors.next() {
|
||||
Some(first) => first,
|
||||
None => return Ok(()),
|
||||
let Some(mut combined) = errors.next() else {
|
||||
return Ok(());
|
||||
};
|
||||
|
||||
for rest in errors {
|
||||
|
||||
@ -13,9 +13,8 @@ pub fn expand_derive_serialize(input: &mut syn::DeriveInput) -> syn::Result<Toke
|
||||
replace_receiver(input);
|
||||
|
||||
let ctxt = Ctxt::new();
|
||||
let cont = match Container::from_ast(&ctxt, input, Derive::Serialize, &private.ident()) {
|
||||
Some(cont) => cont,
|
||||
None => return Err(ctxt.check().unwrap_err()),
|
||||
let Some(cont) = Container::from_ast(&ctxt, input, Derive::Serialize, &private.ident()) else {
|
||||
return Err(ctxt.check().unwrap_err());
|
||||
};
|
||||
precondition(&ctxt, &cont);
|
||||
ctxt.check()?;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user