Skip to content

RA suggests incorrect quick fix / replacement that Clippy doesn't #16596

Closed
@nsabovic

Description

@nsabovic

rust-analyzer version: 0.3.1839-standalone (c06ca6c 2024-02-11)
rust-analyzer version: 0.4.1843-standalone (b9b0d29 2024-02-15)

rustc version: rustc 1.76.0 (07dca489a 2024-02-04)

relevant settings: N/A

In the following code RA suggests replacing filter_map().next() with find_map(), however find_map() requires Self to be Sized (why is beyond me) so actually running this replacement produces code that doesn't compile. Clippy does not offer this suggestion. Tried on stable and preview VSCode plugin.

let mut j = [0].into_iter();
let i: &mut dyn Iterator<Item = i32>  = &mut j;
let dummy_fn = |v| (v > 0).then_some(v + 1);
let _res = i.filter_map(dummy_fn).next();

Metadata

Metadata

Assignees

Labels

A-diagnosticsdiagnostics / error reportingC-bugCategory: bug

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions