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: clean up and test macro visibility print #84074

Merged
merged 1 commit into from
Apr 17, 2021

Conversation

notriddle
Copy link
Contributor

This fixes the overly-complex invariant mentioned in #83237 (comment), where the macro source can't have any links in it only because the cache hasn't been populated yet.

This fixes the overly-complex invariant mentioned in
<rust-lang#83237 (comment)>,
where the macro source can't have any links in it only because the
cache hasn't been populated yet.
@rust-highfive
Copy link
Collaborator

r? @CraftSpider

(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 Apr 10, 2021
@jyn514
Copy link
Member

jyn514 commented Apr 16, 2021

r? @jyn514 since this is closely tied to #83237

@rust-highfive rust-highfive assigned jyn514 and unassigned CraftSpider Apr 16, 2021
@jyn514 jyn514 added the T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. label Apr 16, 2021
Comment on lines -1215 to +1217
let first_name =
path.data[0].data.get_opt_name().expect("modules are always named");
// modified from `resolved_path()` to work with `DefPathData`
let last_name = path.data.last().unwrap().data.get_opt_name().unwrap();
let anchor = anchor(vis_did, &last_name.as_str(), cache).to_string();

let mut s = "pub(".to_owned();
if path.data.len() != 1
|| (first_name != kw::SelfLower && first_name != kw::Super)
{
s.push_str("in ");
}
let mut s = "pub(in ".to_owned();
Copy link
Member

Choose a reason for hiding this comment

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

Why did this change?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It seemed impossible for this conditional to evaluate to false. It's checking if the path is exactly equal to self or super, but there are already conditionals above that check if it's equal to the current module or the parent module.

Removing it also didn't break any test cases, supporting my dead-code theory.

Copy link
Member

Choose a reason for hiding this comment

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

That makes sense, thanks. I think I didn't realize what it was doing when @camelid added the pub(self) handling back in #80368.

@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-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Apr 16, 2021
@jyn514
Copy link
Member

jyn514 commented Apr 16, 2021

@notriddle I have a question about how this interacts with #83237 - you add an assert there that cx.cache.paths.is_empty(), but you also use the new to_src_with_space function. Is that just to make it more clear what's going on? Or is to_src_with_space behaving differently than calling print_with_space with an empty cache?

@notriddle
Copy link
Contributor Author

@jyn514

Is that just to make it more clear what's going on? Or is to_src_with_space behaving differently than calling print_with_space with an empty cache?

That assert is actually outdated. The to_src_with_space function will behave the same as calling print_with_space with an empty cache. I'll remove it.

@jyn514
Copy link
Member

jyn514 commented Apr 16, 2021

I guess it no longer matters one way or the other, yeah - all the assert is checking is that to_source_with_space is consistent with the previous behavior, but the previous behavior was wrong if the cache wasn't empty. Removing the assert sounds fine, since the test suite passed with it once already, that gives me confidence it was at least correct most of the time.

@jyn514
Copy link
Member

jyn514 commented Apr 16, 2021

@bors r+

@bors
Copy link
Contributor

bors commented Apr 16, 2021

📌 Commit 2dfd0bf has been approved by jyn514

@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-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Apr 16, 2021
jyn514 pushed a commit to jyn514/rust that referenced this pull request Apr 16, 2021
… r=jyn514

rustdoc: clean up and test macro visibility print

This fixes the overly-complex invariant mentioned in <rust-lang#83237 (comment)>, where the macro source can't have any links in it only because the cache hasn't been populated yet.
@camelid
Copy link
Member

camelid commented Apr 16, 2021

Will this fix #83000 or is it a pure cleanup with no (expected) behavior changes?

@notriddle
Copy link
Contributor Author

It should have no visible behaviour changes. Just pure cleanup.

@bors
Copy link
Contributor

bors commented Apr 16, 2021

⌛ Testing commit 2dfd0bf with merge 84e9397...

@bors
Copy link
Contributor

bors commented Apr 17, 2021

☀️ Test successful - checks-actions
Approved by: jyn514
Pushing 84e9397 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Apr 17, 2021
@bors bors merged commit 84e9397 into rust-lang:master Apr 17, 2021
@rustbot rustbot added this to the 1.53.0 milestone Apr 17, 2021
@notriddle notriddle deleted the rustdoc-macro-visibility branch April 17, 2021 02:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merged-by-bors This PR was explicitly merged by bors. 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.

7 participants