Rollup merge of #109151 - compiler-errors:debug-assert-alias, r=WaffleLapkin
Assert def-kind is correct for alias types
Make sure we're not constructing alias types for the wrong def-kind, at least for debug cases 😅
This commit is contained in:
commit
9d5d447421
4 changed files with 16 additions and 20 deletions
|
@ -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)
|
||||
| (ty::Opaque | ty::Projection, DefKind::ImplTraitPlaceholder)
|
||||
);
|
||||
self.mk_ty_from_kind(Alias(kind, alias_ty))
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue