Skip to content

feat(lint): Making the lint name a terminal hyperlink to docs - #17538

Merged
epage merged 2 commits into
rust-lang:masterfrom
Suryansh-Dey:link
Sep 30, 2026
Merged

epage merged 2 commits into
rust-lang:masterfrom
Suryansh-Dey:link

Conversation

@Suryansh-Dey

@Suryansh-Dey Suryansh-Dey commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

What does this PR try to resolve?

closes #17438
Change was to modify fn emmited_source to make name a hyperlink. Had to take gctx as arg to prints the terminal escape code for hyperlink.
Updated rest the files accordingly to pass gctx to emmited_source as new argument.

How to test and review this PR?

Run cargo test --test testsuite -- lints all 101 tests passed. (Snapshots were updated to have <a> tag)

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Sep 30, 2026
@Suryansh-Dey
Suryansh-Dey force-pushed the link branch 2 times, most recently from a64a8ba to 2fc9659 Compare September 30, 2026 05:09
@rustbot

rustbot commented Sep 30, 2026

Copy link
Copy Markdown
Collaborator

This PR was rebased onto a different master 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.

@Suryansh-Dey Suryansh-Dey changed the title feat(lint): Making the lint name a terminal hyperlink feat(lint): Making the lint name a terminal hyperlink to docs Sep 30, 2026
Comment thread src/diagnostics/lint.rs
source: LintLevelSource,
gctx: &GlobalContext,
) -> String {
let url = cargo_docs_link(&format!("reference/lints.html#{}", self.name));

@Suryansh-Dey Suryansh-Dey Sep 30, 2026 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

All Cargo lints are automatically scraped and compiled into doc/book/src/reference/lints.md via xtask-lint-docs hence it contains all lint definitions.

View changes since the review

@Suryansh-Dey

Copy link
Copy Markdown
Contributor Author

r? @weihanglo

@rustbot rustbot assigned weihanglo and unassigned epage Sep 30, 2026
@weihanglo

Copy link
Copy Markdown
Member

FWIW, we might want to also detect the toolchain channel/version and prepend that in the URL.

For example, the nightly part in https://doc.rust-lang.org/nightly/cargo/reference/lints.html. It might be tricky in test snapshots as we might need to omit that part in them.

Comment thread src/diagnostics/lint.rs Outdated
@Suryansh-Dey

Suryansh-Dey commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor Author

FWIW, we might want to also detect the toolchain channel/version and prepend that in the URL.

For example, the nightly part in https://doc.rust-lang.org/nightly/cargo/reference/lints.html. It might be tricky in test snapshots as we might need to omit that part in them.

But cargo_docs_link() already handles this so I think we are safe.

@epage

epage commented Sep 30, 2026

Copy link
Copy Markdown
Contributor

That only handles channel. I wonder if it should also handle version in the "" case.

Most other docs aren't as version sensitive as lints which is probably why we didn't do it before.

@epage epage left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@epage
epage added this pull request to the merge queue Sep 30, 2026
Merged via the queue into rust-lang:master with commit f33bbc7 Sep 30, 2026
29 checks passed
@rustbot rustbot removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Sep 30, 2026
rust-bors Bot pushed a commit to rust-lang/rust that referenced this pull request Oct 7, 2026
Update cargo submodule

11 commits in f3865b2a4d1acc5276f6b3c67d0e057f4dab3928..45c3aacf0e8dabdcdb6b7b518db100061d6367a7
2026-09-29 19:58:08 +0000 to 2026-10-06 16:29:08 +0000
- feat(pkgid-spec): Builtin package spec parsing and formatting (rust-lang/cargo#17539)
- feat(hints): support minimum optimization levels (rust-lang/cargo#17368)
- Use trusted publishing for Cargo crates (rust-lang/cargo#17426)
- feat(trim-paths): stabilize `profile.trim-paths` (rust-lang/cargo#17488)
- fix(pkgid): avoid panic on malformed protocol URLs (rust-lang/cargo#17548)
- fix(git)!: Default to net.git-fetch-with-cli if git is present (rust-lang/cargo#17329)
- Improved testsuite file permissions cleanup (rust-lang/cargo#17547)
- docs(guide): Give an example of checking for stale lockfile (rust-lang/cargo#17546)
- Add new peak memory table to cargo timings enabled via `-Zmem-stats` (rust-lang/cargo#17531)
- docs(changlog): Update 1.100.0 to reflect a beta backport (rust-lang/cargo#17542)
- feat(lint): Making the lint name a terminal hyperlink to docs (rust-lang/cargo#17538)
rust-bors Bot pushed a commit to rust-lang/rust that referenced this pull request Oct 7, 2026
Update cargo submodule

11 commits in f3865b2a4d1acc5276f6b3c67d0e057f4dab3928..45c3aacf0e8dabdcdb6b7b518db100061d6367a7
2026-09-29 19:58:08 +0000 to 2026-10-06 16:29:08 +0000
- feat(pkgid-spec): Builtin package spec parsing and formatting (rust-lang/cargo#17539)
- feat(hints): support minimum optimization levels (rust-lang/cargo#17368)
- Use trusted publishing for Cargo crates (rust-lang/cargo#17426)
- feat(trim-paths): stabilize `profile.trim-paths` (rust-lang/cargo#17488)
- fix(pkgid): avoid panic on malformed protocol URLs (rust-lang/cargo#17548)
- fix(git)!: Default to net.git-fetch-with-cli if git is present (rust-lang/cargo#17329)
- Improved testsuite file permissions cleanup (rust-lang/cargo#17547)
- docs(guide): Give an example of checking for stale lockfile (rust-lang/cargo#17546)
- Add new peak memory table to cargo timings enabled via `-Zmem-stats` (rust-lang/cargo#17531)
- docs(changlog): Update 1.100.0 to reflect a beta backport (rust-lang/cargo#17542)
- feat(lint): Making the lint name a terminal hyperlink to docs (rust-lang/cargo#17538)
rust-bors Bot pushed a commit to rust-lang/rust that referenced this pull request Oct 8, 2026
Update cargo submodule



15 commits in f3865b2a4d1acc5276f6b3c67d0e057f4dab3928..29c5daa1afc262323364e039bb70c83372cc702c
2026-09-29 19:58:08 +0000 to 2026-10-07 22:13:48 +0000
- test: mark requiring ssh for tests shelling out to it (rust-lang/cargo#17563)
- chore(deps): update msrv (rust-lang/cargo#17532)
- fix(rustdoc): suppress edition unspecified warnings (rust-lang/cargo#17557)
- chore(deps): update cargo-semver-checks to v0.51.0 (rust-lang/cargo#17553)
- feat(pkgid-spec): Builtin package spec parsing and formatting (rust-lang/cargo#17539)
- feat(hints): support minimum optimization levels (rust-lang/cargo#17368)
- Use trusted publishing for Cargo crates (rust-lang/cargo#17426)
- feat(trim-paths): stabilize `profile.trim-paths` (rust-lang/cargo#17488)
- fix(pkgid): avoid panic on malformed protocol URLs (rust-lang/cargo#17548)
- fix(git)!: Default to net.git-fetch-with-cli if git is present (rust-lang/cargo#17329)
- Improved testsuite file permissions cleanup (rust-lang/cargo#17547)
- docs(guide): Give an example of checking for stale lockfile (rust-lang/cargo#17546)
- Add new peak memory table to cargo timings enabled via `-Zmem-stats` (rust-lang/cargo#17531)
- docs(changlog): Update 1.100.0 to reflect a beta backport (rust-lang/cargo#17542)
- feat(lint): Making the lint name a terminal hyperlink to docs (rust-lang/cargo#17538)
@rustbot rustbot added this to the 1.101.0 milestone Oct 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-unstable Area: nightly unstable support

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Link Cargo lint message to its lint doc

4 participants