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

rustdoc: Return String from doc_value, not Option #92079

Closed
wants to merge 2 commits into from

Conversation

jyn514
Copy link
Member

@jyn514 jyn514 commented Dec 18, 2021

Very few places actually need to special case this, and those that do can use .is_empty() instead.

Note that both plain_text_summary and short_markdown_summary() already special case empty
strings, so this is still taking the fast path for those docs.

This is similar to #92078, but for doc_value instead of collapsed_doc_value. Builds on #92077.

r? @camelid cc @GuillaumeGomez #91072 (comment)

`render/context` always runs after `run_global_context`, so it was always set to `true`.

This is a holdover from when rustdoc allowed configuring passes, but the `collapse-docs` pass was
removed ages ago, and the ability to configure passes is about to be removed.
Very few places actually need to special case this, and those that do can use `.is_empty()` instead.

Note that both `plain_text_summary` and `short_markdown_summary()` already special case empty
strings, so this is still taking the fast path for those docs.
@jyn514 jyn514 added C-cleanup Category: PRs that clean code up or issues documenting cleanup. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. labels Dec 18, 2021
@rust-highfive
Copy link
Contributor

Some changes occurred in clean/types.rs.

cc @camelid

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Dec 18, 2021
@jyn514 jyn514 changed the title Return String from doc_value, not Option rustdoc: Return String from doc_value, not Option Dec 18, 2021
GuillaumeGomez
GuillaumeGomez previously approved these changes Dec 18, 2021
@GuillaumeGomez
Copy link
Member

Hum actually I'm really not sure it's the right way to do so... I explained why here.

@GuillaumeGomez GuillaumeGomez dismissed their stale review December 18, 2021 19:17

Not sure if it's the right solution

@camelid camelid added S-blocked Status: Blocked on something else such as an RFC or other implementation work. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Dec 18, 2021
Copy link
Member

@camelid camelid left a comment

Choose a reason for hiding this comment

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

r=me with the following comments addressed and the blocking PR merged

@@ -525,10 +525,11 @@ fn document_short(
if !show_def_docs {
return;
}
if let Some(s) = item.doc_value() {
let mut summary_html = MarkdownSummaryLine(&s, &item.links(cx)).into_string();
let dox = &item.doc_value();
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
let dox = &item.doc_value();
let dox = item.doc_value();

Copy link
Member

Choose a reason for hiding this comment

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

How does this even compile currently? Doesn't it borrow a temporary?

Copy link
Member Author

Choose a reason for hiding this comment

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

Your suggestion requires borrowing at all the use sites, which makes it more noisy IMO.

The reference here behaves the same as

    let dox = item.doc_value()
    let dox = &dox;

I don't know exactly the rule for it, just that it works.

Copy link
Member

Choose a reason for hiding this comment

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

Your suggestion requires borrowing at all the use sites, which makes it more noisy IMO.

I only see one use site that would need a borrow?

@jyn514 jyn514 added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-blocked Status: Blocked on something else such as an RFC or other implementation work. labels Dec 20, 2021
@bors
Copy link
Collaborator

bors commented Dec 21, 2021

☔ The latest upstream changes (presumably #92095) made this pull request unmergeable. Please resolve the merge conflicts.

@jyn514
Copy link
Member Author

jyn514 commented Jan 8, 2022

I don't have energy to argue about any of this. Feel free to make your own PR if you think it's useful.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-cleanup Category: PRs that clean code up or issues documenting cleanup. S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. 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.

5 participants