I expected to see this happen:
no lint (see #9377) or a working one
Instead, this happened:
command: cargo clippy --fix --allow-no-vcs
Checking rust-playground v0.1.0 (/home/antoni/code/rust-playground)
warning: failed to automatically apply fixes suggested by rustc to crate `rust_playground`
after fixes were automatically applied the compiler reported errors within these files:
* src/main.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[E0282]: type annotations needed
--> src/main.rs:2:8
|
2 | [].into_iter().flatten()
| -- ^^^^^^^^^
| |
| type must be known at this point
|
help: try using a fully qualified path to specify the expected types
|
2 | <[_; 0] as std::iter::IntoIterator>::into_iter([]).flatten()
| +++++++++++++++++++++++++++++++++++++++++++++++ ~
error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0282`.
Original diagnostics will follow.
warning: use of `filter_map` with an identity function
--> src/main.rs:2:20
|
2 | [].into_iter().filter_map(|x| x)
| ^^^^^^^^^^^^^^^^^ help: try: `flatten()`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#filter_map_identity
= note: `#[warn(clippy::filter_map_identity)]` on by default
warning: `rust-playground` (bin "rust-playground") generated 1 warning (run `cargo clippy --fix --bin "rust-playground"` to apply 1 suggestion)
warning: failed to automatically apply fixes suggested by rustc to crate `rust_playground`
after fixes were automatically applied the compiler reported errors within these files:
* src/main.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[E0282]: type annotations needed
--> src/main.rs:2:8
|
2 | [].into_iter().flatten()
| -- ^^^^^^^^^
| |
| type must be known at this point
|
help: try using a fully qualified path to specify the expected types
|
2 | <[_; 0] as std::iter::IntoIterator>::into_iter([]).flatten()
| +++++++++++++++++++++++++++++++++++++++++++++++ ~
error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0282`.
Original diagnostics will follow.
warning: `rust-playground` (bin "rust-playground" test) generated 1 warning (1 duplicate)
Finished dev [unoptimized + debuginfo] target(s) in 0.27s
filter_map(identity) is a recommended use of core::convert::identity, see docs, are docs not tested to have warning lints triggered? this one will apply without error
Summary
title, the following code depends on
filter_map
to tell rustc that the type is Option<_>, which is removed causing a compilation errorReproducer
I tried this code:
I expected to see this happen: no lint (see #9377) or a working one
Instead, this happened: command:
cargo clippy --fix --allow-no-vcs
Version
Additional Labels
@rustbot label +I-suggestion-causes-error