Remove const eval limit and implement an exponential backoff lint instead
This commit is contained in:
parent
578bcbc2b4
commit
05eae08233
41 changed files with 325 additions and 261 deletions
|
@ -1,8 +1,7 @@
|
|||
//! Registering limits:
|
||||
//! * recursion_limit,
|
||||
//! * move_size_limit,
|
||||
//! * type_length_limit, and
|
||||
//! * const_eval_limit
|
||||
//! * move_size_limit, and
|
||||
//! * type_length_limit
|
||||
//!
|
||||
//! There are various parts of the compiler that must impose arbitrary limits
|
||||
//! on how deeply they recurse to prevent stack overflow. Users can override
|
||||
|
@ -34,12 +33,6 @@ pub fn provide(providers: &mut Providers) {
|
|||
sym::type_length_limit,
|
||||
1048576,
|
||||
),
|
||||
const_eval_limit: get_limit(
|
||||
tcx.hir().krate_attrs(),
|
||||
tcx.sess,
|
||||
sym::const_eval_limit,
|
||||
2_000_000,
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -465,10 +465,6 @@ impl fmt::Display for UnsupportedOpInfo {
|
|||
pub enum ResourceExhaustionInfo {
|
||||
/// The stack grew too big.
|
||||
StackFrameLimitReached,
|
||||
/// The program ran for too long.
|
||||
///
|
||||
/// The exact limit is set by the `const_eval_limit` attribute.
|
||||
StepLimitReached,
|
||||
/// There is not enough memory (on the host) to perform an allocation.
|
||||
MemoryExhausted,
|
||||
/// The address space (of the target) is full.
|
||||
|
@ -482,9 +478,6 @@ impl fmt::Display for ResourceExhaustionInfo {
|
|||
StackFrameLimitReached => {
|
||||
write!(f, "reached the configured maximum number of stack frames")
|
||||
}
|
||||
StepLimitReached => {
|
||||
write!(f, "exceeded interpreter step limit (see `#[const_eval_limit]`)")
|
||||
}
|
||||
MemoryExhausted => {
|
||||
write!(f, "tried to allocate more memory than available to compiler")
|
||||
}
|
||||
|
|
|
@ -82,8 +82,6 @@ use std::iter;
|
|||
use std::mem;
|
||||
use std::ops::{Bound, Deref};
|
||||
|
||||
const TINY_CONST_EVAL_LIMIT: Limit = Limit(20);
|
||||
|
||||
#[allow(rustc::usage_of_ty_tykind)]
|
||||
impl<'tcx> Interner for TyCtxt<'tcx> {
|
||||
type AdtDef = ty::AdtDef<'tcx>;
|
||||
|
@ -1178,14 +1176,6 @@ impl<'tcx> TyCtxt<'tcx> {
|
|||
self.limits(()).move_size_limit
|
||||
}
|
||||
|
||||
pub fn const_eval_limit(self) -> Limit {
|
||||
if self.sess.opts.unstable_opts.tiny_const_eval_limit {
|
||||
TINY_CONST_EVAL_LIMIT
|
||||
} else {
|
||||
self.limits(()).const_eval_limit
|
||||
}
|
||||
}
|
||||
|
||||
pub fn all_traits(self) -> impl Iterator<Item = DefId> + 'tcx {
|
||||
iter::once(LOCAL_CRATE)
|
||||
.chain(self.crates(()).iter().copied())
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue