X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;f=compiler%2Frustc_trait_selection%2Fsrc%2Ftraits%2Fcoherence.rs;h=f62ccb99df5ebf12118cfff4e460caaed5eec5e5;hb=c436930f91a4befefa602f2d64d06fc9613d507b;hp=fa94aa19abda594386bf61b758c515621a5a3ec6;hpb=30a5eb063eca51f7dac9fce79d66a95bc8cbacad;p=rust.git diff --git a/compiler/rustc_trait_selection/src/traits/coherence.rs b/compiler/rustc_trait_selection/src/traits/coherence.rs index fa94aa19abd..38e2500da9b 100644 --- a/compiler/rustc_trait_selection/src/traits/coherence.rs +++ b/compiler/rustc_trait_selection/src/traits/coherence.rs @@ -10,14 +10,14 @@ use crate::traits::util::impl_subject_and_oblig; use crate::traits::SkipLeakCheck; use crate::traits::{ - self, FulfillmentContext, Normalized, Obligation, ObligationCause, PredicateObligation, - PredicateObligations, SelectionContext, + self, Normalized, Obligation, ObligationCause, PredicateObligation, PredicateObligations, + SelectionContext, }; use rustc_data_structures::fx::FxIndexSet; use rustc_errors::Diagnostic; use rustc_hir::def_id::{DefId, LOCAL_CRATE}; use rustc_infer::infer::{InferCtxt, TyCtxtInferExt}; -use rustc_infer::traits::{util, TraitEngine}; +use rustc_infer::traits::util; use rustc_middle::traits::specialization_graph::OverlapMode; use rustc_middle::ty::fast_reject::{DeepRejectCtxt, TreatParams}; use rustc_middle::ty::subst::Subst; @@ -302,13 +302,18 @@ fn negative_impl<'cx, 'tcx>( let impl_env = tcx.param_env(impl1_def_id); let subject1 = match traits::fully_normalize( &infcx, - FulfillmentContext::new(), ObligationCause::dummy(), impl_env, tcx.impl_subject(impl1_def_id), ) { Ok(s) => s, - Err(err) => bug!("failed to fully normalize {:?}: {:?}", impl1_def_id, err), + Err(err) => { + tcx.sess.delay_span_bug( + tcx.def_span(impl1_def_id), + format!("failed to fully normalize {:?}: {:?}", impl1_def_id, err), + ); + return false; + } }; // Attempt to prove that impl2 applies, given all of the above. @@ -385,26 +390,15 @@ fn resolve_negative_obligation<'cx, 'tcx>( return false; }; - let mut fulfillment_cx = FulfillmentContext::new(); - fulfillment_cx.register_predicate_obligation(infcx, o); - - let errors = fulfillment_cx.select_all_or_error(infcx); - + let errors = super::fully_solve_obligation(infcx, o); if !errors.is_empty() { return false; } - // FIXME -- also add "assumed to be well formed" types into the `outlives_env` let outlives_env = OutlivesEnvironment::new(param_env); infcx.process_registered_region_obligations(outlives_env.region_bound_pairs(), param_env); - let errors = infcx.resolve_regions(&outlives_env); - - if !errors.is_empty() { - return false; - } - - true + infcx.resolve_regions(&outlives_env).is_empty() } pub fn trait_ref_is_knowable<'tcx>(