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

Simplify typeck/primary_body_of, fix comment to match return signature #87465

Merged

Conversation

audunhalland
Copy link
Contributor

Hi, new contributor here! I'm carefully reading through the various modules just to learn. I noticed this function, primary_body_of, which has gone through a couple of refactors over time, adding new Options to its returned tuple. Observations:

  1. the fn's documentation was not all up to date with the the current return signature.
  2. FnHeader and FnDecl are always both Some or None. So I figured it might just return a reference to the full hir::FnSig, for simplicity and more precise typing. It's a pure refactor.

I'm learning better by working with code than just reading it, so here goes! If you want to avoid pure refactor PRs that don't really fix anything, I can revert the code change to only update the comment instead.

@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 @jackh726 (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 Jul 25, 2021
Comment on lines 286 to +288
Node::ImplItem(item) => match item.kind {
hir::ImplItemKind::Const(ref ty, body) => Some((body, Some(ty), None, None)),
hir::ImplItemKind::Fn(ref sig, body) => {
Some((body, None, Some(&sig.header), Some(&sig.decl)))
}
hir::ImplItemKind::Const(ref ty, body) => Some((body, Some(ty), None)),
hir::ImplItemKind::Fn(ref sig, body) => Some((body, None, Some(&sig))),
Copy link
Member

Choose a reason for hiding this comment

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

This is probably why the two halves were returned separately, I seem to recall a MethodSig existing that was different from FnSig.

Aha, found it! 30d7279 followed by 27511b2 resulted in an unified hir::FnSig, whereas before there was only hir::MethodSig, without a hir::FnSig.

@eddyb
Copy link
Member

eddyb commented Aug 8, 2021

r? @eddyb

@bors r+

@bors
Copy link
Contributor

bors commented Aug 8, 2021

📌 Commit 855fa13 has been approved by eddyb

@rust-highfive rust-highfive assigned eddyb and unassigned jackh726 Aug 8, 2021
@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 Aug 8, 2021
@bors
Copy link
Contributor

bors commented Aug 8, 2021

⌛ Testing commit 855fa13 with merge 0aa151461201015b5ed488f43cfb4a96a6a46634...

@bors
Copy link
Contributor

bors commented Aug 8, 2021

💔 Test failed - checks-actions

@bors bors added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Aug 8, 2021
@rust-log-analyzer
Copy link
Collaborator

A job failed! Check out the build log: (web) (plain)

Click to see the possible cause of the failure (guessed by this bot)

@eddyb
Copy link
Member

eddyb commented Aug 8, 2021

@bors retry (looks spurious)

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

bors commented Aug 9, 2021

⌛ Testing commit 855fa13 with merge d3928b1...

@bors
Copy link
Contributor

bors commented Aug 9, 2021

☀️ Test successful - checks-actions
Approved by: eddyb
Pushing d3928b1 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Aug 9, 2021
@bors bors merged commit d3928b1 into rust-lang:master Aug 9, 2021
@rustbot rustbot added this to the 1.56.0 milestone Aug 9, 2021
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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants