mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-28 21:05:02 +00:00
Add lifetime matcher
This commit is contained in:
parent
59b6cc780b
commit
313854c728
4 changed files with 25 additions and 2 deletions
|
@ -209,7 +209,6 @@ impl_froms!(TokenTree: Leaf, Subtree);
|
|||
|
||||
pub(crate) fn assert_expansion(rules: &MacroRules, invocation: &str, expansion: &str) {
|
||||
let expanded = expand(rules, invocation);
|
||||
assert_eq!(expanded.to_string(), expansion);
|
||||
|
||||
let tree = token_tree_to_macro_items(&expanded);
|
||||
|
||||
|
@ -786,4 +785,16 @@ MACRO_ITEMS@[0; 40)
|
|||
);
|
||||
assert_expansion(&rules, r#"foo! { fn foo() {} }"#, r#"fn foo () {}"#);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_lifetime() {
|
||||
let rules = create_rules(
|
||||
r#"
|
||||
macro_rules! foo {
|
||||
($ lt:lifetime) => { struct Ref<$ lt>{ s: &$ lt str } }
|
||||
}
|
||||
"#,
|
||||
);
|
||||
assert_expansion(&rules, r#"foo!{'a}"#, r#"struct Ref < 'a > {s : & 'a str}"#);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue