From a9b0b057eb7c2ff6e764fadc36d94e90e64b5c90 Mon Sep 17 00:00:00 2001 From: Ayaz Hafiz Date: Sat, 9 May 2020 16:01:42 -0700 Subject: [PATCH] fixup! Preserve and format type aliases in extern blocks --- src/items.rs | 3 +++ tests/target/issue-4159.rs | 6 ++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/items.rs b/src/items.rs index 2c4570a3a759..4e10d0c47572 100644 --- a/src/items.rs +++ b/src/items.rs @@ -1862,6 +1862,9 @@ pub(crate) fn rewrite_type_alias( let lhs = format!("{}=", prefix); rewrite_assign_rhs(context, lhs, &**ty, shape).map(|s| s + ";") } else { + if !generics.where_clause.predicates.is_empty() { + prefix.push_str(&indent.to_string_with_newline(context.config)); + } Some(format!("{};", prefix)) } } diff --git a/tests/target/issue-4159.rs b/tests/target/issue-4159.rs index 52abb132cae8..fed6095354a0 100644 --- a/tests/target/issue-4159.rs +++ b/tests/target/issue-4159.rs @@ -3,11 +3,13 @@ extern "C" { type A<'a> where - 'a: 'static,; + 'a: 'static, + ; type A where - T: 'static,; + T: 'static, + ; type A = u8;