1
Fork 0

Rollup merge of #131748 - lcnr:typing-mode, r=compiler-errors

cleanup canonical queries

best reviewed commit by commit. adding `CanonicalQueryInput` to stop returning `defining_opaque_types` in query responses is the most involved change here.

r? ``@compiler-errors``
This commit is contained in:
Matthias Krüger 2024-10-17 12:07:21 +02:00 committed by GitHub
commit c1f370254c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
39 changed files with 225 additions and 261 deletions

View file

@ -3,12 +3,16 @@ use std::rc::Rc;
use rustc_errors::Diag; use rustc_errors::Diag;
use rustc_hir::def_id::LocalDefId; use rustc_hir::def_id::LocalDefId;
use rustc_infer::infer::canonical::Canonical; use rustc_infer::infer::canonical::CanonicalQueryInput;
use rustc_infer::infer::region_constraints::{Constraint, RegionConstraintData}; use rustc_infer::infer::region_constraints::{Constraint, RegionConstraintData};
use rustc_infer::infer::{ use rustc_infer::infer::{
InferCtxt, RegionResolutionError, RegionVariableOrigin, SubregionOrigin, TyCtxtInferExt as _, InferCtxt, RegionResolutionError, RegionVariableOrigin, SubregionOrigin, TyCtxtInferExt as _,
}; };
use rustc_infer::traits::ObligationCause; use rustc_infer::traits::ObligationCause;
use rustc_infer::traits::query::{
CanonicalTypeOpAscribeUserTypeGoal, CanonicalTypeOpNormalizeGoal,
CanonicalTypeOpProvePredicateGoal,
};
use rustc_middle::ty::error::TypeError; use rustc_middle::ty::error::TypeError;
use rustc_middle::ty::{ use rustc_middle::ty::{
self, RePlaceholder, Region, RegionVid, Ty, TyCtxt, TypeFoldable, UniverseIndex, self, RePlaceholder, Region, RegionVid, Ty, TyCtxt, TypeFoldable, UniverseIndex,
@ -95,9 +99,7 @@ impl<'tcx> ToUniverseInfo<'tcx> for crate::type_check::InstantiateOpaqueType<'tc
} }
} }
impl<'tcx> ToUniverseInfo<'tcx> impl<'tcx> ToUniverseInfo<'tcx> for CanonicalTypeOpProvePredicateGoal<'tcx> {
for Canonical<'tcx, ty::ParamEnvAnd<'tcx, type_op::prove_predicate::ProvePredicate<'tcx>>>
{
fn to_universe_info(self, base_universe: ty::UniverseIndex) -> UniverseInfo<'tcx> { fn to_universe_info(self, base_universe: ty::UniverseIndex) -> UniverseInfo<'tcx> {
UniverseInfo(UniverseInfoInner::TypeOp(Rc::new(PredicateQuery { UniverseInfo(UniverseInfoInner::TypeOp(Rc::new(PredicateQuery {
canonical_query: self, canonical_query: self,
@ -107,7 +109,7 @@ impl<'tcx> ToUniverseInfo<'tcx>
} }
impl<'tcx, T: Copy + fmt::Display + TypeFoldable<TyCtxt<'tcx>> + 'tcx> ToUniverseInfo<'tcx> impl<'tcx, T: Copy + fmt::Display + TypeFoldable<TyCtxt<'tcx>> + 'tcx> ToUniverseInfo<'tcx>
for Canonical<'tcx, ty::ParamEnvAnd<'tcx, type_op::Normalize<T>>> for CanonicalTypeOpNormalizeGoal<'tcx, T>
{ {
fn to_universe_info(self, base_universe: ty::UniverseIndex) -> UniverseInfo<'tcx> { fn to_universe_info(self, base_universe: ty::UniverseIndex) -> UniverseInfo<'tcx> {
UniverseInfo(UniverseInfoInner::TypeOp(Rc::new(NormalizeQuery { UniverseInfo(UniverseInfoInner::TypeOp(Rc::new(NormalizeQuery {
@ -117,9 +119,7 @@ impl<'tcx, T: Copy + fmt::Display + TypeFoldable<TyCtxt<'tcx>> + 'tcx> ToUnivers
} }
} }
impl<'tcx> ToUniverseInfo<'tcx> impl<'tcx> ToUniverseInfo<'tcx> for CanonicalTypeOpAscribeUserTypeGoal<'tcx> {
for Canonical<'tcx, ty::ParamEnvAnd<'tcx, type_op::AscribeUserType<'tcx>>>
{
fn to_universe_info(self, base_universe: ty::UniverseIndex) -> UniverseInfo<'tcx> { fn to_universe_info(self, base_universe: ty::UniverseIndex) -> UniverseInfo<'tcx> {
UniverseInfo(UniverseInfoInner::TypeOp(Rc::new(AscribeUserTypeQuery { UniverseInfo(UniverseInfoInner::TypeOp(Rc::new(AscribeUserTypeQuery {
canonical_query: self, canonical_query: self,
@ -128,7 +128,7 @@ impl<'tcx> ToUniverseInfo<'tcx>
} }
} }
impl<'tcx, F> ToUniverseInfo<'tcx> for Canonical<'tcx, type_op::custom::CustomTypeOp<F>> { impl<'tcx, F> ToUniverseInfo<'tcx> for CanonicalQueryInput<'tcx, type_op::custom::CustomTypeOp<F>> {
fn to_universe_info(self, _base_universe: ty::UniverseIndex) -> UniverseInfo<'tcx> { fn to_universe_info(self, _base_universe: ty::UniverseIndex) -> UniverseInfo<'tcx> {
// We can't rerun custom type ops. // We can't rerun custom type ops.
UniverseInfo::other() UniverseInfo::other()
@ -211,8 +211,7 @@ trait TypeOpInfo<'tcx> {
} }
struct PredicateQuery<'tcx> { struct PredicateQuery<'tcx> {
canonical_query: canonical_query: CanonicalTypeOpProvePredicateGoal<'tcx>,
Canonical<'tcx, ty::ParamEnvAnd<'tcx, type_op::prove_predicate::ProvePredicate<'tcx>>>,
base_universe: ty::UniverseIndex, base_universe: ty::UniverseIndex,
} }
@ -220,7 +219,7 @@ impl<'tcx> TypeOpInfo<'tcx> for PredicateQuery<'tcx> {
fn fallback_error(&self, tcx: TyCtxt<'tcx>, span: Span) -> Diag<'tcx> { fn fallback_error(&self, tcx: TyCtxt<'tcx>, span: Span) -> Diag<'tcx> {
tcx.dcx().create_err(HigherRankedLifetimeError { tcx.dcx().create_err(HigherRankedLifetimeError {
cause: Some(HigherRankedErrorCause::CouldNotProve { cause: Some(HigherRankedErrorCause::CouldNotProve {
predicate: self.canonical_query.value.value.predicate.to_string(), predicate: self.canonical_query.canonical.value.value.predicate.to_string(),
}), }),
span, span,
}) })
@ -253,7 +252,7 @@ impl<'tcx> TypeOpInfo<'tcx> for PredicateQuery<'tcx> {
} }
struct NormalizeQuery<'tcx, T> { struct NormalizeQuery<'tcx, T> {
canonical_query: Canonical<'tcx, ty::ParamEnvAnd<'tcx, type_op::Normalize<T>>>, canonical_query: CanonicalTypeOpNormalizeGoal<'tcx, T>,
base_universe: ty::UniverseIndex, base_universe: ty::UniverseIndex,
} }
@ -264,7 +263,7 @@ where
fn fallback_error(&self, tcx: TyCtxt<'tcx>, span: Span) -> Diag<'tcx> { fn fallback_error(&self, tcx: TyCtxt<'tcx>, span: Span) -> Diag<'tcx> {
tcx.dcx().create_err(HigherRankedLifetimeError { tcx.dcx().create_err(HigherRankedLifetimeError {
cause: Some(HigherRankedErrorCause::CouldNotNormalize { cause: Some(HigherRankedErrorCause::CouldNotNormalize {
value: self.canonical_query.value.value.value.to_string(), value: self.canonical_query.canonical.value.value.value.to_string(),
}), }),
span, span,
}) })
@ -306,7 +305,7 @@ where
} }
struct AscribeUserTypeQuery<'tcx> { struct AscribeUserTypeQuery<'tcx> {
canonical_query: Canonical<'tcx, ty::ParamEnvAnd<'tcx, type_op::AscribeUserType<'tcx>>>, canonical_query: CanonicalTypeOpAscribeUserTypeGoal<'tcx>,
base_universe: ty::UniverseIndex, base_universe: ty::UniverseIndex,
} }

View file

@ -137,7 +137,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
let _: Result<_, ErrorGuaranteed> = self.fully_perform_op( let _: Result<_, ErrorGuaranteed> = self.fully_perform_op(
locations, locations,
category, category,
param_env.and(type_op::prove_predicate::ProvePredicate::new(predicate)), param_env.and(type_op::prove_predicate::ProvePredicate { predicate }),
); );
} }
@ -162,7 +162,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
let result: Result<_, ErrorGuaranteed> = self.fully_perform_op( let result: Result<_, ErrorGuaranteed> = self.fully_perform_op(
location.to_locations(), location.to_locations(),
category, category,
param_env.and(type_op::normalize::Normalize::new(value)), param_env.and(type_op::normalize::Normalize { value }),
); );
result.unwrap_or(value) result.unwrap_or(value)
} }
@ -223,7 +223,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
let _: Result<_, ErrorGuaranteed> = self.fully_perform_op( let _: Result<_, ErrorGuaranteed> = self.fully_perform_op(
Locations::All(span), Locations::All(span),
ConstraintCategory::Boring, 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 @@ impl<'tcx> UniversalRegionRelationsBuilder<'_, 'tcx> {
} }
let TypeOpOutput { output: norm_ty, constraints: constraints_normalize, .. } = self let TypeOpOutput { output: norm_ty, constraints: constraints_normalize, .. } = self
.param_env .param_env
.and(type_op::normalize::Normalize::new(ty)) .and(type_op::normalize::Normalize { value: ty })
.fully_perform(self.infcx, span) .fully_perform(self.infcx, span)
.unwrap_or_else(|guar| TypeOpOutput { .unwrap_or_else(|guar| TypeOpOutput {
output: Ty::new_error(self.infcx.tcx, guar), output: Ty::new_error(self.infcx.tcx, guar),
@ -318,7 +318,7 @@ impl<'tcx> UniversalRegionRelationsBuilder<'_, 'tcx> {
for &(ty, _) in tcx.assumed_wf_types(tcx.local_parent(defining_ty_def_id)) { for &(ty, _) in tcx.assumed_wf_types(tcx.local_parent(defining_ty_def_id)) {
let result: Result<_, ErrorGuaranteed> = self let result: Result<_, ErrorGuaranteed> = self
.param_env .param_env
.and(type_op::normalize::Normalize::new(ty)) .and(type_op::normalize::Normalize { value: ty })
.fully_perform(self.infcx, span); .fully_perform(self.infcx, span);
let Ok(TypeOpOutput { output: norm_ty, constraints: c, .. }) = result else { let Ok(TypeOpOutput { output: norm_ty, constraints: c, .. }) = result else {
continue; continue;
@ -373,7 +373,7 @@ impl<'tcx> UniversalRegionRelationsBuilder<'_, 'tcx> {
) -> Option<&'tcx QueryRegionConstraints<'tcx>> { ) -> Option<&'tcx QueryRegionConstraints<'tcx>> {
let TypeOpOutput { output: bounds, constraints, .. } = self let TypeOpOutput { output: bounds, constraints, .. } = self
.param_env .param_env
.and(type_op::implied_outlives_bounds::ImpliedOutlivesBounds { ty }) .and(type_op::ImpliedOutlivesBounds { ty })
.fully_perform(self.infcx, span) .fully_perform(self.infcx, span)
.map_err(|_: ErrorGuaranteed| debug!("failed to compute implied bounds {:?}", ty)) .map_err(|_: ErrorGuaranteed| debug!("failed to compute implied bounds {:?}", ty))
.ok()?; .ok()?;

View file

@ -11,8 +11,7 @@ use rustc_mir_dataflow::impls::MaybeInitializedPlaces;
use rustc_mir_dataflow::move_paths::{HasMoveData, MoveData, MovePathIndex}; use rustc_mir_dataflow::move_paths::{HasMoveData, MoveData, MovePathIndex};
use rustc_mir_dataflow::points::{DenseLocationMap, PointIndex}; use rustc_mir_dataflow::points::{DenseLocationMap, PointIndex};
use rustc_span::DUMMY_SP; use rustc_span::DUMMY_SP;
use rustc_trait_selection::traits::query::type_op::outlives::DropckOutlives; use rustc_trait_selection::traits::query::type_op::{DropckOutlives, TypeOp, TypeOpOutput};
use rustc_trait_selection::traits::query::type_op::{TypeOp, TypeOpOutput};
use tracing::debug; use tracing::debug;
use crate::location::RichLocation; use crate::location::RichLocation;
@ -632,7 +631,7 @@ impl<'tcx> LivenessContext<'_, '_, '_, 'tcx> {
match typeck match typeck
.param_env .param_env
.and(DropckOutlives::new(dropped_ty)) .and(DropckOutlives { dropped_ty })
.fully_perform(typeck.infcx, DUMMY_SP) .fully_perform(typeck.infcx, DUMMY_SP)
{ {
Ok(TypeOpOutput { output, constraints, .. }) => { Ok(TypeOpOutput { output, constraints, .. }) => {

View file

@ -340,13 +340,13 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
OP: FnOnce(ProbeContext<'_, 'tcx>) -> Result<R, MethodError<'tcx>>, OP: FnOnce(ProbeContext<'_, 'tcx>) -> Result<R, MethodError<'tcx>>,
{ {
let mut orig_values = OriginalQueryValues::default(); let mut orig_values = OriginalQueryValues::default();
let param_env_and_self_ty = self.canonicalize_query( let query_input = self.canonicalize_query(
ParamEnvAnd { param_env: self.param_env, value: self_ty }, ParamEnvAnd { param_env: self.param_env, value: self_ty },
&mut orig_values, &mut orig_values,
); );
let steps = match mode { let steps = match mode {
Mode::MethodCall => self.tcx.method_autoderef_steps(param_env_and_self_ty), Mode::MethodCall => self.tcx.method_autoderef_steps(query_input),
Mode::Path => self.probe(|_| { Mode::Path => self.probe(|_| {
// Mode::Path - the deref steps is "trivial". This turns // Mode::Path - the deref steps is "trivial". This turns
// our CanonicalQuery into a "trivial" QueryResponse. This // our CanonicalQuery into a "trivial" QueryResponse. This
@ -355,11 +355,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
let infcx = &self.infcx; let infcx = &self.infcx;
let (ParamEnvAnd { param_env: _, value: self_ty }, canonical_inference_vars) = let (ParamEnvAnd { param_env: _, value: self_ty }, canonical_inference_vars) =
infcx.instantiate_canonical(span, &param_env_and_self_ty); infcx.instantiate_canonical(span, &query_input.canonical);
debug!( debug!(?self_ty, ?query_input, "probe_op: Mode::Path");
"probe_op: Mode::Path, param_env_and_self_ty={:?} self_ty={:?}",
param_env_and_self_ty, self_ty
);
MethodAutoderefStepsResult { MethodAutoderefStepsResult {
steps: infcx.tcx.arena.alloc_from_iter([CandidateStep { steps: infcx.tcx.arena.alloc_from_iter([CandidateStep {
self_ty: self.make_query_response_ignoring_pending_obligations( self_ty: self.make_query_response_ignoring_pending_obligations(

View file

@ -17,7 +17,8 @@ use tracing::debug;
use crate::infer::InferCtxt; use crate::infer::InferCtxt;
use crate::infer::canonical::{ use crate::infer::canonical::{
Canonical, CanonicalTyVarKind, CanonicalVarInfo, CanonicalVarKind, OriginalQueryValues, Canonical, CanonicalQueryInput, CanonicalTyVarKind, CanonicalVarInfo, CanonicalVarKind,
OriginalQueryValues,
}; };
impl<'tcx> InferCtxt<'tcx> { impl<'tcx> InferCtxt<'tcx> {
@ -40,12 +41,12 @@ impl<'tcx> InferCtxt<'tcx> {
&self, &self,
value: ty::ParamEnvAnd<'tcx, V>, value: ty::ParamEnvAnd<'tcx, V>,
query_state: &mut OriginalQueryValues<'tcx>, query_state: &mut OriginalQueryValues<'tcx>,
) -> Canonical<'tcx, ty::ParamEnvAnd<'tcx, V>> ) -> CanonicalQueryInput<'tcx, ty::ParamEnvAnd<'tcx, V>>
where where
V: TypeFoldable<TyCtxt<'tcx>>, V: TypeFoldable<TyCtxt<'tcx>>,
{ {
let (param_env, value) = value.into_parts(); let (param_env, value) = value.into_parts();
let mut param_env = self.tcx.canonical_param_env_cache.get_or_insert( let param_env = self.tcx.canonical_param_env_cache.get_or_insert(
self.tcx, self.tcx,
param_env, param_env,
query_state, query_state,
@ -62,9 +63,7 @@ impl<'tcx> InferCtxt<'tcx> {
}, },
); );
param_env.defining_opaque_types = self.defining_opaque_types; let canonical = Canonicalizer::canonicalize_with_base(
Canonicalizer::canonicalize_with_base(
param_env, param_env,
value, value,
Some(self), Some(self),
@ -72,7 +71,8 @@ impl<'tcx> InferCtxt<'tcx> {
&CanonicalizeAllFreeRegions, &CanonicalizeAllFreeRegions,
query_state, query_state,
) )
.unchecked_map(|(param_env, value)| param_env.and(value)) .unchecked_map(|(param_env, value)| param_env.and(value));
CanonicalQueryInput { canonical, defining_opaque_types: self.defining_opaque_types() }
} }
/// Canonicalizes a query *response* `V`. When we canonicalize a /// Canonicalizes a query *response* `V`. When we canonicalize a
@ -544,7 +544,6 @@ impl<'cx, 'tcx> Canonicalizer<'cx, 'tcx> {
max_universe: ty::UniverseIndex::ROOT, max_universe: ty::UniverseIndex::ROOT,
variables: List::empty(), variables: List::empty(),
value: (), value: (),
defining_opaque_types: infcx.map(|i| i.defining_opaque_types).unwrap_or_default(),
}; };
Canonicalizer::canonicalize_with_base( Canonicalizer::canonicalize_with_base(
base, base,
@ -614,15 +613,7 @@ impl<'cx, 'tcx> Canonicalizer<'cx, 'tcx> {
.max() .max()
.unwrap_or(ty::UniverseIndex::ROOT); .unwrap_or(ty::UniverseIndex::ROOT);
assert!( Canonical { max_universe, variables: canonical_variables, value: (base.value, out_value) }
!infcx.is_some_and(|infcx| infcx.defining_opaque_types != base.defining_opaque_types)
);
Canonical {
max_universe,
variables: canonical_variables,
value: (base.value, out_value),
defining_opaque_types: base.defining_opaque_types,
}
} }
/// Creates a canonical variable replacing `kind` from the input, /// Creates a canonical variable replacing `kind` from the input,

View file

@ -25,7 +25,7 @@ use rustc_hir as hir;
use rustc_hir::def_id::{DefId, LocalDefId}; use rustc_hir::def_id::{DefId, LocalDefId};
use rustc_macros::extension; use rustc_macros::extension;
pub use rustc_macros::{TypeFoldable, TypeVisitable}; pub use rustc_macros::{TypeFoldable, TypeVisitable};
use rustc_middle::infer::canonical::{Canonical, CanonicalVarValues}; use rustc_middle::infer::canonical::{CanonicalQueryInput, CanonicalVarValues};
use rustc_middle::infer::unify_key::{ use rustc_middle::infer::unify_key::{
ConstVariableOrigin, ConstVariableValue, ConstVidKey, EffectVarValue, EffectVidKey, ConstVariableOrigin, ConstVariableValue, ConstVidKey, EffectVarValue, EffectVidKey,
}; };
@ -606,14 +606,14 @@ impl<'tcx> InferCtxtBuilder<'tcx> {
pub fn build_with_canonical<T>( pub fn build_with_canonical<T>(
mut self, mut self,
span: Span, span: Span,
canonical: &Canonical<'tcx, T>, input: &CanonicalQueryInput<'tcx, T>,
) -> (InferCtxt<'tcx>, T, CanonicalVarValues<'tcx>) ) -> (InferCtxt<'tcx>, T, CanonicalVarValues<'tcx>)
where where
T: TypeFoldable<TyCtxt<'tcx>>, T: TypeFoldable<TyCtxt<'tcx>>,
{ {
self.defining_opaque_types = canonical.defining_opaque_types; self.defining_opaque_types = input.defining_opaque_types;
let infcx = self.build(); let infcx = self.build();
let (value, args) = infcx.instantiate_canonical(span, canonical); let (value, args) = infcx.instantiate_canonical(span, &input.canonical);
(infcx, value, args) (infcx, value, args)
} }

View file

@ -34,6 +34,7 @@ use crate::infer::MemberConstraint;
use crate::mir::ConstraintCategory; use crate::mir::ConstraintCategory;
use crate::ty::{self, GenericArg, List, Ty, TyCtxt, TypeFlags, TypeVisitableExt}; use crate::ty::{self, GenericArg, List, Ty, TyCtxt, TypeFlags, TypeVisitableExt};
pub type CanonicalQueryInput<'tcx, V> = ir::CanonicalQueryInput<TyCtxt<'tcx>, V>;
pub type Canonical<'tcx, V> = ir::Canonical<TyCtxt<'tcx>, V>; pub type Canonical<'tcx, V> = ir::Canonical<TyCtxt<'tcx>, V>;
pub type CanonicalVarInfo<'tcx> = ir::CanonicalVarInfo<TyCtxt<'tcx>>; pub type CanonicalVarInfo<'tcx> = ir::CanonicalVarInfo<TyCtxt<'tcx>>;
pub type CanonicalVarValues<'tcx> = ir::CanonicalVarValues<TyCtxt<'tcx>>; pub type CanonicalVarValues<'tcx> = ir::CanonicalVarValues<TyCtxt<'tcx>>;
@ -182,7 +183,6 @@ impl<'tcx> CanonicalParamEnvCache<'tcx> {
max_universe: ty::UniverseIndex::ROOT, max_universe: ty::UniverseIndex::ROOT,
variables: List::empty(), variables: List::empty(),
value: key, value: key,
defining_opaque_types: ty::List::empty(),
}; };
} }

View file

@ -7,7 +7,7 @@ use rustc_span::symbol::{Ident, Symbol};
use rustc_span::{DUMMY_SP, Span}; use rustc_span::{DUMMY_SP, Span};
use rustc_target::abi; use rustc_target::abi;
use crate::infer::canonical::Canonical; use crate::infer::canonical::CanonicalQueryInput;
use crate::ty::fast_reject::SimplifiedType; use crate::ty::fast_reject::SimplifiedType;
use crate::ty::layout::{TyAndLayout, ValidityRequirement}; use crate::ty::layout::{TyAndLayout, ValidityRequirement};
use crate::ty::{self, GenericArg, GenericArgsRef, Ty, TyCtxt}; use crate::ty::{self, GenericArg, GenericArgsRef, Ty, TyCtxt};
@ -485,7 +485,7 @@ impl Key for Option<Symbol> {
/// Canonical query goals correspond to abstract trait operations that /// Canonical query goals correspond to abstract trait operations that
/// are not tied to any crate in particular. /// are not tied to any crate in particular.
impl<'tcx, T: Clone> Key for Canonical<'tcx, T> { impl<'tcx, T: Clone> Key for CanonicalQueryInput<'tcx, T> {
type Cache<V> = DefaultCache<Self, V>; type Cache<V> = DefaultCache<Self, V>;
fn default_span(&self, _tcx: TyCtxt<'_>) -> Span { fn default_span(&self, _tcx: TyCtxt<'_>) -> Span {

View file

@ -65,10 +65,11 @@ use crate::query::plumbing::{
CyclePlaceholder, DynamicQuery, query_ensure, query_ensure_error_guaranteed, query_get_at, CyclePlaceholder, DynamicQuery, query_ensure, query_ensure_error_guaranteed, query_get_at,
}; };
use crate::traits::query::{ use crate::traits::query::{
CanonicalAliasGoal, CanonicalPredicateGoal, CanonicalTyGoal, CanonicalAliasGoal, CanonicalDropckOutlivesGoal, CanonicalImpliedOutlivesBoundsGoal,
CanonicalTypeOpAscribeUserTypeGoal, CanonicalTypeOpNormalizeGoal, CanonicalPredicateGoal, CanonicalTyGoal, CanonicalTypeOpAscribeUserTypeGoal,
CanonicalTypeOpProvePredicateGoal, DropckConstraint, DropckOutlivesResult, CanonicalTypeOpNormalizeGoal, CanonicalTypeOpProvePredicateGoal, DropckConstraint,
MethodAutoderefStepsResult, NoSolution, NormalizationResult, OutlivesBound, DropckOutlivesResult, MethodAutoderefStepsResult, NoSolution, NormalizationResult,
OutlivesBound,
}; };
use crate::traits::{ use crate::traits::{
CodegenObligationError, DynCompatibilityViolation, EvaluationResult, ImplSource, CodegenObligationError, DynCompatibilityViolation, EvaluationResult, ImplSource,
@ -2010,7 +2011,7 @@ rustc_queries! {
&'tcx Canonical<'tcx, canonical::QueryResponse<'tcx, NormalizationResult<'tcx>>>, &'tcx Canonical<'tcx, canonical::QueryResponse<'tcx, NormalizationResult<'tcx>>>,
NoSolution, NoSolution,
> { > {
desc { "normalizing `{}`", goal.value.value } desc { "normalizing `{}`", goal.canonical.value.value }
} }
/// <div class="warning"> /// <div class="warning">
@ -2024,7 +2025,7 @@ rustc_queries! {
&'tcx Canonical<'tcx, canonical::QueryResponse<'tcx, NormalizationResult<'tcx>>>, &'tcx Canonical<'tcx, canonical::QueryResponse<'tcx, NormalizationResult<'tcx>>>,
NoSolution, NoSolution,
> { > {
desc { "normalizing `{}`", goal.value.value } desc { "normalizing `{}`", goal.canonical.value.value }
} }
/// <div class="warning"> /// <div class="warning">
@ -2038,7 +2039,7 @@ rustc_queries! {
&'tcx Canonical<'tcx, canonical::QueryResponse<'tcx, NormalizationResult<'tcx>>>, &'tcx Canonical<'tcx, canonical::QueryResponse<'tcx, NormalizationResult<'tcx>>>,
NoSolution, NoSolution,
> { > {
desc { "normalizing `{}`", goal.value.value } desc { "normalizing `{}`", goal.canonical.value.value }
} }
/// Do not call this query directly: invoke `try_normalize_erasing_regions` instead. /// Do not call this query directly: invoke `try_normalize_erasing_regions` instead.
@ -2049,32 +2050,32 @@ rustc_queries! {
} }
query implied_outlives_bounds_compat( query implied_outlives_bounds_compat(
goal: CanonicalTyGoal<'tcx> goal: CanonicalImpliedOutlivesBoundsGoal<'tcx>
) -> Result< ) -> Result<
&'tcx Canonical<'tcx, canonical::QueryResponse<'tcx, Vec<OutlivesBound<'tcx>>>>, &'tcx Canonical<'tcx, canonical::QueryResponse<'tcx, Vec<OutlivesBound<'tcx>>>>,
NoSolution, NoSolution,
> { > {
desc { "computing implied outlives bounds for `{}`", goal.value.value } desc { "computing implied outlives bounds for `{}`", goal.canonical.value.value.ty }
} }
query implied_outlives_bounds( query implied_outlives_bounds(
goal: CanonicalTyGoal<'tcx> goal: CanonicalImpliedOutlivesBoundsGoal<'tcx>
) -> Result< ) -> Result<
&'tcx Canonical<'tcx, canonical::QueryResponse<'tcx, Vec<OutlivesBound<'tcx>>>>, &'tcx Canonical<'tcx, canonical::QueryResponse<'tcx, Vec<OutlivesBound<'tcx>>>>,
NoSolution, NoSolution,
> { > {
desc { "computing implied outlives bounds v2 for `{}`", goal.value.value } desc { "computing implied outlives bounds v2 for `{}`", goal.canonical.value.value.ty }
} }
/// Do not call this query directly: /// Do not call this query directly:
/// invoke `DropckOutlives::new(dropped_ty)).fully_perform(typeck.infcx)` instead. /// invoke `DropckOutlives::new(dropped_ty)).fully_perform(typeck.infcx)` instead.
query dropck_outlives( query dropck_outlives(
goal: CanonicalTyGoal<'tcx> goal: CanonicalDropckOutlivesGoal<'tcx>
) -> Result< ) -> Result<
&'tcx Canonical<'tcx, canonical::QueryResponse<'tcx, DropckOutlivesResult<'tcx>>>, &'tcx Canonical<'tcx, canonical::QueryResponse<'tcx, DropckOutlivesResult<'tcx>>>,
NoSolution, NoSolution,
> { > {
desc { "computing dropck types for `{}`", goal.value.value } desc { "computing dropck types for `{}`", goal.canonical.value.value.dropped_ty }
} }
/// Do not call this query directly: invoke `infcx.predicate_may_hold()` or /// Do not call this query directly: invoke `infcx.predicate_may_hold()` or
@ -2082,7 +2083,7 @@ rustc_queries! {
query evaluate_obligation( query evaluate_obligation(
goal: CanonicalPredicateGoal<'tcx> goal: CanonicalPredicateGoal<'tcx>
) -> Result<EvaluationResult, OverflowError> { ) -> Result<EvaluationResult, OverflowError> {
desc { "evaluating trait selection obligation `{}`", goal.value.value } desc { "evaluating trait selection obligation `{}`", goal.canonical.value.value }
} }
/// Do not call this query directly: part of the `Eq` type-op /// Do not call this query directly: part of the `Eq` type-op
@ -2092,7 +2093,7 @@ rustc_queries! {
&'tcx Canonical<'tcx, canonical::QueryResponse<'tcx, ()>>, &'tcx Canonical<'tcx, canonical::QueryResponse<'tcx, ()>>,
NoSolution, NoSolution,
> { > {
desc { "evaluating `type_op_ascribe_user_type` `{:?}`", goal.value.value } desc { "evaluating `type_op_ascribe_user_type` `{:?}`", goal.canonical.value.value }
} }
/// Do not call this query directly: part of the `ProvePredicate` type-op /// Do not call this query directly: part of the `ProvePredicate` type-op
@ -2102,7 +2103,7 @@ rustc_queries! {
&'tcx Canonical<'tcx, canonical::QueryResponse<'tcx, ()>>, &'tcx Canonical<'tcx, canonical::QueryResponse<'tcx, ()>>,
NoSolution, NoSolution,
> { > {
desc { "evaluating `type_op_prove_predicate` `{:?}`", goal.value.value } desc { "evaluating `type_op_prove_predicate` `{:?}`", goal.canonical.value.value }
} }
/// Do not call this query directly: part of the `Normalize` type-op /// Do not call this query directly: part of the `Normalize` type-op
@ -2112,7 +2113,7 @@ rustc_queries! {
&'tcx Canonical<'tcx, canonical::QueryResponse<'tcx, Ty<'tcx>>>, &'tcx Canonical<'tcx, canonical::QueryResponse<'tcx, Ty<'tcx>>>,
NoSolution, NoSolution,
> { > {
desc { "normalizing `{}`", goal.value.value.value } desc { "normalizing `{}`", goal.canonical.value.value.value }
} }
/// Do not call this query directly: part of the `Normalize` type-op /// Do not call this query directly: part of the `Normalize` type-op
@ -2122,7 +2123,7 @@ rustc_queries! {
&'tcx Canonical<'tcx, canonical::QueryResponse<'tcx, ty::Clause<'tcx>>>, &'tcx Canonical<'tcx, canonical::QueryResponse<'tcx, ty::Clause<'tcx>>>,
NoSolution, NoSolution,
> { > {
desc { "normalizing `{:?}`", goal.value.value.value } desc { "normalizing `{:?}`", goal.canonical.value.value.value }
} }
/// Do not call this query directly: part of the `Normalize` type-op /// Do not call this query directly: part of the `Normalize` type-op
@ -2132,7 +2133,7 @@ rustc_queries! {
&'tcx Canonical<'tcx, canonical::QueryResponse<'tcx, ty::PolyFnSig<'tcx>>>, &'tcx Canonical<'tcx, canonical::QueryResponse<'tcx, ty::PolyFnSig<'tcx>>>,
NoSolution, NoSolution,
> { > {
desc { "normalizing `{:?}`", goal.value.value.value } desc { "normalizing `{:?}`", goal.canonical.value.value.value }
} }
/// Do not call this query directly: part of the `Normalize` type-op /// Do not call this query directly: part of the `Normalize` type-op
@ -2142,7 +2143,7 @@ rustc_queries! {
&'tcx Canonical<'tcx, canonical::QueryResponse<'tcx, ty::FnSig<'tcx>>>, &'tcx Canonical<'tcx, canonical::QueryResponse<'tcx, ty::FnSig<'tcx>>>,
NoSolution, NoSolution,
> { > {
desc { "normalizing `{:?}`", goal.value.value.value } desc { "normalizing `{:?}`", goal.canonical.value.value.value }
} }
query instantiate_and_check_impossible_predicates(key: (DefId, GenericArgsRef<'tcx>)) -> bool { query instantiate_and_check_impossible_predicates(key: (DefId, GenericArgsRef<'tcx>)) -> bool {
@ -2163,7 +2164,7 @@ rustc_queries! {
query method_autoderef_steps( query method_autoderef_steps(
goal: CanonicalTyGoal<'tcx> goal: CanonicalTyGoal<'tcx>
) -> MethodAutoderefStepsResult<'tcx> { ) -> MethodAutoderefStepsResult<'tcx> {
desc { "computing autoderef types for `{}`", goal.value.value } desc { "computing autoderef types for `{}`", goal.canonical.value.value }
} }
query supported_target_features(_: CrateNum) -> &'tcx UnordMap<String, Option<Symbol>> { query supported_target_features(_: CrateNum) -> &'tcx UnordMap<String, Option<Symbol>> {

View file

@ -11,16 +11,13 @@ use rustc_span::Span;
pub use rustc_type_ir::solve::NoSolution; pub use rustc_type_ir::solve::NoSolution;
use crate::error::DropCheckOverflow; use crate::error::DropCheckOverflow;
use crate::infer::canonical::{Canonical, QueryResponse}; use crate::infer::canonical::{Canonical, CanonicalQueryInput, QueryResponse};
use crate::ty::{self, GenericArg, Ty, TyCtxt}; use crate::ty::{self, GenericArg, Ty, TyCtxt};
pub mod type_op { pub mod type_op {
use std::fmt;
use rustc_macros::{HashStable, TypeFoldable, TypeVisitable}; use rustc_macros::{HashStable, TypeFoldable, TypeVisitable};
use crate::ty::fold::TypeFoldable; use crate::ty::{Predicate, Ty, UserType};
use crate::ty::{Predicate, Ty, TyCtxt, UserType};
#[derive(Copy, Clone, Debug, Hash, PartialEq, Eq, HashStable, TypeFoldable, TypeVisitable)] #[derive(Copy, Clone, Debug, Hash, PartialEq, Eq, HashStable, TypeFoldable, TypeVisitable)]
pub struct AscribeUserType<'tcx> { pub struct AscribeUserType<'tcx> {
@ -28,12 +25,6 @@ pub mod type_op {
pub user_ty: UserType<'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)] #[derive(Copy, Clone, Debug, Hash, PartialEq, Eq, HashStable, TypeFoldable, TypeVisitable)]
pub struct Eq<'tcx> { pub struct Eq<'tcx> {
pub a: Ty<'tcx>, pub a: Ty<'tcx>,
@ -51,46 +42,50 @@ pub mod type_op {
pub predicate: Predicate<'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)] #[derive(Copy, Clone, Debug, Hash, PartialEq, Eq, HashStable, TypeFoldable, TypeVisitable)]
pub struct Normalize<T> { pub struct Normalize<T> {
pub value: T, pub value: T,
} }
impl<'tcx, T> Normalize<T> #[derive(Copy, Clone, Debug, Hash, PartialEq, Eq, HashStable, TypeFoldable, TypeVisitable)]
where pub struct ImpliedOutlivesBounds<'tcx> {
T: fmt::Debug + TypeFoldable<TyCtxt<'tcx>>, pub ty: Ty<'tcx>,
{ }
pub fn new(value: T) -> Self {
Self { value } #[derive(Copy, Clone, Debug, Hash, PartialEq, Eq, HashStable, TypeFoldable, TypeVisitable)]
} pub struct DropckOutlives<'tcx> {
pub dropped_ty: Ty<'tcx>,
} }
} }
pub type CanonicalAliasGoal<'tcx> = Canonical<'tcx, ty::ParamEnvAnd<'tcx, ty::AliasTy<'tcx>>>; pub type CanonicalAliasGoal<'tcx> =
CanonicalQueryInput<'tcx, ty::ParamEnvAnd<'tcx, ty::AliasTy<'tcx>>>;
pub type CanonicalTyGoal<'tcx> = Canonical<'tcx, ty::ParamEnvAnd<'tcx, Ty<'tcx>>>; pub type CanonicalTyGoal<'tcx> = CanonicalQueryInput<'tcx, ty::ParamEnvAnd<'tcx, Ty<'tcx>>>;
pub type CanonicalPredicateGoal<'tcx> = Canonical<'tcx, ty::ParamEnvAnd<'tcx, ty::Predicate<'tcx>>>; pub type CanonicalPredicateGoal<'tcx> =
CanonicalQueryInput<'tcx, ty::ParamEnvAnd<'tcx, ty::Predicate<'tcx>>>;
pub type CanonicalTypeOpAscribeUserTypeGoal<'tcx> = pub type CanonicalTypeOpAscribeUserTypeGoal<'tcx> =
Canonical<'tcx, ty::ParamEnvAnd<'tcx, type_op::AscribeUserType<'tcx>>>; CanonicalQueryInput<'tcx, ty::ParamEnvAnd<'tcx, type_op::AscribeUserType<'tcx>>>;
pub type CanonicalTypeOpEqGoal<'tcx> = Canonical<'tcx, ty::ParamEnvAnd<'tcx, type_op::Eq<'tcx>>>; pub type CanonicalTypeOpEqGoal<'tcx> =
CanonicalQueryInput<'tcx, ty::ParamEnvAnd<'tcx, type_op::Eq<'tcx>>>;
pub type CanonicalTypeOpSubtypeGoal<'tcx> = pub type CanonicalTypeOpSubtypeGoal<'tcx> =
Canonical<'tcx, ty::ParamEnvAnd<'tcx, type_op::Subtype<'tcx>>>; CanonicalQueryInput<'tcx, ty::ParamEnvAnd<'tcx, type_op::Subtype<'tcx>>>;
pub type CanonicalTypeOpProvePredicateGoal<'tcx> = pub type CanonicalTypeOpProvePredicateGoal<'tcx> =
Canonical<'tcx, ty::ParamEnvAnd<'tcx, type_op::ProvePredicate<'tcx>>>; CanonicalQueryInput<'tcx, ty::ParamEnvAnd<'tcx, type_op::ProvePredicate<'tcx>>>;
pub type CanonicalTypeOpNormalizeGoal<'tcx, T> = pub type CanonicalTypeOpNormalizeGoal<'tcx, T> =
Canonical<'tcx, ty::ParamEnvAnd<'tcx, type_op::Normalize<T>>>; CanonicalQueryInput<'tcx, ty::ParamEnvAnd<'tcx, type_op::Normalize<T>>>;
pub type CanonicalImpliedOutlivesBoundsGoal<'tcx> =
CanonicalQueryInput<'tcx, ty::ParamEnvAnd<'tcx, type_op::ImpliedOutlivesBounds<'tcx>>>;
pub type CanonicalDropckOutlivesGoal<'tcx> =
CanonicalQueryInput<'tcx, ty::ParamEnvAnd<'tcx, type_op::DropckOutlives<'tcx>>>;
#[derive(Clone, Debug, Default, HashStable, TypeFoldable, TypeVisitable)] #[derive(Clone, Debug, Default, HashStable, TypeFoldable, TypeVisitable)]
pub struct DropckOutlivesResult<'tcx> { pub struct DropckOutlivesResult<'tcx> {

View file

@ -83,8 +83,7 @@ impl<'a, D: SolverDelegate<Interner = I>, I: Interner> Canonicalizer<'a, D, I> {
let (max_universe, variables) = canonicalizer.finalize(); let (max_universe, variables) = canonicalizer.finalize();
let defining_opaque_types = delegate.defining_opaque_types(); Canonical { max_universe, variables, value }
Canonical { defining_opaque_types, max_universe, variables, value }
} }
fn get_or_insert_bound_var( fn get_or_insert_bound_var(

View file

@ -17,7 +17,7 @@ pub trait SolverDelegate:
fn build_with_canonical<V>( fn build_with_canonical<V>(
cx: Self::Interner, cx: Self::Interner,
solver_mode: SolverMode, solver_mode: SolverMode,
canonical: &ty::Canonical<Self::Interner, V>, canonical: &ty::CanonicalQueryInput<Self::Interner, V>,
) -> (Self, V, ty::CanonicalVarValues<Self::Interner>) ) -> (Self, V, ty::CanonicalVarValues<Self::Interner>)
where where
V: TypeFoldable<Self::Interner>; V: TypeFoldable<Self::Interner>;

View file

@ -60,7 +60,7 @@ where
(goal, opaque_types).fold_with(&mut EagerResolver::new(self.delegate)); (goal, opaque_types).fold_with(&mut EagerResolver::new(self.delegate));
let mut orig_values = Default::default(); let mut orig_values = Default::default();
let canonical_goal = Canonicalizer::canonicalize( let canonical = Canonicalizer::canonicalize(
self.delegate, self.delegate,
CanonicalizeMode::Input, CanonicalizeMode::Input,
&mut orig_values, &mut orig_values,
@ -71,7 +71,11 @@ where
.mk_predefined_opaques_in_body(PredefinedOpaquesData { opaque_types }), .mk_predefined_opaques_in_body(PredefinedOpaquesData { opaque_types }),
}, },
); );
(orig_values, canonical_goal) let query_input = ty::CanonicalQueryInput {
canonical,
defining_opaque_types: self.delegate.defining_opaque_types(),
};
(orig_values, query_input)
} }
/// To return the constraints of a canonical query to the caller, we canonicalize: /// To return the constraints of a canonical query to the caller, we canonicalize:

View file

@ -283,11 +283,11 @@ where
let mut ecx = EvalCtxt { let mut ecx = EvalCtxt {
delegate, delegate,
variables: canonical_input.variables, variables: canonical_input.canonical.variables,
var_values, var_values,
is_normalizes_to_goal: false, is_normalizes_to_goal: false,
predefined_opaques_in_body: input.predefined_opaques_in_body, predefined_opaques_in_body: input.predefined_opaques_in_body,
max_input_universe: canonical_input.max_universe, max_input_universe: canonical_input.canonical.max_universe,
search_graph, search_graph,
nested_goals: NestedGoals::new(), nested_goals: NestedGoals::new(),
tainted: Ok(()), tainted: Ok(()),

View file

@ -313,6 +313,5 @@ fn response_no_constraints_raw<I: Interner>(
external_constraints: cx.mk_external_constraints(ExternalConstraintsData::default()), external_constraints: cx.mk_external_constraints(ExternalConstraintsData::default()),
certainty, certainty,
}, },
defining_opaque_types: Default::default(),
} }
} }

View file

@ -96,14 +96,19 @@ where
} }
fn step_is_coinductive(cx: I, input: CanonicalInput<I>) -> bool { fn step_is_coinductive(cx: I, input: CanonicalInput<I>) -> bool {
input.value.goal.predicate.is_coinductive(cx) input.canonical.value.goal.predicate.is_coinductive(cx)
} }
} }
fn response_no_constraints<I: Interner>( fn response_no_constraints<I: Interner>(
cx: I, cx: I,
goal: CanonicalInput<I>, input: CanonicalInput<I>,
certainty: Certainty, certainty: Certainty,
) -> QueryResult<I> { ) -> QueryResult<I> {
Ok(super::response_no_constraints_raw(cx, goal.max_universe, goal.variables, certainty)) Ok(super::response_no_constraints_raw(
cx,
input.canonical.max_universe,
input.canonical.variables,
certainty,
))
} }

View file

@ -5,7 +5,9 @@ use rustc_hir::lang_items::LangItem;
pub use rustc_infer::infer::*; pub use rustc_infer::infer::*;
use rustc_macros::extension; use rustc_macros::extension;
use rustc_middle::arena::ArenaAllocatable; use rustc_middle::arena::ArenaAllocatable;
use rustc_middle::infer::canonical::{Canonical, CanonicalQueryResponse, QueryResponse}; use rustc_middle::infer::canonical::{
Canonical, CanonicalQueryInput, CanonicalQueryResponse, QueryResponse,
};
use rustc_middle::traits::query::NoSolution; use rustc_middle::traits::query::NoSolution;
use rustc_middle::ty::{self, GenericArg, Ty, TyCtxt, TypeFoldable, TypeVisitableExt, Upcast}; use rustc_middle::ty::{self, GenericArg, Ty, TyCtxt, TypeFoldable, TypeVisitableExt, Upcast};
use rustc_span::DUMMY_SP; use rustc_span::DUMMY_SP;
@ -132,7 +134,7 @@ impl<'tcx> InferCtxtBuilder<'tcx> {
/// `K: TypeFoldable<TyCtxt<'tcx>>`.) /// `K: TypeFoldable<TyCtxt<'tcx>>`.)
fn enter_canonical_trait_query<K, R>( fn enter_canonical_trait_query<K, R>(
self, self,
canonical_key: &Canonical<'tcx, K>, canonical_key: &CanonicalQueryInput<'tcx, K>,
operation: impl FnOnce(&ObligationCtxt<'_, 'tcx>, K) -> Result<R, NoSolution>, operation: impl FnOnce(&ObligationCtxt<'_, 'tcx>, K) -> Result<R, NoSolution>,
) -> Result<CanonicalQueryResponse<'tcx, R>, NoSolution> ) -> Result<CanonicalQueryResponse<'tcx, R>, NoSolution>
where where

View file

@ -4,7 +4,7 @@ use rustc_data_structures::fx::FxHashSet;
use rustc_hir::def_id::DefId; use rustc_hir::def_id::DefId;
use rustc_infer::infer::canonical::query_response::make_query_region_constraints; use rustc_infer::infer::canonical::query_response::make_query_region_constraints;
use rustc_infer::infer::canonical::{ use rustc_infer::infer::canonical::{
Canonical, CanonicalExt as _, CanonicalVarInfo, CanonicalVarValues, Canonical, CanonicalExt as _, CanonicalQueryInput, CanonicalVarInfo, CanonicalVarValues,
}; };
use rustc_infer::infer::{InferCtxt, RegionVariableOrigin, TyCtxtInferExt}; use rustc_infer::infer::{InferCtxt, RegionVariableOrigin, TyCtxtInferExt};
use rustc_infer::traits::solve::Goal; use rustc_infer::traits::solve::Goal;
@ -47,7 +47,7 @@ impl<'tcx> rustc_next_trait_solver::delegate::SolverDelegate for SolverDelegate<
fn build_with_canonical<V>( fn build_with_canonical<V>(
interner: TyCtxt<'tcx>, interner: TyCtxt<'tcx>,
solver_mode: SolverMode, solver_mode: SolverMode,
canonical: &Canonical<'tcx, V>, canonical: &CanonicalQueryInput<'tcx, V>,
) -> (Self, V, CanonicalVarValues<'tcx>) ) -> (Self, V, CanonicalVarValues<'tcx>)
where where
V: TypeFoldable<TyCtxt<'tcx>>, V: TypeFoldable<TyCtxt<'tcx>>,

View file

@ -1,6 +1,7 @@
use rustc_data_structures::fx::FxIndexSet; use rustc_data_structures::fx::FxIndexSet;
use rustc_infer::infer::InferOk; use rustc_infer::infer::InferOk;
use rustc_infer::infer::resolve::OpportunisticRegionResolver; use rustc_infer::infer::resolve::OpportunisticRegionResolver;
use rustc_infer::traits::query::type_op::ImpliedOutlivesBounds;
use rustc_macros::extension; use rustc_macros::extension;
use rustc_middle::infer::canonical::{OriginalQueryValues, QueryRegionConstraints}; use rustc_middle::infer::canonical::{OriginalQueryValues, QueryRegionConstraints};
use rustc_middle::span_bug; use rustc_middle::span_bug;
@ -54,11 +55,12 @@ fn implied_outlives_bounds<'a, 'tcx>(
assert!(!ty.has_non_region_infer()); assert!(!ty.has_non_region_infer());
let mut canonical_var_values = OriginalQueryValues::default(); let mut canonical_var_values = OriginalQueryValues::default();
let canonical_ty = infcx.canonicalize_query(param_env.and(ty), &mut canonical_var_values); let input = ImpliedOutlivesBounds { ty };
let canonical = infcx.canonicalize_query(param_env.and(input), &mut canonical_var_values);
let implied_bounds_result = if compat { let implied_bounds_result = if compat {
infcx.tcx.implied_outlives_bounds_compat(canonical_ty) infcx.tcx.implied_outlives_bounds_compat(canonical)
} else { } else {
infcx.tcx.implied_outlives_bounds(canonical_ty) infcx.tcx.implied_outlives_bounds(canonical)
}; };
let Ok(canonical_result) = implied_bounds_result else { let Ok(canonical_result) = implied_bounds_result else {
return vec![]; return vec![];

View file

@ -1,4 +1,5 @@
use rustc_data_structures::fx::FxHashSet; use rustc_data_structures::fx::FxHashSet;
use rustc_infer::traits::query::type_op::DropckOutlives;
use rustc_middle::traits::query::{DropckConstraint, DropckOutlivesResult}; use rustc_middle::traits::query::{DropckConstraint, DropckOutlivesResult};
use rustc_middle::ty::{self, EarlyBinder, ParamEnvAnd, Ty, TyCtxt}; use rustc_middle::ty::{self, EarlyBinder, ParamEnvAnd, Ty, TyCtxt};
use rustc_span::{DUMMY_SP, Span}; use rustc_span::{DUMMY_SP, Span};
@ -88,10 +89,10 @@ pub fn trivial_dropck_outlives<'tcx>(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>) -> bool {
pub fn compute_dropck_outlives_inner<'tcx>( pub fn compute_dropck_outlives_inner<'tcx>(
ocx: &ObligationCtxt<'_, 'tcx>, ocx: &ObligationCtxt<'_, 'tcx>,
goal: ParamEnvAnd<'tcx, Ty<'tcx>>, goal: ParamEnvAnd<'tcx, DropckOutlives<'tcx>>,
) -> Result<DropckOutlivesResult<'tcx>, NoSolution> { ) -> Result<DropckOutlivesResult<'tcx>, NoSolution> {
let tcx = ocx.infcx.tcx; let tcx = ocx.infcx.tcx;
let ParamEnvAnd { param_env, value: for_ty } = goal; let ParamEnvAnd { param_env, value: DropckOutlives { dropped_ty } } = goal;
let mut result = DropckOutlivesResult { kinds: vec![], overflows: vec![] }; let mut result = DropckOutlivesResult { kinds: vec![], overflows: vec![] };
@ -99,7 +100,7 @@ pub fn compute_dropck_outlives_inner<'tcx>(
// something from the stack and invoke // something from the stack and invoke
// `dtorck_constraint_for_ty_inner`. This may produce new types that // `dtorck_constraint_for_ty_inner`. This may produce new types that
// have to be pushed on the stack. This continues until we have explored // have to be pushed on the stack. This continues until we have explored
// all the reachable types from the type `for_ty`. // all the reachable types from the type `dropped_ty`.
// //
// Example: Imagine that we have the following code: // Example: Imagine that we have the following code:
// //
@ -129,7 +130,7 @@ pub fn compute_dropck_outlives_inner<'tcx>(
// lead to us trying to push `A` a second time -- to prevent // lead to us trying to push `A` a second time -- to prevent
// infinite recursion, we notice that `A` was already pushed // infinite recursion, we notice that `A` was already pushed
// once and stop. // once and stop.
let mut ty_stack = vec![(for_ty, 0)]; let mut ty_stack = vec![(dropped_ty, 0)];
// Set used to detect infinite recursion. // Set used to detect infinite recursion.
let mut ty_set = FxHashSet::default(); let mut ty_set = FxHashSet::default();

View file

@ -7,7 +7,7 @@ use rustc_middle::ty::{self, ParamEnvAnd, Ty, TyCtxt, UserArgs, UserSelfTy, User
use rustc_span::{DUMMY_SP, Span}; use rustc_span::{DUMMY_SP, Span};
use tracing::{debug, instrument}; use tracing::{debug, instrument};
use crate::infer::canonical::{Canonical, CanonicalQueryResponse}; use crate::infer::canonical::{CanonicalQueryInput, CanonicalQueryResponse};
use crate::traits::ObligationCtxt; use crate::traits::ObligationCtxt;
impl<'tcx> super::QueryTypeOp<'tcx> for AscribeUserType<'tcx> { impl<'tcx> super::QueryTypeOp<'tcx> for AscribeUserType<'tcx> {
@ -22,7 +22,7 @@ impl<'tcx> super::QueryTypeOp<'tcx> for AscribeUserType<'tcx> {
fn perform_query( fn perform_query(
tcx: TyCtxt<'tcx>, tcx: TyCtxt<'tcx>,
canonicalized: Canonical<'tcx, ParamEnvAnd<'tcx, Self>>, canonicalized: CanonicalQueryInput<'tcx, ParamEnvAnd<'tcx, Self>>,
) -> Result<CanonicalQueryResponse<'tcx, ()>, NoSolution> { ) -> Result<CanonicalQueryResponse<'tcx, ()>, NoSolution> {
tcx.type_op_ascribe_user_type(canonicalized) tcx.type_op_ascribe_user_type(canonicalized)
} }

View file

@ -1,7 +1,7 @@
use rustc_infer::infer::canonical::Canonical; use rustc_infer::infer::canonical::CanonicalQueryInput;
use rustc_infer::infer::resolve::OpportunisticRegionResolver; use rustc_infer::infer::resolve::OpportunisticRegionResolver;
use rustc_infer::traits::query::OutlivesBound; use rustc_infer::traits::query::OutlivesBound;
use rustc_macros::{HashStable, TypeFoldable, TypeVisitable}; use rustc_infer::traits::query::type_op::ImpliedOutlivesBounds;
use rustc_middle::infer::canonical::CanonicalQueryResponse; use rustc_middle::infer::canonical::CanonicalQueryResponse;
use rustc_middle::traits::ObligationCause; use rustc_middle::traits::ObligationCause;
use rustc_middle::ty::{self, ParamEnvAnd, Ty, TyCtxt, TypeFolder, TypeVisitableExt}; use rustc_middle::ty::{self, ParamEnvAnd, Ty, TyCtxt, TypeFolder, TypeVisitableExt};
@ -14,11 +14,6 @@ use tracing::debug;
use crate::traits::query::NoSolution; use crate::traits::query::NoSolution;
use crate::traits::{ObligationCtxt, wf}; use crate::traits::{ObligationCtxt, wf};
#[derive(Copy, Clone, Debug, HashStable, TypeFoldable, TypeVisitable)]
pub struct ImpliedOutlivesBounds<'tcx> {
pub ty: Ty<'tcx>,
}
impl<'tcx> super::QueryTypeOp<'tcx> for ImpliedOutlivesBounds<'tcx> { impl<'tcx> super::QueryTypeOp<'tcx> for ImpliedOutlivesBounds<'tcx> {
type QueryResponse = Vec<OutlivesBound<'tcx>>; type QueryResponse = Vec<OutlivesBound<'tcx>>;
@ -38,16 +33,8 @@ impl<'tcx> super::QueryTypeOp<'tcx> for ImpliedOutlivesBounds<'tcx> {
fn perform_query( fn perform_query(
tcx: TyCtxt<'tcx>, tcx: TyCtxt<'tcx>,
canonicalized: Canonical<'tcx, ParamEnvAnd<'tcx, Self>>, canonicalized: CanonicalQueryInput<'tcx, ParamEnvAnd<'tcx, Self>>,
) -> Result<CanonicalQueryResponse<'tcx, Self::QueryResponse>, NoSolution> { ) -> Result<CanonicalQueryResponse<'tcx, Self::QueryResponse>, NoSolution> {
// FIXME this `unchecked_map` is only necessary because the
// query is defined as taking a `ParamEnvAnd<Ty>`; it should
// take an `ImpliedOutlivesBounds` instead
let canonicalized = canonicalized.unchecked_map(|ParamEnvAnd { param_env, value }| {
let ImpliedOutlivesBounds { ty } = value;
param_env.and(ty)
});
if tcx.sess.opts.unstable_opts.no_implied_bounds_compat { if tcx.sess.opts.unstable_opts.no_implied_bounds_compat {
tcx.implied_outlives_bounds(canonicalized) tcx.implied_outlives_bounds(canonicalized)
} else { } else {

View file

@ -1,7 +1,6 @@
use std::fmt; use std::fmt;
use rustc_errors::ErrorGuaranteed; use rustc_errors::ErrorGuaranteed;
use rustc_infer::infer::canonical::Certainty;
use rustc_infer::traits::PredicateObligations; use rustc_infer::traits::PredicateObligations;
use rustc_middle::traits::query::NoSolution; use rustc_middle::traits::query::NoSolution;
use rustc_middle::ty::fold::TypeFoldable; use rustc_middle::ty::fold::TypeFoldable;
@ -9,7 +8,8 @@ use rustc_middle::ty::{ParamEnvAnd, TyCtxt};
use rustc_span::Span; use rustc_span::Span;
use crate::infer::canonical::{ use crate::infer::canonical::{
Canonical, CanonicalQueryResponse, OriginalQueryValues, QueryRegionConstraints, CanonicalQueryInput, CanonicalQueryResponse, Certainty, OriginalQueryValues,
QueryRegionConstraints,
}; };
use crate::infer::{InferCtxt, InferOk}; use crate::infer::{InferCtxt, InferOk};
use crate::traits::{ObligationCause, ObligationCtxt}; use crate::traits::{ObligationCause, ObligationCtxt};
@ -80,7 +80,7 @@ pub trait QueryTypeOp<'tcx>: fmt::Debug + Copy + TypeFoldable<TyCtxt<'tcx>> + 't
/// not captured in the return value. /// not captured in the return value.
fn perform_query( fn perform_query(
tcx: TyCtxt<'tcx>, tcx: TyCtxt<'tcx>,
canonicalized: Canonical<'tcx, ParamEnvAnd<'tcx, Self>>, canonicalized: CanonicalQueryInput<'tcx, ParamEnvAnd<'tcx, Self>>,
) -> Result<CanonicalQueryResponse<'tcx, Self::QueryResponse>, NoSolution>; ) -> Result<CanonicalQueryResponse<'tcx, Self::QueryResponse>, NoSolution>;
/// In the new trait solver, we already do caching in the solver itself, /// In the new trait solver, we already do caching in the solver itself,
@ -102,7 +102,7 @@ pub trait QueryTypeOp<'tcx>: fmt::Debug + Copy + TypeFoldable<TyCtxt<'tcx>> + 't
) -> Result< ) -> Result<
( (
Self::QueryResponse, Self::QueryResponse,
Option<Canonical<'tcx, ParamEnvAnd<'tcx, Self>>>, Option<CanonicalQueryInput<'tcx, ParamEnvAnd<'tcx, Self>>>,
PredicateObligations<'tcx>, PredicateObligations<'tcx>,
Certainty, Certainty,
), ),
@ -135,7 +135,7 @@ where
Q: QueryTypeOp<'tcx>, Q: QueryTypeOp<'tcx>,
{ {
type Output = Q::QueryResponse; type Output = Q::QueryResponse;
type ErrorInfo = Canonical<'tcx, ParamEnvAnd<'tcx, Q>>; type ErrorInfo = CanonicalQueryInput<'tcx, ParamEnvAnd<'tcx, Q>>;
fn fully_perform( fn fully_perform(
self, self,

View file

@ -6,7 +6,7 @@ pub use rustc_middle::traits::query::type_op::Normalize;
use rustc_middle::ty::fold::TypeFoldable; use rustc_middle::ty::fold::TypeFoldable;
use rustc_middle::ty::{self, Lift, ParamEnvAnd, Ty, TyCtxt, TypeVisitableExt}; use rustc_middle::ty::{self, Lift, ParamEnvAnd, Ty, TyCtxt, TypeVisitableExt};
use crate::infer::canonical::{Canonical, CanonicalQueryResponse}; use crate::infer::canonical::{CanonicalQueryInput, CanonicalQueryResponse};
use crate::traits::ObligationCtxt; use crate::traits::ObligationCtxt;
impl<'tcx, T> super::QueryTypeOp<'tcx> for Normalize<T> impl<'tcx, T> super::QueryTypeOp<'tcx> for Normalize<T>
@ -21,7 +21,7 @@ where
fn perform_query( fn perform_query(
tcx: TyCtxt<'tcx>, tcx: TyCtxt<'tcx>,
canonicalized: Canonical<'tcx, ParamEnvAnd<'tcx, Self>>, canonicalized: CanonicalQueryInput<'tcx, ParamEnvAnd<'tcx, Self>>,
) -> Result<CanonicalQueryResponse<'tcx, Self::QueryResponse>, NoSolution> { ) -> Result<CanonicalQueryResponse<'tcx, Self::QueryResponse>, NoSolution> {
T::type_op_method(tcx, canonicalized) T::type_op_method(tcx, canonicalized)
} }
@ -40,14 +40,14 @@ pub trait Normalizable<'tcx>:
{ {
fn type_op_method( fn type_op_method(
tcx: TyCtxt<'tcx>, tcx: TyCtxt<'tcx>,
canonicalized: Canonical<'tcx, ParamEnvAnd<'tcx, Normalize<Self>>>, canonicalized: CanonicalQueryInput<'tcx, ParamEnvAnd<'tcx, Normalize<Self>>>,
) -> Result<CanonicalQueryResponse<'tcx, Self>, NoSolution>; ) -> Result<CanonicalQueryResponse<'tcx, Self>, NoSolution>;
} }
impl<'tcx> Normalizable<'tcx> for Ty<'tcx> { impl<'tcx> Normalizable<'tcx> for Ty<'tcx> {
fn type_op_method( fn type_op_method(
tcx: TyCtxt<'tcx>, tcx: TyCtxt<'tcx>,
canonicalized: Canonical<'tcx, ParamEnvAnd<'tcx, Normalize<Self>>>, canonicalized: CanonicalQueryInput<'tcx, ParamEnvAnd<'tcx, Normalize<Self>>>,
) -> Result<CanonicalQueryResponse<'tcx, Self>, NoSolution> { ) -> Result<CanonicalQueryResponse<'tcx, Self>, NoSolution> {
tcx.type_op_normalize_ty(canonicalized) tcx.type_op_normalize_ty(canonicalized)
} }
@ -56,7 +56,7 @@ impl<'tcx> Normalizable<'tcx> for Ty<'tcx> {
impl<'tcx> Normalizable<'tcx> for ty::Clause<'tcx> { impl<'tcx> Normalizable<'tcx> for ty::Clause<'tcx> {
fn type_op_method( fn type_op_method(
tcx: TyCtxt<'tcx>, tcx: TyCtxt<'tcx>,
canonicalized: Canonical<'tcx, ParamEnvAnd<'tcx, Normalize<Self>>>, canonicalized: CanonicalQueryInput<'tcx, ParamEnvAnd<'tcx, Normalize<Self>>>,
) -> Result<CanonicalQueryResponse<'tcx, Self>, NoSolution> { ) -> Result<CanonicalQueryResponse<'tcx, Self>, NoSolution> {
tcx.type_op_normalize_clause(canonicalized) tcx.type_op_normalize_clause(canonicalized)
} }
@ -65,7 +65,7 @@ impl<'tcx> Normalizable<'tcx> for ty::Clause<'tcx> {
impl<'tcx> Normalizable<'tcx> for ty::PolyFnSig<'tcx> { impl<'tcx> Normalizable<'tcx> for ty::PolyFnSig<'tcx> {
fn type_op_method( fn type_op_method(
tcx: TyCtxt<'tcx>, tcx: TyCtxt<'tcx>,
canonicalized: Canonical<'tcx, ParamEnvAnd<'tcx, Normalize<Self>>>, canonicalized: CanonicalQueryInput<'tcx, ParamEnvAnd<'tcx, Normalize<Self>>>,
) -> Result<CanonicalQueryResponse<'tcx, Self>, NoSolution> { ) -> Result<CanonicalQueryResponse<'tcx, Self>, NoSolution> {
tcx.type_op_normalize_poly_fn_sig(canonicalized) tcx.type_op_normalize_poly_fn_sig(canonicalized)
} }
@ -74,7 +74,7 @@ impl<'tcx> Normalizable<'tcx> for ty::PolyFnSig<'tcx> {
impl<'tcx> Normalizable<'tcx> for ty::FnSig<'tcx> { impl<'tcx> Normalizable<'tcx> for ty::FnSig<'tcx> {
fn type_op_method( fn type_op_method(
tcx: TyCtxt<'tcx>, tcx: TyCtxt<'tcx>,
canonicalized: Canonical<'tcx, ParamEnvAnd<'tcx, Normalize<Self>>>, canonicalized: CanonicalQueryInput<'tcx, ParamEnvAnd<'tcx, Normalize<Self>>>,
) -> Result<CanonicalQueryResponse<'tcx, Self>, NoSolution> { ) -> Result<CanonicalQueryResponse<'tcx, Self>, NoSolution> {
tcx.type_op_normalize_fn_sig(canonicalized) tcx.type_op_normalize_fn_sig(canonicalized)
} }

View file

@ -1,23 +1,12 @@
use rustc_macros::{HashStable, TypeFoldable, TypeVisitable};
use rustc_middle::traits::query::{DropckOutlivesResult, NoSolution}; use rustc_middle::traits::query::{DropckOutlivesResult, NoSolution};
use rustc_middle::ty::{ParamEnvAnd, Ty, TyCtxt}; use rustc_middle::ty::{ParamEnvAnd, TyCtxt};
use crate::infer::canonical::{Canonical, CanonicalQueryResponse}; use crate::infer::canonical::{CanonicalQueryInput, CanonicalQueryResponse};
use crate::traits::ObligationCtxt; use crate::traits::ObligationCtxt;
use crate::traits::query::dropck_outlives::{ use crate::traits::query::dropck_outlives::{
compute_dropck_outlives_inner, trivial_dropck_outlives, compute_dropck_outlives_inner, trivial_dropck_outlives,
}; };
use crate::traits::query::type_op::DropckOutlives;
#[derive(Copy, Clone, Debug, HashStable, TypeFoldable, TypeVisitable)]
pub struct DropckOutlives<'tcx> {
dropped_ty: Ty<'tcx>,
}
impl<'tcx> DropckOutlives<'tcx> {
pub fn new(dropped_ty: Ty<'tcx>) -> Self {
DropckOutlives { dropped_ty }
}
}
impl<'tcx> super::QueryTypeOp<'tcx> for DropckOutlives<'tcx> { impl<'tcx> super::QueryTypeOp<'tcx> for DropckOutlives<'tcx> {
type QueryResponse = DropckOutlivesResult<'tcx>; type QueryResponse = DropckOutlivesResult<'tcx>;
@ -31,16 +20,8 @@ impl<'tcx> super::QueryTypeOp<'tcx> for DropckOutlives<'tcx> {
fn perform_query( fn perform_query(
tcx: TyCtxt<'tcx>, tcx: TyCtxt<'tcx>,
canonicalized: Canonical<'tcx, ParamEnvAnd<'tcx, Self>>, canonicalized: CanonicalQueryInput<'tcx, ParamEnvAnd<'tcx, Self>>,
) -> Result<CanonicalQueryResponse<'tcx, Self::QueryResponse>, NoSolution> { ) -> Result<CanonicalQueryResponse<'tcx, Self::QueryResponse>, NoSolution> {
// FIXME convert to the type expected by the `dropck_outlives`
// query. This should eventually be fixed by changing the
// *underlying query*.
let canonicalized = canonicalized.unchecked_map(|ParamEnvAnd { param_env, value }| {
let DropckOutlives { dropped_ty } = value;
param_env.and(dropped_ty)
});
tcx.dropck_outlives(canonicalized) tcx.dropck_outlives(canonicalized)
} }
@ -48,6 +29,6 @@ impl<'tcx> super::QueryTypeOp<'tcx> for DropckOutlives<'tcx> {
ocx: &ObligationCtxt<'_, 'tcx>, ocx: &ObligationCtxt<'_, 'tcx>,
key: ParamEnvAnd<'tcx, Self>, key: ParamEnvAnd<'tcx, Self>,
) -> Result<Self::QueryResponse, NoSolution> { ) -> Result<Self::QueryResponse, NoSolution> {
compute_dropck_outlives_inner(ocx, key.param_env.and(key.value.dropped_ty)) compute_dropck_outlives_inner(ocx, key.param_env.and(key.value))
} }
} }

View file

@ -5,7 +5,7 @@ use rustc_middle::traits::query::NoSolution;
pub use rustc_middle::traits::query::type_op::ProvePredicate; pub use rustc_middle::traits::query::type_op::ProvePredicate;
use rustc_middle::ty::{self, ParamEnvAnd, TyCtxt}; use rustc_middle::ty::{self, ParamEnvAnd, TyCtxt};
use crate::infer::canonical::{Canonical, CanonicalQueryResponse}; use crate::infer::canonical::{CanonicalQueryInput, CanonicalQueryResponse};
use crate::traits::ObligationCtxt; use crate::traits::ObligationCtxt;
impl<'tcx> super::QueryTypeOp<'tcx> for ProvePredicate<'tcx> { impl<'tcx> super::QueryTypeOp<'tcx> for ProvePredicate<'tcx> {
@ -49,7 +49,7 @@ impl<'tcx> super::QueryTypeOp<'tcx> for ProvePredicate<'tcx> {
fn perform_query( fn perform_query(
tcx: TyCtxt<'tcx>, tcx: TyCtxt<'tcx>,
canonicalized: Canonical<'tcx, ParamEnvAnd<'tcx, Self>>, canonicalized: CanonicalQueryInput<'tcx, ParamEnvAnd<'tcx, Self>>,
) -> Result<CanonicalQueryResponse<'tcx, ()>, NoSolution> { ) -> Result<CanonicalQueryResponse<'tcx, ()>, NoSolution> {
tcx.type_op_prove_predicate(canonicalized) tcx.type_op_prove_predicate(canonicalized)
} }

View file

@ -10,7 +10,7 @@ use rustc_trait_selection::infer::InferCtxtBuilderExt;
use rustc_trait_selection::traits::query::dropck_outlives::{ use rustc_trait_selection::traits::query::dropck_outlives::{
compute_dropck_outlives_inner, dtorck_constraint_for_ty_inner, compute_dropck_outlives_inner, dtorck_constraint_for_ty_inner,
}; };
use rustc_trait_selection::traits::query::{CanonicalTyGoal, NoSolution}; use rustc_trait_selection::traits::query::{CanonicalDropckOutlivesGoal, NoSolution};
use tracing::debug; use tracing::debug;
pub(crate) fn provide(p: &mut Providers) { pub(crate) fn provide(p: &mut Providers) {
@ -19,7 +19,7 @@ pub(crate) fn provide(p: &mut Providers) {
fn dropck_outlives<'tcx>( fn dropck_outlives<'tcx>(
tcx: TyCtxt<'tcx>, tcx: TyCtxt<'tcx>,
canonical_goal: CanonicalTyGoal<'tcx>, canonical_goal: CanonicalDropckOutlivesGoal<'tcx>,
) -> Result<&'tcx Canonical<'tcx, QueryResponse<'tcx, DropckOutlivesResult<'tcx>>>, NoSolution> { ) -> Result<&'tcx Canonical<'tcx, QueryResponse<'tcx, DropckOutlivesResult<'tcx>>>, NoSolution> {
debug!("dropck_outlives(goal={:#?})", canonical_goal); debug!("dropck_outlives(goal={:#?})", canonical_goal);

View file

@ -5,13 +5,14 @@
use rustc_infer::infer::TyCtxtInferExt; use rustc_infer::infer::TyCtxtInferExt;
use rustc_infer::infer::canonical::{self, Canonical}; use rustc_infer::infer::canonical::{self, Canonical};
use rustc_infer::traits::query::OutlivesBound; use rustc_infer::traits::query::OutlivesBound;
use rustc_infer::traits::query::type_op::ImpliedOutlivesBounds;
use rustc_middle::query::Providers; use rustc_middle::query::Providers;
use rustc_middle::ty::TyCtxt; use rustc_middle::ty::TyCtxt;
use rustc_trait_selection::infer::InferCtxtBuilderExt; use rustc_trait_selection::infer::InferCtxtBuilderExt;
use rustc_trait_selection::traits::query::type_op::implied_outlives_bounds::{ use rustc_trait_selection::traits::query::type_op::implied_outlives_bounds::{
compute_implied_outlives_bounds_compat_inner, compute_implied_outlives_bounds_inner, compute_implied_outlives_bounds_compat_inner, compute_implied_outlives_bounds_inner,
}; };
use rustc_trait_selection::traits::query::{CanonicalTyGoal, NoSolution}; use rustc_trait_selection::traits::query::{CanonicalImpliedOutlivesBoundsGoal, NoSolution};
pub(crate) fn provide(p: &mut Providers) { pub(crate) fn provide(p: &mut Providers) {
*p = Providers { implied_outlives_bounds_compat, ..*p }; *p = Providers { implied_outlives_bounds_compat, ..*p };
@ -20,26 +21,26 @@ pub(crate) fn provide(p: &mut Providers) {
fn implied_outlives_bounds_compat<'tcx>( fn implied_outlives_bounds_compat<'tcx>(
tcx: TyCtxt<'tcx>, tcx: TyCtxt<'tcx>,
goal: CanonicalTyGoal<'tcx>, goal: CanonicalImpliedOutlivesBoundsGoal<'tcx>,
) -> Result< ) -> Result<
&'tcx Canonical<'tcx, canonical::QueryResponse<'tcx, Vec<OutlivesBound<'tcx>>>>, &'tcx Canonical<'tcx, canonical::QueryResponse<'tcx, Vec<OutlivesBound<'tcx>>>>,
NoSolution, NoSolution,
> { > {
tcx.infer_ctxt().enter_canonical_trait_query(&goal, |ocx, key| { tcx.infer_ctxt().enter_canonical_trait_query(&goal, |ocx, key| {
let (param_env, ty) = key.into_parts(); let (param_env, ImpliedOutlivesBounds { ty }) = key.into_parts();
compute_implied_outlives_bounds_compat_inner(ocx, param_env, ty) compute_implied_outlives_bounds_compat_inner(ocx, param_env, ty)
}) })
} }
fn implied_outlives_bounds<'tcx>( fn implied_outlives_bounds<'tcx>(
tcx: TyCtxt<'tcx>, tcx: TyCtxt<'tcx>,
goal: CanonicalTyGoal<'tcx>, goal: CanonicalImpliedOutlivesBoundsGoal<'tcx>,
) -> Result< ) -> Result<
&'tcx Canonical<'tcx, canonical::QueryResponse<'tcx, Vec<OutlivesBound<'tcx>>>>, &'tcx Canonical<'tcx, canonical::QueryResponse<'tcx, Vec<OutlivesBound<'tcx>>>>,
NoSolution, NoSolution,
> { > {
tcx.infer_ctxt().enter_canonical_trait_query(&goal, |ocx, key| { tcx.infer_ctxt().enter_canonical_trait_query(&goal, |ocx, key| {
let (param_env, ty) = key.into_parts(); let (param_env, ImpliedOutlivesBounds { ty }) = key.into_parts();
compute_implied_outlives_bounds_inner(ocx, param_env, ty) compute_implied_outlives_bounds_inner(ocx, param_env, ty)
}) })
} }

View file

@ -1,7 +1,7 @@
use std::fmt; use std::fmt;
use rustc_infer::infer::TyCtxtInferExt; use rustc_infer::infer::TyCtxtInferExt;
use rustc_infer::infer::canonical::{Canonical, QueryResponse}; use rustc_infer::infer::canonical::{Canonical, CanonicalQueryInput, QueryResponse};
use rustc_middle::query::Providers; use rustc_middle::query::Providers;
use rustc_middle::traits::query::NoSolution; use rustc_middle::traits::query::NoSolution;
use rustc_middle::ty::{Clause, FnSig, ParamEnvAnd, PolyFnSig, Ty, TyCtxt, TypeFoldable}; use rustc_middle::ty::{Clause, FnSig, ParamEnvAnd, PolyFnSig, Ty, TyCtxt, TypeFoldable};
@ -28,7 +28,7 @@ pub(crate) fn provide(p: &mut Providers) {
fn type_op_ascribe_user_type<'tcx>( fn type_op_ascribe_user_type<'tcx>(
tcx: TyCtxt<'tcx>, tcx: TyCtxt<'tcx>,
canonicalized: Canonical<'tcx, ParamEnvAnd<'tcx, AscribeUserType<'tcx>>>, canonicalized: CanonicalQueryInput<'tcx, ParamEnvAnd<'tcx, AscribeUserType<'tcx>>>,
) -> Result<&'tcx Canonical<'tcx, QueryResponse<'tcx, ()>>, NoSolution> { ) -> Result<&'tcx Canonical<'tcx, QueryResponse<'tcx, ()>>, NoSolution> {
tcx.infer_ctxt().enter_canonical_trait_query(&canonicalized, |ocx, key| { tcx.infer_ctxt().enter_canonical_trait_query(&canonicalized, |ocx, key| {
type_op_ascribe_user_type_with_span(ocx, key, None) type_op_ascribe_user_type_with_span(ocx, key, None)
@ -51,35 +51,35 @@ where
fn type_op_normalize_ty<'tcx>( fn type_op_normalize_ty<'tcx>(
tcx: TyCtxt<'tcx>, tcx: TyCtxt<'tcx>,
canonicalized: Canonical<'tcx, ParamEnvAnd<'tcx, Normalize<Ty<'tcx>>>>, canonicalized: CanonicalQueryInput<'tcx, ParamEnvAnd<'tcx, Normalize<Ty<'tcx>>>>,
) -> Result<&'tcx Canonical<'tcx, QueryResponse<'tcx, Ty<'tcx>>>, NoSolution> { ) -> Result<&'tcx Canonical<'tcx, QueryResponse<'tcx, Ty<'tcx>>>, NoSolution> {
tcx.infer_ctxt().enter_canonical_trait_query(&canonicalized, type_op_normalize) tcx.infer_ctxt().enter_canonical_trait_query(&canonicalized, type_op_normalize)
} }
fn type_op_normalize_clause<'tcx>( fn type_op_normalize_clause<'tcx>(
tcx: TyCtxt<'tcx>, tcx: TyCtxt<'tcx>,
canonicalized: Canonical<'tcx, ParamEnvAnd<'tcx, Normalize<Clause<'tcx>>>>, canonicalized: CanonicalQueryInput<'tcx, ParamEnvAnd<'tcx, Normalize<Clause<'tcx>>>>,
) -> Result<&'tcx Canonical<'tcx, QueryResponse<'tcx, Clause<'tcx>>>, NoSolution> { ) -> Result<&'tcx Canonical<'tcx, QueryResponse<'tcx, Clause<'tcx>>>, NoSolution> {
tcx.infer_ctxt().enter_canonical_trait_query(&canonicalized, type_op_normalize) tcx.infer_ctxt().enter_canonical_trait_query(&canonicalized, type_op_normalize)
} }
fn type_op_normalize_fn_sig<'tcx>( fn type_op_normalize_fn_sig<'tcx>(
tcx: TyCtxt<'tcx>, tcx: TyCtxt<'tcx>,
canonicalized: Canonical<'tcx, ParamEnvAnd<'tcx, Normalize<FnSig<'tcx>>>>, canonicalized: CanonicalQueryInput<'tcx, ParamEnvAnd<'tcx, Normalize<FnSig<'tcx>>>>,
) -> Result<&'tcx Canonical<'tcx, QueryResponse<'tcx, FnSig<'tcx>>>, NoSolution> { ) -> Result<&'tcx Canonical<'tcx, QueryResponse<'tcx, FnSig<'tcx>>>, NoSolution> {
tcx.infer_ctxt().enter_canonical_trait_query(&canonicalized, type_op_normalize) tcx.infer_ctxt().enter_canonical_trait_query(&canonicalized, type_op_normalize)
} }
fn type_op_normalize_poly_fn_sig<'tcx>( fn type_op_normalize_poly_fn_sig<'tcx>(
tcx: TyCtxt<'tcx>, tcx: TyCtxt<'tcx>,
canonicalized: Canonical<'tcx, ParamEnvAnd<'tcx, Normalize<PolyFnSig<'tcx>>>>, canonicalized: CanonicalQueryInput<'tcx, ParamEnvAnd<'tcx, Normalize<PolyFnSig<'tcx>>>>,
) -> Result<&'tcx Canonical<'tcx, QueryResponse<'tcx, PolyFnSig<'tcx>>>, NoSolution> { ) -> Result<&'tcx Canonical<'tcx, QueryResponse<'tcx, PolyFnSig<'tcx>>>, NoSolution> {
tcx.infer_ctxt().enter_canonical_trait_query(&canonicalized, type_op_normalize) tcx.infer_ctxt().enter_canonical_trait_query(&canonicalized, type_op_normalize)
} }
fn type_op_prove_predicate<'tcx>( fn type_op_prove_predicate<'tcx>(
tcx: TyCtxt<'tcx>, tcx: TyCtxt<'tcx>,
canonicalized: Canonical<'tcx, ParamEnvAnd<'tcx, ProvePredicate<'tcx>>>, canonicalized: CanonicalQueryInput<'tcx, ParamEnvAnd<'tcx, ProvePredicate<'tcx>>>,
) -> Result<&'tcx Canonical<'tcx, QueryResponse<'tcx, ()>>, NoSolution> { ) -> Result<&'tcx Canonical<'tcx, QueryResponse<'tcx, ()>>, NoSolution> {
tcx.infer_ctxt().enter_canonical_trait_query(&canonicalized, |ocx, key| { tcx.infer_ctxt().enter_canonical_trait_query(&canonicalized, |ocx, key| {
type_op_prove_predicate_with_cause(ocx, key, ObligationCause::dummy()); type_op_prove_predicate_with_cause(ocx, key, ObligationCause::dummy());

View file

@ -10,6 +10,18 @@ use rustc_type_ir_macros::{Lift_Generic, TypeFoldable_Generic, TypeVisitable_Gen
use crate::inherent::*; use crate::inherent::*;
use crate::{self as ty, Interner, UniverseIndex}; use crate::{self as ty, Interner, UniverseIndex};
#[derive_where(Clone; I: Interner, V: Clone)]
#[derive_where(Hash; I: Interner, V: Hash)]
#[derive_where(PartialEq; I: Interner, V: PartialEq)]
#[derive_where(Eq; I: Interner, V: Eq)]
#[derive_where(Debug; I: Interner, V: fmt::Debug)]
#[derive_where(Copy; I: Interner, V: Copy)]
#[cfg_attr(feature = "nightly", derive(TyEncodable, TyDecodable, HashStable_NoContext))]
pub struct CanonicalQueryInput<I: Interner, V> {
pub canonical: Canonical<I, V>,
pub defining_opaque_types: I::DefiningOpaqueTypes,
}
/// A "canonicalized" type `V` is one where all free inference /// A "canonicalized" type `V` is one where all free inference
/// variables have been rewritten to "canonical vars". These are /// variables have been rewritten to "canonical vars". These are
/// numbered starting from 0 in order of first appearance. /// numbered starting from 0 in order of first appearance.
@ -24,8 +36,6 @@ use crate::{self as ty, Interner, UniverseIndex};
pub struct Canonical<I: Interner, V> { pub struct Canonical<I: Interner, V> {
pub value: V, pub value: V,
pub max_universe: UniverseIndex, pub max_universe: UniverseIndex,
// FIXME(lcnr, oli-obk): try moving this into the query inputs instead
pub defining_opaque_types: I::DefiningOpaqueTypes,
pub variables: I::CanonicalVars, pub variables: I::CanonicalVars,
} }
@ -54,27 +64,17 @@ impl<I: Interner, V> Canonical<I, V> {
/// let b: Canonical<I, (T, Ty<I>)> = a.unchecked_map(|v| (v, ty)); /// let b: Canonical<I, (T, Ty<I>)> = a.unchecked_map(|v| (v, ty));
/// ``` /// ```
pub fn unchecked_map<W>(self, map_op: impl FnOnce(V) -> W) -> Canonical<I, W> { pub fn unchecked_map<W>(self, map_op: impl FnOnce(V) -> W) -> Canonical<I, W> {
let Canonical { defining_opaque_types, max_universe, variables, value } = self; let Canonical { max_universe, variables, value } = self;
Canonical { defining_opaque_types, max_universe, variables, value: map_op(value) } Canonical { max_universe, variables, value: map_op(value) }
}
/// Allows you to map the `value` of a canonical while keeping the same set of
/// bound variables.
///
/// **WARNING:** This function is very easy to mis-use, hence the name! See
/// the comment of [Canonical::unchecked_map] for more details.
pub fn unchecked_rebind<W>(self, value: W) -> Canonical<I, W> {
let Canonical { defining_opaque_types, max_universe, variables, value: _ } = self;
Canonical { defining_opaque_types, max_universe, variables, value }
} }
} }
impl<I: Interner, V: fmt::Display> fmt::Display for Canonical<I, V> { impl<I: Interner, V: fmt::Display> fmt::Display for Canonical<I, V> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let Self { value, max_universe, variables, defining_opaque_types } = self; let Self { value, max_universe, variables } = self;
write!( write!(
f, f,
"Canonical {{ value: {value}, max_universe: {max_universe:?}, variables: {variables:?}, defining_opaque_types: {defining_opaque_types:?} }}", "Canonical {{ value: {value}, max_universe: {max_universe:?}, variables: {variables:?} }}",
) )
} }
} }

View file

@ -71,7 +71,8 @@ pub enum SolverMode {
Coherence, Coherence,
} }
pub type CanonicalInput<I, T = <I as Interner>::Predicate> = Canonical<I, QueryInput<I, T>>; pub type CanonicalInput<I, T = <I as Interner>::Predicate> =
ty::CanonicalQueryInput<I, QueryInput<I, T>>;
pub type CanonicalResponse<I> = Canonical<I, Response<I>>; pub type CanonicalResponse<I> = Canonical<I, Response<I>>;
/// The result of evaluating a canonical query. /// The result of evaluating a canonical query.
/// ///

View file

@ -1,36 +1,36 @@
// MIR for `address_of_reborrow` after SimplifyCfg-initial // MIR for `address_of_reborrow` after SimplifyCfg-initial
| User Type Annotations | User Type Annotations
| 0: user_ty: Canonical { value: Ty(*const ^0), max_universe: U0, variables: [CanonicalVarInfo { kind: Ty(General(U0)) }], defining_opaque_types: [] }, span: $DIR/address_of.rs:8:10: 8:18, inferred_ty: *const [i32; 10] | 0: user_ty: Canonical { value: Ty(*const ^0), max_universe: U0, variables: [CanonicalVarInfo { kind: Ty(General(U0)) }] }, span: $DIR/address_of.rs:8:10: 8:18, inferred_ty: *const [i32; 10]
| 1: user_ty: Canonical { value: Ty(*const dyn std::marker::Send), max_universe: U0, variables: [CanonicalVarInfo { kind: Region(U0) }], defining_opaque_types: [] }, span: $DIR/address_of.rs:10:10: 10:25, inferred_ty: *const dyn std::marker::Send | 1: user_ty: Canonical { value: Ty(*const dyn std::marker::Send), max_universe: U0, variables: [CanonicalVarInfo { kind: Region(U0) }] }, span: $DIR/address_of.rs:10:10: 10:25, inferred_ty: *const dyn std::marker::Send
| 2: user_ty: Canonical { value: Ty(*const ^0), max_universe: U0, variables: [CanonicalVarInfo { kind: Ty(General(U0)) }], defining_opaque_types: [] }, span: $DIR/address_of.rs:14:12: 14:20, inferred_ty: *const [i32; 10] | 2: user_ty: Canonical { value: Ty(*const ^0), max_universe: U0, variables: [CanonicalVarInfo { kind: Ty(General(U0)) }] }, span: $DIR/address_of.rs:14:12: 14:20, inferred_ty: *const [i32; 10]
| 3: user_ty: Canonical { value: Ty(*const ^0), max_universe: U0, variables: [CanonicalVarInfo { kind: Ty(General(U0)) }], defining_opaque_types: [] }, span: $DIR/address_of.rs:14:12: 14:20, inferred_ty: *const [i32; 10] | 3: user_ty: Canonical { value: Ty(*const ^0), max_universe: U0, variables: [CanonicalVarInfo { kind: Ty(General(U0)) }] }, span: $DIR/address_of.rs:14:12: 14:20, inferred_ty: *const [i32; 10]
| 4: user_ty: Canonical { value: Ty(*const [i32; 10]), max_universe: U0, variables: [], defining_opaque_types: [] }, span: $DIR/address_of.rs:15:12: 15:28, inferred_ty: *const [i32; 10] | 4: user_ty: Canonical { value: Ty(*const [i32; 10]), max_universe: U0, variables: [] }, span: $DIR/address_of.rs:15:12: 15:28, inferred_ty: *const [i32; 10]
| 5: user_ty: Canonical { value: Ty(*const [i32; 10]), max_universe: U0, variables: [], defining_opaque_types: [] }, span: $DIR/address_of.rs:15:12: 15:28, inferred_ty: *const [i32; 10] | 5: user_ty: Canonical { value: Ty(*const [i32; 10]), max_universe: U0, variables: [] }, span: $DIR/address_of.rs:15:12: 15:28, inferred_ty: *const [i32; 10]
| 6: user_ty: Canonical { value: Ty(*const dyn std::marker::Send), max_universe: U0, variables: [CanonicalVarInfo { kind: Region(U0) }], defining_opaque_types: [] }, span: $DIR/address_of.rs:16:12: 16:27, inferred_ty: *const dyn std::marker::Send | 6: user_ty: Canonical { value: Ty(*const dyn std::marker::Send), max_universe: U0, variables: [CanonicalVarInfo { kind: Region(U0) }] }, span: $DIR/address_of.rs:16:12: 16:27, inferred_ty: *const dyn std::marker::Send
| 7: user_ty: Canonical { value: Ty(*const dyn std::marker::Send), max_universe: U0, variables: [CanonicalVarInfo { kind: Region(U0) }], defining_opaque_types: [] }, span: $DIR/address_of.rs:16:12: 16:27, inferred_ty: *const dyn std::marker::Send | 7: user_ty: Canonical { value: Ty(*const dyn std::marker::Send), max_universe: U0, variables: [CanonicalVarInfo { kind: Region(U0) }] }, span: $DIR/address_of.rs:16:12: 16:27, inferred_ty: *const dyn std::marker::Send
| 8: user_ty: Canonical { value: Ty(*const [i32]), max_universe: U0, variables: [], defining_opaque_types: [] }, span: $DIR/address_of.rs:17:12: 17:24, inferred_ty: *const [i32] | 8: user_ty: Canonical { value: Ty(*const [i32]), max_universe: U0, variables: [] }, span: $DIR/address_of.rs:17:12: 17:24, inferred_ty: *const [i32]
| 9: user_ty: Canonical { value: Ty(*const [i32]), max_universe: U0, variables: [], defining_opaque_types: [] }, span: $DIR/address_of.rs:17:12: 17:24, inferred_ty: *const [i32] | 9: user_ty: Canonical { value: Ty(*const [i32]), max_universe: U0, variables: [] }, span: $DIR/address_of.rs:17:12: 17:24, inferred_ty: *const [i32]
| 10: user_ty: Canonical { value: Ty(*const ^0), max_universe: U0, variables: [CanonicalVarInfo { kind: Ty(General(U0)) }], defining_opaque_types: [] }, span: $DIR/address_of.rs:19:10: 19:18, inferred_ty: *const [i32; 10] | 10: user_ty: Canonical { value: Ty(*const ^0), max_universe: U0, variables: [CanonicalVarInfo { kind: Ty(General(U0)) }] }, span: $DIR/address_of.rs:19:10: 19:18, inferred_ty: *const [i32; 10]
| 11: user_ty: Canonical { value: Ty(*const dyn std::marker::Send), max_universe: U0, variables: [CanonicalVarInfo { kind: Region(U0) }], defining_opaque_types: [] }, span: $DIR/address_of.rs:21:10: 21:25, inferred_ty: *const dyn std::marker::Send | 11: user_ty: Canonical { value: Ty(*const dyn std::marker::Send), max_universe: U0, variables: [CanonicalVarInfo { kind: Region(U0) }] }, span: $DIR/address_of.rs:21:10: 21:25, inferred_ty: *const dyn std::marker::Send
| 12: user_ty: Canonical { value: Ty(*const ^0), max_universe: U0, variables: [CanonicalVarInfo { kind: Ty(General(U0)) }], defining_opaque_types: [] }, span: $DIR/address_of.rs:24:12: 24:20, inferred_ty: *const [i32; 10] | 12: user_ty: Canonical { value: Ty(*const ^0), max_universe: U0, variables: [CanonicalVarInfo { kind: Ty(General(U0)) }] }, span: $DIR/address_of.rs:24:12: 24:20, inferred_ty: *const [i32; 10]
| 13: user_ty: Canonical { value: Ty(*const ^0), max_universe: U0, variables: [CanonicalVarInfo { kind: Ty(General(U0)) }], defining_opaque_types: [] }, span: $DIR/address_of.rs:24:12: 24:20, inferred_ty: *const [i32; 10] | 13: user_ty: Canonical { value: Ty(*const ^0), max_universe: U0, variables: [CanonicalVarInfo { kind: Ty(General(U0)) }] }, span: $DIR/address_of.rs:24:12: 24:20, inferred_ty: *const [i32; 10]
| 14: user_ty: Canonical { value: Ty(*const [i32; 10]), max_universe: U0, variables: [], defining_opaque_types: [] }, span: $DIR/address_of.rs:25:12: 25:28, inferred_ty: *const [i32; 10] | 14: user_ty: Canonical { value: Ty(*const [i32; 10]), max_universe: U0, variables: [] }, span: $DIR/address_of.rs:25:12: 25:28, inferred_ty: *const [i32; 10]
| 15: user_ty: Canonical { value: Ty(*const [i32; 10]), max_universe: U0, variables: [], defining_opaque_types: [] }, span: $DIR/address_of.rs:25:12: 25:28, inferred_ty: *const [i32; 10] | 15: user_ty: Canonical { value: Ty(*const [i32; 10]), max_universe: U0, variables: [] }, span: $DIR/address_of.rs:25:12: 25:28, inferred_ty: *const [i32; 10]
| 16: user_ty: Canonical { value: Ty(*const dyn std::marker::Send), max_universe: U0, variables: [CanonicalVarInfo { kind: Region(U0) }], defining_opaque_types: [] }, span: $DIR/address_of.rs:26:12: 26:27, inferred_ty: *const dyn std::marker::Send | 16: user_ty: Canonical { value: Ty(*const dyn std::marker::Send), max_universe: U0, variables: [CanonicalVarInfo { kind: Region(U0) }] }, span: $DIR/address_of.rs:26:12: 26:27, inferred_ty: *const dyn std::marker::Send
| 17: user_ty: Canonical { value: Ty(*const dyn std::marker::Send), max_universe: U0, variables: [CanonicalVarInfo { kind: Region(U0) }], defining_opaque_types: [] }, span: $DIR/address_of.rs:26:12: 26:27, inferred_ty: *const dyn std::marker::Send | 17: user_ty: Canonical { value: Ty(*const dyn std::marker::Send), max_universe: U0, variables: [CanonicalVarInfo { kind: Region(U0) }] }, span: $DIR/address_of.rs:26:12: 26:27, inferred_ty: *const dyn std::marker::Send
| 18: user_ty: Canonical { value: Ty(*const [i32]), max_universe: U0, variables: [], defining_opaque_types: [] }, span: $DIR/address_of.rs:27:12: 27:24, inferred_ty: *const [i32] | 18: user_ty: Canonical { value: Ty(*const [i32]), max_universe: U0, variables: [] }, span: $DIR/address_of.rs:27:12: 27:24, inferred_ty: *const [i32]
| 19: user_ty: Canonical { value: Ty(*const [i32]), max_universe: U0, variables: [], defining_opaque_types: [] }, span: $DIR/address_of.rs:27:12: 27:24, inferred_ty: *const [i32] | 19: user_ty: Canonical { value: Ty(*const [i32]), max_universe: U0, variables: [] }, span: $DIR/address_of.rs:27:12: 27:24, inferred_ty: *const [i32]
| 20: user_ty: Canonical { value: Ty(*mut ^0), max_universe: U0, variables: [CanonicalVarInfo { kind: Ty(General(U0)) }], defining_opaque_types: [] }, span: $DIR/address_of.rs:29:10: 29:16, inferred_ty: *mut [i32; 10] | 20: user_ty: Canonical { value: Ty(*mut ^0), max_universe: U0, variables: [CanonicalVarInfo { kind: Ty(General(U0)) }] }, span: $DIR/address_of.rs:29:10: 29:16, inferred_ty: *mut [i32; 10]
| 21: user_ty: Canonical { value: Ty(*mut dyn std::marker::Send), max_universe: U0, variables: [CanonicalVarInfo { kind: Region(U0) }], defining_opaque_types: [] }, span: $DIR/address_of.rs:31:10: 31:23, inferred_ty: *mut dyn std::marker::Send | 21: user_ty: Canonical { value: Ty(*mut dyn std::marker::Send), max_universe: U0, variables: [CanonicalVarInfo { kind: Region(U0) }] }, span: $DIR/address_of.rs:31:10: 31:23, inferred_ty: *mut dyn std::marker::Send
| 22: user_ty: Canonical { value: Ty(*mut ^0), max_universe: U0, variables: [CanonicalVarInfo { kind: Ty(General(U0)) }], defining_opaque_types: [] }, span: $DIR/address_of.rs:34:12: 34:18, inferred_ty: *mut [i32; 10] | 22: user_ty: Canonical { value: Ty(*mut ^0), max_universe: U0, variables: [CanonicalVarInfo { kind: Ty(General(U0)) }] }, span: $DIR/address_of.rs:34:12: 34:18, inferred_ty: *mut [i32; 10]
| 23: user_ty: Canonical { value: Ty(*mut ^0), max_universe: U0, variables: [CanonicalVarInfo { kind: Ty(General(U0)) }], defining_opaque_types: [] }, span: $DIR/address_of.rs:34:12: 34:18, inferred_ty: *mut [i32; 10] | 23: user_ty: Canonical { value: Ty(*mut ^0), max_universe: U0, variables: [CanonicalVarInfo { kind: Ty(General(U0)) }] }, span: $DIR/address_of.rs:34:12: 34:18, inferred_ty: *mut [i32; 10]
| 24: user_ty: Canonical { value: Ty(*mut [i32; 10]), max_universe: U0, variables: [], defining_opaque_types: [] }, span: $DIR/address_of.rs:35:12: 35:26, inferred_ty: *mut [i32; 10] | 24: user_ty: Canonical { value: Ty(*mut [i32; 10]), max_universe: U0, variables: [] }, span: $DIR/address_of.rs:35:12: 35:26, inferred_ty: *mut [i32; 10]
| 25: user_ty: Canonical { value: Ty(*mut [i32; 10]), max_universe: U0, variables: [], defining_opaque_types: [] }, span: $DIR/address_of.rs:35:12: 35:26, inferred_ty: *mut [i32; 10] | 25: user_ty: Canonical { value: Ty(*mut [i32; 10]), max_universe: U0, variables: [] }, span: $DIR/address_of.rs:35:12: 35:26, inferred_ty: *mut [i32; 10]
| 26: user_ty: Canonical { value: Ty(*mut dyn std::marker::Send), max_universe: U0, variables: [CanonicalVarInfo { kind: Region(U0) }], defining_opaque_types: [] }, span: $DIR/address_of.rs:36:12: 36:25, inferred_ty: *mut dyn std::marker::Send | 26: user_ty: Canonical { value: Ty(*mut dyn std::marker::Send), max_universe: U0, variables: [CanonicalVarInfo { kind: Region(U0) }] }, span: $DIR/address_of.rs:36:12: 36:25, inferred_ty: *mut dyn std::marker::Send
| 27: user_ty: Canonical { value: Ty(*mut dyn std::marker::Send), max_universe: U0, variables: [CanonicalVarInfo { kind: Region(U0) }], defining_opaque_types: [] }, span: $DIR/address_of.rs:36:12: 36:25, inferred_ty: *mut dyn std::marker::Send | 27: user_ty: Canonical { value: Ty(*mut dyn std::marker::Send), max_universe: U0, variables: [CanonicalVarInfo { kind: Region(U0) }] }, span: $DIR/address_of.rs:36:12: 36:25, inferred_ty: *mut dyn std::marker::Send
| 28: user_ty: Canonical { value: Ty(*mut [i32]), max_universe: U0, variables: [], defining_opaque_types: [] }, span: $DIR/address_of.rs:37:12: 37:22, inferred_ty: *mut [i32] | 28: user_ty: Canonical { value: Ty(*mut [i32]), max_universe: U0, variables: [] }, span: $DIR/address_of.rs:37:12: 37:22, inferred_ty: *mut [i32]
| 29: user_ty: Canonical { value: Ty(*mut [i32]), max_universe: U0, variables: [], defining_opaque_types: [] }, span: $DIR/address_of.rs:37:12: 37:22, inferred_ty: *mut [i32] | 29: user_ty: Canonical { value: Ty(*mut [i32]), max_universe: U0, variables: [] }, span: $DIR/address_of.rs:37:12: 37:22, inferred_ty: *mut [i32]
| |
fn address_of_reborrow() -> () { fn address_of_reborrow() -> () {
let mut _0: (); let mut _0: ();

View file

@ -1,8 +1,8 @@
// MIR for `main` after SimplifyCfg-initial // MIR for `main` after SimplifyCfg-initial
| User Type Annotations | User Type Annotations
| 0: user_ty: Canonical { value: Ty(std::option::Option<std::boxed::Box<u32>>), max_universe: U0, variables: [], defining_opaque_types: [] }, span: $DIR/basic_assignment.rs:38:17: 38:33, inferred_ty: std::option::Option<std::boxed::Box<u32>> | 0: user_ty: Canonical { value: Ty(std::option::Option<std::boxed::Box<u32>>), max_universe: U0, variables: [] }, span: $DIR/basic_assignment.rs:38:17: 38:33, inferred_ty: std::option::Option<std::boxed::Box<u32>>
| 1: user_ty: Canonical { value: Ty(std::option::Option<std::boxed::Box<u32>>), max_universe: U0, variables: [], defining_opaque_types: [] }, span: $DIR/basic_assignment.rs:38:17: 38:33, inferred_ty: std::option::Option<std::boxed::Box<u32>> | 1: user_ty: Canonical { value: Ty(std::option::Option<std::boxed::Box<u32>>), max_universe: U0, variables: [] }, span: $DIR/basic_assignment.rs:38:17: 38:33, inferred_ty: std::option::Option<std::boxed::Box<u32>>
| |
fn main() -> () { fn main() -> () {
let mut _0: (); let mut _0: ();

View file

@ -1,8 +1,8 @@
// MIR for `main` after built // MIR for `main` after built
| User Type Annotations | User Type Annotations
| 0: user_ty: Canonical { value: Ty(std::option::Option<u8>), max_universe: U0, variables: [], defining_opaque_types: [] }, span: $DIR/issue_101867.rs:4:12: 4:22, inferred_ty: std::option::Option<u8> | 0: user_ty: Canonical { value: Ty(std::option::Option<u8>), max_universe: U0, variables: [] }, span: $DIR/issue_101867.rs:4:12: 4:22, inferred_ty: std::option::Option<u8>
| 1: user_ty: Canonical { value: Ty(std::option::Option<u8>), max_universe: U0, variables: [], defining_opaque_types: [] }, span: $DIR/issue_101867.rs:4:12: 4:22, inferred_ty: std::option::Option<u8> | 1: user_ty: Canonical { value: Ty(std::option::Option<u8>), max_universe: U0, variables: [] }, span: $DIR/issue_101867.rs:4:12: 4:22, inferred_ty: std::option::Option<u8>
| |
fn main() -> () { fn main() -> () {
let mut _0: (); let mut _0: ();

View file

@ -1,10 +1,10 @@
// MIR for `main` after built // MIR for `main` after built
| User Type Annotations | User Type Annotations
| 0: user_ty: Canonical { value: Ty(*mut Test), max_universe: U0, variables: [], defining_opaque_types: [] }, span: $DIR/receiver_ptr_mutability.rs:15:14: 15:23, inferred_ty: *mut Test | 0: user_ty: Canonical { value: Ty(*mut Test), max_universe: U0, variables: [] }, span: $DIR/receiver_ptr_mutability.rs:15:14: 15:23, inferred_ty: *mut Test
| 1: user_ty: Canonical { value: Ty(*mut Test), max_universe: U0, variables: [], defining_opaque_types: [] }, span: $DIR/receiver_ptr_mutability.rs:15:14: 15:23, inferred_ty: *mut Test | 1: user_ty: Canonical { value: Ty(*mut Test), max_universe: U0, variables: [] }, span: $DIR/receiver_ptr_mutability.rs:15:14: 15:23, inferred_ty: *mut Test
| 2: user_ty: Canonical { value: Ty(&&&&*mut Test), max_universe: U0, variables: [CanonicalVarInfo { kind: Region(U0) }, CanonicalVarInfo { kind: Region(U0) }, CanonicalVarInfo { kind: Region(U0) }, CanonicalVarInfo { kind: Region(U0) }], defining_opaque_types: [] }, span: $DIR/receiver_ptr_mutability.rs:19:18: 19:31, inferred_ty: &&&&*mut Test | 2: user_ty: Canonical { value: Ty(&&&&*mut Test), max_universe: U0, variables: [CanonicalVarInfo { kind: Region(U0) }, CanonicalVarInfo { kind: Region(U0) }, CanonicalVarInfo { kind: Region(U0) }, CanonicalVarInfo { kind: Region(U0) }] }, span: $DIR/receiver_ptr_mutability.rs:19:18: 19:31, inferred_ty: &&&&*mut Test
| 3: user_ty: Canonical { value: Ty(&&&&*mut Test), max_universe: U0, variables: [CanonicalVarInfo { kind: Region(U0) }, CanonicalVarInfo { kind: Region(U0) }, CanonicalVarInfo { kind: Region(U0) }, CanonicalVarInfo { kind: Region(U0) }], defining_opaque_types: [] }, span: $DIR/receiver_ptr_mutability.rs:19:18: 19:31, inferred_ty: &&&&*mut Test | 3: user_ty: Canonical { value: Ty(&&&&*mut Test), max_universe: U0, variables: [CanonicalVarInfo { kind: Region(U0) }, CanonicalVarInfo { kind: Region(U0) }, CanonicalVarInfo { kind: Region(U0) }, CanonicalVarInfo { kind: Region(U0) }] }, span: $DIR/receiver_ptr_mutability.rs:19:18: 19:31, inferred_ty: &&&&*mut Test
| |
fn main() -> () { fn main() -> () {
let mut _0: (); let mut _0: ();

View file

@ -1,8 +1,8 @@
// MIR for `main` after built // MIR for `main` after built
| User Type Annotations | User Type Annotations
| 0: user_ty: Canonical { value: Ty(Void), max_universe: U0, variables: [], defining_opaque_types: [] }, span: $DIR/issue_72181_1.rs:17:12: 17:16, inferred_ty: Void | 0: user_ty: Canonical { value: Ty(Void), max_universe: U0, variables: [] }, span: $DIR/issue_72181_1.rs:17:12: 17:16, inferred_ty: Void
| 1: user_ty: Canonical { value: Ty(Void), max_universe: U0, variables: [], defining_opaque_types: [] }, span: $DIR/issue_72181_1.rs:17:12: 17:16, inferred_ty: Void | 1: user_ty: Canonical { value: Ty(Void), max_universe: U0, variables: [] }, span: $DIR/issue_72181_1.rs:17:12: 17:16, inferred_ty: Void
| |
fn main() -> () { fn main() -> () {
let mut _0: (); let mut _0: ();

View file

@ -1,8 +1,8 @@
// MIR for `main` after built // MIR for `main` after built
| User Type Annotations | User Type Annotations
| 0: user_ty: Canonical { value: TypeOf(DefId(0:3 ~ issue_99325[d56d]::function_with_bytes), UserArgs { args: [&*b"AAAA"], user_self_ty: None }), max_universe: U0, variables: [], defining_opaque_types: [] }, span: $DIR/issue_99325.rs:13:16: 13:46, inferred_ty: fn() -> &'static [u8] {function_with_bytes::<&*b"AAAA">} | 0: user_ty: Canonical { value: TypeOf(DefId(0:3 ~ issue_99325[d56d]::function_with_bytes), UserArgs { args: [&*b"AAAA"], user_self_ty: None }), max_universe: U0, variables: [] }, span: $DIR/issue_99325.rs:13:16: 13:46, inferred_ty: fn() -> &'static [u8] {function_with_bytes::<&*b"AAAA">}
| 1: user_ty: Canonical { value: TypeOf(DefId(0:3 ~ issue_99325[d56d]::function_with_bytes), UserArgs { args: [UnevaluatedConst { def: DefId(0:8 ~ issue_99325[d56d]::main::{constant#1}), args: [] }], user_self_ty: None }), max_universe: U0, variables: [], defining_opaque_types: [] }, span: $DIR/issue_99325.rs:14:16: 14:68, inferred_ty: fn() -> &'static [u8] {function_with_bytes::<&*b"AAAA">} | 1: user_ty: Canonical { value: TypeOf(DefId(0:3 ~ issue_99325[d56d]::function_with_bytes), UserArgs { args: [UnevaluatedConst { def: DefId(0:8 ~ issue_99325[d56d]::main::{constant#1}), args: [] }], user_self_ty: None }), max_universe: U0, variables: [] }, span: $DIR/issue_99325.rs:14:16: 14:68, inferred_ty: fn() -> &'static [u8] {function_with_bytes::<&*b"AAAA">}
| |
fn main() -> () { fn main() -> () {
let mut _0: (); let mut _0: ();

View file

@ -1,8 +1,8 @@
// MIR for `main` after built // MIR for `main` after built
| User Type Annotations | User Type Annotations
| 0: user_ty: Canonical { value: TypeOf(DefId(0:3 ~ issue_99325[d56d]::function_with_bytes), UserArgs { args: [&*b"AAAA"], user_self_ty: None }), max_universe: U0, variables: [], defining_opaque_types: [] }, span: $DIR/issue_99325.rs:13:16: 13:46, inferred_ty: fn() -> &'static [u8] {function_with_bytes::<&*b"AAAA">} | 0: user_ty: Canonical { value: TypeOf(DefId(0:3 ~ issue_99325[d56d]::function_with_bytes), UserArgs { args: [&*b"AAAA"], user_self_ty: None }), max_universe: U0, variables: [] }, span: $DIR/issue_99325.rs:13:16: 13:46, inferred_ty: fn() -> &'static [u8] {function_with_bytes::<&*b"AAAA">}
| 1: user_ty: Canonical { value: TypeOf(DefId(0:3 ~ issue_99325[d56d]::function_with_bytes), UserArgs { args: [UnevaluatedConst { def: DefId(0:8 ~ issue_99325[d56d]::main::{constant#1}), args: [] }], user_self_ty: None }), max_universe: U0, variables: [], defining_opaque_types: [] }, span: $DIR/issue_99325.rs:14:16: 14:68, inferred_ty: fn() -> &'static [u8] {function_with_bytes::<&*b"AAAA">} | 1: user_ty: Canonical { value: TypeOf(DefId(0:3 ~ issue_99325[d56d]::function_with_bytes), UserArgs { args: [UnevaluatedConst { def: DefId(0:8 ~ issue_99325[d56d]::main::{constant#1}), args: [] }], user_self_ty: None }), max_universe: U0, variables: [] }, span: $DIR/issue_99325.rs:14:16: 14:68, inferred_ty: fn() -> &'static [u8] {function_with_bytes::<&*b"AAAA">}
| |
fn main() -> () { fn main() -> () {
let mut _0: (); let mut _0: ();