diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:19:13 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:19:13 +0000 |
commit | 218caa410aa38c29984be31a5229b9fa717560ee (patch) | |
tree | c54bd55eeb6e4c508940a30e94c0032fbd45d677 /src/test/ui/proc-macro/auxiliary/subspan.rs | |
parent | Releasing progress-linux version 1.67.1+dfsg1-1~progress7.99u1. (diff) | |
download | rustc-218caa410aa38c29984be31a5229b9fa717560ee.tar.xz rustc-218caa410aa38c29984be31a5229b9fa717560ee.zip |
Merging upstream version 1.68.2+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/test/ui/proc-macro/auxiliary/subspan.rs')
-rw-r--r-- | src/test/ui/proc-macro/auxiliary/subspan.rs | 38 |
1 files changed, 0 insertions, 38 deletions
diff --git a/src/test/ui/proc-macro/auxiliary/subspan.rs b/src/test/ui/proc-macro/auxiliary/subspan.rs deleted file mode 100644 index f92adc040..000000000 --- a/src/test/ui/proc-macro/auxiliary/subspan.rs +++ /dev/null @@ -1,38 +0,0 @@ -// force-host -// no-prefer-dynamic - -#![crate_type = "proc-macro"] -#![feature(proc_macro_diagnostic, proc_macro_span)] - -extern crate proc_macro; - -use proc_macro::{TokenStream, TokenTree, Span, Diagnostic}; - -fn parse(input: TokenStream) -> Result<(), Diagnostic> { - if let Some(TokenTree::Literal(lit)) = input.into_iter().next() { - let mut spans = vec![]; - let string = lit.to_string(); - for hi in string.matches("hi") { - let index = hi.as_ptr() as usize - string.as_ptr() as usize; - let subspan = lit.subspan(index..(index + hi.len())).unwrap(); - spans.push(subspan); - } - - if !spans.is_empty() { - Err(Span::call_site().error("found 'hi's").span_note(spans, "here")) - } else { - Ok(()) - } - } else { - Err(Span::call_site().error("invalid input: expected string literal")) - } -} - -#[proc_macro] -pub fn subspan(input: TokenStream) -> TokenStream { - if let Err(diag) = parse(input) { - diag.emit(); - } - - TokenStream::new() -} |