Fix unnecessary braces warnings

This commit is contained in:
Laurențiu Nicola 2020-04-06 17:21:33 +03:00
parent 2603a9e628
commit 52fd2c8e48
12 changed files with 73 additions and 73 deletions

View file

@ -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,
}
};

View file

@ -73,9 +73,9 @@ fn parse_adt(tt: &tt::Subtree) -> Result<BasicAdtInfo, mbe::ExpandError> {
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)

View file

@ -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<FnCallNode> {
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,
}
}
}

View file

@ -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),
_ => (),
}
}

View file

@ -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,
}
};

View file

@ -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,
}
}

View file

@ -117,18 +117,18 @@ fn structure_node(node: &SyntaxNode) -> Option<StructureNode> {
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();

View file

@ -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,
}
};

View file

@ -49,8 +49,8 @@ pub(crate) fn runnables(db: &RootDatabase, file_id: FileId) -> Vec<Runnable> {
fn runnable(sema: &Semantics<RootDatabase>, item: SyntaxNode) -> Option<Runnable> {
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,
}
}

View file

@ -286,7 +286,7 @@ fn reference_access(def: &Definition, name_ref: &ast::NameRef) -> Option<Referen
}
Some(ReferenceAccess::Read)
},
_ => {None}
_ => None
}
}
});

View file

@ -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)

View file

@ -88,12 +88,12 @@ pub(crate) fn validate(root: &SyntaxNode) -> Vec<SyntaxError> {
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),
_ => (),
}
}