Skip to main content

pedant_core/resolution/rust/
limits.rs

1//! Resource ceilings shared by project loading and snapshot construction.
2
3/// Explicit bounds on everything a project or snapshot may traverse.
4///
5/// Every field has a documented default. A caller may lower a value to prove a
6/// bound, or raise one for a large repository; nothing is truncated silently.
7#[derive(Debug, Clone, Copy, PartialEq, Eq)]
8pub struct ResolutionLimits {
9    /// Manifests one project may read. Default 4,096.
10    pub max_manifests: u32,
11    /// Directory entries one project may visit while expanding `[workspace]`
12    /// member and exclude globs. Default 65,536.
13    ///
14    /// `max_manifests` bounds what a project reads, not what it walks: a
15    /// pattern such as `*/*` accepts every directory as a prefix, so the scan
16    /// descends a whole tree — a populated `target/` included — before the
17    /// first manifest is read and the manifest ceiling applies.
18    pub max_member_scan_entries: u32,
19    /// Resolution units one snapshot may hold. Default 4,096.
20    pub max_units: u32,
21    /// Distinct source files one snapshot may hold. Default 65,536.
22    pub max_source_files: u32,
23    /// Bytes one source file may hold. Default 8 MiB.
24    pub max_source_file_bytes: u64,
25    /// Bytes all distinct source text may hold. Default 512 MiB.
26    pub max_total_source_bytes: u64,
27    /// Rust module nesting depth followed inside one unit. Default 256.
28    pub max_module_depth: u32,
29    /// Rust module instances one unit may hold. Default 65,536.
30    ///
31    /// Depth and distinct-source ceilings do not bound this on their own: a
32    /// declaration graph that reaches one source through several `#[path]`
33    /// alternatives instantiates that source once per route, so a few dozen
34    /// files can name millions of instances while every other ceiling holds.
35    pub max_module_instances: u32,
36    /// Cargo dependency depth followed from the root target. Default 256.
37    pub max_dependency_depth: u32,
38    /// Syntax nesting depth accepted while parsing. Default 256.
39    pub max_syntax_depth: u32,
40    /// Candidates one reference may carry. Default 1,024.
41    pub max_candidates_per_reference: u32,
42}
43
44impl Default for ResolutionLimits {
45    fn default() -> Self {
46        Self {
47            max_manifests: 4_096,
48            max_member_scan_entries: 65_536,
49            max_units: 4_096,
50            max_source_files: 65_536,
51            max_source_file_bytes: 8 * 1_024 * 1_024,
52            max_total_source_bytes: 512 * 1_024 * 1_024,
53            max_module_depth: 256,
54            max_module_instances: 65_536,
55            max_dependency_depth: 256,
56            max_syntax_depth: 256,
57            max_candidates_per_reference: 1_024,
58        }
59    }
60}