Skip to content

Commit 085f046

Browse files
committed
Add is_defaulted_unit helper method
1 parent 5dbaefb commit 085f046

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

src/librustc/traits/select.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -425,9 +425,7 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
425425
// Test whether this is a `()` which was produced by defaulting a
426426
// diverging type variable with `!` disabled. If so, we may need
427427
// to raise a warning.
428-
if let ty::TyTuple(_, true) = obligation.predicate.skip_binder()
429-
.self_ty().sty {
430-
428+
if obligation.predicate.skip_binder().self_ty().is_defaulted_unit() {
431429
let mut raise_warning = true;
432430
// Don't raise a warning if the trait is implemented for ! and only
433431
// permits a trivial implementation for !. This stops us warning

src/librustc/ty/sty.rs

+9
Original file line numberDiff line numberDiff line change
@@ -977,6 +977,15 @@ impl<'a, 'gcx, 'tcx> TyS<'tcx> {
977977
}
978978
}
979979

980+
// Test whether this is a `()` which was produced by defaulting a
981+
// diverging type variable with feature(never_type) disabled.
982+
pub fn is_defaulted_unit(&self) -> bool {
983+
match self.sty {
984+
TyTuple(_, true) => true,
985+
_ => false,
986+
}
987+
}
988+
980989
/// Checks whether a type is visibly uninhabited from a particular module.
981990
/// # Example
982991
/// ```rust

0 commit comments

Comments
 (0)