Skip to content

Commit 4a1f8e9

Browse files
committed
Add is_defaulted_unit helper method
1 parent 9141075 commit 4a1f8e9

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

src/librustc/traits/select.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -429,9 +429,7 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
429429
// Test whether this is a `()` which was produced by defaulting a
430430
// diverging type variable with `!` disabled. If so, we may need
431431
// to raise a warning.
432-
if let ty::TyTuple(_, true) = obligation.predicate.skip_binder()
433-
.self_ty().sty {
434-
432+
if obligation.predicate.skip_binder().self_ty().is_defaulted_unit() {
435433
let mut raise_warning = true;
436434
// Don't raise a warning if the trait is implemented for ! and only
437435
// permits a trivial implementation for !. This stops us warning

src/librustc/ty/sty.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -983,6 +983,15 @@ impl<'a, 'gcx, 'tcx> TyS<'tcx> {
983983
}
984984
}
985985

986+
// Test whether this is a `()` which was produced by defaulting a
987+
// diverging type variable with feature(never_type) disabled.
988+
pub fn is_defaulted_unit(&self) -> bool {
989+
match self.sty {
990+
TyTuple(_, true) => true,
991+
_ => false,
992+
}
993+
}
994+
986995
/// Checks whether a type is visibly uninhabited from a particular module.
987996
/// # Example
988997
/// ```rust

0 commit comments

Comments
 (0)