Auto merge of #81055 - matthewjasper:non-fatal-overflow, r=nikomatsakis

Make hitting the recursion limit in projection non-fatal

This change was originally made in #80246 to avoid future (effectively) infinite loop bugs in projections,
but wundergraph relies on rustc recovering here.

cc #80953

r? `@nikomatsakis`
This commit is contained in:
bors 2021-01-28 18:57:10 +00:00
commit c0b64d97be
4 changed files with 63 additions and 13 deletions

View file

@ -736,14 +736,9 @@ fn project_type<'cx, 'tcx>(
if !selcx.tcx().sess.recursion_limit().value_within_limit(obligation.recursion_depth) {
debug!("project: overflow!");
match selcx.query_mode() {
super::TraitQueryMode::Standard => {
selcx.infcx().report_overflow_error(&obligation, true);
}
super::TraitQueryMode::Canonical => {
return Err(ProjectionTyError::TraitSelectionError(SelectionError::Overflow));
}
}
// This should really be an immediate error, but some existing code
// relies on being able to recover from this.
return Err(ProjectionTyError::TraitSelectionError(SelectionError::Overflow));
}
let obligation_trait_ref = &obligation.predicate.trait_ref(selcx.tcx());

View file

@ -291,10 +291,6 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
self.infcx.tcx
}
pub(super) fn query_mode(&self) -> TraitQueryMode {
self.query_mode
}
///////////////////////////////////////////////////////////////////////////
// Selection
//