Skip to content

Failed to fix 'passing a unit value to a function' #14857

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

Open
nicktrandafil opened this issue May 20, 2025 · 3 comments · May be fixed by #14881
Open

Failed to fix 'passing a unit value to a function' #14857

nicktrandafil opened this issue May 20, 2025 · 3 comments · May be fixed by #14881
Assignees
Labels
C-bug Category: Clippy is not doing the correct thing I-suggestion-causes-error Issue: The suggestions provided by this Lint cause an ICE/error when applied

Comments

@nicktrandafil
Copy link

nicktrandafil commented May 20, 2025

Summary

cargo clippy --fix output:

warning: passing a unit value to a function
   --> src/lib.rs:209:23
    |
209 |         new_input_tx: watch::channel(Default::default()).0,
    |                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unit_arg
    = note: `#[warn(clippy::unit_arg)]` on by default
help: move the expression in front of the call and replace it with the unit literal `()`
    |
209 ~         new_input_tx: {
210 +             Default::default();
211 +             watch::channel(())
212 ~         }.0,
    |

after fixes were automatically applied the compiler reported errors within these files:

  * src/lib.rs

This likely indicates a bug in either rustc or cargo itself,
and we would appreciate a bug report! You're likely to see
a number of compiler warnings after this message which cargo
attempted to fix but failed. If you could open an issue at
https://github.com/rust-lang/rust-clippy/issues
quoting the full output of this command we'd be very appreciative!
Note that you may be able to make some more progress in the near-term
fixing code with the `--broken-code` flag

The following errors were reported:
error[E0790]: cannot call associated function on trait without specifying the corresponding `impl` type
   --> src/lib.rs:210:13
    |
210 |             Default::default();
    |             ^^^^^^^^^^^^^^^^^^ cannot call associated function of trait
    |
help: use a fully-qualified path to a specific available implementation
    |
210 |             </* self type */ as Default>::default();
    |             +++++++++++++++++++        +

error: aborting due to 1 previous error

For more information about this error, try `rustc --explain E0790`.
Original diagnostics will follow.
@nicktrandafil nicktrandafil added the C-bug Category: Clippy is not doing the correct thing label May 20, 2025
@samueltardieu
Copy link
Contributor

@rustbot label +I-suggestion-causes-error

@rustbot rustbot added the I-suggestion-causes-error Issue: The suggestions provided by this Lint cause an ICE/error when applied label May 20, 2025
@profetia
Copy link
Contributor

I think we should just remove the expr if it is Default:: default

@profetia
Copy link
Contributor

@rustbot claim

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: Clippy is not doing the correct thing I-suggestion-causes-error Issue: The suggestions provided by this Lint cause an ICE/error when applied
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants