Rollup merge of #110220 - lcnr:regionzz, r=compiler-errors
cleanup our region error API - require `TypeErrCtxt` to always result in an error, closing #108810 - move `resolve_regions_and_report_errors` to the `ObligationCtxt` - call `process_registered_region_obligations` in `resolve_regions` - move `resolve_regions` into the `outlives` submodule - add `#[must_use]` to functions returning lists of errors r? types
This commit is contained in:
commit
6f1500aec2
15 changed files with 192 additions and 237 deletions
|
@ -186,7 +186,8 @@ impl<'tcx> AutoTraitFinder<'tcx> {
|
|||
panic!("Unable to fulfill trait {:?} for '{:?}': {:?}", trait_did, ty, errors);
|
||||
}
|
||||
|
||||
infcx.process_registered_region_obligations(&Default::default(), full_env);
|
||||
let outlives_env = OutlivesEnvironment::new(full_env);
|
||||
infcx.process_registered_region_obligations(&outlives_env);
|
||||
|
||||
let region_data =
|
||||
infcx.inner.borrow_mut().unwrap_region_constraints().region_constraint_data().clone();
|
||||
|
|
|
@ -405,9 +405,6 @@ fn resolve_negative_obligation<'tcx>(
|
|||
param_env,
|
||||
infcx.implied_bounds_tys(param_env, body_def_id, wf_tys),
|
||||
);
|
||||
|
||||
infcx.process_registered_region_obligations(outlives_env.region_bound_pairs(), param_env);
|
||||
|
||||
infcx.resolve_regions(&outlives_env).is_empty()
|
||||
}
|
||||
|
||||
|
|
|
@ -6,11 +6,13 @@ use super::{ChalkFulfillmentContext, FulfillmentContext};
|
|||
use crate::solve::FulfillmentCtxt as NextFulfillmentCtxt;
|
||||
use crate::traits::NormalizeExt;
|
||||
use rustc_data_structures::fx::FxIndexSet;
|
||||
use rustc_errors::ErrorGuaranteed;
|
||||
use rustc_hir::def_id::{DefId, LocalDefId};
|
||||
use rustc_infer::infer::at::ToTrace;
|
||||
use rustc_infer::infer::canonical::{
|
||||
Canonical, CanonicalQueryResponse, CanonicalVarValues, QueryResponse,
|
||||
};
|
||||
use rustc_infer::infer::outlives::env::OutlivesEnvironment;
|
||||
use rustc_infer::infer::{DefineOpaqueTypes, InferCtxt, InferOk};
|
||||
use rustc_infer::traits::query::Fallible;
|
||||
use rustc_infer::traits::{
|
||||
|
@ -173,14 +175,33 @@ impl<'a, 'tcx> ObligationCtxt<'a, 'tcx> {
|
|||
.map(|infer_ok| self.register_infer_ok_obligations(infer_ok))
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
pub fn select_where_possible(&self) -> Vec<FulfillmentError<'tcx>> {
|
||||
self.engine.borrow_mut().select_where_possible(self.infcx)
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
pub fn select_all_or_error(&self) -> Vec<FulfillmentError<'tcx>> {
|
||||
self.engine.borrow_mut().select_all_or_error(self.infcx)
|
||||
}
|
||||
|
||||
/// Resolves regions and reports errors.
|
||||
///
|
||||
/// Takes ownership of the context as doing trait solving afterwards
|
||||
/// will result in region constraints getting ignored.
|
||||
pub fn resolve_regions_and_report_errors(
|
||||
self,
|
||||
generic_param_scope: LocalDefId,
|
||||
outlives_env: &OutlivesEnvironment<'tcx>,
|
||||
) -> Result<(), ErrorGuaranteed> {
|
||||
let errors = self.infcx.resolve_regions(&outlives_env);
|
||||
if errors.is_empty() {
|
||||
Ok(())
|
||||
} else {
|
||||
Err(self.infcx.err_ctxt().report_region_errors(generic_param_scope, &errors))
|
||||
}
|
||||
}
|
||||
|
||||
pub fn assumed_wf_types(
|
||||
&self,
|
||||
param_env: ty::ParamEnv<'tcx>,
|
||||
|
|
|
@ -1776,7 +1776,10 @@ impl<'tcx> InferCtxtPrivExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
|
|||
|
||||
// constrain inference variables a bit more to nested obligations from normalize so
|
||||
// we can have more helpful errors.
|
||||
ocx.select_where_possible();
|
||||
//
|
||||
// we intentionally drop errors from normalization here,
|
||||
// since the normalization is just done to improve the error message.
|
||||
let _ = ocx.select_where_possible();
|
||||
|
||||
if let Err(new_err) = ocx.eq_exp(
|
||||
&obligation.cause,
|
||||
|
|
|
@ -117,10 +117,6 @@ pub fn type_allowed_to_implement_copy<'tcx>(
|
|||
FxIndexSet::from_iter([self_type]),
|
||||
),
|
||||
);
|
||||
infcx.process_registered_region_obligations(
|
||||
outlives_env.region_bound_pairs(),
|
||||
param_env,
|
||||
);
|
||||
let errors = infcx.resolve_regions(&outlives_env);
|
||||
if !errors.is_empty() {
|
||||
infringing.push((field, ty, InfringingFieldsReason::Regions(errors)));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue