Implement RFC 1861: Extern types

This commit is contained in:
Paul Lietar 2017-09-03 19:53:58 +01:00 committed by Paul Liétar
parent bed9a85c40
commit 77f7e85d7f
81 changed files with 737 additions and 120 deletions

View file

@ -5671,6 +5671,24 @@ impl<'a> Parser<'a> {
})
}
/// Parse a type from a foreign module
fn parse_item_foreign_type(&mut self, vis: ast::Visibility, lo: Span, attrs: Vec<Attribute>)
-> PResult<'a, ForeignItem> {
self.expect_keyword(keywords::Type)?;
let ident = self.parse_ident()?;
let hi = self.span;
self.expect(&token::Semi)?;
Ok(ast::ForeignItem {
ident: ident,
attrs: attrs,
node: ForeignItemKind::Ty,
id: ast::DUMMY_NODE_ID,
span: lo.to(hi),
vis: vis
})
}
/// Parse extern crate links
///
/// # Examples
@ -6145,6 +6163,10 @@ impl<'a> Parser<'a> {
if self.check_keyword(keywords::Fn) {
return Ok(Some(self.parse_item_foreign_fn(visibility, lo, attrs)?));
}
// FOREIGN TYPE ITEM
if self.check_keyword(keywords::Type) {
return Ok(Some(self.parse_item_foreign_type(visibility, lo, attrs)?));
}
// FIXME #5668: this will occur for a macro invocation:
match self.parse_macro_use_or_failure(attrs, true, false, lo, visibility)? {