Skip to content

rustdoc::bare_urls URL detection cuts off on underscore #162345

Description

@DanielEScherzer

I tried

/// See https://en.wikipedia.org/wiki/Rust_(programming_language)
fn main() {
    println!("Hello, world!");
}

and then ran cargo doc:

root@7db9afd9db3d:/rust/tests/rustdoc-demo# cargo doc
warning: this URL is not a hyperlink
 --> src/main.rs:1:9
  |
1 | /// See https://en.wikipedia.org/wiki/Rust_(programming_language)
  |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  |
  = note: bare URLs are not automatically turned into clickable links
  = note: `#[warn(rustdoc::bare_urls)]` on by default
help: use an automatic link instead
  |
1 | /// See <https://en.wikipedia.org/wiki/Rust>_(programming_language)
  |         +                                  +

warning: `rustdoc-demo` (bin "rustdoc-demo" doc) generated 1 warning (run `cargo fix --bin "rustdoc-demo" -p rustdoc-demo` to apply 1 suggestion)
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.18s
   Generated /rust/tests/rustdoc-demo/target/doc/rustdoc_demo/index.html

expected output:

root@7db9afd9db3d:/rust/tests/rustdoc-demo# cargo doc
warning: this URL is not a hyperlink
 --> src/main.rs:1:9
  |
1 | /// See https://en.wikipedia.org/wiki/Rust_(programming_language)
  |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  |
  = note: bare URLs are not automatically turned into clickable links
  = note: `#[warn(rustdoc::bare_urls)]` on by default
help: use an automatic link instead
  |
1 | /// See <https://en.wikipedia.org/wiki/Rust_(programming_language)>
  |         +                                                         +

warning: `rustdoc-demo` (bin "rustdoc-demo" doc) generated 1 warning (run `cargo fix --bin "rustdoc-demo" -p rustdoc-demo` to apply 1 suggestion)
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.18s
   Generated /rust/tests/rustdoc-demo/target/doc/rustdoc_demo/index.html

versions:

  • cargo 1.98.1 (797e8a9bc 2026-08-05)
  • rustc 1.98.1 (48a229c 2026-09-01)
  • rustdoc 1.98.1 (48a229c 2026-09-01)

@rustbot label T-rustdoc A-diagnostics A-suggestion-diagnostics D-invalid-suggestion

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsA-suggestion-diagnosticsArea: Suggestions generated by the compiler applied by `cargo fix`D-invalid-suggestionDiagnostics: A structured suggestion resulting in incorrect code.T-rustdocRelevant to the rustdoc 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