Skip to content

cargo clippy --fix generated broken code #9583

Open
@rbtcollins

Description

@rbtcollins

Output from clippy.

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

  * examples/threads.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/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[E0277]: the `?` operator can only be used in an async block that returns `Result` or `Option` (or another type that implements `std::ops::FromResidual`)
  --> examples/threads.rs:61:32
   |
60 |       rt.block_on(async {
   |  _______________________-
61 | |         client.register().await?
   | |                                ^ cannot use the `?` operator in an async block that returns `()`
62 | |     })?;
   | |_____- this function should return `Result` or `Option` to accept `?`
   |
   = help: the trait `std::ops::FromResidual<std::result::Result<std::convert::Infallible, std::boxed::Box<dyn std::error::Error + std::marker::Send + std::marker::Sync>>>` is not implemented for `()`

error[E0277]: the `?` operator can only be applied to values that implement `std::ops::Try`
  --> examples/threads.rs:60:5
   |
60 | /     rt.block_on(async {
61 | |         client.register().await?
62 | |     })?;
   | |_______^ the `?` operator cannot be applied to type `()`
   |
   = help: the trait `std::ops::Try` is not implemented for `()`

error: aborting due to 2 previous errors

I would be happy if either the lint didn't fire, or if clippy fixed things with code that works.

Meta

The same error occurs with nightly.

rustc --version --verbose:

rustc 1.64.0 (a55dd71d5 2022-09-19)
rustc 1.66.0-nightly (57f097ea2 2022-10-01)

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: Clippy is not doing the correct thingI-suggestion-causes-errorIssue: The suggestions provided by this Lint cause an ICE/error when applied

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions