Opt-in diagnostics reporting to avoid doing extra work in the new solver
This commit is contained in:
@@ -10,7 +10,7 @@ use rustc_hir::intravisit;
|
||||
use rustc_hir::{GenericParamKind, ImplItemKind};
|
||||
use rustc_infer::infer::outlives::env::OutlivesEnvironment;
|
||||
use rustc_infer::infer::{self, InferCtxt, TyCtxtInferExt};
|
||||
use rustc_infer::traits::util;
|
||||
use rustc_infer::traits::{util, FulfillmentErrorLike};
|
||||
use rustc_middle::ty::error::{ExpectedFound, TypeError};
|
||||
use rustc_middle::ty::fold::BottomUpFolder;
|
||||
use rustc_middle::ty::util::ExplicitSelf;
|
||||
@@ -225,7 +225,7 @@ fn compare_method_predicate_entailment<'tcx>(
|
||||
let param_env = traits::normalize_param_env_or_error(tcx, param_env, normalize_cause);
|
||||
|
||||
let infcx = &tcx.infer_ctxt().build();
|
||||
let ocx = ObligationCtxt::new(infcx);
|
||||
let ocx = ObligationCtxt::new_with_diagnostics(infcx);
|
||||
|
||||
debug!("compare_impl_method: caller_bounds={:?}", param_env.caller_bounds());
|
||||
|
||||
@@ -493,7 +493,7 @@ pub(super) fn collect_return_position_impl_trait_in_trait_tys<'tcx>(
|
||||
);
|
||||
|
||||
let infcx = &tcx.infer_ctxt().build();
|
||||
let ocx = ObligationCtxt::new(infcx);
|
||||
let ocx = ObligationCtxt::new_with_diagnostics(infcx);
|
||||
|
||||
// Normalize the impl signature with fresh variables for lifetime inference.
|
||||
let misc_cause = ObligationCause::misc(return_span, impl_m_def_id);
|
||||
@@ -764,17 +764,23 @@ pub(super) fn collect_return_position_impl_trait_in_trait_tys<'tcx>(
|
||||
Ok(&*tcx.arena.alloc(remapped_types))
|
||||
}
|
||||
|
||||
struct ImplTraitInTraitCollector<'a, 'tcx> {
|
||||
ocx: &'a ObligationCtxt<'a, 'tcx>,
|
||||
struct ImplTraitInTraitCollector<'a, 'tcx, E>
|
||||
where
|
||||
E: FulfillmentErrorLike<'tcx>,
|
||||
{
|
||||
ocx: &'a ObligationCtxt<'a, 'tcx, E>,
|
||||
types: FxIndexMap<DefId, (Ty<'tcx>, ty::GenericArgsRef<'tcx>)>,
|
||||
span: Span,
|
||||
param_env: ty::ParamEnv<'tcx>,
|
||||
body_id: LocalDefId,
|
||||
}
|
||||
|
||||
impl<'a, 'tcx> ImplTraitInTraitCollector<'a, 'tcx> {
|
||||
impl<'a, 'tcx, E> ImplTraitInTraitCollector<'a, 'tcx, E>
|
||||
where
|
||||
E: FulfillmentErrorLike<'tcx>,
|
||||
{
|
||||
fn new(
|
||||
ocx: &'a ObligationCtxt<'a, 'tcx>,
|
||||
ocx: &'a ObligationCtxt<'a, 'tcx, E>,
|
||||
span: Span,
|
||||
param_env: ty::ParamEnv<'tcx>,
|
||||
body_id: LocalDefId,
|
||||
@@ -783,7 +789,10 @@ impl<'a, 'tcx> ImplTraitInTraitCollector<'a, 'tcx> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx> TypeFolder<TyCtxt<'tcx>> for ImplTraitInTraitCollector<'_, 'tcx> {
|
||||
impl<'tcx, E> TypeFolder<TyCtxt<'tcx>> for ImplTraitInTraitCollector<'_, 'tcx, E>
|
||||
where
|
||||
E: FulfillmentErrorLike<'tcx>,
|
||||
{
|
||||
fn interner(&self) -> TyCtxt<'tcx> {
|
||||
self.ocx.infcx.tcx
|
||||
}
|
||||
@@ -1777,7 +1786,7 @@ fn compare_const_predicate_entailment<'tcx>(
|
||||
);
|
||||
|
||||
let infcx = tcx.infer_ctxt().build();
|
||||
let ocx = ObligationCtxt::new(&infcx);
|
||||
let ocx = ObligationCtxt::new_with_diagnostics(&infcx);
|
||||
|
||||
let impl_ct_own_bounds = impl_ct_predicates.instantiate_own(tcx, impl_args);
|
||||
for (predicate, span) in impl_ct_own_bounds {
|
||||
@@ -1910,7 +1919,7 @@ fn compare_type_predicate_entailment<'tcx>(
|
||||
let param_env = ty::ParamEnv::new(tcx.mk_clauses(&hybrid_preds.predicates), Reveal::UserFacing);
|
||||
let param_env = traits::normalize_param_env_or_error(tcx, param_env, normalize_cause);
|
||||
let infcx = tcx.infer_ctxt().build();
|
||||
let ocx = ObligationCtxt::new(&infcx);
|
||||
let ocx = ObligationCtxt::new_with_diagnostics(&infcx);
|
||||
|
||||
debug!("compare_type_predicate_entailment: caller_bounds={:?}", param_env.caller_bounds());
|
||||
|
||||
@@ -1977,7 +1986,7 @@ pub(super) fn check_type_bounds<'tcx>(
|
||||
let rebased_args = impl_ty_args.rebase_onto(tcx, container_id, impl_trait_ref.args);
|
||||
|
||||
let infcx = tcx.infer_ctxt().build();
|
||||
let ocx = ObligationCtxt::new(&infcx);
|
||||
let ocx = ObligationCtxt::new_with_diagnostics(&infcx);
|
||||
|
||||
// A synthetic impl Trait for RPITIT desugaring has no HIR, which we currently use to get the
|
||||
// span for an impl's associated type. Instead, for these, use the def_span for the synthesized
|
||||
|
||||
Reference in New Issue
Block a user