mirror of
https://github.com/rust-lang/rust.git
synced 2025-04-28 02:57:37 +00:00
More ensure stack to avoid segfault with increased recursion_limit
This commit is contained in:
parent
1841fb97e1
commit
00b380b8ca
@ -7,6 +7,7 @@ use crate::autoderef::Autoderef;
|
||||
use crate::infer::InferCtxt;
|
||||
use crate::traits::normalize_projection_type;
|
||||
|
||||
use rustc_data_structures::stack::ensure_sufficient_stack;
|
||||
use rustc_errors::{error_code, struct_span_err, Applicability, DiagnosticBuilder, Style};
|
||||
use rustc_hir as hir;
|
||||
use rustc_hir::def::DefKind;
|
||||
@ -1912,12 +1913,15 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
|
||||
|
||||
let parent_predicate = parent_trait_ref.without_const().to_predicate(tcx);
|
||||
if !self.is_recursive_obligation(obligated_types, &data.parent_code) {
|
||||
self.note_obligation_cause_code(
|
||||
err,
|
||||
&parent_predicate,
|
||||
&data.parent_code,
|
||||
obligated_types,
|
||||
);
|
||||
// #74711: avoid a stack overflow
|
||||
ensure_sufficient_stack(|| {
|
||||
self.note_obligation_cause_code(
|
||||
err,
|
||||
&parent_predicate,
|
||||
&data.parent_code,
|
||||
obligated_types,
|
||||
)
|
||||
});
|
||||
}
|
||||
}
|
||||
ObligationCauseCode::ImplDerivedObligation(ref data) => {
|
||||
@ -1928,22 +1932,28 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
|
||||
parent_trait_ref.skip_binder().self_ty()
|
||||
));
|
||||
let parent_predicate = parent_trait_ref.without_const().to_predicate(tcx);
|
||||
self.note_obligation_cause_code(
|
||||
err,
|
||||
&parent_predicate,
|
||||
&data.parent_code,
|
||||
obligated_types,
|
||||
);
|
||||
// #74711: avoid a stack overflow
|
||||
ensure_sufficient_stack(|| {
|
||||
self.note_obligation_cause_code(
|
||||
err,
|
||||
&parent_predicate,
|
||||
&data.parent_code,
|
||||
obligated_types,
|
||||
)
|
||||
});
|
||||
}
|
||||
ObligationCauseCode::DerivedObligation(ref data) => {
|
||||
let parent_trait_ref = self.resolve_vars_if_possible(&data.parent_trait_ref);
|
||||
let parent_predicate = parent_trait_ref.without_const().to_predicate(tcx);
|
||||
self.note_obligation_cause_code(
|
||||
err,
|
||||
&parent_predicate,
|
||||
&data.parent_code,
|
||||
obligated_types,
|
||||
);
|
||||
// #74711: avoid a stack overflow
|
||||
ensure_sufficient_stack(|| {
|
||||
self.note_obligation_cause_code(
|
||||
err,
|
||||
&parent_predicate,
|
||||
&data.parent_code,
|
||||
obligated_types,
|
||||
)
|
||||
});
|
||||
}
|
||||
ObligationCauseCode::CompareImplMethodObligation { .. } => {
|
||||
err.note(&format!(
|
||||
|
Loading…
Reference in New Issue
Block a user