Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/proc-macro-test/imp/src/lib.rs')
| -rw-r--r-- | crates/proc-macro-test/imp/src/lib.rs | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/crates/proc-macro-test/imp/src/lib.rs b/crates/proc-macro-test/imp/src/lib.rs index d0f73dca32..d9018b1b87 100644 --- a/crates/proc-macro-test/imp/src/lib.rs +++ b/crates/proc-macro-test/imp/src/lib.rs @@ -1,7 +1,7 @@ //! Exports a few trivial procedural macros for testing. #![warn(rust_2018_idioms, unused_lifetimes)] -#![feature(proc_macro_span)] +#![feature(proc_macro_span, proc_macro_def_site)] use proc_macro::{Group, Ident, Literal, Punct, Span, TokenStream, TokenTree}; @@ -61,6 +61,18 @@ pub fn fn_like_span_join(args: TokenStream) -> TokenStream { ))) } +#[proc_macro] +pub fn fn_like_span_ops(args: TokenStream) -> TokenStream { + let args = &mut args.into_iter(); + let mut first = args.next().unwrap(); + first.set_span(Span::def_site()); + let mut second = args.next().unwrap(); + second.set_span(second.span().resolved_at(Span::def_site())); + let mut third = args.next().unwrap(); + third.set_span(third.span().start()); + TokenStream::from_iter(vec![first, second, third]) +} + #[proc_macro_attribute] pub fn attr_noop(_args: TokenStream, item: TokenStream) -> TokenStream { item |