Skip to content

Conversation

GuillaumeGomez
Copy link
Member

I came across this case when working on another part of rustdoc. Not a game changer but a nice little improvement.

cc @camelid

r? @jyn514

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Feb 18, 2021
@GuillaumeGomez GuillaumeGomez added the T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. label Feb 18, 2021
Copy link
Contributor

@pickfire pickfire left a comment

Choose a reason for hiding this comment

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

Looks good to me although I am not quite sure where are we calculating item attributes twice.

@GuillaumeGomez
Copy link
Member Author

@pickfire We compute them in Item::from_hir_id_and_parts and then we replace the attrs field with the value returned by merged_attrs. :)

@camelid camelid added the C-cleanup Category: PRs that clean code up or issues documenting cleanup. label Feb 19, 2021
def_id,
name,
kind,
box cx.tcx.get_attrs(def_id).clean(cx),
Copy link
Contributor

@bugadani bugadani Feb 19, 2021

Choose a reason for hiding this comment

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

How common is the case where attrs are empty? That box I think can be optimized (by turning the field into Option<Box<>>). I was planning on doing that, but unless it's a bigger change, it could probably be part of this PR.

Not entirely sure, though.

Copy link
Member Author

Choose a reason for hiding this comment

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

I wouldn't bet on that to be honest. Trying to be too clever never ends well.

Copy link
Contributor

Choose a reason for hiding this comment

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

We'll see, I guess I'll submit a PR anyway. But true, the additional complexity might backfire a bit.

Copy link
Member

Choose a reason for hiding this comment

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

I don't think I'd call that too clever. @bugadani I'd be interested in seeing that PR :)

@jyn514
Copy link
Member

jyn514 commented Feb 22, 2021

@bors r+

@bors
Copy link
Collaborator

bors commented Feb 22, 2021

📌 Commit 0e07904 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-review Status: Awaiting review from the assignee but also interested parties. labels Feb 22, 2021
@jyn514 jyn514 added the I-compiletime Issue: Problems and improvements with respect to compile times. label Feb 22, 2021
@GuillaumeGomez
Copy link
Member Author

@bors: rollup

@jyn514
Copy link
Member

jyn514 commented Feb 22, 2021

@bors rollup=iffy

This affects perf.

Dylan-DPC-zz pushed a commit to Dylan-DPC-zz/rust that referenced this pull request Feb 24, 2021
… r=jyn514

Prevent to compute Item attributes twice

I came across this case when working on another part of rustdoc. Not a game changer but a nice little improvement.

cc `@camelid`

r? `@jyn514`
@Dylan-DPC-zz
Copy link

failed in rollup

@bors r-

@bors bors 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-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Feb 24, 2021
@jyn514
Copy link
Member

jyn514 commented Feb 24, 2021

error[E0308]: mismatched types
   --> src/librustdoc/clean/types.rs:175:34
    |
175 |             source: source.clean(cx),
    |                                  ^^ types differ in mutability
    |
    = note: expected mutable reference `&mut DocContext<'_>`
                       found reference `&DocContext<'_>`
error[E0308]: mismatched types
   --> src/librustdoc/clean/types.rs:177:57
    |
    |
177 |             visibility: cx.tcx.visibility(def_id).clean(cx),
    |                                                         ^^ types differ in mutability
    |
    = note: expected mutable reference `&mut DocContext<'_>`
                       found reference `&DocContext<'_>`
error: aborting due to 2 previous errors

@GuillaumeGomez this had a semantic conflict, it needs to be rebased.

@GuillaumeGomez
Copy link
Member Author

Rebased!

@bors: r=jyn514

@bors
Copy link
Collaborator

bors commented Feb 24, 2021

📌 Commit cc0d531 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 Feb 24, 2021
Dylan-DPC-zz pushed a commit to Dylan-DPC-zz/rust that referenced this pull request Feb 24, 2021
… r=jyn514

Prevent to compute Item attributes twice

I came across this case when working on another part of rustdoc. Not a game changer but a nice little improvement.

cc `@camelid`

r? `@jyn514`
@bors
Copy link
Collaborator

bors commented Feb 25, 2021

⌛ Testing commit cc0d531 with merge b36f770...

@bors
Copy link
Collaborator

bors commented Feb 25, 2021

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

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Feb 25, 2021
@bors bors merged commit b36f770 into rust-lang:master Feb 25, 2021
@rustbot rustbot added this to the 1.52.0 milestone Feb 25, 2021
@GuillaumeGomez GuillaumeGomez deleted the cleanup-attrs-twice branch February 25, 2021 15:16
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. I-compiletime Issue: Problems and improvements with respect to compile times. 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.

9 participants