Skip to content

nightly regression: #[doc(alias)] does not resolve across crate re-imports #152939

@Bromeon

Description

@Bromeon

Code

Two crates: dep, and main depending on dep.

// dep/lib.rs
#[doc(alias = "answer")] 
pub fn number() -> i32 { 42 }

// main/main.rs
pub use dep::number;

Reproduction Steps

The following Bash code sets everything up:

cargo new dep --lib
cargo new main
cd main
cargo add dep --path ../dep
echo '#[doc(alias = "answer")] pub fn number() -> i32 { 42 }' > ../dep/src/lib.rs
echo 'pub use dep::number;' > src/lib.rs
cargo doc --no-deps --open

You can change rustup default stable/nightly beforehand to switch between behaviors.

Expected Outcome

In the docs page now opened in the browser, search for the string "answer".
On stable Rust, the alias across crates is found in search:

Image

Also, when running cargo doc on nightly without --no-deps, the alias is found in the other crate dep:

Image

Actual Output

On nightly with cargo doc --no-deps, no results when looking for "answer":

Image

Version

Stable and nightly (both latest as of today):

rustdoc 1.93.1 (01f6ddf75 2026-02-11)
rustdoc 1.95.0-nightly (0376d43d4 2026-02-20)

Additional Details

Similar but not identical to #141475.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-doc-aliasArea: `#[doc(alias)]`C-bugCategory: This is a bug.T-rustdocRelevant to the rustdoc team, which will review and decide on the PR/issue.regression-from-stable-to-nightlyPerformance or correctness regression from stable to nightly.

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions