Skip to content

Enhance suggestions for unresolved links with typos path - #159502

Merged
rust-bors[bot] merged 1 commit into
rust-lang:mainfrom
chenyukang:yukang-fix-159496-rustdoc-link-typo
Aug 27, 2026
Merged

Enhance suggestions for unresolved links with typos path#159502
rust-bors[bot] merged 1 commit into
rust-lang:mainfrom
chenyukang:yukang-fix-159496-rustdoc-link-typo

Conversation

@chenyukang

@chenyukang chenyukang commented Jul 18, 2026

Copy link
Copy Markdown
Member

Fixes #159496

r? @estebank

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. labels Jul 18, 2026

@mejrs mejrs left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

r? me

Can you also add a test for typos in included files, like #[doc = include_str!(...)]? IIRC we do produce errors that point into included files.

View changes since this review

Comment thread src/librustdoc/passes/collect_intra_doc_links.rs Outdated
let span = span
.with_lo(span.lo() + BytePos(start as u32))
.with_hi(span.lo() + BytePos((start + unresolved.len()) as u32));
diag.span_suggestion_verbose(span, msg, candidate, Applicability::MaybeIncorrect);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this bytepos arithmetic really necessary? Perhaps consider just suggesting the proper path for the entire span.

let children = module.as_local().map_or_else(
|| tcx.module_children(module.to_def_id()),
|local_module| tcx.module_children_local(local_module.to_local_def_id()),
);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't really like map_or_else, i would write it like this, but up to you

let children = if let Some(local_id) = module {
    ...
} else {
    ...
}

@rustbot rustbot assigned mejrs and unassigned estebank Aug 18, 2026
@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Aug 18, 2026
@chenyukang
chenyukang force-pushed the yukang-fix-159496-rustdoc-link-typo branch from 1e67410 to fa36454 Compare August 25, 2026 13:42
@rustbot

rustbot commented Aug 25, 2026

Copy link
Copy Markdown
Collaborator

This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed.

Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers.

@chenyukang

Copy link
Copy Markdown
Member Author

@rustbot ready

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Aug 25, 2026

@mejrs mejrs left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rust-bors

rust-bors Bot commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

📌 Commit fa36454 has been approved by mejrs

It is now in the queue for this repository.

@rust-bors rust-bors Bot added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Aug 26, 2026
rust-bors Bot pushed a commit that referenced this pull request Aug 26, 2026
Rollup of 5 pull requests

Successful merges:

 - #159502 (Enhance suggestions for unresolved links with typos path)
 - #161052 (Add regression test for generic inference)
 - #161210 (Improve missing extern crate diagnostics in Rust 2015)
 - #161818 (Fix long type on diagnostics for conditionally implemented traits)
 - #161839 (Fix doc link to pointer::addr)
@rust-bors
rust-bors Bot merged commit ed470c8 into rust-lang:main Aug 27, 2026
13 checks passed
rust-bors Bot pushed a commit that referenced this pull request Aug 27, 2026
Rollup merge of #159502 - chenyukang:yukang-fix-159496-rustdoc-link-typo, r=mejrs

Enhance suggestions for unresolved links with typos path

Fixes #159496

r? @estebank
@rustbot rustbot added this to the 1.100.0 milestone Aug 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Detect typos in broken_intra_doc_links

4 participants