region_outlives_predicate no snapshot

This commit is contained in:
lcnr 2022-07-20 11:49:20 +02:00
parent 608625dae9
commit 43ccacf89b
6 changed files with 15 additions and 42 deletions

View file

@ -559,7 +559,7 @@ E0790: include_str!("./error_codes/E0790.md"),
// E0273, // on_unimplemented #1 // E0273, // on_unimplemented #1
// E0274, // on_unimplemented #2 // E0274, // on_unimplemented #2
// E0278, // requirement is not satisfied // E0278, // requirement is not satisfied
E0279, // requirement is not satisfied // E0279,
E0280, // requirement is not satisfied E0280, // requirement is not satisfied
// E0285, // overflow evaluation builtin bounds // E0285, // overflow evaluation builtin bounds
// E0296, // replaced with a generic attribute input check // E0296, // replaced with a generic attribute input check

View file

@ -1061,16 +1061,11 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
&self, &self,
cause: &traits::ObligationCause<'tcx>, cause: &traits::ObligationCause<'tcx>,
predicate: ty::PolyRegionOutlivesPredicate<'tcx>, predicate: ty::PolyRegionOutlivesPredicate<'tcx>,
) -> UnitResult<'tcx> { ) {
self.commit_if_ok(|_snapshot| { let ty::OutlivesPredicate(r_a, r_b) = self.replace_bound_vars_with_placeholders(predicate);
let ty::OutlivesPredicate(r_a, r_b) = let origin =
self.replace_bound_vars_with_placeholders(predicate); SubregionOrigin::from_obligation_cause(cause, || RelateRegionParamBound(cause.span));
let origin = SubregionOrigin::from_obligation_cause(cause, || { self.sub_regions(origin, r_b, r_a); // `b : a` ==> `a <= b`
RelateRegionParamBound(cause.span)
});
self.sub_regions(origin, r_b, r_a); // `b : a` ==> `a <= b`
Ok(())
})
} }
/// Number of type variables created so far. /// Number of type variables created so far.

View file

@ -793,9 +793,7 @@ impl<'tcx> AutoTraitFinder<'tcx> {
} }
ty::PredicateKind::RegionOutlives(binder) => { ty::PredicateKind::RegionOutlives(binder) => {
let binder = bound_predicate.rebind(binder); let binder = bound_predicate.rebind(binder);
if select.infcx().region_outlives_predicate(&dummy_cause, binder).is_err() { select.infcx().region_outlives_predicate(&dummy_cause, binder)
return false;
}
} }
ty::PredicateKind::TypeOutlives(binder) => { ty::PredicateKind::TypeOutlives(binder) => {
let binder = bound_predicate.rebind(binder); let binder = bound_predicate.rebind(binder);

View file

@ -789,24 +789,9 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
span_bug!(span, "coerce requirement gave wrong error: `{:?}`", predicate) span_bug!(span, "coerce requirement gave wrong error: `{:?}`", predicate)
} }
ty::PredicateKind::RegionOutlives(predicate) => { ty::PredicateKind::RegionOutlives(..)
let predicate = bound_predicate.rebind(predicate); | ty::PredicateKind::Projection(..)
let predicate = self.resolve_vars_if_possible(predicate); | ty::PredicateKind::TypeOutlives(..) => {
let err = self
.region_outlives_predicate(&obligation.cause, predicate)
.err()
.unwrap();
struct_span_err!(
self.tcx.sess,
span,
E0279,
"the requirement `{}` is not satisfied (`{}`)",
predicate,
err,
)
}
ty::PredicateKind::Projection(..) | ty::PredicateKind::TypeOutlives(..) => {
let predicate = self.resolve_vars_if_possible(obligation.predicate); let predicate = self.resolve_vars_if_possible(obligation.predicate);
struct_span_err!( struct_span_err!(
self.tcx.sess, self.tcx.sess,

View file

@ -359,15 +359,10 @@ impl<'a, 'b, 'tcx> ObligationProcessor for FulfillProcessor<'a, 'b, 'tcx> {
ty::PredicateKind::RegionOutlives(data) => { ty::PredicateKind::RegionOutlives(data) => {
if infcx.considering_regions || data.has_placeholders() { if infcx.considering_regions || data.has_placeholders() {
match infcx infcx.region_outlives_predicate(&obligation.cause, Binder::dummy(data));
.region_outlives_predicate(&obligation.cause, Binder::dummy(data))
{
Ok(()) => ProcessResult::Changed(vec![]),
Err(_) => ProcessResult::Error(CodeSelectionError(Unimplemented)),
}
} else {
ProcessResult::Changed(vec![])
} }
ProcessResult::Changed(vec![])
} }
ty::PredicateKind::TypeOutlives(ty::OutlivesPredicate(t_a, r_b)) => { ty::PredicateKind::TypeOutlives(ty::OutlivesPredicate(t_a, r_b)) => {

View file

@ -10,8 +10,8 @@ use regex::Regex;
// A few of those error codes can't be tested but all the others can and *should* be tested! // A few of those error codes can't be tested but all the others can and *should* be tested!
const EXEMPTED_FROM_TEST: &[&str] = &[ const EXEMPTED_FROM_TEST: &[&str] = &[
"E0279", "E0313", "E0377", "E0461", "E0462", "E0465", "E0476", "E0490", "E0514", "E0519", "E0313", "E0377", "E0461", "E0462", "E0465", "E0476", "E0490", "E0514", "E0519", "E0523",
"E0523", "E0554", "E0640", "E0717", "E0729", "E0789", "E0554", "E0640", "E0717", "E0729", "E0789",
]; ];
// Some error codes don't have any tests apparently... // Some error codes don't have any tests apparently...