From e054985771ec8e3c964b061bd12a5a33fcf25658 Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Sun, 14 May 2023 10:46:55 +0200 Subject: [PATCH] Parse builtin# syntax --- src/expr.rs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/expr.rs b/src/expr.rs index 46046c8b0f..0f1a6953e2 100644 --- a/src/expr.rs +++ b/src/expr.rs @@ -965,6 +965,7 @@ pub(crate) mod parsing { use std::cmp::Ordering; mod kw { + crate::custom_keyword!(builtin); crate::custom_keyword!(raw); } @@ -1594,6 +1595,8 @@ pub(crate) mod parsing { || input.peek(Token![async]) && (input.peek2(Token![|]) || input.peek2(Token![move])) { expr_closure(input, allow_struct).map(Expr::Closure) + } else if input.peek(kw::builtin) && input.peek2(Token![#]) { + expr_builtin(input) } else if input.peek(Ident) || input.peek(Token![::]) || input.peek(Token![<]) @@ -1692,6 +1695,21 @@ pub(crate) mod parsing { } } + #[cfg(feature = "full")] + fn expr_builtin(input: ParseStream) -> Result { + let begin = input.fork(); + + input.parse::()?; + input.parse::()?; + input.parse::()?; + + let args; + parenthesized!(args in input); + args.parse::()?; + + Ok(Expr::Verbatim(verbatim::between(begin, input))) + } + fn path_or_macro_or_struct( input: ParseStream, #[cfg(feature = "full")] allow_struct: AllowStruct,