mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-25 16:24:46 +00:00
Use TraitEngine in more places that don't specifically need FulfillmentCtxt::new_in_snapshot
This commit is contained in:
parent
6dbae3ad19
commit
58f107ab56
@ -10,7 +10,7 @@ use rustc_middle::mir::*;
|
|||||||
use rustc_middle::ty::{self, subst::SubstsRef, AdtDef, Ty};
|
use rustc_middle::ty::{self, subst::SubstsRef, AdtDef, Ty};
|
||||||
use rustc_span::DUMMY_SP;
|
use rustc_span::DUMMY_SP;
|
||||||
use rustc_trait_selection::traits::{
|
use rustc_trait_selection::traits::{
|
||||||
self, FulfillmentContext, ImplSource, Obligation, ObligationCause, SelectionContext,
|
self, ImplSource, Obligation, ObligationCause, SelectionContext, TraitEngineExt,
|
||||||
};
|
};
|
||||||
|
|
||||||
use super::ConstCx;
|
use super::ConstCx;
|
||||||
@ -191,7 +191,7 @@ impl Qualif for NeedsNonConstDrop {
|
|||||||
|
|
||||||
// If we successfully found one, then select all of the predicates
|
// If we successfully found one, then select all of the predicates
|
||||||
// implied by our const drop impl.
|
// implied by our const drop impl.
|
||||||
let mut fcx = FulfillmentContext::new();
|
let mut fcx = <dyn TraitEngine<'tcx>>::new(cx.tcx);
|
||||||
for nested in impl_src.nested_obligations() {
|
for nested in impl_src.nested_obligations() {
|
||||||
fcx.register_predicate_obligation(&infcx, nested);
|
fcx.register_predicate_obligation(&infcx, nested);
|
||||||
}
|
}
|
||||||
|
@ -205,7 +205,7 @@ impl<'tcx> AutoTraitFinder<'tcx> {
|
|||||||
// At this point, we already have all of the bounds we need. FulfillmentContext is used
|
// At this point, we already have all of the bounds we need. FulfillmentContext is used
|
||||||
// to store all of the necessary region/lifetime bounds in the InferContext, as well as
|
// to store all of the necessary region/lifetime bounds in the InferContext, as well as
|
||||||
// an additional sanity check.
|
// an additional sanity check.
|
||||||
let mut fulfill = FulfillmentContext::new();
|
let mut fulfill = <dyn TraitEngine<'tcx>>::new(tcx);
|
||||||
fulfill.register_bound(&infcx, full_env, ty, trait_did, ObligationCause::dummy());
|
fulfill.register_bound(&infcx, full_env, ty, trait_did, ObligationCause::dummy());
|
||||||
let errors = fulfill.select_all_or_error(&infcx);
|
let errors = fulfill.select_all_or_error(&infcx);
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
use crate::infer::{DefiningAnchor, TyCtxtInferExt};
|
use crate::infer::{DefiningAnchor, TyCtxtInferExt};
|
||||||
use crate::traits::{
|
use crate::traits::{
|
||||||
FulfillmentContext, ImplSource, Obligation, ObligationCause, SelectionContext, TraitEngine,
|
ImplSource, Obligation, ObligationCause, SelectionContext, TraitEngine, TraitEngineExt,
|
||||||
Unimplemented,
|
Unimplemented,
|
||||||
};
|
};
|
||||||
use rustc_middle::traits::CodegenObligationError;
|
use rustc_middle::traits::CodegenObligationError;
|
||||||
@ -55,7 +55,7 @@ pub fn codegen_fulfill_obligation<'tcx>(
|
|||||||
// Currently, we use a fulfillment context to completely resolve
|
// Currently, we use a fulfillment context to completely resolve
|
||||||
// all nested obligations. This is because they can inform the
|
// all nested obligations. This is because they can inform the
|
||||||
// inference of the impl's type parameters.
|
// inference of the impl's type parameters.
|
||||||
let mut fulfill_cx = FulfillmentContext::new();
|
let mut fulfill_cx = <dyn TraitEngine<'tcx>>::new(tcx);
|
||||||
let impl_source = selection.map(|predicate| {
|
let impl_source = selection.map(|predicate| {
|
||||||
fulfill_cx.register_predicate_obligation(&infcx, predicate);
|
fulfill_cx.register_predicate_obligation(&infcx, predicate);
|
||||||
});
|
});
|
||||||
|
@ -11,7 +11,7 @@ use crate::traits::util::impl_subject_and_oblig;
|
|||||||
use crate::traits::SkipLeakCheck;
|
use crate::traits::SkipLeakCheck;
|
||||||
use crate::traits::{
|
use crate::traits::{
|
||||||
self, FulfillmentContext, Normalized, Obligation, ObligationCause, PredicateObligation,
|
self, FulfillmentContext, Normalized, Obligation, ObligationCause, PredicateObligation,
|
||||||
PredicateObligations, SelectionContext,
|
PredicateObligations, SelectionContext, TraitEngineExt,
|
||||||
};
|
};
|
||||||
use rustc_data_structures::fx::FxIndexSet;
|
use rustc_data_structures::fx::FxIndexSet;
|
||||||
use rustc_errors::Diagnostic;
|
use rustc_errors::Diagnostic;
|
||||||
@ -385,7 +385,7 @@ fn resolve_negative_obligation<'cx, 'tcx>(
|
|||||||
return false;
|
return false;
|
||||||
};
|
};
|
||||||
|
|
||||||
let mut fulfillment_cx = FulfillmentContext::new();
|
let mut fulfillment_cx = <dyn TraitEngine<'tcx>>::new(infcx.tcx);
|
||||||
fulfillment_cx.register_predicate_obligation(infcx, o);
|
fulfillment_cx.register_predicate_obligation(infcx, o);
|
||||||
|
|
||||||
let errors = fulfillment_cx.select_all_or_error(infcx);
|
let errors = fulfillment_cx.select_all_or_error(infcx);
|
||||||
|
@ -163,7 +163,7 @@ pub fn type_known_to_meet_bound_modulo_regions<'a, 'tcx>(
|
|||||||
// The handling of regions in this area of the code is terrible,
|
// The handling of regions in this area of the code is terrible,
|
||||||
// see issue #29149. We should be able to improve on this with
|
// see issue #29149. We should be able to improve on this with
|
||||||
// NLL.
|
// NLL.
|
||||||
let mut fulfill_cx = FulfillmentContext::new();
|
let mut fulfill_cx = <dyn TraitEngine<'tcx>>::new(infcx.tcx);
|
||||||
|
|
||||||
// We can use a dummy node-id here because we won't pay any mind
|
// We can use a dummy node-id here because we won't pay any mind
|
||||||
// to region obligations that arise (there shouldn't really be any
|
// to region obligations that arise (there shouldn't really be any
|
||||||
|
@ -14,7 +14,9 @@ use specialization_graph::GraphExt;
|
|||||||
|
|
||||||
use crate::infer::{InferCtxt, InferOk, TyCtxtInferExt};
|
use crate::infer::{InferCtxt, InferOk, TyCtxtInferExt};
|
||||||
use crate::traits::select::IntercrateAmbiguityCause;
|
use crate::traits::select::IntercrateAmbiguityCause;
|
||||||
use crate::traits::{self, coherence, FutureCompatOverlapErrorKind, ObligationCause, TraitEngine};
|
use crate::traits::{
|
||||||
|
self, coherence, FutureCompatOverlapErrorKind, ObligationCause, TraitEngine, TraitEngineExt,
|
||||||
|
};
|
||||||
use rustc_data_structures::fx::{FxHashSet, FxIndexSet};
|
use rustc_data_structures::fx::{FxHashSet, FxIndexSet};
|
||||||
use rustc_errors::{struct_span_err, EmissionGuarantee, LintDiagnosticBuilder};
|
use rustc_errors::{struct_span_err, EmissionGuarantee, LintDiagnosticBuilder};
|
||||||
use rustc_hir::def_id::{DefId, LocalDefId};
|
use rustc_hir::def_id::{DefId, LocalDefId};
|
||||||
@ -24,8 +26,8 @@ use rustc_session::lint::builtin::COHERENCE_LEAK_CHECK;
|
|||||||
use rustc_session::lint::builtin::ORDER_DEPENDENT_TRAIT_OBJECTS;
|
use rustc_session::lint::builtin::ORDER_DEPENDENT_TRAIT_OBJECTS;
|
||||||
use rustc_span::{Span, DUMMY_SP};
|
use rustc_span::{Span, DUMMY_SP};
|
||||||
|
|
||||||
use super::util;
|
use super::SelectionContext;
|
||||||
use super::{FulfillmentContext, SelectionContext};
|
use super::{util, FulfillmentContext};
|
||||||
|
|
||||||
/// Information pertinent to an overlapping impl error.
|
/// Information pertinent to an overlapping impl error.
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
@ -207,7 +209,7 @@ fn fulfill_implication<'a, 'tcx>(
|
|||||||
// (which are packed up in penv)
|
// (which are packed up in penv)
|
||||||
|
|
||||||
infcx.save_and_restore_in_snapshot_flag(|infcx| {
|
infcx.save_and_restore_in_snapshot_flag(|infcx| {
|
||||||
let mut fulfill_cx = FulfillmentContext::new();
|
let mut fulfill_cx = <dyn TraitEngine<'tcx>>::new(infcx.tcx);
|
||||||
for oblig in obligations.chain(more_obligations) {
|
for oblig in obligations.chain(more_obligations) {
|
||||||
fulfill_cx.register_predicate_obligation(&infcx, oblig);
|
fulfill_cx.register_predicate_obligation(&infcx, oblig);
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
use crate::infer::{InferCtxt, TyCtxtInferExt};
|
use crate::infer::{InferCtxt, TyCtxtInferExt};
|
||||||
use crate::traits::ObligationCause;
|
use crate::traits::ObligationCause;
|
||||||
use crate::traits::{self, TraitEngine};
|
use crate::traits::{TraitEngine, TraitEngineExt};
|
||||||
|
|
||||||
use rustc_data_structures::fx::FxHashSet;
|
use rustc_data_structures::fx::FxHashSet;
|
||||||
use rustc_hir as hir;
|
use rustc_hir as hir;
|
||||||
@ -78,7 +78,7 @@ fn type_marked_structural<'tcx>(
|
|||||||
adt_ty: Ty<'tcx>,
|
adt_ty: Ty<'tcx>,
|
||||||
cause: ObligationCause<'tcx>,
|
cause: ObligationCause<'tcx>,
|
||||||
) -> bool {
|
) -> bool {
|
||||||
let mut fulfillment_cx = traits::FulfillmentContext::new();
|
let mut fulfillment_cx = <dyn TraitEngine<'tcx>>::new(infcx.tcx);
|
||||||
// require `#[derive(PartialEq)]`
|
// require `#[derive(PartialEq)]`
|
||||||
let structural_peq_def_id =
|
let structural_peq_def_id =
|
||||||
infcx.tcx.require_lang_item(LangItem::StructuralPeq, Some(cause.span));
|
infcx.tcx.require_lang_item(LangItem::StructuralPeq, Some(cause.span));
|
||||||
|
@ -14,8 +14,7 @@ use rustc_span::source_map::DUMMY_SP;
|
|||||||
use rustc_trait_selection::infer::InferCtxtBuilderExt;
|
use rustc_trait_selection::infer::InferCtxtBuilderExt;
|
||||||
use rustc_trait_selection::traits::query::{CanonicalTyGoal, Fallible, NoSolution};
|
use rustc_trait_selection::traits::query::{CanonicalTyGoal, Fallible, NoSolution};
|
||||||
use rustc_trait_selection::traits::wf;
|
use rustc_trait_selection::traits::wf;
|
||||||
use rustc_trait_selection::traits::FulfillmentContext;
|
use rustc_trait_selection::traits::{TraitEngine, TraitEngineExt};
|
||||||
use rustc_trait_selection::traits::TraitEngine;
|
|
||||||
use smallvec::{smallvec, SmallVec};
|
use smallvec::{smallvec, SmallVec};
|
||||||
|
|
||||||
pub(crate) fn provide(p: &mut Providers) {
|
pub(crate) fn provide(p: &mut Providers) {
|
||||||
@ -52,7 +51,7 @@ fn compute_implied_outlives_bounds<'tcx>(
|
|||||||
|
|
||||||
let mut implied_bounds = vec![];
|
let mut implied_bounds = vec![];
|
||||||
|
|
||||||
let mut fulfill_cx = FulfillmentContext::new();
|
let mut fulfill_cx = <dyn TraitEngine<'tcx>>::new(tcx);
|
||||||
|
|
||||||
while let Some(arg) = wf_args.pop() {
|
while let Some(arg) = wf_args.pop() {
|
||||||
if !checked_wf_args.insert(arg) {
|
if !checked_wf_args.insert(arg) {
|
||||||
|
@ -117,7 +117,7 @@ fn visit_implementation_of_copy(tcx: TyCtxt<'_>, impl_did: LocalDefId) {
|
|||||||
// it is not immediately clear why Copy is not implemented for a field, since
|
// it is not immediately clear why Copy is not implemented for a field, since
|
||||||
// all we point at is the field itself.
|
// all we point at is the field itself.
|
||||||
tcx.infer_ctxt().ignoring_regions().enter(|infcx| {
|
tcx.infer_ctxt().ignoring_regions().enter(|infcx| {
|
||||||
let mut fulfill_cx = traits::FulfillmentContext::new();
|
let mut fulfill_cx = <dyn TraitEngine<'_>>::new(tcx);
|
||||||
fulfill_cx.register_bound(
|
fulfill_cx.register_bound(
|
||||||
&infcx,
|
&infcx,
|
||||||
param_env,
|
param_env,
|
||||||
|
@ -7,7 +7,7 @@ use rustc_infer::traits::TraitEngine;
|
|||||||
use rustc_infer::traits::{ObligationCause, WellFormedLoc};
|
use rustc_infer::traits::{ObligationCause, WellFormedLoc};
|
||||||
use rustc_middle::ty::query::Providers;
|
use rustc_middle::ty::query::Providers;
|
||||||
use rustc_middle::ty::{self, Region, ToPredicate, TyCtxt, TypeFoldable, TypeFolder};
|
use rustc_middle::ty::{self, Region, ToPredicate, TyCtxt, TypeFoldable, TypeFolder};
|
||||||
use rustc_trait_selection::traits;
|
use rustc_trait_selection::traits::{self, TraitEngineExt};
|
||||||
|
|
||||||
pub fn provide(providers: &mut Providers) {
|
pub fn provide(providers: &mut Providers) {
|
||||||
*providers = Providers { diagnostic_hir_wf_check, ..*providers };
|
*providers = Providers { diagnostic_hir_wf_check, ..*providers };
|
||||||
@ -66,7 +66,7 @@ fn diagnostic_hir_wf_check<'tcx>(
|
|||||||
impl<'tcx> Visitor<'tcx> for HirWfCheck<'tcx> {
|
impl<'tcx> Visitor<'tcx> for HirWfCheck<'tcx> {
|
||||||
fn visit_ty(&mut self, ty: &'tcx hir::Ty<'tcx>) {
|
fn visit_ty(&mut self, ty: &'tcx hir::Ty<'tcx>) {
|
||||||
self.tcx.infer_ctxt().enter(|infcx| {
|
self.tcx.infer_ctxt().enter(|infcx| {
|
||||||
let mut fulfill = traits::FulfillmentContext::new();
|
let mut fulfill = <dyn TraitEngine<'tcx>>::new(self.tcx);
|
||||||
let tcx_ty =
|
let tcx_ty =
|
||||||
self.icx.to_ty(ty).fold_with(&mut EraseAllBoundRegions { tcx: self.tcx });
|
self.icx.to_ty(ty).fold_with(&mut EraseAllBoundRegions { tcx: self.tcx });
|
||||||
let cause = traits::ObligationCause::new(
|
let cause = traits::ObligationCause::new(
|
||||||
|
@ -3,7 +3,7 @@ use rustc_middle::ty::{self, Ty};
|
|||||||
use rustc_trait_selection::infer::InferCtxt;
|
use rustc_trait_selection::infer::InferCtxt;
|
||||||
use rustc_trait_selection::traits::query::type_op::{self, TypeOp, TypeOpOutput};
|
use rustc_trait_selection::traits::query::type_op::{self, TypeOp, TypeOpOutput};
|
||||||
use rustc_trait_selection::traits::query::NoSolution;
|
use rustc_trait_selection::traits::query::NoSolution;
|
||||||
use rustc_trait_selection::traits::{FulfillmentContext, ObligationCause, TraitEngine};
|
use rustc_trait_selection::traits::{ObligationCause, TraitEngine, TraitEngineExt};
|
||||||
|
|
||||||
pub use rustc_middle::traits::query::OutlivesBound;
|
pub use rustc_middle::traits::query::OutlivesBound;
|
||||||
|
|
||||||
@ -63,7 +63,7 @@ impl<'cx, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'cx, 'tcx> {
|
|||||||
if let Some(constraints) = constraints {
|
if let Some(constraints) = constraints {
|
||||||
// Instantiation may have produced new inference variables and constraints on those
|
// Instantiation may have produced new inference variables and constraints on those
|
||||||
// variables. Process these constraints.
|
// variables. Process these constraints.
|
||||||
let mut fulfill_cx = FulfillmentContext::new();
|
let mut fulfill_cx = <dyn TraitEngine<'tcx>>::new(self.tcx);
|
||||||
let cause = ObligationCause::misc(span, body_id);
|
let cause = ObligationCause::misc(span, body_id);
|
||||||
for &constraint in &constraints.outlives {
|
for &constraint in &constraints.outlives {
|
||||||
let obligation = self.query_outlives_constraint_to_obligation(
|
let obligation = self.query_outlives_constraint_to_obligation(
|
||||||
|
Loading…
Reference in New Issue
Block a user