Skip to main content

associated_item_path

Function associated_item_path 

Source
pub fn associated_item_path(
    kind: ItemKind,
    segs: &[String],
) -> Option<AssocAnchorKind>
Expand description

Detect a parent-qualified associated item: Parent::member.

segs must already have the crate-root prefix stripped (see super::strip_crate_prefix_segments).

Exactly one predicate decides this: the parent segment starts with an ASCII uppercase letter. An uppercase module would fire rustc’s non_snake_case lint, so an uppercase parent is a type — never a module — and the path therefore can never be a free item. That single rule keeps u32::MAX and f32::EPSILON on the legacy free-constant page (std/u32/constant.MAX.html) the standard library still serves, while routing Duration::MAX to struct.Duration.html#associatedconstant.MAX.

The leaf’s letter case is not consulted. It looks like a second discriminator, but it adds no discriminating power once the parent is known to be a type — it only narrows the domain, and rebuilds the original defect inside the range it excludes. With a leaf-case guard, Iterator::item fell through to the free-item branch and built std/iter/Iterator/type.item.html, a path no rustdoc ever emitted, with no suggestions. Without it, the same typo reaches the parent page and fails with the real member names.

Returns None for every other shape, so the caller falls back to the free item page ({kind}.{name}.html).