mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-28 04:44:57 +00:00
minor: simplify
This commit is contained in:
parent
56b51852c2
commit
177a183e85
1 changed files with 5 additions and 11 deletions
|
@ -448,8 +448,8 @@ impl<'db> SemanticsImpl<'db> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn resolve_derive_macro(&self, attr: &ast::Attr) -> Option<Vec<MacroDef>> {
|
fn resolve_derive_macro(&self, attr: &ast::Attr) -> Option<Vec<MacroDef>> {
|
||||||
let macro_call_ids = self.derive_macro_calls(attr)?;
|
let res = self
|
||||||
let res = macro_call_ids
|
.derive_macro_calls(attr)?
|
||||||
.iter()
|
.iter()
|
||||||
.map(|&call| {
|
.map(|&call| {
|
||||||
let loc: MacroCallLoc = self.db.lookup_intern_macro_call(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>> {
|
fn expand_derive_macro(&self, attr: &ast::Attr) -> Option<Vec<SyntaxNode>> {
|
||||||
let macro_call_ids = self.derive_macro_calls(attr)?;
|
let res: Vec<_> = self
|
||||||
|
.derive_macro_calls(attr)?
|
||||||
let expansions: Vec<_> = macro_call_ids
|
|
||||||
.iter()
|
.iter()
|
||||||
.map(|call| call.as_file())
|
.map(|call| call.as_file())
|
||||||
.flat_map(|file_id| {
|
.flat_map(|file_id| {
|
||||||
|
@ -471,12 +470,7 @@ impl<'db> SemanticsImpl<'db> {
|
||||||
Some(node)
|
Some(node)
|
||||||
})
|
})
|
||||||
.collect();
|
.collect();
|
||||||
|
Some(res)
|
||||||
if expansions.is_empty() {
|
|
||||||
None
|
|
||||||
} else {
|
|
||||||
Some(expansions)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn derive_macro_calls(&self, attr: &ast::Attr) -> Option<Vec<MacroCallId>> {
|
fn derive_macro_calls(&self, attr: &ast::Attr) -> Option<Vec<MacroCallId>> {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue