Auto merge of #9099 - joshtriplett:unnecessary-lazy-eval-then-some, r=flip1995

Extend unnecessary_lazy_eval to cover `bool::then` -> `bool::then_some`

fixes #9097

changelog: Extend `unnecessary_lazy_eval` to convert `bool::then` to `bool::then_some`
This commit is contained in:
bors
2022-07-06 09:20:55 +00:00
22 changed files with 78 additions and 54 deletions

View File

@@ -1016,7 +1016,7 @@ pub fn can_move_expr_to_closure<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'
captures: HirIdMap::default(),
};
v.visit_expr(expr);
v.allow_closure.then(|| v.captures)
v.allow_closure.then_some(v.captures)
}
/// Returns the method names and argument list of nested method call expressions that make up

View File

@@ -12,6 +12,7 @@ macro_rules! msrv_aliases {
// names may refer to stabilized feature flags or library items
msrv_aliases! {
1,62,0 { BOOL_THEN_SOME }
1,53,0 { OR_PATTERNS, MANUAL_BITS, BTREE_MAP_RETAIN, BTREE_SET_RETAIN }
1,52,0 { STR_SPLIT_ONCE, REM_EUCLID_CONST }
1,51,0 { BORROW_AS_PTR, UNSIGNED_ABS }

View File

@@ -353,7 +353,7 @@ pub fn snippet_with_context<'a>(
/// span containing `m!(0)`.
pub fn walk_span_to_context(span: Span, outer: SyntaxContext) -> Option<Span> {
let outer_span = hygiene::walk_chain(span, outer);
(outer_span.ctxt() == outer).then(|| outer_span)
(outer_span.ctxt() == outer).then_some(outer_span)
}
/// Removes block comments from the given `Vec` of lines.