@@ -1562,11 +1562,7 @@ impl<'a, 'tcx> ShallowResolver<'a, 'tcx> {
1562
1562
ShallowResolver { infcx }
1563
1563
}
1564
1564
1565
- // We have this force-inlined variant of `shallow_resolve` for the one
1566
- // callsite that is extremely hot. All other callsites use the normal
1567
- // variant.
1568
- #[ inline( always) ]
1569
- pub fn inlined_shallow_resolve ( & mut self , typ : Ty < ' tcx > ) -> Ty < ' tcx > {
1565
+ pub fn shallow_resolve ( & mut self , typ : Ty < ' tcx > ) -> Ty < ' tcx > {
1570
1566
match typ. sty {
1571
1567
ty:: Infer ( ty:: TyVar ( v) ) => {
1572
1568
// Not entirely obvious: if `typ` is a type variable,
@@ -1601,6 +1597,42 @@ impl<'a, 'tcx> ShallowResolver<'a, 'tcx> {
1601
1597
_ => typ,
1602
1598
}
1603
1599
}
1600
+
1601
+ // `resolver.shallow_resolve_changed(ty)` is equivalent to
1602
+ // `resolver.shallow_resolve(ty) != ty`, but more efficient. It's always
1603
+ // inlined, despite being large, because it has a single call site that is
1604
+ // extremely hot.
1605
+ #[ inline( always) ]
1606
+ pub fn shallow_resolve_changed ( & mut self , typ : Ty < ' tcx > ) -> bool {
1607
+ match typ. sty {
1608
+ ty:: Infer ( ty:: TyVar ( v) ) => {
1609
+ use self :: type_variable:: TypeVariableValue ;
1610
+
1611
+ // See the comment in `shallow_resolve()`.
1612
+ match self . infcx . type_variables . borrow_mut ( ) . probe ( v) {
1613
+ TypeVariableValue :: Known { value : t } => self . fold_ty ( t) != typ,
1614
+ TypeVariableValue :: Unknown { .. } => false ,
1615
+ }
1616
+ }
1617
+
1618
+ ty:: Infer ( ty:: IntVar ( v) ) => {
1619
+ match self . infcx . int_unification_table . borrow_mut ( ) . probe_value ( v) {
1620
+ Some ( v) => v. to_type ( self . infcx . tcx ) != typ,
1621
+ None => false ,
1622
+ }
1623
+ }
1624
+
1625
+ ty:: Infer ( ty:: FloatVar ( v) ) => {
1626
+ match self . infcx . float_unification_table . borrow_mut ( ) . probe_value ( v) {
1627
+ Some ( v) => v. to_type ( self . infcx . tcx ) != typ,
1628
+ None => false ,
1629
+ }
1630
+ }
1631
+
1632
+ _ => false ,
1633
+ }
1634
+ }
1635
+
1604
1636
}
1605
1637
1606
1638
impl < ' a , ' tcx > TypeFolder < ' tcx > for ShallowResolver < ' a , ' tcx > {
@@ -1609,7 +1641,7 @@ impl<'a, 'tcx> TypeFolder<'tcx> for ShallowResolver<'a, 'tcx> {
1609
1641
}
1610
1642
1611
1643
fn fold_ty ( & mut self , ty : Ty < ' tcx > ) -> Ty < ' tcx > {
1612
- self . inlined_shallow_resolve ( ty)
1644
+ self . shallow_resolve ( ty)
1613
1645
}
1614
1646
1615
1647
fn fold_const ( & mut self , ct : & ' tcx ty:: Const < ' tcx > ) -> & ' tcx ty:: Const < ' tcx > {
0 commit comments