Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/proc-macro-srv/proc-macro-test/imp/src/lib.rs')
-rw-r--r--crates/proc-macro-srv/proc-macro-test/imp/src/lib.rs10
1 files changed, 10 insertions, 0 deletions
diff --git a/crates/proc-macro-srv/proc-macro-test/imp/src/lib.rs b/crates/proc-macro-srv/proc-macro-test/imp/src/lib.rs
index b4fac26d6e..06c76b6d03 100644
--- a/crates/proc-macro-srv/proc-macro-test/imp/src/lib.rs
+++ b/crates/proc-macro-srv/proc-macro-test/imp/src/lib.rs
@@ -79,6 +79,16 @@ pub fn fn_like_span_ops(args: TokenStream) -> TokenStream {
TokenStream::from_iter(vec![first, second, third])
}
+/// Returns the line and column of the first token's span as two integer literals.
+#[proc_macro]
+pub fn fn_like_span_line_column(args: TokenStream) -> TokenStream {
+ let first = args.into_iter().next().unwrap();
+ let span = first.span();
+ let line = Literal::usize_unsuffixed(span.line());
+ let column = Literal::usize_unsuffixed(span.column());
+ TokenStream::from_iter(vec![TokenTree::Literal(line), TokenTree::Literal(column)])
+}
+
#[proc_macro_attribute]
pub fn attr_noop(_args: TokenStream, item: TokenStream) -> TokenStream {
item