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: Cleanup associated const value rendering #42286

Merged
merged 1 commit into from
Jun 1, 2017

Conversation

ollie27
Copy link
Member

@ollie27 ollie27 commented May 28, 2017

Rather than (ab)using Debug for outputting the type in plain text use the
alternate format parameter which already does exactly that. This fixes
type parameters for example which would output raw HTML.

Also cleans up adding parens around references to trait objects.

@rust-highfive
Copy link
Collaborator

r? @steveklabnik

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

@frewsxcv frewsxcv added the T-dev-tools Relevant to the dev-tools subteam, which will review and decide on the PR/issue. label May 29, 2017
@carols10cents carols10cents added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label May 29, 2017
@@ -498,13 +488,9 @@ fn resolved_path(w: &mut fmt::Formatter, did: DefId, path: &clean::Path,
} else {
root.push_str(&seg.name);
root.push_str("/");
if is_not_debug {
Copy link
Member

Choose a reason for hiding this comment

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

I'm pretty surprised that we have the same outcome in here.

Copy link
Member Author

Choose a reason for hiding this comment

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

With w.alternate() == true it does write!(w, "{}::", seg.name)?;, as can be seen above. The is_not_debug == false case did exactly the same thing.

Copy link
Member

Choose a reason for hiding this comment

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

Oh I see!

} else {
write!(f, "{:#}::", self_type)?
}
if should_show_cast {
Copy link
Member

Choose a reason for hiding this comment

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

Once again I'm surprised the code does the same thing.

Copy link
Member Author

Choose a reason for hiding this comment

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

The is_not_debug == false case was:

if should_show_cast {
    write!(f, "<{:?} as {:?}>::", self_type, trait_)?
} else {
    write!(f, "{:?}::", self_type)?
}

The f.alternate() == true case is:

if should_show_cast {
    write!(f, "<{:#} as {:#}>::", self_type, trait_)?
} else {
    write!(f, "{:#}::", self_type)?
}

@GuillaumeGomez
Copy link
Member

Just waiting for some other people to review as well to confirm I didn't miss anything.

cc @rust-lang/dev-tools

@steveklabnik
Copy link
Member

@bors: r+

thanks so much!

@bors
Copy link
Contributor

bors commented May 30, 2017

📌 Commit ef9b2e8 has been approved by steveklabnik

@bors
Copy link
Contributor

bors commented May 31, 2017

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

@ollie27
Copy link
Member Author

ollie27 commented May 31, 2017

I've rebased and redone #42318.

Rather than (ab)using Debug for outputting the type in plain text use the
alternate format parameter which already does exactly that. This fixes
type parameters for example which would output raw HTML.

Also cleans up adding parens around references to trait objects.
} else {
write!(f, "&amp;{}{}", lt, m)?;
}
write!(f, "(")?;
Copy link
Member

Choose a reason for hiding this comment

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

Oh I see. Better indeed!

@GuillaumeGomez
Copy link
Member

Thanks for the update and the improvement!

@bors: r+

@bors
Copy link
Contributor

bors commented May 31, 2017

📌 Commit 86ea93e has been approved by GuillaumeGomez

frewsxcv added a commit to frewsxcv/rust that referenced this pull request Jun 1, 2017
…laumeGomez

rustdoc: Cleanup associated const value rendering

Rather than (ab)using Debug for outputting the type in plain text use the
alternate format parameter which already does exactly that. This fixes
type parameters for example which would output raw HTML.

Also cleans up adding parens around references to trait objects.
frewsxcv added a commit to frewsxcv/rust that referenced this pull request Jun 1, 2017
…laumeGomez

rustdoc: Cleanup associated const value rendering

Rather than (ab)using Debug for outputting the type in plain text use the
alternate format parameter which already does exactly that. This fixes
type parameters for example which would output raw HTML.

Also cleans up adding parens around references to trait objects.
bors added a commit that referenced this pull request Jun 1, 2017
Rollup of 9 pull requests

- Successful merges: #42136, #42275, #42286, #42297, #42302, #42306, #42314, #42324, #42347
- Failed merges:
@bors bors merged commit 86ea93e into rust-lang:master Jun 1, 2017
@ollie27 ollie27 deleted the rustdoc_assoc_const branch June 1, 2017 08:44
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-dev-tools Relevant to the dev-tools subteam, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants