- 
                Notifications
    You must be signed in to change notification settings 
- Fork 152
Fix clippy unused_unit warnings in host_bindgen macro for void return functions #658
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
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | 
|---|---|---|
|  | @@ -655,7 +655,7 @@ pub fn emit_hl_unmarshal_param(s: &mut State, id: Ident, pt: &Value) -> TokenStr | |
| /// are no names in it (i.e. a unit type) | ||
| pub fn emit_hl_unmarshal_result(s: &mut State, id: Ident, rt: &etypes::Result) -> TokenStream { | ||
| match rt { | ||
| etypes::Result::Named(rs) if rs.is_empty() => quote! { () }, | ||
| etypes::Result::Named(rs) if rs.is_empty() => TokenStream::new(), | ||
| There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't like this as a solution, because it changes the contract for this helper to something a lot less intuitive: 
 becomes 
 which means that it can't generally be used to uniformly generate a return value. Right now, this expression is only used in the tail position of a function definition, so it works "by coincidence"---but this change makes the interface more brittle (e.g. if you wanted to refactor the macro to trace the return value, you would need special cases to not accidentally generate an empty  | ||
| etypes::Result::Unnamed(vt) => { | ||
| let toks = emit_hl_unmarshal_value(s, id, vt); | ||
| quote! { { #toks }.0 } | ||
|  | ||
| Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| # Seeds for failure cases proptest has generated in the past. It is | ||
| # automatically read and these particular cases re-run before any | ||
| # novel cases are generated. | ||
| # | ||
| # It is recommended to check this file in to source control so that | ||
| # everyone who runs the test benefits from these saved cases. | ||
| cc 9e697e3320100630afae15901d82d23237f04e3d8090ec2c9ecb211fbf322909 # shrinks to x = 0.0 | ||
| cc 033b8487116d6b64d1c321ca2475618b943551b670ed562648c12f3a7586243a # shrinks to x = EnumA | ||
| cc 37f8b1a347c5a2a096a8904b918c0f049b729c80e329ed63dc1b501258a2973b # shrinks to x = false | ||
| cc f401ff3b24d9e0b6a5332fbaecbb5cde12d13d932d33d27a5d15ce2ea73a1125 # shrinks to x = 'A' | ||
|          | ||
| There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. let's not do dependency updates in this PR and leave that for independent PRs. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Reverted the Cargo.lock dependency updates to keep this PR focused only on the clippy fix. (412ab9f) | 
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this will be needed since this use case is handled by return an empty quote
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right! Since
emit_hl_unmarshal_resultreturnsTokenStream::new()for void functions, the conditional logic wasn't needed. Simplified the code to use unmarshal directly. (412ab9f)