summaryrefslogtreecommitdiffstats
path: root/tests/ui/suggestions/auxiliary/issue-61963.rs
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:19:03 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:19:03 +0000
commit64d98f8ee037282c35007b64c2649055c56af1db (patch)
tree5492bcf97fce41ee1c0b1cc2add283f3e66cdab0 /tests/ui/suggestions/auxiliary/issue-61963.rs
parentAdding debian version 1.67.1+dfsg1-1. (diff)
downloadrustc-64d98f8ee037282c35007b64c2649055c56af1db.tar.xz
rustc-64d98f8ee037282c35007b64c2649055c56af1db.zip
Merging upstream version 1.68.2+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/ui/suggestions/auxiliary/issue-61963.rs')
-rw-r--r--tests/ui/suggestions/auxiliary/issue-61963.rs41
1 files changed, 41 insertions, 0 deletions
diff --git a/tests/ui/suggestions/auxiliary/issue-61963.rs b/tests/ui/suggestions/auxiliary/issue-61963.rs
new file mode 100644
index 000000000..e86f1610a
--- /dev/null
+++ b/tests/ui/suggestions/auxiliary/issue-61963.rs
@@ -0,0 +1,41 @@
+// force-host
+// no-prefer-dynamic
+#![crate_type = "proc-macro"]
+
+extern crate proc_macro;
+
+use proc_macro::{Group, Spacing, Punct, TokenTree, TokenStream};
+
+// This macro exists as part of a reproduction of #61963 but without using quote/syn/proc_macro2.
+
+#[proc_macro_attribute]
+pub fn dom_struct(_: TokenStream, input: TokenStream) -> TokenStream {
+ // Construct the expected output tokens - the input but with a `#[derive(DomObject)]` applied.
+ let attributes: TokenStream =
+ "#[derive(DomObject)]".to_string().parse().unwrap();
+ let output: TokenStream = attributes.into_iter()
+ .chain(input.into_iter()).collect();
+
+ let mut tokens: Vec<_> = output.into_iter().collect();
+ // Adjust the spacing of `>` tokens to match what `quote` would produce.
+ for token in tokens.iter_mut() {
+ if let TokenTree::Group(group) = token {
+ let mut tokens: Vec<_> = group.stream().into_iter().collect();
+ for token in tokens.iter_mut() {
+ if let TokenTree::Punct(p) = token {
+ if p.as_char() == '>' {
+ *p = Punct::new('>', Spacing::Alone);
+ }
+ }
+ }
+
+ let mut stream = TokenStream::new();
+ stream.extend(tokens);
+ *group = Group::new(group.delimiter(), stream);
+ }
+ }
+
+ let mut output = TokenStream::new();
+ output.extend(tokens);
+ output
+}