diff --git a/crates/hir_def/src/body.rs b/crates/hir_def/src/body.rs index 71375fe4a6e..ebb15e20cba 100644 --- a/crates/hir_def/src/body.rs +++ b/crates/hir_def/src/body.rs @@ -421,12 +421,12 @@ pub fn expr_syntax(&self, expr: ExprId) -> Result { } 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 @@ pub fn label_syntax(&self, label: LabelId) -> LabelSource { } 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 @@ pub fn field_syntax(&self, expr: ExprId) -> InFile> 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 ca337bd0057..512a9312a77 100644 --- a/crates/hir_def/src/body/lower.rs +++ b/crates/hir_def/src/body/lower.rs @@ -941,17 +941,15 @@ fn from(ast_lit_kind: ast::LiteralKind) -> Self { 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 bb3a34a7c1e..456ed9e6103 100644 --- a/crates/hir_def/src/data.rs +++ b/crates/hir_def/src/data.rs @@ -66,7 +66,7 @@ pub(crate) fn fn_data_query(db: &dyn DefDatabase, func: FunctionId) -> Arc 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 bdea31a166f..bad5f9aa243 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 2045cf7bdfe..ad6cd36ca60 100644 --- a/crates/hir_ty/src/tls.rs +++ b/crates/hir_ty/src/tls.rs @@ -128,6 +128,6 @@ pub(crate) fn set_current_program(p: &dyn HirDatabase, op: OP) -> R // 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 5520ee55286..6111bdb94aa 100644 --- a/crates/ide/src/extend_selection.rs +++ b/crates/ide/src/extend_selection.rs @@ -283,7 +283,7 @@ fn nearby_delimiter( 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 d8dda784c55..556659d07c9 100644 --- a/crates/ide_assists/src/handlers/extract_module.rs +++ b/crates/ide_assists/src/handlers/extract_module.rs @@ -417,7 +417,7 @@ fn change_visibility(&self, record_fields: Vec) -> Option 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 5ea58b74fe3..9d46e2b0785 100644 --- a/crates/ide_diagnostics/src/handlers/unlinked_file.rs +++ b/crates/ide_diagnostics/src/handlers/unlinked_file.rs @@ -117,12 +117,7 @@ fn is_outline_mod(item: &ast::Item) -> bool { } // 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 19a007e072a..a69a77c7ee2 100644 --- a/crates/syntax/src/ast/make.rs +++ b/crates/syntax/src/ast/make.rs @@ -49,7 +49,7 @@ pub fn field_from_idents<'a>( ) -> 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) }