From 52fd2c8e4858c548195edceb83c02437d2d28ee5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lauren=C8=9Biu=20Nicola?= Date: Mon, 6 Apr 2020 17:21:33 +0300 Subject: Fix unnecessary braces warnings --- crates/ra_hir/src/semantics/source_to_def.rs | 18 +++++----- crates/ra_hir_expand/src/builtin_derive.rs | 6 ++-- crates/ra_ide/src/call_info.rs | 14 ++++---- crates/ra_ide/src/completion/complete_fn_param.rs | 4 +-- crates/ra_ide/src/completion/complete_keyword.rs | 6 ++-- crates/ra_ide/src/display/navigation_target.rs | 42 +++++++++++------------ crates/ra_ide/src/display/structure.rs | 16 ++++----- crates/ra_ide/src/goto_type_definition.rs | 6 ++-- crates/ra_ide/src/runnables.rs | 4 +-- crates/ra_ide_db/src/search.rs | 2 +- crates/ra_ide_db/src/symbol_index.rs | 16 ++++----- crates/ra_syntax/src/validation.rs | 12 +++---- 12 files changed, 73 insertions(+), 73 deletions(-) (limited to 'crates') diff --git a/crates/ra_hir/src/semantics/source_to_def.rs b/crates/ra_hir/src/semantics/source_to_def.rs index 8843f2835..66724919b 100644 --- a/crates/ra_hir/src/semantics/source_to_def.rs +++ b/crates/ra_hir/src/semantics/source_to_def.rs @@ -208,12 +208,12 @@ impl SourceToDefCtx<'_, '_> { for container in src.cloned().ancestors_with_macros(self.db.upcast()).skip(1) { let res: GenericDefId = match_ast! { match (container.value) { - ast::FnDef(it) => { self.fn_to_def(container.with_value(it))?.into() }, - ast::StructDef(it) => { self.struct_to_def(container.with_value(it))?.into() }, - ast::EnumDef(it) => { self.enum_to_def(container.with_value(it))?.into() }, - ast::TraitDef(it) => { self.trait_to_def(container.with_value(it))?.into() }, - ast::TypeAliasDef(it) => { self.type_alias_to_def(container.with_value(it))?.into() }, - ast::ImplDef(it) => { self.impl_to_def(container.with_value(it))?.into() }, + ast::FnDef(it) => self.fn_to_def(container.with_value(it))?.into(), + ast::StructDef(it) => self.struct_to_def(container.with_value(it))?.into(), + ast::EnumDef(it) => self.enum_to_def(container.with_value(it))?.into(), + ast::TraitDef(it) => self.trait_to_def(container.with_value(it))?.into(), + ast::TypeAliasDef(it) => self.type_alias_to_def(container.with_value(it))?.into(), + ast::ImplDef(it) => self.impl_to_def(container.with_value(it))?.into(), _ => continue, } }; @@ -226,9 +226,9 @@ impl SourceToDefCtx<'_, '_> { for container in src.cloned().ancestors_with_macros(self.db.upcast()).skip(1) { let res: DefWithBodyId = match_ast! { match (container.value) { - ast::ConstDef(it) => { self.const_to_def(container.with_value(it))?.into() }, - ast::StaticDef(it) => { self.static_to_def(container.with_value(it))?.into() }, - ast::FnDef(it) => { self.fn_to_def(container.with_value(it))?.into() }, + ast::ConstDef(it) => self.const_to_def(container.with_value(it))?.into(), + ast::StaticDef(it) => self.static_to_def(container.with_value(it))?.into(), + ast::FnDef(it) => self.fn_to_def(container.with_value(it))?.into(), _ => continue, } }; diff --git a/crates/ra_hir_expand/src/builtin_derive.rs b/crates/ra_hir_expand/src/builtin_derive.rs index 79aea5806..bb45b0f1d 100644 --- a/crates/ra_hir_expand/src/builtin_derive.rs +++ b/crates/ra_hir_expand/src/builtin_derive.rs @@ -73,9 +73,9 @@ fn parse_adt(tt: &tt::Subtree) -> Result { let node = item.syntax(); let (name, params) = match_ast! { match node { - ast::StructDef(it) => { (it.name(), it.type_param_list()) }, - ast::EnumDef(it) => { (it.name(), it.type_param_list()) }, - ast::UnionDef(it) => { (it.name(), it.type_param_list()) }, + ast::StructDef(it) => (it.name(), it.type_param_list()), + ast::EnumDef(it) => (it.name(), it.type_param_list()), + ast::UnionDef(it) => (it.name(), it.type_param_list()), _ => { debug!("unexpected node is {:?}", node); return Err(mbe::ExpandError::ConversionError) diff --git a/crates/ra_ide/src/call_info.rs b/crates/ra_ide/src/call_info.rs index 39d09a07f..ca57eceff 100644 --- a/crates/ra_ide/src/call_info.rs +++ b/crates/ra_ide/src/call_info.rs @@ -109,7 +109,7 @@ impl FnCallNode { syntax.ancestors().find_map(|node| { match_ast! { match node { - ast::CallExpr(it) => { Some(FnCallNode::CallExpr(it)) }, + ast::CallExpr(it) => Some(FnCallNode::CallExpr(it)), ast::MethodCallExpr(it) => { let arg_list = it.arg_list()?; if !syntax.text_range().is_subrange(&arg_list.syntax().text_range()) { @@ -117,8 +117,8 @@ impl FnCallNode { } Some(FnCallNode::MethodCallExpr(it)) }, - ast::MacroCall(it) => { Some(FnCallNode::MacroCallExpr(it)) }, - _ => { None }, + ast::MacroCall(it) => Some(FnCallNode::MacroCallExpr(it)), + _ => None, } } }) @@ -127,10 +127,10 @@ impl FnCallNode { pub(crate) fn with_node_exact(node: &SyntaxNode) -> Option { match_ast! { match node { - ast::CallExpr(it) => { Some(FnCallNode::CallExpr(it)) }, - ast::MethodCallExpr(it) => { Some(FnCallNode::MethodCallExpr(it)) }, - ast::MacroCall(it) => { Some(FnCallNode::MacroCallExpr(it)) }, - _ => { None }, + ast::CallExpr(it) => Some(FnCallNode::CallExpr(it)), + ast::MethodCallExpr(it) => Some(FnCallNode::MethodCallExpr(it)), + ast::MacroCall(it) => Some(FnCallNode::MacroCallExpr(it)), + _ => None, } } } diff --git a/crates/ra_ide/src/completion/complete_fn_param.rs b/crates/ra_ide/src/completion/complete_fn_param.rs index 9226ac055..62ae5ccb4 100644 --- a/crates/ra_ide/src/completion/complete_fn_param.rs +++ b/crates/ra_ide/src/completion/complete_fn_param.rs @@ -18,8 +18,8 @@ pub(super) fn complete_fn_param(acc: &mut Completions, ctx: &CompletionContext) for node in ctx.token.parent().ancestors() { match_ast! { match node { - ast::SourceFile(it) => { process(it, &mut params) }, - ast::ItemList(it) => { process(it, &mut params) }, + ast::SourceFile(it) => process(it, &mut params), + ast::ItemList(it) => process(it, &mut params), _ => (), } } diff --git a/crates/ra_ide/src/completion/complete_keyword.rs b/crates/ra_ide/src/completion/complete_keyword.rs index 1e053ea4a..38f9c34e7 100644 --- a/crates/ra_ide/src/completion/complete_keyword.rs +++ b/crates/ra_ide/src/completion/complete_keyword.rs @@ -86,9 +86,9 @@ fn is_in_loop_body(leaf: &SyntaxToken) -> bool { } let loop_body = match_ast! { match node { - ast::ForExpr(it) => { it.loop_body() }, - ast::WhileExpr(it) => { it.loop_body() }, - ast::LoopExpr(it) => { it.loop_body() }, + ast::ForExpr(it) => it.loop_body(), + ast::WhileExpr(it) => it.loop_body(), + ast::LoopExpr(it) => it.loop_body(), _ => None, } }; diff --git a/crates/ra_ide/src/display/navigation_target.rs b/crates/ra_ide/src/display/navigation_target.rs index d57451cc8..e61846995 100644 --- a/crates/ra_ide/src/display/navigation_target.rs +++ b/crates/ra_ide/src/display/navigation_target.rs @@ -399,17 +399,17 @@ pub(crate) fn docs_from_symbol(db: &RootDatabase, symbol: &FileSymbol) -> Option match_ast! { match node { - ast::FnDef(it) => { it.doc_comment_text() }, - ast::StructDef(it) => { it.doc_comment_text() }, - ast::EnumDef(it) => { it.doc_comment_text() }, - ast::TraitDef(it) => { it.doc_comment_text() }, - ast::Module(it) => { it.doc_comment_text() }, - ast::TypeAliasDef(it) => { it.doc_comment_text() }, - ast::ConstDef(it) => { it.doc_comment_text() }, - ast::StaticDef(it) => { it.doc_comment_text() }, - ast::RecordFieldDef(it) => { it.doc_comment_text() }, - ast::EnumVariant(it) => { it.doc_comment_text() }, - ast::MacroCall(it) => { it.doc_comment_text() }, + ast::FnDef(it) => it.doc_comment_text(), + ast::StructDef(it) => it.doc_comment_text(), + ast::EnumDef(it) => it.doc_comment_text(), + ast::TraitDef(it) => it.doc_comment_text(), + ast::Module(it) => it.doc_comment_text(), + ast::TypeAliasDef(it) => it.doc_comment_text(), + ast::ConstDef(it) => it.doc_comment_text(), + ast::StaticDef(it) => it.doc_comment_text(), + ast::RecordFieldDef(it) => it.doc_comment_text(), + ast::EnumVariant(it) => it.doc_comment_text(), + ast::MacroCall(it) => it.doc_comment_text(), _ => None, } } @@ -424,16 +424,16 @@ pub(crate) fn description_from_symbol(db: &RootDatabase, symbol: &FileSymbol) -> match_ast! { match node { - ast::FnDef(it) => { it.short_label() }, - ast::StructDef(it) => { it.short_label() }, - ast::EnumDef(it) => { it.short_label() }, - ast::TraitDef(it) => { it.short_label() }, - ast::Module(it) => { it.short_label() }, - ast::TypeAliasDef(it) => { it.short_label() }, - ast::ConstDef(it) => { it.short_label() }, - ast::StaticDef(it) => { it.short_label() }, - ast::RecordFieldDef(it) => { it.short_label() }, - ast::EnumVariant(it) => { it.short_label() }, + ast::FnDef(it) => it.short_label(), + ast::StructDef(it) => it.short_label(), + ast::EnumDef(it) => it.short_label(), + ast::TraitDef(it) => it.short_label(), + ast::Module(it) => it.short_label(), + ast::TypeAliasDef(it) => it.short_label(), + ast::ConstDef(it) => it.short_label(), + ast::StaticDef(it) => it.short_label(), + ast::RecordFieldDef(it) => it.short_label(), + ast::EnumVariant(it) => it.short_label(), _ => None, } } diff --git a/crates/ra_ide/src/display/structure.rs b/crates/ra_ide/src/display/structure.rs index 5774e9a8b..7a774785c 100644 --- a/crates/ra_ide/src/display/structure.rs +++ b/crates/ra_ide/src/display/structure.rs @@ -117,18 +117,18 @@ fn structure_node(node: &SyntaxNode) -> Option { decl_with_detail(it, Some(detail)) }, - ast::StructDef(it) => { decl(it) }, - ast::EnumDef(it) => { decl(it) }, - ast::EnumVariant(it) => { decl(it) }, - ast::TraitDef(it) => { decl(it) }, - ast::Module(it) => { decl(it) }, + ast::StructDef(it) => decl(it), + ast::EnumDef(it) => decl(it), + ast::EnumVariant(it) => decl(it), + ast::TraitDef(it) => decl(it), + ast::Module(it) => decl(it), ast::TypeAliasDef(it) => { let ty = it.type_ref(); decl_with_type_ref(it, ty) }, - ast::RecordFieldDef(it) => { decl_with_ascription(it) }, - ast::ConstDef(it) => { decl_with_ascription(it) }, - ast::StaticDef(it) => { decl_with_ascription(it) }, + ast::RecordFieldDef(it) => decl_with_ascription(it), + ast::ConstDef(it) => decl_with_ascription(it), + ast::StaticDef(it) => decl_with_ascription(it), ast::ImplDef(it) => { let target_type = it.target_type()?; let target_trait = it.target_trait(); diff --git a/crates/ra_ide/src/goto_type_definition.rs b/crates/ra_ide/src/goto_type_definition.rs index 869a4708b..bd2688df1 100644 --- a/crates/ra_ide/src/goto_type_definition.rs +++ b/crates/ra_ide/src/goto_type_definition.rs @@ -18,9 +18,9 @@ pub(crate) fn goto_type_definition( let (ty, node) = sema.ancestors_with_macros(token.parent()).find_map(|node| { let ty = match_ast! { match node { - ast::Expr(expr) => { sema.type_of_expr(&expr)? }, - ast::Pat(pat) => { sema.type_of_pat(&pat)? }, - _ => { return None }, + ast::Expr(expr) => sema.type_of_expr(&expr)?, + ast::Pat(pat) => sema.type_of_pat(&pat)?, + _ => return None, } }; diff --git a/crates/ra_ide/src/runnables.rs b/crates/ra_ide/src/runnables.rs index 74877e90f..9433f3a24 100644 --- a/crates/ra_ide/src/runnables.rs +++ b/crates/ra_ide/src/runnables.rs @@ -49,8 +49,8 @@ pub(crate) fn runnables(db: &RootDatabase, file_id: FileId) -> Vec { fn runnable(sema: &Semantics, item: SyntaxNode) -> Option { match_ast! { match item { - ast::FnDef(it) => { runnable_fn(sema, it) }, - ast::Module(it) => { runnable_mod(sema, it) }, + ast::FnDef(it) => runnable_fn(sema, it), + ast::Module(it) => runnable_mod(sema, it), _ => None, } } diff --git a/crates/ra_ide_db/src/search.rs b/crates/ra_ide_db/src/search.rs index 05a0eed30..1bf014149 100644 --- a/crates/ra_ide_db/src/search.rs +++ b/crates/ra_ide_db/src/search.rs @@ -286,7 +286,7 @@ fn reference_access(def: &Definition, name_ref: &ast::NameRef) -> Option {None} + _ => None } } }); diff --git a/crates/ra_ide_db/src/symbol_index.rs b/crates/ra_ide_db/src/symbol_index.rs index 0f46f93c1..d30458d86 100644 --- a/crates/ra_ide_db/src/symbol_index.rs +++ b/crates/ra_ide_db/src/symbol_index.rs @@ -354,14 +354,14 @@ fn to_symbol(node: &SyntaxNode) -> Option<(SmolStr, SyntaxNodePtr, TextRange)> { } match_ast! { match node { - ast::FnDef(it) => { decl(it) }, - ast::StructDef(it) => { decl(it) }, - ast::EnumDef(it) => { decl(it) }, - ast::TraitDef(it) => { decl(it) }, - ast::Module(it) => { decl(it) }, - ast::TypeAliasDef(it) => { decl(it) }, - ast::ConstDef(it) => { decl(it) }, - ast::StaticDef(it) => { decl(it) }, + ast::FnDef(it) => decl(it), + ast::StructDef(it) => decl(it), + ast::EnumDef(it) => decl(it), + ast::TraitDef(it) => decl(it), + ast::Module(it) => decl(it), + ast::TypeAliasDef(it) => decl(it), + ast::ConstDef(it) => decl(it), + ast::StaticDef(it) => decl(it), ast::MacroCall(it) => { if it.is_macro_rules().is_some() { decl(it) diff --git a/crates/ra_syntax/src/validation.rs b/crates/ra_syntax/src/validation.rs index 7915cf8cb..f85b3e61b 100644 --- a/crates/ra_syntax/src/validation.rs +++ b/crates/ra_syntax/src/validation.rs @@ -88,12 +88,12 @@ pub(crate) fn validate(root: &SyntaxNode) -> Vec { for node in root.descendants() { match_ast! { match node { - ast::Literal(it) => { validate_literal(it, &mut errors) }, - ast::BlockExpr(it) => { block::validate_block_expr(it, &mut errors) }, - ast::FieldExpr(it) => { validate_numeric_name(it.name_ref(), &mut errors) }, - ast::RecordField(it) => { validate_numeric_name(it.name_ref(), &mut errors) }, - ast::Visibility(it) => { validate_visibility(it, &mut errors) }, - ast::RangeExpr(it) => { validate_range_expr(it, &mut errors) }, + ast::Literal(it) => validate_literal(it, &mut errors), + ast::BlockExpr(it) => block::validate_block_expr(it, &mut errors), + ast::FieldExpr(it) => validate_numeric_name(it.name_ref(), &mut errors), + ast::RecordField(it) => validate_numeric_name(it.name_ref(), &mut errors), + ast::Visibility(it) => validate_visibility(it, &mut errors), + ast::RangeExpr(it) => validate_range_expr(it, &mut errors), _ => (), } } -- cgit v1.2.3