Simplify ty::ClosureKind::extends

This is valid per the comment of the `ClosureKind` defition
This commit is contained in:
Maybe Waffle 2022-11-22 18:35:58 +00:00
parent 4b6e1d1c5f
commit fa89f53352

View File

@ -97,15 +97,7 @@ impl<'tcx> ClosureKind {
/// Returns `true` if a type that impls this closure kind
/// must also implement `other`.
pub fn extends(self, other: ty::ClosureKind) -> bool {
matches!(
(self, other),
(ClosureKind::Fn, ClosureKind::Fn)
| (ClosureKind::Fn, ClosureKind::FnMut)
| (ClosureKind::Fn, ClosureKind::FnOnce)
| (ClosureKind::FnMut, ClosureKind::FnMut)
| (ClosureKind::FnMut, ClosureKind::FnOnce)
| (ClosureKind::FnOnce, ClosureKind::FnOnce)
)
self <= other
}
/// Returns the representative scalar type for this closure kind.