Remove ParamEnvAnd::into_parts.

The fields are public, so this doesn't need a method, normal
deconstruction and/or field access is good enough.
This commit is contained in:
Nicholas Nethercote
2025-07-31 09:02:15 +10:00
parent c4e3cc0228
commit a949c47f0d
6 changed files with 8 additions and 14 deletions

View File

@@ -277,7 +277,7 @@ where
// `QueryNormalizeExt::query_normalize` used in the query and `normalize` called below:
// the former fails to normalize the `nll/relate_tys/impl-fn-ignore-binder-via-bottom.rs`
// test. Check after #85499 lands to see if its fixes have erased this difference.
let (param_env, value) = key.into_parts();
let ty::ParamEnvAnd { param_env, value } = key;
let _ = ocx.normalize(&cause, param_env, value.value);
let diag = try_extract_error_from_fulfill_cx(
@@ -324,7 +324,7 @@ where
mbcx.infcx.tcx.infer_ctxt().build_with_canonical(cause.span, &self.canonical_query);
let ocx = ObligationCtxt::new(&infcx);
let (param_env, value) = key.into_parts();
let ty::ParamEnvAnd { param_env, value } = key;
let _ = ocx.deeply_normalize(&cause, param_env, value.value);
let diag = try_extract_error_from_fulfill_cx(

View File

@@ -44,7 +44,7 @@ impl<'tcx> InferCtxt<'tcx> {
where
V: TypeFoldable<TyCtxt<'tcx>>,
{
let (param_env, value) = value.into_parts();
let ty::ParamEnvAnd { param_env, value } = value;
let canonical_param_env = self.tcx.canonical_param_env_cache.get_or_insert(
self.tcx,
param_env,

View File

@@ -1011,12 +1011,6 @@ pub struct ParamEnvAnd<'tcx, T> {
pub value: T,
}
impl<'tcx, T> ParamEnvAnd<'tcx, T> {
pub fn into_parts(self) -> (ParamEnv<'tcx>, T) {
(self.param_env, self.value)
}
}
/// The environment in which to do trait solving.
///
/// Most of the time you only need to care about the `ParamEnv`

View File

@@ -44,7 +44,7 @@ pub fn type_op_ascribe_user_type_with_span<'tcx>(
key: ParamEnvAnd<'tcx, AscribeUserType<'tcx>>,
span: Span,
) -> Result<(), NoSolution> {
let (param_env, AscribeUserType { mir_ty, user_ty }) = key.into_parts();
let ty::ParamEnvAnd { param_env, value: AscribeUserType { mir_ty, user_ty } } = key;
debug!("type_op_ascribe_user_type: mir_ty={:?} user_ty={:?}", mir_ty, user_ty);
match user_ty.kind {
UserTypeKind::Ty(user_ty) => relate_mir_and_user_ty(ocx, param_env, span, mir_ty, user_ty)?,

View File

@@ -7,7 +7,7 @@ use rustc_infer::infer::canonical::{self, Canonical};
use rustc_infer::traits::query::OutlivesBound;
use rustc_infer::traits::query::type_op::ImpliedOutlivesBounds;
use rustc_middle::query::Providers;
use rustc_middle::ty::TyCtxt;
use rustc_middle::ty::{ParamEnvAnd, TyCtxt};
use rustc_span::DUMMY_SP;
use rustc_trait_selection::infer::InferCtxtBuilderExt;
use rustc_trait_selection::traits::query::type_op::implied_outlives_bounds::compute_implied_outlives_bounds_inner;
@@ -25,7 +25,7 @@ fn implied_outlives_bounds<'tcx>(
NoSolution,
> {
tcx.infer_ctxt().enter_canonical_trait_query(&goal, |ocx, key| {
let (param_env, ImpliedOutlivesBounds { ty }) = key.into_parts();
let ParamEnvAnd { param_env, value: ImpliedOutlivesBounds { ty } } = key;
compute_implied_outlives_bounds_inner(
ocx,
param_env,

View File

@@ -43,7 +43,7 @@ fn type_op_normalize<'tcx, T>(
where
T: fmt::Debug + TypeFoldable<TyCtxt<'tcx>>,
{
let (param_env, Normalize { value }) = key.into_parts();
let ParamEnvAnd { param_env, value: Normalize { value } } = key;
let Normalized { value, obligations } =
ocx.infcx.at(&ObligationCause::dummy(), param_env).query_normalize(value)?;
ocx.register_obligations(obligations);
@@ -96,6 +96,6 @@ pub fn type_op_prove_predicate_with_cause<'tcx>(
key: ParamEnvAnd<'tcx, ProvePredicate<'tcx>>,
cause: ObligationCause<'tcx>,
) {
let (param_env, ProvePredicate { predicate }) = key.into_parts();
let ParamEnvAnd { param_env, value: ProvePredicate { predicate } } = key;
ocx.register_obligation(Obligation::new(ocx.infcx.tcx, cause, param_env, predicate));
}