10704: internal: Short-circuit `descend_into_macros_single` r=Veykril a=Veykril

There is no need to descend everything if all we are interested in is the first mapping.
This bring `descend_into_macros` timing in highlighting in `rust-analyzer/src/config.rs` from `154ms - descend_into_macros (2190 calls)` to `24ms - descend_into_macros (2190 calls)` since we use the single variant there(will regress once we want to highlight multiple namespaces again though).
bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
This commit is contained in:
bors[bot] 2021-11-05 15:06:37 +00:00 committed by GitHub
commit 726b4dd8bd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 84 additions and 52 deletions

View file

@ -18,7 +18,7 @@ pub mod eager;
use base_db::ProcMacroKind;
use either::Either;
pub use mbe::{ExpandError, ExpandResult};
pub use mbe::{ExpandError, ExpandResult, Origin};
use std::{hash::Hash, iter, sync::Arc};
@ -380,9 +380,11 @@ pub struct ExpansionInfo {
exp_map: Arc<mbe::TokenMap>,
}
pub use mbe::Origin;
impl ExpansionInfo {
pub fn expanded(&self) -> InFile<SyntaxNode> {
self.expanded.clone()
}
pub fn call_node(&self) -> Option<InFile<SyntaxNode>> {
Some(self.arg.with_value(self.arg.value.parent()?))
}