Skip to content
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

Improve handling of rustdoc lints when used with raw doc fragments. #136400

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

lolbinarycat
Copy link
Contributor

  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 #135851

@rustbot
Copy link
Collaborator

rustbot commented Feb 1, 2025

r? @fmease

rustbot has assigned @fmease.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. labels Feb 1, 2025
@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@lolbinarycat lolbinarycat force-pushed the rustdoc-link-lint-135851 branch from a9a435b to c6d7696 Compare February 3, 2025 19:23
sp = sp.with_lo(sp.lo() + BytePos(match_start as u32));
sp = sp.with_hi(sp.lo() + BytePos((md_range.end - md_range.start) as u32));
return Some(sp);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

This logic is run on a compiler's happy path, when rustdoc and its lints are not involved.
Could you do a perf run before merging this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

source_span_to_markdown_range is? for what purpose?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

i just checked every usage of this function in this repo, and they're all in rustdoc lints

Copy link
Member

@fmease fmease Feb 4, 2025

Choose a reason for hiding this comment

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

Huh, that's odd. source_span_to_markdown_range is indeed not used in the compiler. It should be part of rustdoc instead (it doesn't rely on any compiler-internal APIs, so that would technically work) — except that this situation is slightly suspicious. Maybe it used to be used by the compiler in the past, we need to check the history. Also, it might indicate that whoever uses that function doesn't handle cross-crate intra-doc links correctly.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

i feel like i'm missing something, i don't see how intra-doc lints are relevant here.

Copy link
Contributor

Choose a reason for hiding this comment

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

i just checked every usage of this function in this repo, and they're all in rustdoc lints

If something is not used in the compiler, then it should not live in compiler/rustc_resolve.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

do you want me to move it in this PR, or can it be done in a followup?

@lolbinarycat
Copy link
Contributor Author

@fmease what module do you want me to move source_span_to_markdown_range into, or should that be left for a followup PR?

@lolbinarycat
Copy link
Contributor Author

@fmease reminder to look at this.

@lolbinarycat
Copy link
Contributor Author

@fmease it's been a week, are you going to get to this, or should I reroll reviewers?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

rustdoc's automatic link suggestion is syntactically invalid when the link is in a #[doc] attribute
5 participants