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

Queryify more metadata #41766

Closed
wants to merge 2 commits into from
Closed

Conversation

cramertj
Copy link
Member

@cramertj cramertj commented May 5, 2017

@shepmaster
Copy link
Member

Thanks @cramertj ! We'll get @nikomatsakis to give this a thorough review shortly!

@shepmaster shepmaster added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label May 5, 2017
@@ -128,6 +128,23 @@ provide! { <'tcx> tcx, def_id, cdata
!cdata.is_proc_macro(def_id.index) &&
cdata.maybe_entry(def_id.index).and_then(|item| item.decode(cdata).mir).is_some()
}
is_const_fn => {
let constness = match cdata.entry(def_id.index).kind {
Copy link
Contributor

@hackeryarn hackeryarn May 5, 2017

Choose a reason for hiding this comment

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

@cramertj we had a discussion with @nikomatsakis about leaving any implementations that are longer than single liners as part of CrateMetadata and just calling those methods on cdata here. This would keep the macro calls clean and simple.

Copy link
Member Author

Choose a reason for hiding this comment

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

Okay! I'll change that. Thanks for the heads-up.

/// If the given def ID describes an item belonging to a trait,
/// return the ID of the trait that the trait item belongs to.
/// Otherwise, return `None`.
fn trait_of_item<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> Option<DefId> {
Copy link
Contributor

@hackeryarn hackeryarn May 5, 2017

Choose a reason for hiding this comment

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

I believe your error is coming from here. I actually implemented this also... It has to do with you not handling the case where it's not part of local crate. See https://github.com/rust-lang/rust/pull/41724/files#diff-c888afeccd78f53e5ea3eb04089e46ddR2683

You can feel free to fix this or just remove this implementation.

Copy link
Member Author

Choose a reason for hiding this comment

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

If you already did it I'll just remove it from this PR. We should probably come up with a better system for tracking this.

Copy link
Contributor

Choose a reason for hiding this comment

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

Well there are about 38 more conversions left. How about I just take the first half and you can take the rest? I will start where you left off and take it up until fn derive_registrar_fn(&self, cnum: CrateNum) -> Option<DefId>;, and you can start form there. If one of us finishes first and wants to continue we can just touch base on the original issue.

Copy link
Member Author

@cramertj cramertj May 5, 2017

Choose a reason for hiding this comment

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

I'm not sure exactly how many there really are left, though, because I skipped a bunch that were used in librustc_resolve. Also, we still have to figure out what we're doing about the ones that take CrateNum as an arg-- I was planning to make a separate macro or adapt the existing one to support those.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think we can still make CrateNum work. There are a few queries using it now. Like:

https://github.com/cramertj/rust/blob/e349452f5213080f948d45b63ee28539c900df40/src/librustc/ty/maps.rs#L723

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, it uses it as a map, but it's not provided by the provide macro in cstore_impl, which assumes that the arguments are DefIds..

Copy link
Contributor

@nikomatsakis nikomatsakis left a comment

Choose a reason for hiding this comment

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

ok, so, @achernyak already pointed out the conflict with the other PR, and the idea of keeping macro simple, but other than that r=me

@cramertj
Copy link
Member Author

cramertj commented May 5, 2017

@nikomatsakis I think I already addressed those comments before you made your comment. Are there still changes you'd like to see?

@nikomatsakis
Copy link
Contributor

@bors r+

@bors
Copy link
Contributor

bors commented May 8, 2017

📌 Commit e349452 has been approved by nikomatsakis

@frewsxcv
Copy link
Member

frewsxcv commented May 9, 2017

@arielb1 arielb1 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 May 9, 2017
@bors
Copy link
Contributor

bors commented May 9, 2017

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

@bors
Copy link
Contributor

bors commented May 11, 2017

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

@Mark-Simulacrum
Copy link
Member

@cramertj Looks like there are still some merge conflicts to resolve.

@cramertj
Copy link
Member Author

Closing this to keep the PR list clear. I'll open a new PR once I've had a chance to test on windows.

@cramertj cramertj closed this May 19, 2017
@cramertj cramertj deleted the more-crate-metadata branch September 21, 2017 16:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants