Skip to content

Commit 73a09f3

Browse files
committed
skip eq_types and sub_types when the two types are equal
1 parent 956e2f8 commit 73a09f3

File tree

1 file changed

+10
-0
lines changed
  • src/librustc_mir/borrow_check/nll/type_check

1 file changed

+10
-0
lines changed

src/librustc_mir/borrow_check/nll/type_check/mod.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -759,6 +759,11 @@ impl<'a, 'gcx, 'tcx> TypeChecker<'a, 'gcx, 'tcx> {
759759
sup: Ty<'tcx>,
760760
locations: Locations,
761761
) -> UnitResult<'tcx> {
762+
// Micro-optimization.
763+
if sub == sup {
764+
return Ok(());
765+
}
766+
762767
self.fully_perform_op(
763768
locations,
764769
|| format!("sub_types({:?} <: {:?})", sub, sup),
@@ -772,6 +777,11 @@ impl<'a, 'gcx, 'tcx> TypeChecker<'a, 'gcx, 'tcx> {
772777

773778
#[inline(never)]
774779
fn eq_types(&mut self, a: Ty<'tcx>, b: Ty<'tcx>, locations: Locations) -> UnitResult<'tcx> {
780+
// Micro-optimization.
781+
if a == b {
782+
return Ok(());
783+
}
784+
775785
self.fully_perform_op(
776786
locations,
777787
|| format!("eq_types({:?} = {:?})", a, b),

0 commit comments

Comments
 (0)