Skip to content

Commit efda52a

Browse files
authored
Merge pull request #1454 from dtolnay/builtin
Parse `builtin #` syntax
2 parents dad8eba + e054985 commit efda52a

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

src/expr.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -965,6 +965,7 @@ pub(crate) mod parsing {
965965
use std::cmp::Ordering;
966966

967967
mod kw {
968+
crate::custom_keyword!(builtin);
968969
crate::custom_keyword!(raw);
969970
}
970971

@@ -1594,6 +1595,8 @@ pub(crate) mod parsing {
15941595
|| input.peek(Token![async]) && (input.peek2(Token![|]) || input.peek2(Token![move]))
15951596
{
15961597
expr_closure(input, allow_struct).map(Expr::Closure)
1598+
} else if input.peek(kw::builtin) && input.peek2(Token![#]) {
1599+
expr_builtin(input)
15971600
} else if input.peek(Ident)
15981601
|| input.peek(Token![::])
15991602
|| input.peek(Token![<])
@@ -1692,6 +1695,21 @@ pub(crate) mod parsing {
16921695
}
16931696
}
16941697

1698+
#[cfg(feature = "full")]
1699+
fn expr_builtin(input: ParseStream) -> Result<Expr> {
1700+
let begin = input.fork();
1701+
1702+
input.parse::<kw::builtin>()?;
1703+
input.parse::<Token![#]>()?;
1704+
input.parse::<Ident>()?;
1705+
1706+
let args;
1707+
parenthesized!(args in input);
1708+
args.parse::<TokenStream>()?;
1709+
1710+
Ok(Expr::Verbatim(verbatim::between(begin, input)))
1711+
}
1712+
16951713
fn path_or_macro_or_struct(
16961714
input: ParseStream,
16971715
#[cfg(feature = "full")] allow_struct: AllowStruct,

0 commit comments

Comments
 (0)