@@ -1959,20 +1959,20 @@ declare_clippy_lint! {
1959
1959
1960
1960
declare_clippy_lint ! {
1961
1961
/// ### What it does
1962
- /// Finds _.f (_).g (_) where the method calls may be collapsed together and where f and g are transformers: map, all, any, find, etc.
1962
+ /// Finds `_.map (_).f (_)` where the method calls may be collapsed together and where f is a transformer: ` map`, ` all`, ` any`, ` find` , etc.
1963
1963
///
1964
1964
/// ### Why is this bad?
1965
1965
/// It is unnecessarily verbose and complex.
1966
1966
///
1967
1967
/// ### Example
1968
1968
/// ```rust
1969
1969
/// let iter = vec![1, 2, 3].into_iter();
1970
- /// let _ = iter.map(|x| foo(x)).flat_map (|x| bar(x) );
1970
+ /// let _ = iter.map(|x| x * 2).map (|x| x + 1 );
1971
1971
/// ```
1972
1972
/// Use instead:
1973
1973
/// ```rust
1974
1974
/// let iter = vec![1, 2, 3].into_iter();
1975
- /// let _ = iter.flat_map (|x| bar(foo(x)) );
1975
+ /// let _ = iter.map (|x| x * 2 + 1 );
1976
1976
/// ```
1977
1977
#[ clippy:: version = "1.60.0" ]
1978
1978
pub MAP_THEN_IDENTITY_TRANSFORMER ,
@@ -2062,6 +2062,7 @@ impl_lint_pass!(Methods => [
2062
2062
MANUAL_SPLIT_ONCE ,
2063
2063
NEEDLESS_SPLITN ,
2064
2064
UNNECESSARY_TO_OWNED ,
2065
+ MAP_THEN_IDENTITY_TRANSFORMER ,
2065
2066
] ) ;
2066
2067
2067
2068
/// Extracts a method call name, args, and `Span` of the method name.
@@ -2384,7 +2385,7 @@ fn check_methods<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>, msrv: Optio
2384
2385
} ,
2385
2386
( "find" , [ f_arg] ) => filter_map:: check ( cx, expr, recv2, f_arg, span2, recv, m_arg, span, true ) ,
2386
2387
( name2 @ "map" , [ arg2] ) => {
2387
- map_then_identity_transformer:: check ( cx, span2, name2, arg2, name, m_arg)
2388
+ map_then_identity_transformer:: check ( cx, span2, name2, arg2, name, m_arg) ;
2388
2389
} ,
2389
2390
_ => { } ,
2390
2391
}
0 commit comments