about summary refs log tree commit diff
diff options
context:
space:
mode:
authorAleksey Kladov <aleksey.kladov@gmail.com>2021-12-28 16:51:17 +0300
committerAleksey Kladov <aleksey.kladov@gmail.com>2021-12-28 16:52:15 +0300
commit177a183e85467390bff24df6d72dbe0c9831d26a (patch)
treee889c1daedc53edbc621b67d1fc1fb0e266328f7
parent56b51852c239effd266fa3853ba5eb5da367cbf1 (diff)
downloadrust-177a183e85467390bff24df6d72dbe0c9831d26a.tar.gz
rust-177a183e85467390bff24df6d72dbe0c9831d26a.zip
minor: simplify
-rw-r--r--crates/hir/src/semantics.rs16
1 files changed, 5 insertions, 11 deletions
diff --git a/crates/hir/src/semantics.rs b/crates/hir/src/semantics.rs
index f3d8550a87f..1070a26c26e 100644
--- a/crates/hir/src/semantics.rs
+++ b/crates/hir/src/semantics.rs
@@ -448,8 +448,8 @@ impl<'db> SemanticsImpl<'db> {
     }
 
     fn resolve_derive_macro(&self, attr: &ast::Attr) -> Option<Vec<MacroDef>> {
-        let macro_call_ids = self.derive_macro_calls(attr)?;
-        let res = macro_call_ids
+        let res = self
+            .derive_macro_calls(attr)?
             .iter()
             .map(|&call| {
                 let loc: MacroCallLoc = self.db.lookup_intern_macro_call(call);
@@ -460,9 +460,8 @@ impl<'db> SemanticsImpl<'db> {
     }
 
     fn expand_derive_macro(&self, attr: &ast::Attr) -> Option<Vec<SyntaxNode>> {
-        let macro_call_ids = self.derive_macro_calls(attr)?;
-
-        let expansions: Vec<_> = macro_call_ids
+        let res: Vec<_> = self
+            .derive_macro_calls(attr)?
             .iter()
             .map(|call| call.as_file())
             .flat_map(|file_id| {
@@ -471,12 +470,7 @@ impl<'db> SemanticsImpl<'db> {
                 Some(node)
             })
             .collect();
-
-        if expansions.is_empty() {
-            None
-        } else {
-            Some(expansions)
-        }
+        Some(res)
     }
 
     fn derive_macro_calls(&self, attr: &ast::Attr) -> Option<Vec<MacroCallId>> {