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
impl Scope
pub fn from_patterns(patterns: &[String]) -> Result<Self>
pub fn from_paths_spec(spec: &PathsSpec) -> Result<Self>
Sourcepub fn from_spec(spec: &RuleSpec) -> Result<Self>
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).
Sourcepub fn scope_filter(&self) -> Option<&ScopeFilter>
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.
Sourcepub fn matches(&self, path: &Path, index: &FileIndex) -> bool
pub fn matches(&self, path: &Path, index: &FileIndex) -> bool
Returns true iff path is in scope:
- Excluded patterns reject (dominant).
- Include patterns must match (skipped if no includes).
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§
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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