about summary refs log tree commit diff
path: root/tests/ui/fmt/auxiliary
diff options
context:
space:
mode:
authorNilstrieb <48135649+Nilstrieb@users.noreply.github.com>2023-01-18 19:47:22 +0100
committerNilstrieb <48135649+Nilstrieb@users.noreply.github.com>2023-01-18 20:33:17 +0100
commita8086cf9dfbe733f1172dfba816c8e65d3f35e76 (patch)
tree4c689d20a594cfe2be52a9060109f47d43bbada4 /tests/ui/fmt/auxiliary
parent1f72129ffe5e8c495113f9a2d4e1730f7fad3209 (diff)
downloadrust-a8086cf9dfbe733f1172dfba816c8e65d3f35e76.tar.gz
rust-a8086cf9dfbe733f1172dfba816c8e65d3f35e76.zip
Revert "Improve heuristics whether `format_args` string is a source literal"
This reverts commit e6c02aad9345925cfed74f86b414c4d0715d381b.

Keeps the code improvements from the PR and the test (as a known-bug).
Diffstat (limited to 'tests/ui/fmt/auxiliary')
-rw-r--r--tests/ui/fmt/auxiliary/format-string-proc-macro.rs12
1 files changed, 12 insertions, 0 deletions
diff --git a/tests/ui/fmt/auxiliary/format-string-proc-macro.rs b/tests/ui/fmt/auxiliary/format-string-proc-macro.rs
index 539c8fb27b3..1b7ef93f41d 100644
--- a/tests/ui/fmt/auxiliary/format-string-proc-macro.rs
+++ b/tests/ui/fmt/auxiliary/format-string-proc-macro.rs
@@ -28,6 +28,7 @@ pub fn err_with_input_span(input: TokenStream) -> TokenStream {
     TokenStream::from(TokenTree::Literal(lit))
 }
 
+
 #[proc_macro]
 pub fn respan_to_invalid_format_literal(input: TokenStream) -> TokenStream {
     let mut s = Literal::string("{");
@@ -38,3 +39,14 @@ pub fn respan_to_invalid_format_literal(input: TokenStream) -> TokenStream {
         TokenTree::from(Group::new(Delimiter::Parenthesis, TokenTree::from(s).into())),
     ])
 }
+
+#[proc_macro]
+pub fn capture_a_with_prepended_space_preserve_span(input: TokenStream) -> TokenStream {
+    let mut s = Literal::string(" {a}");
+    s.set_span(input.into_iter().next().unwrap().span());
+    TokenStream::from_iter([
+        TokenTree::from(Ident::new("format", Span::call_site())),
+        TokenTree::from(Punct::new('!', Spacing::Alone)),
+        TokenTree::from(Group::new(Delimiter::Parenthesis, TokenTree::from(s).into())),
+    ])
+}