- 
                Notifications
    
You must be signed in to change notification settings  - Fork 13.9k
 
Closed
Labels
A-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.Area: Lints (warnings about flaws in source code) such as unused_mut.A-suggestion-diagnosticsArea: Suggestions generated by the compiler applied by `cargo fix`Area: Suggestions generated by the compiler applied by `cargo fix`D-invalid-suggestionDiagnostics: A structured suggestion resulting in incorrect code.Diagnostics: A structured suggestion resulting in incorrect code.T-rustdocRelevant to the rustdoc team, which will review and decide on the PR/issue.Relevant to the rustdoc team, which will review and decide on the PR/issue.
Description
#[doc = "https://rust-lang.org"]
pub fn doc_attribute() {}
/// https://rust-lang.org
pub fn doc_comment() {}Running rustdoc on that code produces the following output:
warning: this URL is not a hyperlink
 --> issue.rs:1:9
  |
1 | #[doc = "https://rust-lang.org"]
  |         ^^^^^^^^^^^^^^^^^^^^^^^
  |
  = 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 | #[doc = <"https://rust-lang.org">]
  |         +                       +
warning: this URL is not a hyperlink
 --> issue.rs:4:5
  |
4 | /// https://rust-lang.org
  |     ^^^^^^^^^^^^^^^^^^^^^
  |
  = note: bare URLs are not automatically turned into clickable links
help: use an automatic link instead
  |
4 | /// <https://rust-lang.org>
  |     +                     +
warning: 2 warnings emitted
The replacement suggestion is correct for the link in the doc comment, but syntactically incorrect for the one in the #[doc] attribute - it should suggest #[doc = "<https://rust-lang.org>"] instead.
The bug happens on both stable (rustdoc 1.84.0 (9fc6b4312 2025-01-07)) and nightly (rustdoc 1.86.0-nightly (f3d1d47fd 2025-01-20)).
Metadata
Metadata
Assignees
Labels
A-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.Area: Lints (warnings about flaws in source code) such as unused_mut.A-suggestion-diagnosticsArea: Suggestions generated by the compiler applied by `cargo fix`Area: Suggestions generated by the compiler applied by `cargo fix`D-invalid-suggestionDiagnostics: A structured suggestion resulting in incorrect code.Diagnostics: A structured suggestion resulting in incorrect code.T-rustdocRelevant to the rustdoc team, which will review and decide on the PR/issue.Relevant to the rustdoc team, which will review and decide on the PR/issue.