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.rs48
1 files changed, 47 insertions, 1 deletions
diff --git a/crates/test-fixture/src/lib.rs b/crates/test-fixture/src/lib.rs
index 1f9a14cc90..b40b7757c6 100644
--- a/crates/test-fixture/src/lib.rs
+++ b/crates/test-fixture/src/lib.rs
@@ -376,7 +376,7 @@ impl ChangeFixture {
}
}
-fn default_test_proc_macros() -> [(String, ProcMacro); 6] {
+fn default_test_proc_macros() -> [(String, ProcMacro); 7] {
[
(
r#"
@@ -468,6 +468,21 @@ pub fn issue_18089(_attr: TokenStream, _item: TokenStream) -> TokenStream {
disabled: false,
},
),
+ (
+ r#"
+#[proc_macro_attribute]
+pub fn issue_18840(_attr: TokenStream, _item: TokenStream) -> TokenStream {
+ loop {}
+}
+"#
+ .into(),
+ ProcMacro {
+ name: Symbol::intern("issue_18840"),
+ kind: ProcMacroKind::Attr,
+ expander: sync::Arc::new(Issue18840ProcMacroExpander),
+ disabled: false,
+ },
+ ),
]
}
@@ -646,6 +661,37 @@ impl ProcMacroExpander for AttributeInputReplaceProcMacroExpander {
}
#[derive(Debug)]
+struct Issue18840ProcMacroExpander;
+impl ProcMacroExpander for Issue18840ProcMacroExpander {
+ fn expand(
+ &self,
+ fn_: &TopSubtree,
+ _: Option<&TopSubtree>,
+ _: &Env,
+ def_site: Span,
+ _: Span,
+ _: Span,
+ _: Option<String>,
+ ) -> Result<TopSubtree, ProcMacroExpansionError> {
+ // Input:
+ // ```
+ // #[issue_18840]
+ // fn foo() { let loop {} }
+ // ```
+
+ // The span that was created by the fixup infra.
+ let fixed_up_span = fn_.token_trees().flat_tokens()[5].first_span();
+ let mut result =
+ quote! {fixed_up_span => ::core::compile_error! { "my cool compile_error!" } };
+ // Make it so we won't remove the top subtree when reversing fixups.
+ let top_subtree_delimiter_mut = result.top_subtree_delimiter_mut();
+ top_subtree_delimiter_mut.open = def_site;
+ top_subtree_delimiter_mut.close = def_site;
+ Ok(result)
+ }
+}
+
+#[derive(Debug)]
struct MirrorProcMacroExpander;
impl ProcMacroExpander for MirrorProcMacroExpander {
fn expand(