Parse unsafe extern block

This commit is contained in:
David Tolnay 2020-11-22 20:43:00 -08:00
parent cadf0e9fb6
commit 8a11da40a7
No known key found for this signature in database
GPG key ID: F9BA143B95FF6D82
3 changed files with 25 additions and 3 deletions

View file

@ -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);