diff options
| author | Michael Goulet <michael@errs.io> | 2023-03-14 22:56:20 +0000 |
|---|---|---|
| committer | Michael Goulet <michael@errs.io> | 2023-03-14 22:56:24 +0000 |
| commit | e482701998aa63915f5144562008a8f6388dcb6e (patch) | |
| tree | 9ea2b49766a07069d82ab9f254b67cb5838e1af6 | |
| parent | f1b1ed7e18f1fbe5226a96626827c625985f8285 (diff) | |
| download | rust-e482701998aa63915f5144562008a8f6388dcb6e.tar.gz rust-e482701998aa63915f5144562008a8f6388dcb6e.zip | |
Assert def-kind is correct for alias types
| -rw-r--r-- | compiler/rustc_middle/src/ty/context.rs | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/compiler/rustc_middle/src/ty/context.rs b/compiler/rustc_middle/src/ty/context.rs index 8dd8f95fcc7..43203a97671 100644 --- a/compiler/rustc_middle/src/ty/context.rs +++ b/compiler/rustc_middle/src/ty/context.rs @@ -71,6 +71,7 @@ use rustc_type_ir::WithCachedTypeInfo; use rustc_type_ir::{CollectAndApply, DynKind, Interner, TypeFlags}; use std::any::Any; +use std::assert_matches::debug_assert_matches; use std::borrow::Borrow; use std::cmp::Ordering; use std::fmt; @@ -2049,6 +2050,12 @@ impl<'tcx> TyCtxt<'tcx> { #[inline] pub fn mk_alias(self, kind: ty::AliasKind, alias_ty: ty::AliasTy<'tcx>) -> Ty<'tcx> { + debug_assert_matches!( + (kind, self.def_kind(alias_ty.def_id)), + (ty::Opaque, DefKind::OpaqueTy) + | (ty::Projection, DefKind::AssocTy | DefKind::AssocConst) + | (ty::Opaque | ty::Projection, DefKind::ImplTraitPlaceholder) + ); self.mk_ty_from_kind(Alias(kind, alias_ty)) } |
