Skip to main content

Scope

Struct Scope 

Source
pub struct Scope { /* private fields */ }
Expand description

Compiled include/exclude matcher built from a PathsSpec or raw pattern list, optionally bundled with a ScopeFilter ancestor-manifest gate.

Patterns prefixed with ! are treated as excludes when passed as a flat list. Paths are matched relative to the repository root. Globs are compiled with literal_separator(true) — i.e., Git-style semantics where * never crosses a path separator. ** is required to descend into subdirectories.

The optional scope_filter is the v0.9.6 ScopeFilter gate (e.g. has_ancestor: Cargo.toml). v0.9.10 moved it into Scope so matches(&Path, &FileIndex) honours it on every call automatically — the v0.9.6/v0.9.7/v0.9.9 silent-no-op bug class can no longer recur.

Implementations§

Source§

impl Scope

Source

pub fn from_patterns(patterns: &[String]) -> Result<Self>

Source

pub fn from_paths_spec(spec: &PathsSpec) -> Result<Self>

Source

pub fn from_spec(spec: &RuleSpec) -> Result<Self>

Build a Scope from a RuleSpec — bundles the rule’s paths: (or match-all if absent) AND its scope_filter: into a single value. This is the canonical constructor for rule builders since v0.9.10; preferring it over from_paths_spec is what compile-enforces every rule to honour scope_filter (the v0.9.6/.7/.9 silent-no-op bug class).

Source

pub fn match_all() -> Self

Match-all scope (used when no paths is configured on a rule).

Source

pub fn scope_filter(&self) -> Option<&ScopeFilter>

Borrow the optional ScopeFilter this scope carries. Used by dispatch sites (e.g. for_each_dir’s literal- path bypass) that already have a &Scope in hand and want to consult the filter without going through matches.

Source

pub fn matches(&self, path: &Path, index: &FileIndex) -> bool

Returns true iff path is in scope:

  1. Excluded patterns reject (dominant).
  2. Include patterns must match (skipped if no includes).
  3. scope_filter (if any) must match.

The index argument is the engine’s FileIndex — required because scope_filter may need to walk ancestors looking for a manifest (e.g. has_ancestor: Cargo.toml). Callers that don’t have a scope_filter on this scope still pass it; the cost is a single Option::is_none branch.

#[inline] is load-bearing — this method runs on every (rule, file) pair in the per-file dispatch hot loop. Without it, cross-crate calls from alint-rules rules’ evaluate bodies don’t inline through thin LTO and the Option<ScopeFilter> None-branch becomes a non-inlined function call (~40 % slowdown on S6 10k vs v0.9.9 without the hint).

Trait Implementations§

Source§

impl Clone for Scope

Source§

fn clone(&self) -> Scope

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 Debug for Scope

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Freeze for Scope

§

impl RefUnwindSafe for Scope

§

impl Send for Scope

§

impl Sync for Scope

§

impl Unpin for Scope

§

impl UnsafeUnpin for Scope

§

impl UnwindSafe for Scope

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<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> 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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more