Revert "Proper handling $crate and local_inner_macros"

This commit is contained in:
Jonas Schievink 2021-01-03 11:47:57 +01:00 committed by GitHub
parent 354c1daedc
commit 85cc3cfec9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 55 additions and 179 deletions

View file

@ -340,8 +340,11 @@ impl ExpansionInfo {
Some(self.expanded.with_value(token))
}
pub fn map_token_up(&self, token: &SyntaxToken) -> Option<(InFile<SyntaxToken>, Origin)> {
let token_id = self.exp_map.token_by_range(token.text_range())?;
pub fn map_token_up(
&self,
token: InFile<&SyntaxToken>,
) -> Option<(InFile<SyntaxToken>, Origin)> {
let token_id = self.exp_map.token_by_range(token.value.text_range())?;
let (token_id, origin) = self.macro_def.0.map_id_up(token_id);
let (token_map, tt) = match origin {
@ -356,7 +359,7 @@ impl ExpansionInfo {
),
};
let range = token_map.range_by_token(token_id)?.by_kind(token.kind())?;
let range = token_map.range_by_token(token_id)?.by_kind(token.value.kind())?;
let token = algo::find_covering_element(&tt.value, range + tt.value.text_range().start())
.into_token()?;
Some((tt.with_value(token), origin))
@ -492,7 +495,7 @@ fn ascend_call_token(
expansion: &ExpansionInfo,
token: InFile<SyntaxToken>,
) -> Option<InFile<SyntaxToken>> {
let (mapped, origin) = expansion.map_token_up(&token.value)?;
let (mapped, origin) = expansion.map_token_up(token.as_ref())?;
if origin != Origin::Call {
return None;
}