Query-ify global limit attribute handling
This commit is contained in:
parent
90442458ac
commit
ff15b5e2c7
30 changed files with 153 additions and 91 deletions
|
@ -53,7 +53,7 @@ impl<'a, 'tcx> Iterator for Autoderef<'a, 'tcx> {
|
|||
}
|
||||
|
||||
// If we have reached the recursion limit, error gracefully.
|
||||
if !tcx.sess.recursion_limit().value_within_limit(self.state.steps.len()) {
|
||||
if !tcx.recursion_limit(()).value_within_limit(self.state.steps.len()) {
|
||||
if !self.silence_errors {
|
||||
report_autoderef_recursion_limit_error(tcx, self.span, self.state.cur_ty);
|
||||
}
|
||||
|
@ -217,7 +217,7 @@ impl<'a, 'tcx> Autoderef<'a, 'tcx> {
|
|||
|
||||
pub fn report_autoderef_recursion_limit_error<'tcx>(tcx: TyCtxt<'tcx>, span: Span, ty: Ty<'tcx>) {
|
||||
// We've reached the recursion limit, error gracefully.
|
||||
let suggested_limit = tcx.sess.recursion_limit() * 2;
|
||||
let suggested_limit = tcx.recursion_limit(()) * 2;
|
||||
let msg = format!("reached the recursion limit while auto-dereferencing `{:?}`", ty);
|
||||
let error_id = (DiagnosticMessageId::ErrorId(55), Some(span), msg);
|
||||
let fresh = tcx.sess.one_time_diagnostics.borrow_mut().insert(error_id);
|
||||
|
|
|
@ -2310,7 +2310,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
|
|||
}
|
||||
|
||||
fn suggest_new_overflow_limit(&self, err: &mut DiagnosticBuilder<'_>) {
|
||||
let current_limit = self.tcx.sess.recursion_limit();
|
||||
let current_limit = self.tcx.recursion_limit(());
|
||||
let suggested_limit = current_limit * 2;
|
||||
err.help(&format!(
|
||||
"consider adding a `#![recursion_limit=\"{}\"]` attribute to your crate (`{}`)",
|
||||
|
|
|
@ -344,7 +344,7 @@ impl<'a, 'b, 'tcx> TypeFolder<'tcx> for AssocTypeNormalizer<'a, 'b, 'tcx> {
|
|||
Reveal::UserFacing => ty,
|
||||
|
||||
Reveal::All => {
|
||||
let recursion_limit = self.tcx().sess.recursion_limit();
|
||||
let recursion_limit = self.tcx().recursion_limit(());
|
||||
if !recursion_limit.value_within_limit(self.depth) {
|
||||
let obligation = Obligation::with_depth(
|
||||
self.cause.clone(),
|
||||
|
@ -726,7 +726,7 @@ fn project_type<'cx, 'tcx>(
|
|||
) -> Result<ProjectedTy<'tcx>, ProjectionTyError<'tcx>> {
|
||||
debug!(?obligation, "project_type");
|
||||
|
||||
if !selcx.tcx().sess.recursion_limit().value_within_limit(obligation.recursion_depth) {
|
||||
if !selcx.tcx().recursion_limit(()).value_within_limit(obligation.recursion_depth) {
|
||||
debug!("project: overflow!");
|
||||
// This should really be an immediate error, but some existing code
|
||||
// relies on being able to recover from this.
|
||||
|
|
|
@ -116,7 +116,7 @@ impl<'cx, 'tcx> TypeFolder<'tcx> for QueryNormalizer<'cx, 'tcx> {
|
|||
Reveal::UserFacing => ty,
|
||||
|
||||
Reveal::All => {
|
||||
let recursion_limit = self.tcx().sess.recursion_limit();
|
||||
let recursion_limit = self.tcx().recursion_limit(());
|
||||
if !recursion_limit.value_within_limit(self.anon_depth) {
|
||||
let obligation = Obligation::with_depth(
|
||||
self.cause.clone(),
|
||||
|
|
|
@ -993,7 +993,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||
obligation: &Obligation<'tcx, T>,
|
||||
error_obligation: &Obligation<'tcx, V>,
|
||||
) -> Result<(), OverflowError> {
|
||||
if !self.infcx.tcx.sess.recursion_limit().value_within_limit(obligation.recursion_depth) {
|
||||
if !self.infcx.tcx.recursion_limit(()).value_within_limit(obligation.recursion_depth) {
|
||||
match self.query_mode {
|
||||
TraitQueryMode::Standard => {
|
||||
self.infcx().report_overflow_error(error_obligation, true);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue