diff options
author | Jonas Schievink <[email protected]> | 2021-06-06 14:51:49 +0100 |
---|---|---|
committer | Jonas Schievink <[email protected]> | 2021-06-06 15:48:13 +0100 |
commit | 1d5c60ff548c082a59eebda4bbaede99cec3cc4d (patch) | |
tree | a8cb03b4e8afd7d499308bd9f4b387db90b353a3 /crates/hir_expand | |
parent | d616a6a45697589a5fb4eeb4a30382322f8b8184 (diff) |
Replace attribute with equivalent whitespace
This is needed to that the `TokenMap` we create contains offsets that
match the source.
Diffstat (limited to 'crates/hir_expand')
-rw-r--r-- | crates/hir_expand/src/input.rs | 6 |
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 | ||
3 | use syntax::{ | 3 | use 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 | ||