diff --git a/crates/hir_def/src/body.rs b/crates/hir_def/src/body.rs index 71375fe4a6..ebb15e20cb 100644 --- a/crates/hir_def/src/body.rs +++ b/crates/hir_def/src/body.rs @@ -421,12 +421,12 @@ impl BodySourceMap { } pub fn node_expr(&self, node: InFile<&ast::Expr>) -> Option { - let src = node.map(|it| AstPtr::new(it)); + let src = node.map(AstPtr::new); self.expr_map.get(&src).cloned() } pub fn node_macro_file(&self, node: InFile<&ast::MacroCall>) -> Option { - let src = node.map(|it| AstPtr::new(it)); + let src = node.map(AstPtr::new); self.expansions.get(&src).cloned() } @@ -449,7 +449,7 @@ impl BodySourceMap { } pub fn node_label(&self, node: InFile<&ast::Label>) -> Option { - let src = node.map(|it| AstPtr::new(it)); + let src = node.map(AstPtr::new); self.label_map.get(&src).cloned() } @@ -457,7 +457,7 @@ impl BodySourceMap { self.field_map_back[&expr].clone() } pub fn node_field(&self, node: InFile<&ast::RecordExprField>) -> Option { - let src = node.map(|it| AstPtr::new(it)); + let src = node.map(AstPtr::new); self.field_map.get(&src).cloned() } diff --git a/crates/hir_def/src/body/lower.rs b/crates/hir_def/src/body/lower.rs index ca337bd005..512a9312a7 100644 --- a/crates/hir_def/src/body/lower.rs +++ b/crates/hir_def/src/body/lower.rs @@ -941,17 +941,15 @@ impl From for Literal { LiteralKind::IntNumber(lit) => { if let builtin @ Some(_) = lit.suffix().and_then(BuiltinFloat::from_suffix) { Literal::Float(Default::default(), builtin) - } else if let builtin @ Some(_) = - lit.suffix().and_then(|it| BuiltinInt::from_suffix(it)) - { + } else if let builtin @ Some(_) = lit.suffix().and_then(BuiltinInt::from_suffix) { Literal::Int(lit.value().unwrap_or(0) as i128, builtin) } else { - let builtin = lit.suffix().and_then(|it| BuiltinUint::from_suffix(it)); + let builtin = lit.suffix().and_then(BuiltinUint::from_suffix); Literal::Uint(lit.value().unwrap_or(0), builtin) } } LiteralKind::FloatNumber(lit) => { - let ty = lit.suffix().and_then(|it| BuiltinFloat::from_suffix(it)); + let ty = lit.suffix().and_then(BuiltinFloat::from_suffix); Literal::Float(Default::default(), ty) } LiteralKind::ByteString(bs) => { diff --git a/crates/hir_def/src/data.rs b/crates/hir_def/src/data.rs index bb3a34a7c1..456ed9e610 100644 --- a/crates/hir_def/src/data.rs +++ b/crates/hir_def/src/data.rs @@ -66,7 +66,7 @@ impl FunctionData { .by_key("rustc_legacy_const_generics") .tt_values() .next() - .map(|arg| parse_rustc_legacy_const_generics(arg)) + .map(parse_rustc_legacy_const_generics) .unwrap_or_default(); Arc::new(FunctionData { diff --git a/crates/hir_expand/src/builtin_derive_macro.rs b/crates/hir_expand/src/builtin_derive_macro.rs index 5a909e9a50..f7d5532df5 100644 --- a/crates/hir_expand/src/builtin_derive_macro.rs +++ b/crates/hir_expand/src/builtin_derive_macro.rs @@ -88,9 +88,8 @@ fn parse_adt(tt: &tt::Subtree) -> Result { debug!("parsed item has no name"); ExpandError::Other("missing name".into()) })?; - let name_token_id = token_map - .token_by_range(name.syntax().text_range()) - .unwrap_or_else(|| TokenId::unspecified()); + let name_token_id = + token_map.token_by_range(name.syntax().text_range()).unwrap_or_else(TokenId::unspecified); let name_token = tt::Ident { id: name_token_id, text: name.text().into() }; let type_or_const_params = params.map_or(0, |type_param_list| type_param_list.type_or_const_params().count()); diff --git a/crates/hir_expand/src/builtin_fn_macro.rs b/crates/hir_expand/src/builtin_fn_macro.rs index bdea31a166..bad5f9aa24 100644 --- a/crates/hir_expand/src/builtin_fn_macro.rs +++ b/crates/hir_expand/src/builtin_fn_macro.rs @@ -446,7 +446,7 @@ fn concat_bytes_expand( match token.kind() { syntax::SyntaxKind::BYTE => bytes.push(token.text().to_string()), syntax::SyntaxKind::BYTE_STRING => { - let components = unquote_byte_string(lit).unwrap_or_else(|| Vec::new()); + let components = unquote_byte_string(lit).unwrap_or_else(Vec::new); components.into_iter().for_each(|x| bytes.push(x.to_string())); } _ => { diff --git a/crates/hir_ty/src/tls.rs b/crates/hir_ty/src/tls.rs index 2045cf7bdf..ad6cd36ca6 100644 --- a/crates/hir_ty/src/tls.rs +++ b/crates/hir_ty/src/tls.rs @@ -128,6 +128,6 @@ mod unsafe_tls { // type. let static_p: &DebugContext<'static> = unsafe { std::mem::transmute::<&DebugContext, &DebugContext<'static>>(&ctx) }; - PROGRAM.set(static_p, || op()) + PROGRAM.set(static_p, op) } } diff --git a/crates/ide/src/extend_selection.rs b/crates/ide/src/extend_selection.rs index 5520ee5528..6111bdb94a 100644 --- a/crates/ide/src/extend_selection.rs +++ b/crates/ide/src/extend_selection.rs @@ -283,7 +283,7 @@ fn extend_list_item(node: &SyntaxNode) -> Option { let final_node = delimiter_node .next_sibling_or_token() .and_then(|it| it.into_token()) - .filter(|node| is_single_line_ws(node)) + .filter(is_single_line_ws) .unwrap_or(delimiter_node); return Some(TextRange::new(node.text_range().start(), final_node.text_range().end())); diff --git a/crates/ide_assists/src/handlers/extract_module.rs b/crates/ide_assists/src/handlers/extract_module.rs index d8dda784c5..556659d07c 100644 --- a/crates/ide_assists/src/handlers/extract_module.rs +++ b/crates/ide_assists/src/handlers/extract_module.rs @@ -417,7 +417,7 @@ impl Module { replacements.append(&mut impl_item_replacements); record_field_parents.into_iter().for_each(|x| { - x.1.descendants().filter_map(|x| ast::RecordField::cast(x)).for_each(|desc| { + x.1.descendants().filter_map(ast::RecordField::cast).for_each(|desc| { let is_record_field_present = record_fields .clone() .into_iter() diff --git a/crates/ide_db/src/syntax_helpers/insert_whitespace_into_node.rs b/crates/ide_db/src/syntax_helpers/insert_whitespace_into_node.rs index 0f1dd96f6f..7f5563d9d0 100644 --- a/crates/ide_db/src/syntax_helpers/insert_whitespace_into_node.rs +++ b/crates/ide_db/src/syntax_helpers/insert_whitespace_into_node.rs @@ -85,7 +85,7 @@ pub fn insert_ws_into(syn: SyntaxNode) -> SyntaxNode { } mods.push(do_nl(after, tok)); } - LIFETIME_IDENT if is_next(|it| is_text(it), true) => { + LIFETIME_IDENT if is_next(is_text, true) => { mods.push(do_ws(after, tok)); } AS_KW | DYN_KW | IMPL_KW => { diff --git a/crates/ide_diagnostics/src/handlers/unlinked_file.rs b/crates/ide_diagnostics/src/handlers/unlinked_file.rs index 5ea58b74fe..9d46e2b078 100644 --- a/crates/ide_diagnostics/src/handlers/unlinked_file.rs +++ b/crates/ide_diagnostics/src/handlers/unlinked_file.rs @@ -117,12 +117,7 @@ fn make_fixes( } // If there are existing `mod m;` items, append after them (after the first group of them, rather). - match ast - .items() - .skip_while(|item| !is_outline_mod(item)) - .take_while(|item| is_outline_mod(item)) - .last() - { + match ast.items().skip_while(|item| !is_outline_mod(item)).take_while(is_outline_mod).last() { Some(last) => { cov_mark::hit!(unlinked_file_append_to_existing_mods); let offset = last.syntax().text_range().end(); diff --git a/crates/syntax/src/ast/make.rs b/crates/syntax/src/ast/make.rs index 19a007e072..a69a77c7ee 100644 --- a/crates/syntax/src/ast/make.rs +++ b/crates/syntax/src/ast/make.rs @@ -49,7 +49,7 @@ pub mod ext { ) -> Option { let mut iter = parts.into_iter(); let base = expr_path(ext::ident_path(iter.next()?)); - let expr = iter.fold(base, |base, s| expr_field(base, s)); + let expr = iter.fold(base, expr_field); Some(expr) }