Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/test-fixture/src/lib.rs')
-rw-r--r--crates/test-fixture/src/lib.rs72
1 files changed, 69 insertions, 3 deletions
diff --git a/crates/test-fixture/src/lib.rs b/crates/test-fixture/src/lib.rs
index 0e72d79687..422aa08e35 100644
--- a/crates/test-fixture/src/lib.rs
+++ b/crates/test-fixture/src/lib.rs
@@ -376,8 +376,8 @@ impl ChangeFixture {
}
}
-fn default_test_proc_macros() -> [(String, ProcMacro); 8] {
- [
+fn default_test_proc_macros() -> Box<[(String, ProcMacro)]> {
+ Box::new([
(
r#"
#[proc_macro_attribute]
@@ -498,7 +498,22 @@ pub fn issue_17479(input: TokenStream) -> TokenStream {
disabled: false,
},
),
- ]
+ (
+ r#"
+#[proc_macro_attribute]
+pub fn issue_18898(_attr: TokenStream, input: TokenStream) -> TokenStream {
+ input
+}
+"#
+ .into(),
+ ProcMacro {
+ name: Symbol::intern("issue_18898"),
+ kind: ProcMacroKind::Bang,
+ expander: sync::Arc::new(Issue18898ProcMacroExpander),
+ disabled: false,
+ },
+ ),
+ ])
}
fn filter_test_proc_macros(
@@ -801,3 +816,54 @@ impl ProcMacroExpander for Issue17479ProcMacroExpander {
})
}
}
+
+// Reads ident type within string quotes, for issue #17479.
+#[derive(Debug)]
+struct Issue18898ProcMacroExpander;
+impl ProcMacroExpander for Issue18898ProcMacroExpander {
+ fn expand(
+ &self,
+ subtree: &TopSubtree,
+ _: Option<&TopSubtree>,
+ _: &Env,
+ def_site: Span,
+ _: Span,
+ _: Span,
+ _: Option<String>,
+ ) -> Result<TopSubtree, ProcMacroExpansionError> {
+ let span = subtree
+ .token_trees()
+ .flat_tokens()
+ .last()
+ .ok_or_else(|| ProcMacroExpansionError::Panic("malformed input".to_owned()))?
+ .first_span();
+ let overly_long_subtree = quote! {span =>
+ {
+ let a = 5;
+ let a = 5;
+ let a = 5;
+ let a = 5;
+ let a = 5;
+ let a = 5;
+ let a = 5;
+ let a = 5;
+ let a = 5;
+ let a = 5;
+ let a = 5;
+ let a = 5;
+ let a = 5;
+ let a = 5;
+ let a = 5;
+ let a = 5;
+ let a = 5;
+ let a = 5;
+ let a = 5;
+ }
+ };
+ Ok(quote! { def_site =>
+ fn foo() {
+ #overly_long_subtree
+ }
+ })
+ }
+}