Skip to content

Commit 596c951

Browse files
committed
fixup! Preserve and format type aliases in extern blocks
1 parent d87c77b commit 596c951

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

rustfmt-core/rustfmt-lib/src/items.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1935,6 +1935,9 @@ pub(crate) fn rewrite_type_alias(
19351935
let lhs = format!("{}=", prefix);
19361936
rewrite_assign_rhs(context, lhs, &**ty, shape).map(|s| s + ";")
19371937
} else {
1938+
if !generics.where_clause.predicates.is_empty() {
1939+
prefix.push_str(&indent.to_string_with_newline(context.config));
1940+
}
19381941
Some(format!("{};", prefix))
19391942
}
19401943
}

rustfmt-core/rustfmt-lib/tests/target/issue-4159.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,13 @@ extern "C" {
33

44
type A<'a>
55
where
6-
'a: 'static,;
6+
'a: 'static,
7+
;
78

89
type A<T: Ord>
910
where
10-
T: 'static,;
11+
T: 'static,
12+
;
1113

1214
type A = u8;
1315

0 commit comments

Comments
 (0)