Function rustc_middle::ty::fast_reject::simplify_type
source · [−]pub fn simplify_type<'tcx>(
tcx: TyCtxt<'tcx>,
ty: Ty<'tcx>,
treat_params: TreatParams
) -> Option<SimplifiedType>Expand description
Tries to simplify a type by only returning the outermost injective¹ layer, if one exists.
The idea is to get something simple that we can use to quickly decide if two types could unify, for example during method lookup.
A special case here are parameters and projections, which are only injective if they are treated as bound types.
For example when storing impls based on their simplified self type, we treat generic parameters as placeholders. We must not simplify them here, as they can unify with any other type.
With projections we have to be even more careful, as even when treating them as bound types this is still only correct if they are fully normalized.
¹ meaning that if the outermost layers are different, then the whole types are also different.