-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
unnecessary_wraps is a bad default lint #6726
Comments
I also think the In my use case, some functions return a Take for example the following code where the fn process_instruction(&mut self, instruction: Instr) -> Result<(), SicImageEngineError> {
match instruction {
Instr::Operation(op) => self.process_operation(op),
Instr::EnvAdd(item) => self.insert_env(*item),
Instr::EnvRemove(key) => self.remove_env(*key),
}
} Here, The After fixing the code to resolve this linter issue, it becomes: fn process_instruction(&mut self, instruction: &Instr) -> Result<(), SicImageEngineError> {
match instruction {
Instr::Operation(op) => self.process_operation(op),
Instr::EnvAdd(item) => {
self.insert_env(*item);
Ok(())
}
Instr::EnvRemove(key) => {
self.remove_env(*key);
Ok(())
}
}
} Here, the complexity of the Another exampleimpl Action for UpdateManifest<'_> { fn run(&mut self, args: &PublishWorkspace) -> anyhow::Result<()> { if args.dry_run { // -> This fn returns Ok(()) "unnecessarily" dry_update_dependency_version(self.package, args.version()) } else { // -> This fn can actually fail live_update_dependency_version(self.package, args.version()) } } } |
It's also add that you would have to refactor your API just because the code in the current implementation might not return an error. |
Another example where this lint may not be desirable: I have a small parser here where all parsing functions have a similar signature (very much like nom parsers):
Sometimes the parsing function is infallible and always returns |
Even with downgrading the lint, a check to not lint exported items would be useful. |
Lint name:
unnecessary_wraps
The newly introduced
unnecessary_wraps
lint is one I now need to disable everywhere it has popped up so far as a warning. The reason for this is that we useserde(default = func)
a lot and when you have a nullable type you need to return aSome(value)
from that function.I would make an argument that this lint should not be in the list of default lints because of there being a lot of legitimate cases where one does need "unnecessary wrapping".
The text was updated successfully, but these errors were encountered: