Skip to content

Commit

Permalink
Add suport for extern types.
Browse files Browse the repository at this point in the history
  • Loading branch information
plietar authored and nrc committed Oct 29, 2017
1 parent cf0d494 commit c1e8979
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/items.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2740,8 +2740,10 @@ impl Rewrite for ast::ForeignItem {
format!("{}{}{};", prefix, sep, ty_str)
})
}
// FIXME(#2097) support extern types.
ast::ForeignItemKind::Ty => unimplemented!(),
ast::ForeignItemKind::Ty => {
let vis = format_visibility(&self.vis);
Some(format!("{}type {};", vis, self.ident))
}
}?;

let missing_span = if self.attrs.is_empty() {
Expand Down
5 changes: 5 additions & 0 deletions tests/source/extern.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ extern {
fn DMR_GetDevice(pHDev: *mut HDEV, searchMode: DeviceSearchMode, pSearchString: *const c_char, devNr: c_uint, wildcard: c_char) -> TDMR_ERROR;

fn quux() -> (); // Post comment

pub type
Foo;

type Bar;
}

extern "Rust" { static ext: u32;
Expand Down
4 changes: 4 additions & 0 deletions tests/target/extern.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ extern "C" {
) -> TDMR_ERROR;

fn quux() -> (); // Post comment

pub type Foo;

type Bar;
}

extern "Rust" {
Expand Down

0 comments on commit c1e8979

Please sign in to comment.