-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Fix some clippy warnings #466
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
Conversation
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.
lgtm. Thanks for the PR @jacwah !
Thanks for the fixes! :) |
I think I would. I have been in that part of the code and I agree it's more readable the way it is, but overall the clippy rule is good. We don't want "accepted" warnings cluttering up things, I don't think. Not sure about the Box one, though. Generally, having "accepted" warnings is bad in my opinion (then you have to mentally exclude them every time you run clippy again) so finding some way to make them go away is preferred. |
Regarding large_enum_variant:
After boxing TemplateError:
Boxing RenderError too makes only a marginal difference:
Boxing can be done transparently like this: --- a/src/lib.rs
+++ b/src/lib.rs
@@ -104,8 +104,8 @@ pub mod errors {
error_chain!{
foreign_links {
Io(::std::io::Error);
HandlebarsRender(::handlebars::RenderError);
- HandlebarsTemplate(::handlebars::TemplateError);
+ HandlebarsTemplate(Box<::handlebars::TemplateError>);
Utf8(::std::string::FromUtf8Error);
}
@@ -116,4 +116,10 @@ pub mod errors {
}
}
}
+
+ impl From<::handlebars::TemplateError> for Error {
+ fn from(e: ::handlebars::TemplateError) -> Error {
+ From::from(Box::new(e))
+ }
+ }
} |
Fix some clippy warnings
In response to #458.
I did not fix two of clippy's warnings:
I think the code is more readable as it is currently than clippy's suggestion. Should I add
#[cfg_attr(feature = "cargo-clippy", allow(let_and_return))]
or are warnings okay here?Not sure what to do about this one. Boxing the errors seems more invasive, so I'll leave that decision to someone else. I don't see why any of these variants should be large though.