Skip to content

Commit 7c6f764

Browse files
committed
Hide -> () in Fn traits
1 parent 35c948f commit 7c6f764

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

crates/hir_ty/src/display.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -778,8 +778,10 @@ fn write_bounds_like_dyn_trait(
778778
}
779779
WhereClause::AliasEq(alias_eq) if is_fn_trait => {
780780
is_fn_trait = false;
781-
write!(f, " -> ")?;
782-
alias_eq.ty.hir_fmt(f)?;
781+
if !alias_eq.ty.is_unit() {
782+
write!(f, " -> ")?;
783+
alias_eq.ty.hir_fmt(f)?;
784+
}
783785
}
784786
WhereClause::AliasEq(AliasEq { ty, alias }) => {
785787
// in types in actual Rust, these will always come

crates/hir_ty/src/tests/traits.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3095,16 +3095,16 @@ fn foo() {
30953095
478..576 '{ ...&s); }': ()
30963096
488..489 's': Option<i32>
30973097
492..504 'Option::None': Option<i32>
3098-
514..515 'f': Box<dyn FnOnce(&Option<i32>) -> ()>
3098+
514..515 'f': Box<dyn FnOnce(&Option<i32>)>
30993099
549..562 'box (|ps| {})': Box<|{unknown}| -> ()>
31003100
554..561 '|ps| {}': |{unknown}| -> ()
31013101
555..557 'ps': {unknown}
31023102
559..561 '{}': ()
3103-
568..569 'f': Box<dyn FnOnce(&Option<i32>) -> ()>
3103+
568..569 'f': Box<dyn FnOnce(&Option<i32>)>
31043104
568..573 'f(&s)': ()
31053105
570..572 '&s': &Option<i32>
31063106
571..572 's': Option<i32>
3107-
549..562: expected Box<dyn FnOnce(&Option<i32>) -> ()>, got Box<|{unknown}| -> ()>
3107+
549..562: expected Box<dyn FnOnce(&Option<i32>)>, got Box<|{unknown}| -> ()>
31083108
"#]],
31093109
);
31103110
}

0 commit comments

Comments
 (0)