Struct Sources
struct Sources {
declared: BTreeMap<(String, String), BTreeSet<Kind>>,
hidden_declarations: BTreeSet<(String, String)>,
reexported: BTreeMap<(String, String), BTreeSet<Reexport>>,
crates: BTreeSet<String>,
public_scopes: BTreeSet<String>,
files: BTreeSet<String>,
}Expand description
The workspace’s own sources, indexed for kind resolution.
Fields§
§declared: BTreeMap<(String, String), BTreeSet<Kind>>Every pub item declaration, as (file, name) → kinds.
Keyed by file so a lookup can be narrowed to a re-export’s own scope:
Cursor is a storage cursor and a study cursor, and the two have
different pages.
Public declarations that rustdoc hides with #[doc(hidden)].
Hidden declarations stay indexed for resolving an explicitly inlined public re-export, but never become map entries on their own.
reexported: BTreeMap<(String, String), BTreeSet<Reexport>>Every pub use leaf, as (file, name) → source path, for following a
re-export of a re-export.
crates: BTreeSet<String>Every workspace crate name, so a path’s first segment can be classified as a crate rather than a module.
public_scopes: BTreeSet<String>Every module source scope that a public path reaches from its crate’s
root — crates/atune/src/gp yes, crates/atune/src/gp/kernel no, because
that one is mod kernel;.
This is the distinction rustdoc’s inline-versus-link rule turns on, and
“every module on the way is pub” is the whole of it: pub use crate::gp::GpEi keeps its page at atune/gp/, while pub use open_storage::open_storage out of a private module is inlined at the crate
root. Measured the same way check-api-links measures it from the other
side — rustdoc writes a module’s index.html only for a module a public
path reaches, and the two answers agree on every module of this workspace.
files: BTreeSet<String>Every indexed source file, so a scope can be tested for existence.
Implementations§
§impl Sources
impl Sources
fn index(groups: &[&Vec<SourceFile>], crates: BTreeSet<String>) -> Self
fn index(groups: &[&Vec<SourceFile>], crates: BTreeSet<String>) -> Self
Indexes every declaration and every pub use in the given crates.
fn has_scope(&self, scope: &str) -> bool
fn has_scope(&self, scope: &str) -> bool
Does any indexed source file lie in this module scope?
The test that separates a relative pub use path from an external crate’s.
fn same_crate_scope(&self, reference: &str, from: &str) -> Option<String>
fn same_crate_scope(&self, reference: &str, from: &str) -> Option<String>
The source scope a same-crate re-export path names, or None when the
path names another crate.
Distinct from Sources::scope_of, which resolves any path it can: this
answers only the question rustdoc’s rule asks — “is the original in this
crate, and if so, where?” — because a cross-crate re-export is inlined
whether or not its original is public.
fn kind(
&self,
reference: &str,
from: &str,
name: &str,
hops: usize,
) -> Result<Kind, String>
fn kind( &self, reference: &str, from: &str, name: &str, hops: usize, ) -> Result<Kind, String>
The kind of the item that <from>::<name> names, following re-exports.
reference is the file that spells from, because crate:: and a bare
module name are both relative to the crate that file belongs to.
§Errors
The sentence to report: a scope in a crate outside the workspace, a name
nothing under the scope declares or re-exports, two kinds for one name, or
a chain longer than MAX_HOPS.
fn page_target(
&self,
reference: &str,
from: &str,
name: &str,
hops: usize,
) -> Result<(String, String), String>
fn page_target( &self, reference: &str, from: &str, name: &str, hops: usize, ) -> Result<(String, String), String>
The directory and name of a non-inlined re-export’s rustdoc page.
A same-crate re-export whose source path is public links to the original declaration. If the source path is private, rustdoc creates a page under the re-export’s spelling, and a later re-export must keep pointing at that page. An explicitly inlined intermediate in the same module is itself the target rustdoc exposes to a forwarding re-export; an inline in another public module remains transparent to that forwarding path.
Whether the source item carries #[doc(hidden)], following re-exports.
Hidden declarations remain in the index because an explicitly inlined public re-export can still produce a rustdoc page for them. This query is used only for a non-inlined re-export, which rustdoc omits when any source declaration or intermediate re-export is hidden.
fn scope_of(&self, reference: &str, from: &str) -> Option<String>
fn scope_of(&self, reference: &str, from: &str) -> Option<String>
The source directory a re-export path names, relative to the file that spells it.
Three forms, and the third is the one that was wrong for six slices
(§1.3.100). crate::a::b is absolute from the referencing file’s crate
root. A first segment naming a workspace crate is that crate’s root. Anything
else is relative to the referencing file’s own module directory — not to
its crate root, which is only the same thing in a crate-root file. So
pub use gp::TvGp; in crates/atune/src/pb2/mod.rs is
crates/atune/src/pb2/gp, and reading it as crates/atune/src/gp finds a
different module that happens to exist.
None when the path’s first segment is a crate outside the workspace —
std::sync::Arc — whose pages this site does not publish.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Sources
impl RefUnwindSafe for Sources
impl Send for Sources
impl Sync for Sources
impl Unpin for Sources
impl UnsafeUnpin for Sources
impl UnwindSafe for Sources
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