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

refactor and reword intra-doc link errors #74528

Merged
merged 1 commit into from
Jul 22, 2020

Conversation

euclio
Copy link
Contributor

@euclio euclio commented Jul 19, 2020

This commit refactors intra-doc link error reporting to deduplicate code
and decouple error construction from the type of error. This greatly
improves flexibility at each error construction site, while reducing the
complexity of the diagnostic creation.

This commit also rewords the diagnostics for clarity and style:

  • Diagnostics should not end in periods.
  • It's unnecessary to say "ignoring it". Since this is a warning by
    default, it's already clear that the link is ignored.

@rust-highfive
Copy link
Collaborator

r? @ollie27

(rust_highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jul 19, 2020
@jyn514
Copy link
Member

jyn514 commented Jul 20, 2020

r? @jyn514

@rust-highfive rust-highfive assigned jyn514 and unassigned ollie27 Jul 20, 2020
}

diag.help(
r#"to escape `[` and `]` characters, just add '\' before them like `\[` or `\]`"#,
Copy link
Member

Choose a reason for hiding this comment

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

While we're cleaning up things, I think 'just' is a little dismissive.

Suggested change
r#"to escape `[` and `]` characters, just add '\' before them like `\[` or `\]`"#,
r#"to escape `[` and `]` characters, add '\' before them: `\[` or `\]`"#,

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed. What I'd really like to do here is use a structured suggestion but I don't think that's feasible until pulldown-cmark/pulldown-cmark#373 is fixed.

src/librustdoc/passes/collect_intra_doc_links.rs Outdated Show resolved Hide resolved
src/librustdoc/passes/collect_intra_doc_links.rs Outdated Show resolved Hide resolved
}

// FIXME: Create a version of this suggestion for when we don't have the span.
Copy link
Member

Choose a reason for hiding this comment

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

When would we not have a span? If it's expanded from a macro or something?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yep, or if raw #[doc] attributes are used.

src/librustdoc/passes/collect_intra_doc_links.rs Outdated Show resolved Hide resolved
Comment on lines 219 to 221
if extra_fragment.is_some() {
return Err(ErrorKind::AnchorFailure(
"primitive types cannot be followed by anchors",
));
return Err(ErrorKind::AnchorFailure(AnchorFailure::Primitive));
}
Copy link
Member

Choose a reason for hiding this comment

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

It would be nice to factor all this out somehow ... but I don't have a clear idea for how to do so.

@jyn514
Copy link
Member

jyn514 commented Jul 20, 2020

The CI failure is from rustfmt. Other than that this looks great :)

This commit refactors intra-doc link error reporting to deduplicate code
and decouple error construction from the type of error. This greatly
improves flexibility at each error construction site, while reducing the
complexity of the diagnostic creation.

This commit also rewords the diagnostics for clarity and style:

- Diagnostics should not end in periods.
- It's unnecessary to say "ignoring it". Since this is a warning by
  default, it's already clear that the link is ignored.
@jyn514
Copy link
Member

jyn514 commented Jul 20, 2020

@bors r+

@bors
Copy link
Contributor

bors commented Jul 20, 2020

📌 Commit 7f3e2c0 has been approved by jyn514

@bors
Copy link
Contributor

bors commented Jul 20, 2020

🌲 The tree is currently closed for pull requests below priority 5, this pull request will be tested once the tree is reopened

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jul 20, 2020
@jyn514 jyn514 added A-intra-doc-links Area: Intra-doc links, the ability to link to items in docs by name C-enhancement Category: An issue proposing an enhancement or a PR with one. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. labels Jul 20, 2020
Manishearth added a commit to Manishearth/rust that referenced this pull request Jul 22, 2020
refactor and reword intra-doc link errors

This commit refactors intra-doc link error reporting to deduplicate code
and decouple error construction from the type of error. This greatly
improves flexibility at each error construction site, while reducing the
complexity of the diagnostic creation.

This commit also rewords the diagnostics for clarity and style:

- Diagnostics should not end in periods.
- It's unnecessary to say "ignoring it". Since this is a warning by
  default, it's already clear that the link is ignored.
bors added a commit to rust-lang-ci/rust that referenced this pull request Jul 22, 2020
…arth

Rollup of 9 pull requests

Successful merges:

 - rust-lang#73655 (va_args implementation for AAPCS.)
 - rust-lang#73893 (Stabilize control-flow-guard codegen option)
 - rust-lang#74237 (compiletest: Rewrite extract_*_version functions)
 - rust-lang#74454 (small coherence cleanup)
 - rust-lang#74528 (refactor and reword intra-doc link errors)
 - rust-lang#74568 (Apply rust-lang#66379 to `*mut T` `as_ref`)
 - rust-lang#74570 (Use forge links for prioritization procedure)
 - rust-lang#74589 (Update books)
 - rust-lang#74635 (Fix tooltip position if the documentation starts with a code block)

Failed merges:

r? @ghost
@bors bors merged commit f4079ce into rust-lang:master Jul 22, 2020
@euclio euclio deleted the intra-link-errors branch July 22, 2020 18:19
@cuviper cuviper added this to the 1.47.0 milestone May 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-intra-doc-links Area: Intra-doc links, the ability to link to items in docs by name C-enhancement Category: An issue proposing an enhancement or a PR with one. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. 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.

6 participants