Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #[warn(clippy::try_err)] in ser_macros.rs #1032

Merged
merged 2 commits into from
Aug 2, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -262,4 +262,4 @@ jobs:
rustup component add clippy
- name: Run default clippy linting
run: |
cargo clippy -- -Aclippy::erasing_op -Aclippy::never_loop -Aclippy::if_same_then_else
cargo clippy -- -Aclippy::erasing_op -Aclippy::never_loop -Aclippy::if_same_then_else -Dclippy::try_err
18 changes: 9 additions & 9 deletions lightning/src/util/ser_macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ macro_rules! check_tlv_order {
#[allow(unused_comparisons)] // Note that $type may be 0 making the second comparison always true
let invalid_order = ($last_seen_type.is_none() || $last_seen_type.unwrap() < $type) && $typ.0 > $type;
if invalid_order {
Err(DecodeError::InvalidValue)?
return Err(DecodeError::InvalidValue);
}
}};
($last_seen_type: expr, $typ: expr, $type: expr, option) => {{
Expand All @@ -109,7 +109,7 @@ macro_rules! check_missing_tlv {
#[allow(unused_comparisons)] // Note that $type may be 0 making the second comparison always true
let missing_req_type = $last_seen_type.is_none() || $last_seen_type.unwrap() < $type;
if missing_req_type {
Err(DecodeError::InvalidValue)?
return Err(DecodeError::InvalidValue);
}
}};
($last_seen_type: expr, $type: expr, vec_type) => {{
Expand Down Expand Up @@ -149,20 +149,20 @@ macro_rules! decode_tlv_stream {
match ser::Readable::read(&mut tracking_reader) {
Err(DecodeError::ShortRead) => {
if !tracking_reader.have_read {
break 'tlv_read
break 'tlv_read;
} else {
Err(DecodeError::ShortRead)?
return Err(DecodeError::ShortRead);
}
},
Err(e) => Err(e)?,
Err(e) => return Err(e),
Ok(t) => t,
}
};

// Types must be unique and monotonically increasing:
match last_seen_type {
Some(t) if typ.0 <= t => {
Err(DecodeError::InvalidValue)?
return Err(DecodeError::InvalidValue);
},
_ => {},
}
Expand All @@ -180,11 +180,11 @@ macro_rules! decode_tlv_stream {
decode_tlv!(s, $field, $fieldty);
if s.bytes_remain() {
s.eat_remaining()?; // Return ShortRead if there's actually not enough bytes
Err(DecodeError::InvalidValue)?
return Err(DecodeError::InvalidValue);
}
},)*
x if x % 2 == 0 => {
Err(DecodeError::UnknownRequiredFeature)?
return Err(DecodeError::UnknownRequiredFeature);
},
_ => {},
}
Expand Down Expand Up @@ -490,7 +490,7 @@ macro_rules! impl_writeable_tlv_based_enum {
Ok($st::$tuple_variant_name(Readable::read(reader)?))
}),*
_ => {
Err(DecodeError::UnknownRequiredFeature)?
Err(DecodeError::UnknownRequiredFeature)
},
}
}
Expand Down