aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2021-06-06 15:50:06 +0100
committerGitHub <[email protected]>2021-06-06 15:50:06 +0100
commit13da28cc2bc1b59f7af817eca36927a71edb023c (patch)
treea8cb03b4e8afd7d499308bd9f4b387db90b353a3
parentd616a6a45697589a5fb4eeb4a30382322f8b8184 (diff)
parent1d5c60ff548c082a59eebda4bbaede99cec3cc4d (diff)
Merge #9155
9155: internal: replace attribute with equivalent whitespace r=jonas-schievink a=jonas-schievink This is needed to that the `TokenMap` we create contains offsets that match the source. Currently the offsets don't match because the attribute is removed, shifting all subsequent token offsets by the attribute's text length. Currently this fix has no visible effect because we don't remap tokens in attribute macros. bors r+ Co-authored-by: Jonas Schievink <[email protected]>
-rw-r--r--crates/hir_expand/src/input.rs6
1 files changed, 4 insertions, 2 deletions
diff --git a/crates/hir_expand/src/input.rs b/crates/hir_expand/src/input.rs
index 40116a479..82dc7f326 100644
--- a/crates/hir_expand/src/input.rs
+++ b/crates/hir_expand/src/input.rs
@@ -1,7 +1,7 @@
1//! Macro input conditioning. 1//! Macro input conditioning.
2 2
3use syntax::{ 3use syntax::{
4 ast::{self, AttrsOwner}, 4 ast::{self, make, AttrsOwner},
5 AstNode, SyntaxNode, 5 AstNode, SyntaxNode,
6}; 6};
7 7
@@ -61,7 +61,9 @@ fn remove_attr_invoc(item: ast::Item, attr_index: usize) -> ast::Item {
61 .attrs() 61 .attrs()
62 .nth(attr_index) 62 .nth(attr_index)
63 .unwrap_or_else(|| panic!("cannot find attribute #{}", attr_index)); 63 .unwrap_or_else(|| panic!("cannot find attribute #{}", attr_index));
64 attr.syntax().detach(); 64 let syntax_index = attr.syntax().index();
65 let ws = make::tokens::whitespace(&" ".repeat(u32::from(attr.syntax().text().len()) as usize));
66 item.syntax().splice_children(syntax_index..syntax_index + 1, vec![ws.into()]);
65 item 67 item
66} 68}
67 69