# 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.

**This function should only be used if you need to store or retrieve the type from some
hashmap. If you want to quickly decide whether two types may unify, use the DeepRejectCtxt
instead.**

The idea is to get something simple that we can use to quickly decide if two types could unify,
for example during method lookup. If this function returns `Some(x)`

it can only unify with
types for which this method returns either `Some(x)`

as well or `None`

.

A special case here are parameters and projections, which are only injective if they are treated as placeholders.

For example when storing impls based on their simplified self type, we treat generic parameters as if they were inference variables. We must not simplify them here, as they can unify with any other type.

With projections we have to be even more careful, as treating them as placeholders is only correct if they are fully normalized.

¹ meaning that if the outermost layers are different, then the whole types are also different.