You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
warning: this returns a `Result<_, ()>`
--> src/lib.rs:6:1
|
6 | pub fn ret_err() -> Result<(),()> {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= help: use a custom `Error` type instead
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#result_unit_err
= note: `#[warn(clippy::result_unit_err)]` on by default
However, Error is not available in no_std without enabling the error_in_core feature (tracking issue).
As discussed in #9671, this lint should be suggesting returning a non-unit type as the lint checks that Err is a unit, not that it doesn't implement Error. I think the fix here is to just change the lint to first recommend returning a non-unit type, then suggest one that implements Error, mentioning the feature gate if on no_std. I'd be happy to implement this or whatever other solution people would prefer.
Description
This lint currently suggests implementing a custom
Error
type, as seen in the below example:Running Clippy on a project with the following
lib.rs
:will yield the following warning:
However,
Error
is not available inno_std
without enabling theerror_in_core
feature (tracking issue).As discussed in #9671, this lint should be suggesting returning a non-unit type as the lint checks that
Err
is a unit, not that it doesn't implementError
. I think the fix here is to just change the lint to first recommend returning a non-unit type, then suggest one that implementsError
, mentioning the feature gate if onno_std
. I'd be happy to implement this or whatever other solution people would prefer.Version
Additional Labels
No response
The text was updated successfully, but these errors were encountered: