remove type_op constructors

This commit is contained in:
lcnr 2024-10-15 18:11:37 +02:00
parent 401f9b4e0a
commit 9334d85e69
3 changed files with 6 additions and 30 deletions

View File

@ -137,7 +137,7 @@ pub(super) fn prove_predicate(
let _: Result<_, ErrorGuaranteed> = self.fully_perform_op(
locations,
category,
param_env.and(type_op::prove_predicate::ProvePredicate::new(predicate)),
param_env.and(type_op::prove_predicate::ProvePredicate { predicate }),
);
}
@ -162,7 +162,7 @@ pub(super) fn normalize_with_category<T>(
let result: Result<_, ErrorGuaranteed> = self.fully_perform_op(
location.to_locations(),
category,
param_env.and(type_op::normalize::Normalize::new(value)),
param_env.and(type_op::normalize::Normalize { value }),
);
result.unwrap_or(value)
}
@ -223,7 +223,7 @@ pub(super) fn ascribe_user_type(
let _: Result<_, ErrorGuaranteed> = self.fully_perform_op(
Locations::All(span),
ConstraintCategory::Boring,
self.param_env.and(type_op::ascribe_user_type::AscribeUserType::new(mir_ty, user_ty)),
self.param_env.and(type_op::ascribe_user_type::AscribeUserType { mir_ty, user_ty }),
);
}

View File

@ -280,7 +280,7 @@ pub(crate) fn create(mut self) -> CreateResult<'tcx> {
}
let TypeOpOutput { output: norm_ty, constraints: constraints_normalize, .. } = self
.param_env
.and(type_op::normalize::Normalize::new(ty))
.and(type_op::normalize::Normalize { value: ty })
.fully_perform(self.infcx, span)
.unwrap_or_else(|guar| TypeOpOutput {
output: Ty::new_error(self.infcx.tcx, guar),
@ -318,7 +318,7 @@ pub(crate) fn create(mut self) -> CreateResult<'tcx> {
for &(ty, _) in tcx.assumed_wf_types(tcx.local_parent(defining_ty_def_id)) {
let result: Result<_, ErrorGuaranteed> = self
.param_env
.and(type_op::normalize::Normalize::new(ty))
.and(type_op::normalize::Normalize { value: ty })
.fully_perform(self.infcx, span);
let Ok(TypeOpOutput { output: norm_ty, constraints: c, .. }) = result else {
continue;

View File

@ -15,12 +15,9 @@
use crate::ty::{self, GenericArg, Ty, TyCtxt};
pub mod type_op {
use std::fmt;
use rustc_macros::{HashStable, TypeFoldable, TypeVisitable};
use crate::ty::fold::TypeFoldable;
use crate::ty::{Predicate, Ty, TyCtxt, UserType};
use crate::ty::{Predicate, Ty, UserType};
#[derive(Copy, Clone, Debug, Hash, PartialEq, Eq, HashStable, TypeFoldable, TypeVisitable)]
pub struct AscribeUserType<'tcx> {
@ -28,12 +25,6 @@ pub struct AscribeUserType<'tcx> {
pub user_ty: UserType<'tcx>,
}
impl<'tcx> AscribeUserType<'tcx> {
pub fn new(mir_ty: Ty<'tcx>, user_ty: UserType<'tcx>) -> Self {
Self { mir_ty, user_ty }
}
}
#[derive(Copy, Clone, Debug, Hash, PartialEq, Eq, HashStable, TypeFoldable, TypeVisitable)]
pub struct Eq<'tcx> {
pub a: Ty<'tcx>,
@ -51,26 +42,11 @@ pub struct ProvePredicate<'tcx> {
pub predicate: Predicate<'tcx>,
}
impl<'tcx> ProvePredicate<'tcx> {
pub fn new(predicate: Predicate<'tcx>) -> Self {
ProvePredicate { predicate }
}
}
#[derive(Copy, Clone, Debug, Hash, PartialEq, Eq, HashStable, TypeFoldable, TypeVisitable)]
pub struct Normalize<T> {
pub value: T,
}
impl<'tcx, T> Normalize<T>
where
T: fmt::Debug + TypeFoldable<TyCtxt<'tcx>>,
{
pub fn new(value: T) -> Self {
Self { value }
}
}
#[derive(Copy, Clone, Debug, Hash, PartialEq, Eq, HashStable, TypeFoldable, TypeVisitable)]
pub struct ImpliedOutlivesBounds<'tcx> {
pub ty: Ty<'tcx>,