diff options
| author | bors <bors@rust-lang.org> | 2025-01-13 10:18:26 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2025-01-13 10:18:26 +0000 |
| commit | 3ff1b6410e87a237559ab76ecd50f180afbe861f (patch) | |
| tree | 68eb1d0fbe3f19c9d8bc6021ffa1844651fbd40a /compiler/rustc_query_system/src/query | |
| parent | b4045a404ec7f2010ab0465b6b0b35aa8c752248 (diff) | |
| parent | 4b81c5beb19fa273fe5690bfc5d531b73e87b542 (diff) | |
| download | rust-3ff1b6410e87a237559ab76ecd50f180afbe861f.tar.gz rust-3ff1b6410e87a237559ab76ecd50f180afbe861f.zip | |
Auto merge of #135167 - mzacho:depth-limit-const-eval-query, r=oli-obk
Depth limit const eval query Currently the const-eval query doesn't have a recursion limit or timeout, causing the complier to freeze in an infinite loop, see #125718. This PR depth limits the `eval_to_const_value_raw` query (with the [`recursion_limit`](https://doc.rust-lang.org/reference/attributes/limits.html) attribute) and improves the diagnostics for query overflow errors, so spans are reported for other dep kinds than `layout_of` (e.g. `eval_to_const_value_raw`). fixes #125718 fixes #114192
Diffstat (limited to 'compiler/rustc_query_system/src/query')
| -rw-r--r-- | compiler/rustc_query_system/src/query/job.rs | 20 |
1 files changed, 9 insertions, 11 deletions
diff --git a/compiler/rustc_query_system/src/query/job.rs b/compiler/rustc_query_system/src/query/job.rs index 2a7d759ab35..3e179c61f39 100644 --- a/compiler/rustc_query_system/src/query/job.rs +++ b/compiler/rustc_query_system/src/query/job.rs @@ -15,7 +15,7 @@ use rustc_span::{DUMMY_SP, Span}; use crate::dep_graph::DepContext; use crate::error::CycleStack; use crate::query::plumbing::CycleError; -use crate::query::{DepKind, QueryContext, QueryStackFrame}; +use crate::query::{QueryContext, QueryStackFrame}; /// Represents a span and a query key. #[derive(Clone, Debug)] @@ -136,20 +136,18 @@ impl QueryJobId { #[cold] #[inline(never)] - pub fn try_find_layout_root( - &self, - query_map: QueryMap, - layout_of_kind: DepKind, - ) -> Option<(QueryJobInfo, usize)> { - let mut last_layout = None; - let mut current_id = Some(*self); - let mut depth = 0; + pub fn find_dep_kind_root(&self, query_map: QueryMap) -> (QueryJobInfo, usize) { + let mut depth = 1; + let info = query_map.get(&self).unwrap(); + let dep_kind = info.query.dep_kind; + let mut current_id = info.job.parent; + let mut last_layout = (info.clone(), depth); while let Some(id) = current_id { let info = query_map.get(&id).unwrap(); - if info.query.dep_kind == layout_of_kind { + if info.query.dep_kind == dep_kind { depth += 1; - last_layout = Some((info.clone(), depth)); + last_layout = (info.clone(), depth); } current_id = info.job.parent; } |
