aboutsummaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
authorJonas Schievink <[email protected]>2021-05-11 23:57:41 +0100
committerJonas Schievink <[email protected]>2021-05-11 23:57:41 +0100
commitc868414dcd50bbfe433cc93f8319d41e6742542c (patch)
tree852aceb23512b159e24316f58ef32c2f09ed8eb7 /crates
parentc6e2ba43bbfef80d4ecabbc9edd5be9d058f6db9 (diff)
Revert "Strip delimiter from fn-like proc macro input"
This reverts commit bda68e23328ca62a71da348a13c4d13cc8f991f3.
Diffstat (limited to 'crates')
-rw-r--r--crates/hir_expand/src/input.rs31
-rw-r--r--crates/hir_expand/src/lib.rs4
2 files changed, 2 insertions, 33 deletions
diff --git a/crates/hir_expand/src/input.rs b/crates/hir_expand/src/input.rs
index 860aa049b..112216859 100644
--- a/crates/hir_expand/src/input.rs
+++ b/crates/hir_expand/src/input.rs
@@ -1,9 +1,8 @@
1//! Macro input conditioning. 1//! Macro input conditioning.
2 2
3use parser::SyntaxKind;
4use syntax::{ 3use syntax::{
5 ast::{self, AttrsOwner}, 4 ast::{self, AttrsOwner},
6 AstNode, SyntaxElement, SyntaxNode, 5 AstNode, SyntaxNode,
7}; 6};
8 7
9use crate::{ 8use crate::{
@@ -20,33 +19,7 @@ pub(crate) fn process_macro_input(
20 let loc: MacroCallLoc = db.lookup_intern_macro(id); 19 let loc: MacroCallLoc = db.lookup_intern_macro(id);
21 20
22 match loc.kind { 21 match loc.kind {
23 MacroCallKind::FnLike { .. } => { 22 MacroCallKind::FnLike { .. } => node,
24 if !loc.def.is_proc_macro() {
25 // MBE macros expect the parentheses as part of their input.
26 return node;
27 }
28
29 // The input includes the `(` + `)` delimiter tokens, so remove them before passing this
30 // to the macro.
31 let node = node.clone_for_update();
32 if let Some(SyntaxElement::Token(tkn)) = node.first_child_or_token() {
33 if matches!(
34 tkn.kind(),
35 SyntaxKind::L_BRACK | SyntaxKind::L_PAREN | SyntaxKind::L_CURLY
36 ) {
37 tkn.detach();
38 }
39 }
40 if let Some(SyntaxElement::Token(tkn)) = node.last_child_or_token() {
41 if matches!(
42 tkn.kind(),
43 SyntaxKind::R_BRACK | SyntaxKind::R_PAREN | SyntaxKind::R_CURLY
44 ) {
45 tkn.detach();
46 }
47 }
48 node
49 }
50 MacroCallKind::Derive { derive_attr_index, .. } => { 23 MacroCallKind::Derive { derive_attr_index, .. } => {
51 let item = match ast::Item::cast(node.clone()) { 24 let item = match ast::Item::cast(node.clone()) {
52 Some(item) => item, 25 Some(item) => item,
diff --git a/crates/hir_expand/src/lib.rs b/crates/hir_expand/src/lib.rs
index 88cb16ca4..5df11856e 100644
--- a/crates/hir_expand/src/lib.rs
+++ b/crates/hir_expand/src/lib.rs
@@ -272,10 +272,6 @@ impl MacroDefId {
272 }; 272 };
273 Either::Left(*id) 273 Either::Left(*id)
274 } 274 }
275
276 pub fn is_proc_macro(&self) -> bool {
277 matches!(self.kind, MacroDefKind::ProcMacro(..))
278 }
279} 275}
280 276
281#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] 277#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]