Struct Walk
struct Walk<'a> {
sources: &'a Sources,
files: BTreeMap<&'a str, &'a SourceFile>,
collected: BTreeMap<String, BTreeSet<(Kind, String)>>,
unresolved: Vec<String>,
queue: Vec<Pending>,
walked: BTreeSet<String>,
}Expand description
The Rust walk’s running state.
Fields§
§sources: &'a SourcesEvery indexed declaration and re-export, plus the public-scope set.
files: BTreeMap<&'a str, &'a SourceFile>Every parsed file, by repository-relative path, for walking a module body.
collected: BTreeMap<String, BTreeSet<(Kind, String)>>A symbol can be two items at once — atune::Space is the Space trait and
the Space derive macro, and rustdoc writes both trait.Space.html and
derive.Space.html. Collected as a multimap so the collision is visible,
then split into disambiguated keys.
unresolved: Vec<String>Every unresolved name, not the first: a developer who has just moved a
module wants the whole list, and a generator that stops at the first makes
the second look like a new regression (the rule generate_all::run already
follows across generators).
queue: Vec<Pending>Modules found but not yet walked.
walked: BTreeSet<String>Module keys already walked, so a module reachable by two paths — or a
cyclic pub use — is walked once instead of forever.
Implementations§
§impl Walk<'_>
impl Walk<'_>
fn module(&mut self, reference: &str, key: &str, doc_dir: &str, items: &[Item])
fn module(&mut self, reference: &str, key: &str, doc_dir: &str, items: &[Item])
Maps every public item a module body declares or re-exports.
reference is the file the body is written in — which is what a relative
pub use path is resolved against. key and doc_dir are the module’s
symbol prefix and documented directory.
fn declaration(
&mut self,
reference: &str,
key: &str,
doc_dir: &str,
name: &str,
kind: Kind,
)
fn declaration( &mut self, reference: &str, key: &str, doc_dir: &str, name: &str, kind: Kind, )
Files one declaration under the key and page that actually name it.
Almost always the enclosing module’s — except for a macro, which Rust
exports from the crate root however deeply it is written:
#[macro_export] macro_rules! storage_conformance_tests sits in
atune_core::storage::conformance and its only valid path is
atune_core::storage_conformance_tests, with its page at
atune_core/macro.storage_conformance_tests.html. The same holds for a proc
macro, whose crate exports every macro at its root. Found by
check-api-links, which is exactly the class of mistake it exists to catch
(§1.3.113) — and it is the other half of §1.3.85, where the facade’s
conformance feature doc promises atune::storage_conformance_tests! and
that path does not resolve either.
fn submodule(
&mut self,
reference: &str,
key: &str,
doc_dir: &str,
module: &ItemMod,
)
fn submodule( &mut self, reference: &str, key: &str, doc_dir: &str, module: &ItemMod, )
Records a pub mod, then walks it — inline bodies here, files via the queue.
fn leaf(&mut self, reference: &str, key: &str, doc_dir: &str, leaf: &Leaf)
fn leaf(&mut self, reference: &str, key: &str, doc_dir: &str, leaf: &Leaf)
Resolves one re-exported leaf and files it, or records why it could not be.
fn enqueue(&mut self, key: String, doc_dir: String, scope: String)
fn enqueue(&mut self, key: String, doc_dir: String, scope: String)
Queues a module for walking, once.
fn pending(&mut self, pending: &Pending)
fn pending(&mut self, pending: &Pending)
Walks a queued module’s own source file.
A module is either <scope>.rs or <scope>/mod.rs, and both spellings are
in this workspace. A scope with neither is not an error: an inline
module’s members were walked at its declaration, and a re-exported module
from outside the three indexed crates has no file here to read.
fn resolve(
&self,
reference: &str,
here: &str,
leaf: &Leaf,
) -> Result<(String, Kind, String), String>
fn resolve( &self, reference: &str, here: &str, leaf: &Leaf, ) -> Result<(String, Kind, String), String>
Where a re-exported leaf’s rustdoc page lives, what kind of item it is, and which name rustdoc gave the page.
§Errors
The sentence to report when the leaf’s declaration cannot be followed, or
when two declarations of the name under one scope disagree about its kind. A
kind decides the file name, so a guess would be a dead link. Returned as a
detail rather than as an Error so the caller can collect every one.
Auto Trait Implementations§
impl<'a> !Send for Walk<'a>
impl<'a> !Sync for Walk<'a>
impl<'a> Freeze for Walk<'a>
impl<'a> RefUnwindSafe for Walk<'a>
impl<'a> Unpin for Walk<'a>
impl<'a> UnsafeUnpin for Walk<'a>
impl<'a> UnwindSafe for Walk<'a>
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
impl<T, U> Imply<T> for U
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> 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