mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-11-10 07:04:22 +00:00
Add test for idents incl. raw idents
This commit is contained in:
parent
9cf99a9c71
commit
941416a1d6
2 changed files with 25 additions and 1 deletions
|
@ -84,6 +84,20 @@ fn test_fn_like_mk_literals() {
|
|||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_fn_like_mk_idents() {
|
||||
// FIXME: this test is wrong: raw should be 'r#raw' but ABIs 1.64 and below
|
||||
// simply ignore `is_raw` when implementing the `Ident` interface.
|
||||
assert_expand(
|
||||
"fn_like_mk_idents",
|
||||
r#""#,
|
||||
expect![[r#"
|
||||
SUBTREE $
|
||||
IDENT standard 4294967295
|
||||
IDENT raw 4294967295"#]],
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_fn_like_macro_clone_literals() {
|
||||
assert_expand(
|
||||
|
@ -134,6 +148,7 @@ fn list_test_macros() {
|
|||
fn_like_error [FuncLike]
|
||||
fn_like_clone_tokens [FuncLike]
|
||||
fn_like_mk_literals [FuncLike]
|
||||
fn_like_mk_idents [FuncLike]
|
||||
attr_noop [Attr]
|
||||
attr_panic [Attr]
|
||||
attr_error [Attr]
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
#![warn(rust_2018_idioms, unused_lifetimes, semicolon_in_expressions_from_macros)]
|
||||
|
||||
use proc_macro::{Group, Ident, Literal, Punct, TokenStream, TokenTree};
|
||||
use proc_macro::{Group, Ident, Literal, Punct, Span, TokenStream, TokenTree};
|
||||
|
||||
#[proc_macro]
|
||||
pub fn fn_like_noop(args: TokenStream) -> TokenStream {
|
||||
|
@ -40,6 +40,15 @@ pub fn fn_like_mk_literals(_args: TokenStream) -> TokenStream {
|
|||
TokenStream::from_iter(trees)
|
||||
}
|
||||
|
||||
#[proc_macro]
|
||||
pub fn fn_like_mk_idents(_args: TokenStream) -> TokenStream {
|
||||
let trees: Vec<TokenTree> = vec![
|
||||
TokenTree::from(Ident::new("standard", Span::call_site())),
|
||||
TokenTree::from(Ident::new_raw("raw", Span::call_site())),
|
||||
];
|
||||
TokenStream::from_iter(trees)
|
||||
}
|
||||
|
||||
#[proc_macro_attribute]
|
||||
pub fn attr_noop(_args: TokenStream, item: TokenStream) -> TokenStream {
|
||||
item
|
||||
|
|
Loading…
Reference in a new issue