remove unnecessary lazy evaluations
This commit is contained in:
@@ -91,7 +91,7 @@ fn recursive_merge(lhs: &ast::UseTree, rhs: &ast::UseTree, merge: MergeBehavior)
|
||||
.flat_map(|list| list.use_trees())
|
||||
// We use Option here to early return from this function(this is not the
|
||||
// same as a `filter` op).
|
||||
.map(|tree| merge.is_tree_allowed(&tree).then(|| tree))
|
||||
.map(|tree| merge.is_tree_allowed(&tree).then_some(tree))
|
||||
.collect::<Option<_>>()?;
|
||||
use_trees.sort_unstable_by(|a, b| path_cmp_for_sort(a.path(), b.path()));
|
||||
for rhs_t in rhs.use_tree_list().into_iter().flat_map(|list| list.use_trees()) {
|
||||
|
||||
@@ -608,7 +608,7 @@ impl<'a> FindUsages<'a> {
|
||||
let reference = FileReference {
|
||||
range,
|
||||
name: ast::NameLike::NameRef(name_ref.clone()),
|
||||
category: is_name_ref_in_import(name_ref).then(|| ReferenceCategory::Import),
|
||||
category: is_name_ref_in_import(name_ref).then_some(ReferenceCategory::Import),
|
||||
};
|
||||
sink(file_id, reference)
|
||||
}
|
||||
@@ -787,7 +787,7 @@ impl ReferenceCategory {
|
||||
fn new(def: &Definition, r: &ast::NameRef) -> Option<ReferenceCategory> {
|
||||
// Only Locals and Fields have accesses for now.
|
||||
if !matches!(def, Definition::Local(_) | Definition::Field(_)) {
|
||||
return is_name_ref_in_import(r).then(|| ReferenceCategory::Import);
|
||||
return is_name_ref_in_import(r).then_some(ReferenceCategory::Import);
|
||||
}
|
||||
|
||||
let mode = r.syntax().ancestors().find_map(|node| {
|
||||
|
||||
@@ -449,7 +449,7 @@ pub fn parse_tt_as_comma_sep_paths(input: ast::TokenTree) -> Option<Vec<ast::Pat
|
||||
let input_expressions = tokens.group_by(|tok| tok.kind() == T![,]);
|
||||
let paths = input_expressions
|
||||
.into_iter()
|
||||
.filter_map(|(is_sep, group)| (!is_sep).then(|| group))
|
||||
.filter_map(|(is_sep, group)| (!is_sep).then_some(group))
|
||||
.filter_map(|mut tokens| {
|
||||
syntax::hacks::parse_expr_from_str(&tokens.join("")).and_then(|expr| match expr {
|
||||
ast::Expr::PathExpr(it) => it.path(),
|
||||
|
||||
Reference in New Issue
Block a user