summaryrefslogtreecommitdiffstats
path: root/vendor/xflags-macros/src/lib.rs
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:11:38 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:12:43 +0000
commitcf94bdc0742c13e2a0cac864c478b8626b266e1b (patch)
tree044670aa50cc5e2b4229aa0b6b3df6676730c0a6 /vendor/xflags-macros/src/lib.rs
parentAdding debian version 1.65.0+dfsg1-2. (diff)
downloadrustc-cf94bdc0742c13e2a0cac864c478b8626b266e1b.tar.xz
rustc-cf94bdc0742c13e2a0cac864c478b8626b266e1b.zip
Merging upstream version 1.66.0+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r--vendor/xflags-macros/src/lib.rs26
1 files changed, 23 insertions, 3 deletions
diff --git a/vendor/xflags-macros/src/lib.rs b/vendor/xflags-macros/src/lib.rs
index 8fac00587..f1c0e0599 100644
--- a/vendor/xflags-macros/src/lib.rs
+++ b/vendor/xflags-macros/src/lib.rs
@@ -8,19 +8,39 @@ pub fn xflags(_ts: proc_macro::TokenStream) -> proc_macro::TokenStream {
// Stub out the code, but let rust-analyzer resolve the invocation
#[cfg(not(test))]
{
- let cmd = parse::parse(_ts).unwrap();
- let text = emit::emit(&cmd);
+ let text = match parse::xflags(_ts) {
+ Ok(cmd) => emit::emit(&cmd),
+ Err(err) => format!("compile_error!(\"invalid flags syntax, {err}\");"),
+ };
text.parse().unwrap()
}
#[cfg(test)]
unimplemented!()
}
+#[proc_macro]
+pub fn parse_or_exit(_ts: proc_macro::TokenStream) -> proc_macro::TokenStream {
+ // Stub out the code, but let rust-analyzer resolve the invocation
+ #[cfg(not(test))]
+ {
+ let text = match parse::parse_or_exit(_ts) {
+ Ok(cmd) => emit::emit(&cmd),
+ Err(err) => format!("compile_error!(\"invalid flags syntax, {err}\")"),
+ };
+ text.parse().unwrap()
+ }
+ #[cfg(test)]
+ {
+ let _ = parse::parse_or_exit;
+ unimplemented!();
+ }
+}
+
#[cfg(test)]
pub fn compile(src: &str) -> String {
use proc_macro2::TokenStream;
let ts = src.parse::<TokenStream>().unwrap();
- let cmd = parse::parse(ts).unwrap();
+ let cmd = parse::xflags(ts).unwrap();
emit::emit(&cmd)
}