Use TraitEngine in more places, make FulfillmentCtxt constructor more private
This commit is contained in:
parent
34115d040b
commit
ed17c6b1c3
5 changed files with 12 additions and 10 deletions
|
@ -62,6 +62,7 @@ use rustc_span::{self, BytePos, DesugaringKind, Span};
|
||||||
use rustc_target::spec::abi::Abi;
|
use rustc_target::spec::abi::Abi;
|
||||||
use rustc_trait_selection::infer::InferCtxtExt as _;
|
use rustc_trait_selection::infer::InferCtxtExt as _;
|
||||||
use rustc_trait_selection::traits::error_reporting::TypeErrCtxtExt as _;
|
use rustc_trait_selection::traits::error_reporting::TypeErrCtxtExt as _;
|
||||||
|
use rustc_trait_selection::traits::TraitEngineExt as _;
|
||||||
use rustc_trait_selection::traits::{self, ObligationCause, ObligationCauseCode};
|
use rustc_trait_selection::traits::{self, ObligationCause, ObligationCauseCode};
|
||||||
|
|
||||||
use smallvec::{smallvec, SmallVec};
|
use smallvec::{smallvec, SmallVec};
|
||||||
|
@ -1038,7 +1039,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
let Ok(ok) = coerce.coerce(source, target) else {
|
let Ok(ok) = coerce.coerce(source, target) else {
|
||||||
return false;
|
return false;
|
||||||
};
|
};
|
||||||
let mut fcx = traits::FulfillmentContext::new_in_snapshot();
|
let mut fcx = <dyn TraitEngine<'tcx>>::new_in_snapshot(self.tcx);
|
||||||
fcx.register_predicate_obligations(self, ok.obligations);
|
fcx.register_predicate_obligations(self, ok.obligations);
|
||||||
fcx.select_where_possible(&self).is_empty()
|
fcx.select_where_possible(&self).is_empty()
|
||||||
})
|
})
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
use crate::errors::AutoDerefReachedRecursionLimit;
|
use crate::errors::AutoDerefReachedRecursionLimit;
|
||||||
use crate::traits::query::evaluate_obligation::InferCtxtExt;
|
use crate::traits::query::evaluate_obligation::InferCtxtExt;
|
||||||
use crate::traits::{self, TraitEngine};
|
use crate::traits::{self, TraitEngine, TraitEngineExt};
|
||||||
use rustc_hir as hir;
|
use rustc_hir as hir;
|
||||||
use rustc_infer::infer::InferCtxt;
|
use rustc_infer::infer::InferCtxt;
|
||||||
use rustc_middle::ty::{self, TraitRef, Ty, TyCtxt};
|
use rustc_middle::ty::{self, TraitRef, Ty, TyCtxt};
|
||||||
|
@ -139,7 +139,7 @@ impl<'a, 'tcx> Autoderef<'a, 'tcx> {
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut fulfillcx = traits::FulfillmentContext::new_in_snapshot();
|
let mut fulfillcx = <dyn TraitEngine<'tcx>>::new_in_snapshot(tcx);
|
||||||
let normalized_ty = fulfillcx.normalize_projection_type(
|
let normalized_ty = fulfillcx.normalize_projection_type(
|
||||||
&self.infcx,
|
&self.infcx,
|
||||||
self.param_env,
|
self.param_env,
|
||||||
|
|
|
@ -19,7 +19,7 @@ pub struct FulfillmentContext<'tcx> {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl FulfillmentContext<'_> {
|
impl FulfillmentContext<'_> {
|
||||||
pub(crate) fn new() -> Self {
|
pub(super) fn new() -> Self {
|
||||||
FulfillmentContext {
|
FulfillmentContext {
|
||||||
obligations: FxIndexSet::default(),
|
obligations: FxIndexSet::default(),
|
||||||
relationships: FxHashMap::default(),
|
relationships: FxHashMap::default(),
|
||||||
|
|
|
@ -3,13 +3,14 @@ pub mod on_unimplemented;
|
||||||
pub mod suggestions;
|
pub mod suggestions;
|
||||||
|
|
||||||
use super::{
|
use super::{
|
||||||
FulfillmentContext, FulfillmentError, FulfillmentErrorCode, MismatchedProjectionTypes,
|
FulfillmentError, FulfillmentErrorCode, MismatchedProjectionTypes, Obligation, ObligationCause,
|
||||||
Obligation, ObligationCause, ObligationCauseCode, OutputTypeParameterMismatch, Overflow,
|
ObligationCauseCode, OutputTypeParameterMismatch, Overflow, PredicateObligation,
|
||||||
PredicateObligation, SelectionContext, SelectionError, TraitNotObjectSafe,
|
SelectionContext, SelectionError, TraitNotObjectSafe,
|
||||||
};
|
};
|
||||||
use crate::infer::error_reporting::{TyCategory, TypeAnnotationNeeded as ErrorCode};
|
use crate::infer::error_reporting::{TyCategory, TypeAnnotationNeeded as ErrorCode};
|
||||||
use crate::infer::type_variable::{TypeVariableOrigin, TypeVariableOriginKind};
|
use crate::infer::type_variable::{TypeVariableOrigin, TypeVariableOriginKind};
|
||||||
use crate::infer::{self, InferCtxt, TyCtxtInferExt};
|
use crate::infer::{self, InferCtxt, TyCtxtInferExt};
|
||||||
|
use crate::traits::engine::TraitEngineExt as _;
|
||||||
use crate::traits::query::evaluate_obligation::InferCtxtExt as _;
|
use crate::traits::query::evaluate_obligation::InferCtxtExt as _;
|
||||||
use crate::traits::query::normalize::AtExt as _;
|
use crate::traits::query::normalize::AtExt as _;
|
||||||
use crate::traits::specialize::to_pretty_impl_header;
|
use crate::traits::specialize::to_pretty_impl_header;
|
||||||
|
@ -352,7 +353,7 @@ impl<'tcx> InferCtxtExt<'tcx> for InferCtxt<'tcx> {
|
||||||
})
|
})
|
||||||
.to_predicate(self.tcx),
|
.to_predicate(self.tcx),
|
||||||
);
|
);
|
||||||
let mut fulfill_cx = FulfillmentContext::new_in_snapshot();
|
let mut fulfill_cx = <dyn TraitEngine<'tcx>>::new_in_snapshot(self.tcx);
|
||||||
fulfill_cx.register_predicate_obligation(self, obligation);
|
fulfill_cx.register_predicate_obligation(self, obligation);
|
||||||
if fulfill_cx.select_all_or_error(self).is_empty() {
|
if fulfill_cx.select_all_or_error(self).is_empty() {
|
||||||
return Ok((
|
return Ok((
|
||||||
|
|
|
@ -85,7 +85,7 @@ static_assert_size!(PendingPredicateObligation<'_>, 72);
|
||||||
|
|
||||||
impl<'a, 'tcx> FulfillmentContext<'tcx> {
|
impl<'a, 'tcx> FulfillmentContext<'tcx> {
|
||||||
/// Creates a new fulfillment context.
|
/// Creates a new fulfillment context.
|
||||||
pub fn new() -> FulfillmentContext<'tcx> {
|
pub(super) fn new() -> FulfillmentContext<'tcx> {
|
||||||
FulfillmentContext {
|
FulfillmentContext {
|
||||||
predicates: ObligationForest::new(),
|
predicates: ObligationForest::new(),
|
||||||
relationships: FxHashMap::default(),
|
relationships: FxHashMap::default(),
|
||||||
|
@ -93,7 +93,7 @@ impl<'a, 'tcx> FulfillmentContext<'tcx> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn new_in_snapshot() -> FulfillmentContext<'tcx> {
|
pub(super) fn new_in_snapshot() -> FulfillmentContext<'tcx> {
|
||||||
FulfillmentContext {
|
FulfillmentContext {
|
||||||
predicates: ObligationForest::new(),
|
predicates: ObligationForest::new(),
|
||||||
relationships: FxHashMap::default(),
|
relationships: FxHashMap::default(),
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue