Skip to content

Commit 177a183

Browse files
committed
minor: simplify
1 parent 56b5185 commit 177a183

File tree

1 file changed

+5
-11
lines changed

1 file changed

+5
-11
lines changed

crates/hir/src/semantics.rs

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -448,8 +448,8 @@ impl<'db> SemanticsImpl<'db> {
448448
}
449449

450450
fn resolve_derive_macro(&self, attr: &ast::Attr) -> Option<Vec<MacroDef>> {
451-
let macro_call_ids = self.derive_macro_calls(attr)?;
452-
let res = macro_call_ids
451+
let res = self
452+
.derive_macro_calls(attr)?
453453
.iter()
454454
.map(|&call| {
455455
let loc: MacroCallLoc = self.db.lookup_intern_macro_call(call);
@@ -460,9 +460,8 @@ impl<'db> SemanticsImpl<'db> {
460460
}
461461

462462
fn expand_derive_macro(&self, attr: &ast::Attr) -> Option<Vec<SyntaxNode>> {
463-
let macro_call_ids = self.derive_macro_calls(attr)?;
464-
465-
let expansions: Vec<_> = macro_call_ids
463+
let res: Vec<_> = self
464+
.derive_macro_calls(attr)?
466465
.iter()
467466
.map(|call| call.as_file())
468467
.flat_map(|file_id| {
@@ -471,12 +470,7 @@ impl<'db> SemanticsImpl<'db> {
471470
Some(node)
472471
})
473472
.collect();
474-
475-
if expansions.is_empty() {
476-
None
477-
} else {
478-
Some(expansions)
479-
}
473+
Some(res)
480474
}
481475

482476
fn derive_macro_calls(&self, attr: &ast::Attr) -> Option<Vec<MacroCallId>> {

0 commit comments

Comments
 (0)