Auto merge of #103877 - oli-obk:const_eval_step_limit, r=fee1-dead
Replace const eval limit by a lint and add an exponential backoff warning The lint triggers at the first power of 2 that comes after 1 million function calls or traversed back-edges (takes less than a second on usual programs). After the first emission, an unsilenceable warning is repeated at every following power of 2 terminators, causing it to get reported less and less the longer the evaluation runs. cc `@rust-lang/wg-const-eval` fixes #93481 closes #67217
This commit is contained in:
@@ -4,6 +4,7 @@ use std::mem;
|
||||
|
||||
use either::{Either, Left, Right};
|
||||
|
||||
use hir::CRATE_HIR_ID;
|
||||
use rustc_hir::{self as hir, def_id::DefId, definitions::DefPathData};
|
||||
use rustc_index::IndexVec;
|
||||
use rustc_middle::mir;
|
||||
@@ -405,6 +406,15 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
|
||||
self.stack().last().map_or(self.tcx.span, |f| f.current_span())
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
/// Find the first stack frame that is within the current crate, if any, otherwise return the crate's HirId
|
||||
pub fn best_lint_scope(&self) -> hir::HirId {
|
||||
self.stack()
|
||||
.iter()
|
||||
.find_map(|frame| frame.body.source.def_id().as_local())
|
||||
.map_or(CRATE_HIR_ID, |def_id| self.tcx.hir().local_def_id_to_hir_id(def_id))
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
pub(crate) fn stack(&self) -> &[Frame<'mir, 'tcx, M::Provenance, M::FrameExtra>] {
|
||||
M::stack(self)
|
||||
|
||||
Reference in New Issue
Block a user