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

Remove unnecessary self_ty parameter to get_blanket_impls #81349

Merged
merged 1 commit into from
Feb 28, 2021

Conversation

jyn514
Copy link
Member

@jyn514 jyn514 commented Jan 24, 2021

It can be calculated when necessary at the callsite, there's no need to
pass it separately.

This also renames param_env_def_id to item_def_id.

cc @eddyb

@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 Jan 24, 2021
@rust-highfive
Copy link
Collaborator

r? @ollie27

(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 Jan 24, 2021
@jyn514
Copy link
Member Author

jyn514 commented Jan 24, 2021

@eddyb you have this fixme in rustdoc:

    // FIXME(eddyb) figure out a better way to pass information about
    // parametrization of `ty` than `param_env_def_id`.

Why is param_env_def_id wrong? Why would there need to be a better way?

src/librustdoc/clean/auto_trait.rs Outdated Show resolved Hide resolved
src/librustdoc/clean/blanket_impl.rs Outdated Show resolved Hide resolved
src/librustdoc/clean/utils.rs Outdated Show resolved Hide resolved
@bors

This comment has been minimized.

@camelid camelid added the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label Jan 28, 2021
@camelid camelid self-assigned this Jan 29, 2021
@camelid camelid removed their assignment Feb 7, 2021
@jyn514 jyn514 force-pushed the blanket-impls-cleanup branch 2 times, most recently from 918315a to dd6130a Compare February 11, 2021 17:53
@jyn514
Copy link
Member Author

jyn514 commented Feb 11, 2021

@camelid this is finally ready for review again :)

@jyn514 jyn514 removed the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label Feb 11, 2021
@camelid
Copy link
Member

camelid commented Feb 12, 2021

I may not be able to review this PR since I'm not very familiar with the code, but I'll assign myself so I don't forget about it altogether :)

@ollie27 Feel free to review/approve this if you want to — I just assigned myself because otherwise I'll never remember to look at it.

@camelid camelid self-assigned this Feb 12, 2021
@bors

This comment has been minimized.

@camelid camelid 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 Feb 19, 2021
@jyn514 jyn514 added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Feb 23, 2021
@bors

This comment has been minimized.

src/librustdoc/clean/blanket_impl.rs Show resolved Hide resolved
src/librustdoc/clean/utils.rs Show resolved Hide resolved
Comment on lines -448 to +447
param_env_def_id: DefId,
item_def_id: DefId,
Copy link
Member

Choose a reason for hiding this comment

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

Why was this change made? Did the meaning change, or is item_def_id closer to the meaning than param_env_def_id? Do ParamEnvs even have DefIds?

Sorry for all the questions; I know almost nothing about ParamEnv :)

Copy link
Member Author

Choose a reason for hiding this comment

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

item_def_id is closer to the meaning. All items have a ParamEnv, but the same ParamEnv may be used for things other than items (e.g. each expression in the body of a function). Before, there was a semantic mismatch in the representation: it passed in a Ty, but not all types are items (for example &T). So to get the param env of the type it had to pass in the DefId too. Now it passes in the DefId only, which allows getting both the param env and the type without any additional info.

Copy link
Member

Choose a reason for hiding this comment

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

How will get_blanket_impls behave now for blanket impls like impl Foo for &Struct where the type is &Struct but the type_of the item_def_id is Struct? (Unless I'm misunderstanding what the item_def_id is referring to.)

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 same as it did before, all this does is rename the parameter and move the type_of into the function. I don't know exactly how it worked before.

@camelid camelid 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 Feb 25, 2021
@camelid
Copy link
Member

camelid commented Feb 26, 2021

Could you take a look at #81349 (comment)?

@rustbot label: -S-waiting-on-review +S-waiting-on-author

@rustbot rustbot 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 Feb 26, 2021
@camelid
Copy link
Member

camelid commented Feb 26, 2021

@eddyb you have this fixme in rustdoc:

    // FIXME(eddyb) figure out a better way to pass information about
    // parametrization of `ty` than `param_env_def_id`.

Why is param_env_def_id wrong? Why would there need to be a better way?

Do you want to follow up with eddyb or someone else about this?

@jyn514
Copy link
Member Author

jyn514 commented Feb 26, 2021

Do you want to follow up with eddyb or someone else about this?

I would rather not block on it, eddyb is very behind on github notifications.

@jyn514 jyn514 added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Feb 26, 2021
@camelid
Copy link
Member

camelid commented Feb 27, 2021

I'm not sure if I'd feel comfortable approving this on my own given my lack of familiarity with ParamEnv, as well as eddyb's FIXME. If you can get someone with knowledge of ParamEnv to look it over I would feel more comfortable approving.

@jyn514
Copy link
Member Author

jyn514 commented Feb 27, 2021

r? @lcnr

@rust-highfive rust-highfive assigned lcnr and unassigned ollie27 and camelid Feb 27, 2021
Copy link
Contributor

@lcnr lcnr left a comment

Choose a reason for hiding this comment

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

some nits

r=me after that

src/librustdoc/clean/auto_trait.rs Outdated Show resolved Hide resolved
src/librustdoc/clean/auto_trait.rs Outdated Show resolved Hide resolved
@camelid camelid 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 Feb 27, 2021
It can be calculated when necessary at the callsite, there's no need to
pass it separately.

This also renames `param_env_def_id` to `item_def_id`.
@jyn514
Copy link
Member Author

jyn514 commented Feb 28, 2021

@bors r=lcnr

@bors
Copy link
Contributor

bors commented Feb 28, 2021

📌 Commit c47c2c6 has been approved by lcnr

@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 28, 2021
@bors
Copy link
Contributor

bors commented Feb 28, 2021

⌛ Testing commit c47c2c6 with merge e37a13c...

@bors
Copy link
Contributor

bors commented Feb 28, 2021

☀️ Test successful - checks-actions
Approved by: lcnr
Pushing e37a13c to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Feb 28, 2021
@bors bors merged commit e37a13c into rust-lang:master Feb 28, 2021
@rustbot rustbot added this to the 1.52.0 milestone Feb 28, 2021
@jyn514 jyn514 deleted the blanket-impls-cleanup branch February 28, 2021 23:14
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. 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