diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2020-03-03 17:30:08 +0000 |
---|---|---|
committer | GitHub <[email protected]> | 2020-03-03 17:30:08 +0000 |
commit | 7a322f9afff05b88507a6956a2d84a3abef0a0d6 (patch) | |
tree | f811a7f405edca2b7e0c32666604117ef6486229 /crates/ra_syntax/src/ast | |
parent | 13b25d73b56ede36d1680efc19f5c11b0669b96c (diff) | |
parent | 4d5e80c6c86aa6bfee50e9f8b80b365c3120ed80 (diff) |
Merge #3392
3392: Implement concat eager macro r=matklad a=edwin0cheng
This PR implements the following things:
1. Add basic eager macro infrastructure by introducing `EagerCallId` such that the new `MacroCallId` is defined as :
```
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub enum MacroCallId {
LazyMacro(LazyMacroId),
EagerMacro(EagerMacroId),
}
```
2. Add `concat!` builtin macro.
Co-authored-by: Edwin Cheng <[email protected]>
Diffstat (limited to 'crates/ra_syntax/src/ast')
-rw-r--r-- | crates/ra_syntax/src/ast/make.rs | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/crates/ra_syntax/src/ast/make.rs b/crates/ra_syntax/src/ast/make.rs index 3f11b747f..0da24560e 100644 --- a/crates/ra_syntax/src/ast/make.rs +++ b/crates/ra_syntax/src/ast/make.rs | |||
@@ -219,7 +219,7 @@ fn unroot(n: SyntaxNode) -> SyntaxNode { | |||
219 | } | 219 | } |
220 | 220 | ||
221 | pub mod tokens { | 221 | pub mod tokens { |
222 | use crate::{AstNode, Parse, SourceFile, SyntaxKind::*, SyntaxToken, T}; | 222 | use crate::{ast, AstNode, Parse, SourceFile, SyntaxKind::*, SyntaxToken, T}; |
223 | use once_cell::sync::Lazy; | 223 | use once_cell::sync::Lazy; |
224 | 224 | ||
225 | pub(super) static SOURCE_FILE: Lazy<Parse<SourceFile>> = | 225 | pub(super) static SOURCE_FILE: Lazy<Parse<SourceFile>> = |
@@ -251,6 +251,12 @@ pub mod tokens { | |||
251 | sf.syntax().first_child_or_token().unwrap().into_token().unwrap() | 251 | sf.syntax().first_child_or_token().unwrap().into_token().unwrap() |
252 | } | 252 | } |
253 | 253 | ||
254 | pub fn literal(text: &str) -> SyntaxToken { | ||
255 | assert_eq!(text.trim(), text); | ||
256 | let lit: ast::Literal = super::ast_from_text(&format!("fn f() {{ let _ = {}; }}", text)); | ||
257 | lit.syntax().first_child_or_token().unwrap().into_token().unwrap() | ||
258 | } | ||
259 | |||
254 | pub fn single_newline() -> SyntaxToken { | 260 | pub fn single_newline() -> SyntaxToken { |
255 | SOURCE_FILE | 261 | SOURCE_FILE |
256 | .tree() | 262 | .tree() |