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

Pass Context as &mut in rustdoc #91468

Closed
wants to merge 9 commits into from
Closed

Pass Context as &mut in rustdoc #91468

wants to merge 9 commits into from

Conversation

Milo123459
Copy link
Contributor

Solves #90323

@rust-highfive
Copy link
Collaborator

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @CraftSpider (or someone else) soon.

Please see the contribution instructions for more information.

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Dec 2, 2021
@rust-log-analyzer

This comment has been minimized.

) {
write!(
w,
"{}{}const <a href=\"{}\" class=\"constant\">{}</a>: {}",
extra,
it.visibility.print_with_space(it.def_id, cx),
it.visibility.print_with_space(it.def_id, &cx.clone()),
Copy link
Member

Choose a reason for hiding this comment

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

Why is this clone necessary? I think you can just do &*cx.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not sure, let me test

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah right, it differs the mutability and causes borrowing issues.

Copy link
Member

Choose a reason for hiding this comment

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

What about moving this up and before the write so you can use &mut cx after?

@jyn514
Copy link
Member

jyn514 commented Dec 2, 2021

r? @jyn514

@rust-highfive rust-highfive assigned jyn514 and unassigned CraftSpider Dec 2, 2021
@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 2, 2021
@rust-log-analyzer

This comment has been minimized.

@jyn514
Copy link
Member

jyn514 commented Dec 3, 2021

@Milo123459 I suspect the test failure is because of all the new clones you added and that rustdoc depended on the state being shared. Do you think it would be feasible to remove the clones? I can help you out if you run into trouble :)

@Milo123459
Copy link
Contributor Author

Sure! Thanks

@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 Dec 3, 2021
@@ -43,6 +43,7 @@ use crate::try_err;
/// It is intended that this context is a lightweight object which can be fairly
/// easily cloned because it is cloned per work-job (about once per item in the
/// rustdoc tree).
#[derive(Clone)]
Copy link
Member

Choose a reason for hiding this comment

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

This must be removed before this PR is merged; Context intentionally does not implement Clone (cf. make_child_renderer()). We should probably add something to its docs about 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.

Alright, shall work on it.

Copy link
Member

Choose a reason for hiding this comment

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

Please feel free to ask for help here or on Zulip :)

Copy link
Member

@GuillaumeGomez GuillaumeGomez Dec 4, 2021

Choose a reason for hiding this comment

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

An easy way to check that a type doesn't implement a trait is to have a doc code like this:

/// ```compile_fail
/// let c = Context { ... };
/// c.clone();
/// ```

:)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hey, are you suggesting that has been implemented or should be implemented?

Anyway - I'm almost finished removing the clones!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yea I take that back, this is proving to be a challenge haha

@rust-log-analyzer

This comment has been minimized.

@bors
Copy link
Contributor

bors commented Dec 19, 2021

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

@Milo123459 Milo123459 marked this pull request as draft December 25, 2021 13:00
@Milo123459 Milo123459 closed this Jan 25, 2022
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.

10 participants