@@ -1617,38 +1617,40 @@ impl<'a, 'tcx> ShallowResolver<'a, 'tcx> {
16171617 // `resolver.shallow_resolve(ty) != ty`, but more efficient. It's always
16181618 // inlined, despite being large, because it has only two call sites that
16191619 // are extremely hot.
1620+ //
1621+ // Note that `typ` is always a `ty::Infer(_)`.
16201622 #[ 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 {
16221624 match typ. kind {
16231625 ty:: Infer ( ty:: TyVar ( v) ) => {
16241626 use self :: type_variable:: TypeVariableValue ;
16251627
1626- // See the comment in `shallow_resolve()`.
1628+ // If `inlined_probe` returns a `Known` value it never matches
1629+ // `typ`.
16271630 match self . infcx . type_variables . borrow_mut ( ) . inlined_probe ( v) {
1628- TypeVariableValue :: Known { value : t } => self . fold_ty ( t) != typ,
16291631 TypeVariableValue :: Unknown { .. } => false ,
1632+ TypeVariableValue :: Known { .. } => true ,
16301633 }
16311634 }
16321635
16331636 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 ( )
16381641 }
16391642
16401643 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+ //
16411647 // 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 ( )
16461649 }
16471650
1648- _ => false ,
1651+ _ => unreachable ! ( ) ,
16491652 }
16501653 }
1651-
16521654}
16531655
16541656impl < ' a , ' tcx > TypeFolder < ' tcx > for ShallowResolver < ' a , ' tcx > {
0 commit comments