aboutsummaryrefslogtreecommitdiff
path: root/crates/mbe
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2020-12-15 14:45:09 +0000
committerGitHub <[email protected]>2020-12-15 14:45:09 +0000
commitbd4c352831662762ee7a66da77ec9adf623b0a0a (patch)
tree725dfad20b95344ad363b35860cf7e57067bb5e5 /crates/mbe
parent39aae835fd70d06092c1be1add6eef3984439529 (diff)
parent479babf8740a4d3cf6fc03a5f4a2fca00d387501 (diff)
Merge #6893
6893: Move to upstream `macro_rules!` model r=matklad a=jonas-schievink This changes `macro_rules!` from being treated as a macro invocation to being a first-class item. It also disallows using an additional ident argument for regular macros, so `m! ident(...);` now fails to parse. This matches upstream Rust, and makes the code somewhat simpler by removing repeated "is this a `macro_rules!` call" checks. It will also simplify allowing visibilities on macros, which is currently being proposed in https://github.com/rust-lang/rust/pull/78166. Co-authored-by: Jonas Schievink <[email protected]>
Diffstat (limited to 'crates/mbe')
-rw-r--r--crates/mbe/src/mbe_expander.rs2
-rw-r--r--crates/mbe/src/tests.rs4
2 files changed, 3 insertions, 3 deletions
diff --git a/crates/mbe/src/mbe_expander.rs b/crates/mbe/src/mbe_expander.rs
index 97bce0536..a80b73db4 100644
--- a/crates/mbe/src/mbe_expander.rs
+++ b/crates/mbe/src/mbe_expander.rs
@@ -163,7 +163,7 @@ mod tests {
163 fn create_rules(macro_definition: &str) -> crate::MacroRules { 163 fn create_rules(macro_definition: &str) -> crate::MacroRules {
164 let source_file = ast::SourceFile::parse(macro_definition).ok().unwrap(); 164 let source_file = ast::SourceFile::parse(macro_definition).ok().unwrap();
165 let macro_definition = 165 let macro_definition =
166 source_file.syntax().descendants().find_map(ast::MacroCall::cast).unwrap(); 166 source_file.syntax().descendants().find_map(ast::MacroRules::cast).unwrap();
167 167
168 let (definition_tt, _) = 168 let (definition_tt, _) =
169 ast_to_token_tree(&macro_definition.token_tree().unwrap()).unwrap(); 169 ast_to_token_tree(&macro_definition.token_tree().unwrap()).unwrap();
diff --git a/crates/mbe/src/tests.rs b/crates/mbe/src/tests.rs
index 843054fe8..dff6e98c2 100644
--- a/crates/mbe/src/tests.rs
+++ b/crates/mbe/src/tests.rs
@@ -48,7 +48,7 @@ mod rule_parsing {
48 let macro_definition = format!(" macro_rules! m {{ {} }} ", arm_definition); 48 let macro_definition = format!(" macro_rules! m {{ {} }} ", arm_definition);
49 let source_file = ast::SourceFile::parse(&macro_definition).ok().unwrap(); 49 let source_file = ast::SourceFile::parse(&macro_definition).ok().unwrap();
50 let macro_definition = 50 let macro_definition =
51 source_file.syntax().descendants().find_map(ast::MacroCall::cast).unwrap(); 51 source_file.syntax().descendants().find_map(ast::MacroRules::cast).unwrap();
52 52
53 let (definition_tt, _) = 53 let (definition_tt, _) =
54 ast_to_token_tree(&macro_definition.token_tree().unwrap()).unwrap(); 54 ast_to_token_tree(&macro_definition.token_tree().unwrap()).unwrap();
@@ -1668,7 +1668,7 @@ impl MacroFixture {
1668fn parse_macro_to_tt(ra_fixture: &str) -> tt::Subtree { 1668fn parse_macro_to_tt(ra_fixture: &str) -> tt::Subtree {
1669 let source_file = ast::SourceFile::parse(ra_fixture).ok().unwrap(); 1669 let source_file = ast::SourceFile::parse(ra_fixture).ok().unwrap();
1670 let macro_definition = 1670 let macro_definition =
1671 source_file.syntax().descendants().find_map(ast::MacroCall::cast).unwrap(); 1671 source_file.syntax().descendants().find_map(ast::MacroRules::cast).unwrap();
1672 1672
1673 let (definition_tt, _) = ast_to_token_tree(&macro_definition.token_tree().unwrap()).unwrap(); 1673 let (definition_tt, _) = ast_to_token_tree(&macro_definition.token_tree().unwrap()).unwrap();
1674 1674