Skip to main content

Budget

Enum Budget 

Source
#[non_exhaustive]
pub enum Budget {
Show 15 variants Delimiters, Angles, PrefixOperators, ClosureBars, ElseIf, Recursion, ModuleDepth, ModulePaths, DirectoryDepth, FileTokens, TotalBytes, ItemBytes, FactBytes, GlobBytes, Work,
}
Expand description

A budget of a load.

The first six bound shapes that make syn recurse and are enforced by the pre-scan before a file is parsed. The others bound the module walk, discovery, the tokens of one file, the bytes one load reads and keeps and the steps of glob table work one load makes. The limits live in one table, Budget::limit, which the code and the documentation share. The token budget, the four byte budgets and the work budget are defaults that LoadOptions can change.

Variants (Non-exhaustive)§

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

Delimiters

Open delimiters ((, [, {) nested at one point.

§

Angles

Open < brackets nested in one delimiter level.

§

PrefixOperators

Consecutive prefix operators (!, -, *, &, &&).

§

ClosureBars

Back-to-back closure heads (|| or |...| with no body between).

§

ElseIf

Chained else if links.

§

Recursion

The nesting that the parser builds by recursion, counted additively over every open delimiter level: the counted tokens of each open level since its count last returned to zero, plus one for each open delimiter. Parsing a file, reading its facts and dropping its syntax tree take at most RECURSION_UNIT_BYTES of the parse stack for each unit, so the limit keeps them within half of PARSE_STACK_BYTES.

§

ModuleDepth

Modules nested along one path from a target root, files and inline modules together. Unlike the others it is counted by the module walk and not by the pre-scan.

§

ModulePaths

Module paths recorded in one load: every arrival of the module walk at a file, counted over all targets. Counted by the module walk.

§

DirectoryDepth

Directories nested below a root, counted by package discovery and by the expansion of workspace.members patterns.

§

FileTokens

Guard token units of one file, counted by the pre-scan. A doc comment counts as its attribute. A numeric run may fuse up to three native leaves; PreparedSource::native_token_bound gives a separate checked native ceiling. This bounds token structure, not the complete native parser heap or work. PARSE_BYTES_PER_TOKEN is an empirical reference for the measured statement shape.

§

TotalBytes

Bytes read in one load: every source file and manifest.

§

ItemBytes

Bytes the symbol index keeps: every item record and the index entries built for each module path, each shared string once, and cumulative native load traversal spills, and immutable derived glob reach/broken facts with their shared allocation header.

§

FactBytes

Bytes of the facts read from the files of one load, counted on the parse thread as they are built.

§

GlobBytes

Bytes of the glob scope tables held at once: what each module exports to glob imports, kept once for every class of importers that see the same of it and shared by them, the glob imports that read each table, and the changes waiting to be passed on as the tables grow. Also bounds retained named-import reads, queues, subscriptions and graph scratch used to settle imports, including loads without globs, scratch for impl self-type and trait-path traversal and derived glob-fact construction, and the live scratch of selected-route proofs in a query after the load.

§

Work

Steps of glob table work in one load, counted as they are made and never given back: each queue, subscription and import-graph step, derived glob-fact construction and traversal, admitted buffer growth, each retained-read traversal, impl self-type and trait-path traversal and its retained path segments and bytes, each glob read listed and each name gathered when a view is built, each name a new reader is given, each reader a change is passed on to, each glob read read again when what a module’s globs bring in under a name is read again, each step of the search for the modules that hold an item apart from a reading module, and each glob read a lookup of what the globs of a module bring in looks at, with each view looked at to find those reads, charged at the next checkpoint of the load. These are the steps whose number grows faster than the bytes of the tables on some shapes of globs, so the budget bounds the work of settling them whatever their bytes. A query after the load counts the steps of its own lookups and selected-route determinacy proofs against the same budget, with the limit LoadOptions::max_query_work.

Implementations§

Source§

impl Budget

Source

pub const ALL: [Budget; 15]

Every budget, in table order.

Source

pub const fn limit(self) -> usize

The most the budget allows; one more is refused. For the token budget, the four byte budgets and the work budget this is the default of the matching LoadOptions field.

Source

pub const fn name(self) -> &'static str

The budget’s name as it appears in messages.

Trait Implementations§

Source§

impl Clone for Budget

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for Budget

Source§

impl Debug for Budget

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Display for Budget

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for Budget

Source§

impl Hash for Budget

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl Ord for Budget

Source§

fn cmp(&self, other: &Self) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 (const: unstable) · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 (const: unstable) · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 (const: unstable) · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

fn clamp_to<R>(self, range: R) -> Self
where Self: Sized, R: ClampBounds<Self>,

🔬This is a nightly-only experimental API. (clamp_to)
Restrict a value to a certain range. Read more
Source§

impl PartialEq for Budget

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl PartialOrd for Budget

Source§

fn partial_cmp(&self, other: &Self) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 (const: unstable) · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 (const: unstable) · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 (const: unstable) · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 (const: unstable) · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl StructuralPartialEq for Budget

Auto Trait Implementations§

§

impl Forget for Budget

§

impl Freeze for Budget

§

impl Move for Budget

§

impl RefUnwindSafe for Budget

§

impl Send for Budget

§

impl Sync for Budget

§

impl Unpin for Budget

§

impl UnsafeUnpin for Budget

§

impl UnwindSafe for Budget

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<Q, K> Comparable<K> for Q
where Q: Ord + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn compare(&self, key: &K) -> Ordering

Compare self to key and return their ordering.
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Whether this borrowed key equals the stored key.
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> EvidenceLease for T
where T: Debug + Send + Sync,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.