Combine `ty::Projection` and `ty::Opaque` into `ty::Alias` by compiler-errors ·...
source link: https://github.com/rust-lang/rust/pull/104986
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
Implements rust-lang/types-team#79.
This PR consolidates ty::Projection
and ty::Opaque
into a single ty::Alias
, with an AliasKind
and AliasTy
type (renamed from ty::ProjectionTy
, which is the inner data of ty::Projection
) defined as so:
enum AliasKind {
Projection,
Opaque,
}
struct AliasTy<'tcx> {
def_id: DefId,
substs: SubstsRef<'tcx>,
}
Since we don't have access to TyCtxt
in type flags computation, and because repeatedly calling DefKind
on the def-id is expensive, these two types are distinguished with ty::AliasKind
, conveniently glob-imported into ty::{Projection, Opaque}
. For example:
match ty.kind() {
- ty::Opaque(..) =>
+ ty::Alias(ty::Opaque, ..) => {}
_ => {}
}
This PR also consolidates match arms that treated ty::Opaque
and ty::Projection
identically.
r? @ghost
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK