1
Fork 0

Split UserTypeAnnotation to have a kind

This commit is contained in:
Michael Goulet 2024-12-11 20:10:47 +00:00
parent 4a204bebdf
commit 1da411e750
13 changed files with 60 additions and 36 deletions

View file

@ -3,7 +3,7 @@ use rustc_infer::traits::Obligation;
use rustc_middle::traits::query::NoSolution;
pub use rustc_middle::traits::query::type_op::AscribeUserType;
use rustc_middle::traits::{ObligationCause, ObligationCauseCode};
use rustc_middle::ty::{self, ParamEnvAnd, Ty, TyCtxt, UserArgs, UserSelfTy, UserType};
use rustc_middle::ty::{self, ParamEnvAnd, Ty, TyCtxt, UserArgs, UserSelfTy, UserTypeKind};
use rustc_span::{DUMMY_SP, Span};
use tracing::{debug, instrument};
@ -46,9 +46,9 @@ pub fn type_op_ascribe_user_type_with_span<'tcx>(
let (param_env, AscribeUserType { mir_ty, user_ty }) = key.into_parts();
debug!("type_op_ascribe_user_type: mir_ty={:?} user_ty={:?}", mir_ty, user_ty);
let span = span.unwrap_or(DUMMY_SP);
match user_ty {
UserType::Ty(user_ty) => relate_mir_and_user_ty(ocx, param_env, span, mir_ty, user_ty)?,
UserType::TypeOf(def_id, user_args) => {
match user_ty.kind {
UserTypeKind::Ty(user_ty) => relate_mir_and_user_ty(ocx, param_env, span, mir_ty, user_ty)?,
UserTypeKind::TypeOf(def_id, user_args) => {
relate_mir_and_user_args(ocx, param_env, span, mir_ty, def_id, user_args)?
}
};