Skip to content

Fix unnecessary braces warnings #3866

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 7, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions crates/ra_hir/src/semantics/source_to_def.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
};
Expand All @@ -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,
}
};
Expand Down
6 changes: 3 additions & 3 deletions crates/ra_hir_expand/src/builtin_derive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
14 changes: 7 additions & 7 deletions crates/ra_ide/src/call_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,16 +109,16 @@ 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()) {
return None;
}
Some(FnCallNode::MethodCallExpr(it))
},
ast::MacroCall(it) => { Some(FnCallNode::MacroCallExpr(it)) },
_ => { None },
ast::MacroCall(it) => Some(FnCallNode::MacroCallExpr(it)),
_ => None,
}
}
})
Expand All @@ -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,
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions crates/ra_ide/src/completion/complete_fn_param.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
_ => (),
}
}
Expand Down
6 changes: 3 additions & 3 deletions crates/ra_ide/src/completion/complete_keyword.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
};
Expand Down
42 changes: 21 additions & 21 deletions crates/ra_ide/src/display/navigation_target.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
}
Expand All @@ -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,
}
}
Expand Down
16 changes: 8 additions & 8 deletions crates/ra_ide/src/display/structure.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
6 changes: 3 additions & 3 deletions crates/ra_ide/src/goto_type_definition.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
};

Expand Down
4 changes: 2 additions & 2 deletions crates/ra_ide/src/runnables.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
}
Expand Down
2 changes: 1 addition & 1 deletion crates/ra_ide_db/src/search.rs
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ fn reference_access(def: &Definition, name_ref: &ast::NameRef) -> Option<Referen
}
Some(ReferenceAccess::Read)
},
_ => {None}
_ => None
}
}
});
Expand Down
16 changes: 8 additions & 8 deletions crates/ra_ide_db/src/symbol_index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
12 changes: 6 additions & 6 deletions crates/ra_syntax/src/validation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
_ => (),
}
}
Expand Down