-
Notifications
You must be signed in to change notification settings - Fork 13.3k
rustdoc's automatic link suggestion is syntactically invalid when the link is in a #[doc]
attribute
#135851
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
#[doc]
attribute#[doc]
attribute
Hi, I maybe found the outmost codes that thriggered this issue rust/src/librustdoc/passes/lint/bare_urls.rs Lines 19 to 35 in 22a220a
For the raw doc, the sp includes the double quotation marks(like "https:://somewhere.com", not https:://somewhere.com). I did a hack solution to drop the double quotation marks
I'm not sure it's deserve to submit a PR bases on this hack solution. |
I belive this is because of the limitations of |
oh yeah the current system is extremely broken if there's even a single |
partial fix for rust-lang#135851
…1, r=<try> Improve handling of rustdoc lints when used with raw doc fragments. 1. `rustdoc::bare_urls` no longer outputs incoherent suggestions if `source_span_for_markdown_range` returns None, instead outputting no suggestion 2. `source_span_for_markdown_range` has one more heuristic, so it will return `None` less often. 3. add ui test to make sure we don't emit nonsense suggestions. fixes rust-lang#135851
Running
rustdoc
on that code produces the following output: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)
).The text was updated successfully, but these errors were encountered: