From 8a11da40a789e5d73c5c11d69ba87638ddff8676 Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Sun, 22 Nov 2020 20:43:00 -0800 Subject: Parse unsafe extern block --- crates/parser/src/grammar/items.rs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'crates/parser/src/grammar') diff --git a/crates/parser/src/grammar/items.rs b/crates/parser/src/grammar/items.rs index 780bc470a..ad29b82f7 100644 --- a/crates/parser/src/grammar/items.rs +++ b/crates/parser/src/grammar/items.rs @@ -112,7 +112,7 @@ pub(super) fn maybe_item(p: &mut Parser, m: Marker) -> Result<(), Marker> { has_mods = true; } - if p.at(T![extern]) { + if p.at(T![extern]) && p.nth(1) != T!['{'] && (p.nth(1) != STRING || p.nth(2) != T!['{']) { has_mods = true; abi(p); } @@ -181,6 +181,14 @@ pub(super) fn maybe_item(p: &mut Parser, m: Marker) -> Result<(), Marker> { T![type] => { type_alias(p, m); } + + // unsafe extern "C" {} + T![extern] => { + abi(p); + extern_item_list(p); + m.complete(p, EXTERN_BLOCK); + } + _ => { if !has_visibility && !has_mods { return Err(m); -- cgit v1.2.3