Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/tools/rustfmt/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1019,7 +1019,11 @@ impl Rewrite for ast::Ty {
}
ast::TyKind::UnsafeBinder(ref binder) => {
let mut result = String::new();
if let Some(ref lifetime_str) =
if binder.generic_params.is_empty() {
// We always want to write `unsafe<>` since `unsafe<> Ty`
// and `Ty` are distinct types.
result.push_str("unsafe<> ")
} else if let Some(ref lifetime_str) =
rewrite_bound_params(context, shape, &binder.generic_params)
{
result.push_str("unsafe<");
Expand Down
3 changes: 3 additions & 0 deletions src/tools/rustfmt/tests/source/unsafe-binders.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,6 @@ struct Foo {
struct Bar(unsafe<'a> &'a ());

impl Trait for unsafe<'a> &'a () {}

fn empty()
-> unsafe<> () {}
2 changes: 2 additions & 0 deletions src/tools/rustfmt/tests/target/unsafe-binders.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,5 @@ struct Foo {
struct Bar(unsafe<'a> &'a ());

impl Trait for unsafe<'a> &'a () {}

fn empty() -> unsafe<> () {}
Loading