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:
@@ -736,15 +736,10 @@ fn project_type<'cx, 'tcx>(
|
|||||||
|
|
||||||
if !selcx.tcx().sess.recursion_limit().value_within_limit(obligation.recursion_depth) {
|
if !selcx.tcx().sess.recursion_limit().value_within_limit(obligation.recursion_depth) {
|
||||||
debug!("project: overflow!");
|
debug!("project: overflow!");
|
||||||
match selcx.query_mode() {
|
// This should really be an immediate error, but some existing code
|
||||||
super::TraitQueryMode::Standard => {
|
// relies on being able to recover from this.
|
||||||
selcx.infcx().report_overflow_error(&obligation, true);
|
|
||||||
}
|
|
||||||
super::TraitQueryMode::Canonical => {
|
|
||||||
return Err(ProjectionTyError::TraitSelectionError(SelectionError::Overflow));
|
return Err(ProjectionTyError::TraitSelectionError(SelectionError::Overflow));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
let obligation_trait_ref = &obligation.predicate.trait_ref(selcx.tcx());
|
let obligation_trait_ref = &obligation.predicate.trait_ref(selcx.tcx());
|
||||||
|
|
||||||
|
|||||||
@@ -291,10 +291,6 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||||||
self.infcx.tcx
|
self.infcx.tcx
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(super) fn query_mode(&self) -> TraitQueryMode {
|
|
||||||
self.query_mode
|
|
||||||
}
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////
|
||||||
// Selection
|
// Selection
|
||||||
//
|
//
|
||||||
|
|||||||
@@ -0,0 +1,58 @@
|
|||||||
|
// Regression test for #80953. Hitting the recursion limit in projection
|
||||||
|
// is non-fatal. The above code, minimised from wundergraph shows a case
|
||||||
|
// where this is relied on.
|
||||||
|
|
||||||
|
// check-pass
|
||||||
|
|
||||||
|
struct AlternateTable {}
|
||||||
|
struct AlternateQuery {}
|
||||||
|
|
||||||
|
pub trait Query {}
|
||||||
|
pub trait AsQuery {
|
||||||
|
type Query;
|
||||||
|
}
|
||||||
|
impl<T: Query> AsQuery for T {
|
||||||
|
type Query = Self;
|
||||||
|
}
|
||||||
|
impl AsQuery for AlternateTable {
|
||||||
|
type Query = AlternateQuery;
|
||||||
|
}
|
||||||
|
|
||||||
|
pub trait Table: AsQuery {
|
||||||
|
type PrimaryKey;
|
||||||
|
}
|
||||||
|
impl Table for AlternateTable {
|
||||||
|
type PrimaryKey = ();
|
||||||
|
}
|
||||||
|
|
||||||
|
pub trait FilterDsl<Predicate> {
|
||||||
|
type Output;
|
||||||
|
}
|
||||||
|
pub type Filter<Source, Predicate> = <Source as FilterDsl<Predicate>>::Output;
|
||||||
|
impl<T, Predicate> FilterDsl<Predicate> for T
|
||||||
|
where
|
||||||
|
T: Table,
|
||||||
|
T::Query: FilterDsl<Predicate>,
|
||||||
|
{
|
||||||
|
type Output = Filter<T::Query, Predicate>;
|
||||||
|
}
|
||||||
|
impl<Predicate> FilterDsl<Predicate> for AlternateQuery {
|
||||||
|
type Output = &'static str;
|
||||||
|
}
|
||||||
|
|
||||||
|
pub trait HandleDelete {
|
||||||
|
type Filter;
|
||||||
|
}
|
||||||
|
impl<T> HandleDelete for T
|
||||||
|
where
|
||||||
|
T: Table,
|
||||||
|
T::Query: FilterDsl<T::PrimaryKey>,
|
||||||
|
Filter<T::Query, T::PrimaryKey>: ,
|
||||||
|
{
|
||||||
|
type Filter = Filter<T::Query, T::PrimaryKey>;
|
||||||
|
}
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
let x: <AlternateTable as HandleDelete>::Filter = "Hello, world";
|
||||||
|
println!("{}", x);
|
||||||
|
}
|
||||||
@@ -1,10 +1,11 @@
|
|||||||
error[E0275]: overflow evaluating the requirement `<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<T as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next`
|
error[E0275]: overflow evaluating the requirement `<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<T as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next: Sized`
|
||||||
--> $DIR/issue-23122-2.rs:9:5
|
--> $DIR/issue-23122-2.rs:9:5
|
||||||
|
|
|
|
||||||
LL | type Next = <GetNext<T::Next> as Next>::Next;
|
LL | type Next = <GetNext<T::Next> as Next>::Next;
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
|
|
||||||
= help: consider adding a `#![recursion_limit="256"]` attribute to your crate (`issue_23122_2`)
|
= help: consider adding a `#![recursion_limit="256"]` attribute to your crate (`issue_23122_2`)
|
||||||
|
= note: required because of the requirements on the impl of `Next` for `GetNext<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<T as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next>`
|
||||||
|
|
||||||
error: aborting due to previous error
|
error: aborting due to previous error
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user