Skip to main content

Sources

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.

§hidden_declarations: BTreeSet<(String, String)>

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

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

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>

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>

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>

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.

fn is_hidden( &self, reference: &str, from: &str, name: &str, hops: usize, ) -> Result<bool, String>

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>

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§

§

impl Debug for Sources

§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

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
§

impl<T> ByRef<T> for T

§

fn by_ref(&self) -> &T

§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T, U> Imply<T> for U
where T: ?Sized, U: ?Sized,

§

impl<T> Instrument for T

§

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

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

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
§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

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

impl<T> Ungil for T
where T: Send,

§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

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
§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

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