Skip to content

use osc 8 hyperlinks to link to the reference for lints when they are printed #125528

Open
@lolbinarycat

Description

@lolbinarycat

Code

struct Foo;

Current output

⣿
Standard Error

   Compiling playground v0.0.1 (/playground)
warning: struct `Foo` is never constructed
 --> src/lib.rs:1:8
  |
1 | struct Foo;
  |        ^^^
  |
  = note: `#[warn(dead_code)]` on by default

warning: `playground` (lib) generated 1 warning
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.33s

Desired output

same as above, but with the `#[warn(dead_code)]` part being an [osc 8](https://gist.github.com/egmontkob/eb114294efbcd5adb1944c9f3cb5feda) hyperlink to <https://doc.rust-lang.org/rustc/lints/listing/warn-by-default.html#dead-code>.

Rationale and extra context

cargo already does something similar, see https://github.com/rust-lang/cargo/blob/a8d72c675ee52dd57f0d8f2bae6655913c15b2fb/src/cargo/core/compiler/job_queue/mod.rs#L830

something similar could also be done for numbered error messages.

Other cases

No response

Rust Version

rustc 1.80.0-nightly (9cdfe285c 2024-05-22)
binary: rustc
commit-hash: 9cdfe285ca724c801dc9f78d22b24ea69b787f26
commit-date: 2024-05-22
host: x86_64-unknown-linux-gnu
release: 1.80.0-nightly
LLVM version: 18.1.6

Anything else?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    -Zterminal-urlsUnstable option: emit OSC8 hyperlinks in diagnosticsA-diagnosticsArea: Messages for errors, warnings, and lintsT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions