Pull out logic from #111131, plus some new logic in EvalCtxt::normalize_opaque_type
Co-authored-by: lcnr <rust@lcnr.de>
This commit is contained in:
parent
7664dfe433
commit
4d80b8090c
13 changed files with 122 additions and 43 deletions
|
@ -996,17 +996,11 @@ impl<'tcx> Term<'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
/// This function returns the inner `AliasTy` if this term is a projection.
|
||||
///
|
||||
/// FIXME: rename `AliasTy` to `AliasTerm` and make sure we correctly
|
||||
/// deal with constants.
|
||||
pub fn to_projection_term(&self, tcx: TyCtxt<'tcx>) -> Option<AliasTy<'tcx>> {
|
||||
/// This function returns the inner `AliasTy` for a `ty::Alias` or `ConstKind::Unevaluated`.
|
||||
pub fn to_alias_ty(&self, tcx: TyCtxt<'tcx>) -> Option<AliasTy<'tcx>> {
|
||||
match self.unpack() {
|
||||
TermKind::Ty(ty) => match ty.kind() {
|
||||
ty::Alias(kind, alias_ty) => match kind {
|
||||
AliasKind::Projection | AliasKind::Inherent => Some(*alias_ty),
|
||||
AliasKind::Opaque => None,
|
||||
},
|
||||
TermKind::Ty(ty) => match *ty.kind() {
|
||||
ty::Alias(_kind, alias_ty) => Some(alias_ty),
|
||||
_ => None,
|
||||
},
|
||||
TermKind::Const(ct) => match ct.kind() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue