Skip to content

Commit c1e8979

Browse files
plietarnrc
authored andcommitted
Add suport for extern types.
See rust-lang/rust#44295
1 parent cf0d494 commit c1e8979

File tree

3 files changed

+13
-2
lines changed

3 files changed

+13
-2
lines changed

src/items.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -2740,8 +2740,10 @@ impl Rewrite for ast::ForeignItem {
27402740
format!("{}{}{};", prefix, sep, ty_str)
27412741
})
27422742
}
2743-
// FIXME(#2097) support extern types.
2744-
ast::ForeignItemKind::Ty => unimplemented!(),
2743+
ast::ForeignItemKind::Ty => {
2744+
let vis = format_visibility(&self.vis);
2745+
Some(format!("{}type {};", vis, self.ident))
2746+
}
27452747
}?;
27462748

27472749
let missing_span = if self.attrs.is_empty() {

tests/source/extern.rs

+5
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,11 @@ extern {
2525
fn DMR_GetDevice(pHDev: *mut HDEV, searchMode: DeviceSearchMode, pSearchString: *const c_char, devNr: c_uint, wildcard: c_char) -> TDMR_ERROR;
2626

2727
fn quux() -> (); // Post comment
28+
29+
pub type
30+
Foo;
31+
32+
type Bar;
2833
}
2934

3035
extern "Rust" { static ext: u32;

tests/target/extern.rs

+4
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@ extern "C" {
3434
) -> TDMR_ERROR;
3535

3636
fn quux() -> (); // Post comment
37+
38+
pub type Foo;
39+
40+
type Bar;
3741
}
3842

3943
extern "Rust" {

0 commit comments

Comments
 (0)