@@ -1617,38 +1617,40 @@ impl<'a, 'tcx> ShallowResolver<'a, 'tcx> {
1617
1617
// `resolver.shallow_resolve(ty) != ty`, but more efficient. It's always
1618
1618
// inlined, despite being large, because it has only two call sites that
1619
1619
// are extremely hot.
1620
+ //
1621
+ // Note that `typ` is always a `ty::Infer(_)`.
1620
1622
#[ inline( always) ]
1621
- pub fn shallow_resolve_changed ( & mut self , typ : Ty < ' tcx > ) -> bool {
1623
+ pub fn shallow_resolve_changed ( & self , typ : Ty < ' tcx > ) -> bool {
1622
1624
match typ. kind {
1623
1625
ty:: Infer ( ty:: TyVar ( v) ) => {
1624
1626
use self :: type_variable:: TypeVariableValue ;
1625
1627
1626
- // See the comment in `shallow_resolve()`.
1628
+ // If `inlined_probe` returns a `Known` value it never matches
1629
+ // `typ`.
1627
1630
match self . infcx . type_variables . borrow_mut ( ) . inlined_probe ( v) {
1628
- TypeVariableValue :: Known { value : t } => self . fold_ty ( t) != typ,
1629
1631
TypeVariableValue :: Unknown { .. } => false ,
1632
+ TypeVariableValue :: Known { .. } => true ,
1630
1633
}
1631
1634
}
1632
1635
1633
1636
ty:: Infer ( ty:: IntVar ( v) ) => {
1634
- match self . infcx . int_unification_table . borrow_mut ( ) . inlined_probe_value ( v ) {
1635
- Some ( v ) => v . to_type ( self . infcx . tcx ) != typ ,
1636
- None => false ,
1637
- }
1637
+ // If inlined_probe_value returns a value it's always a
1638
+ // `ty::Int(_)` or `ty::UInt(_)`, which nevers matches a
1639
+ // `ty::Infer(_)`.
1640
+ self . infcx . int_unification_table . borrow_mut ( ) . inlined_probe_value ( v ) . is_some ( )
1638
1641
}
1639
1642
1640
1643
ty:: Infer ( ty:: FloatVar ( v) ) => {
1644
+ // If inlined_probe_value returns a value it's always a
1645
+ // `ty::Float(_)`, which nevers matches a `ty::Infer(_)`.
1646
+ //
1641
1647
// Not `inlined_probe_value(v)` because this call site is colder.
1642
- match self . infcx . float_unification_table . borrow_mut ( ) . probe_value ( v) {
1643
- Some ( v) => v. to_type ( self . infcx . tcx ) != typ,
1644
- None => false ,
1645
- }
1648
+ self . infcx . float_unification_table . borrow_mut ( ) . probe_value ( v) . is_some ( )
1646
1649
}
1647
1650
1648
- _ => false ,
1651
+ _ => unreachable ! ( ) ,
1649
1652
}
1650
1653
}
1651
-
1652
1654
}
1653
1655
1654
1656
impl < ' a , ' tcx > TypeFolder < ' tcx > for ShallowResolver < ' a , ' tcx > {
0 commit comments