From c1e897907ab7be25fe302a0ccd7a927ff0410203 Mon Sep 17 00:00:00 2001 From: Paul Lietar Date: Tue, 5 Sep 2017 02:22:17 +0100 Subject: [PATCH] Add suport for extern types. See https://github.com/rust-lang/rust/pull/44295 --- src/items.rs | 6 ++++-- tests/source/extern.rs | 5 +++++ tests/target/extern.rs | 4 ++++ 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/items.rs b/src/items.rs index 25ed376f277..82056c59dac 100644 --- a/src/items.rs +++ b/src/items.rs @@ -2740,8 +2740,10 @@ fn rewrite(&self, context: &RewriteContext, shape: Shape) -> Option { 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() { diff --git a/tests/source/extern.rs b/tests/source/extern.rs index 5546b217226..bc82bcd61db 100644 --- a/tests/source/extern.rs +++ b/tests/source/extern.rs @@ -25,6 +25,11 @@ 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; diff --git a/tests/target/extern.rs b/tests/target/extern.rs index c0601a4d0e1..1d49b76dc42 100644 --- a/tests/target/extern.rs +++ b/tests/target/extern.rs @@ -34,6 +34,10 @@ fn DMR_GetDevice( ) -> TDMR_ERROR; fn quux() -> (); // Post comment + + pub type Foo; + + type Bar; } extern "Rust" { -- 2.44.0