Skip to content

More Queries for Crate Metadata - #41724

Merged
bors merged 11 commits into
rust-lang:masterfrom
hackeryarn:master
May 11, 2017
Merged

More Queries for Crate Metadata#41724
bors merged 11 commits into
rust-lang:masterfrom
hackeryarn:master

Conversation

@hackeryarn

@hackeryarnhackeryarn commented May 3, 2017

Copy link
Copy Markdown
Contributor

This covers a little bit of clean up and the following parts of #41417:

  • fn item_attrs(&self, def_id: DefId) -> Vec<ast::Attribute>;
  • fn fn_arg_names(&self, did: DefId) -> Vec<ast::Name>;
  • fn trait_of_item(&self, def_id: DefId) -> Option<DefId>;
  • fn impl_parent(&self, impl_def_id: DefId) -> Option<DefId>;
  • fn is_foreign_item(&self, did: DefId) -> bool;
  • fn is_exported_symbol(&self, def_id: DefId) -> bool;

r? @nikomatsakis

@aidanhs

Copy link
Copy Markdown
Contributor

Thanks for the PR @achernyak! We'll make sure @nikomatsakis or another reviewer gets to this soon.

@aidanhsaidanhs added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label May 3, 2017
@nikomatsakis

Copy link
Copy Markdown
Contributor

@bors r+

@bors

bors commented May 5, 2017

Copy link
Copy Markdown
Collaborator

📌 Commit 5a7946d has been approved by nikomatsakis

Comment threadsrc/librustc/ty/mod.rs Outdated
/// Otherwise, return `None`.
fn trait_of_item<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> Option<DefId> {
if def_id.krate != LOCAL_CRATE {
return None

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Er, wait, this seems surprising. What is going on here exactly?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think I expected this code to only run when the krate isLOCAL_CRATE, no?

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

Isn't that what this is doing? This returns None if it's not a LOCAL_CRATE.

// This is only used by rustdoc anyway, which shouldn't have
// incremental recompilation ever enabled.
fn_arg_names => { cdata.get_fn_arg_names(def_id.index) }
trait_of_item => { cdata.get_trait_of_item(def_id.index) }

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

...and I expected this code to run for other crates.

@nikomatsakis

Copy link
Copy Markdown
Contributor

@bors r-

@hackeryarn

Copy link
Copy Markdown
ContributorAuthor

@nikomatsakis I think I covered what you were asking for.

@hackeryarn

Copy link
Copy Markdown
ContributorAuthor

@cramertj This PR should now cover all the simple cases for DefId based queries. I've skipped any queries that would require providing tcx access to functions that currently don't have it, and so on.

Comment threadsrc/librustc/ty/mod.rs Outdated
/// Otherwise, return `None`.
fn trait_of_item<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> Option<DefId> {
if def_id.krate != LOCAL_CRATE {
return tcx.trait_of_item(def_id)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I am pretty sure that this if can be removed -- or else there is a bug. After all, tcx.trait_of_item(def_id) should just call back into this code, since this is a query implementation.

@hackeryarn

Copy link
Copy Markdown
ContributorAuthor

@nikomatsakis you were absolutely right. It can be removed!

@bors

bors commented May 9, 2017

Copy link
Copy Markdown
Collaborator

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

@hackeryarn
hackeryarnforce-pushed the master branch 5 times, most recently from 6b3900a to 2486a8eCompareMay 9, 2017 17:55
@hackeryarn
hackeryarnforce-pushed the master branch 3 times, most recently from 41f03e4 to a468875CompareMay 9, 2017 19:40
@nikomatsakis

Copy link
Copy Markdown
Contributor

@bors r+

@bors

bors commented May 10, 2017

Copy link
Copy Markdown
Collaborator

📌 Commit 35812d1 has been approved by nikomatsakis

frewsxcv added a commit to frewsxcv/rust that referenced this pull request May 11, 2017
More Queries for Crate Metadata
This covers a little bit of clean up and the following parts of rust-lang#41417:
* `fn item_attrs(&self, def_id: DefId) -> Vec<ast::Attribute>;`
* `fn fn_arg_names(&self, did: DefId) -> Vec<ast::Name>;`
* `fn trait_of_item(&self, def_id: DefId) -> Option<DefId>;`
* `fn impl_parent(&self, impl_def_id: DefId) -> Option<DefId>;`
* ` fn is_foreign_item(&self, did: DefId) -> bool;`
* `fn is_exported_symbol(&self, def_id: DefId) -> bool;`
r? @nikomatsakis
@frewsxcvfrewsxcv mentioned this pull request May 11, 2017
frewsxcv added a commit to frewsxcv/rust that referenced this pull request May 11, 2017
More Queries for Crate Metadata
This covers a little bit of clean up and the following parts of rust-lang#41417:
* `fn item_attrs(&self, def_id: DefId) -> Vec<ast::Attribute>;`
* `fn fn_arg_names(&self, did: DefId) -> Vec<ast::Name>;`
* `fn trait_of_item(&self, def_id: DefId) -> Option<DefId>;`
* `fn impl_parent(&self, impl_def_id: DefId) -> Option<DefId>;`
* ` fn is_foreign_item(&self, did: DefId) -> bool;`
* `fn is_exported_symbol(&self, def_id: DefId) -> bool;`
r? @nikomatsakis
@frewsxcvfrewsxcv mentioned this pull request May 11, 2017
bors added a commit that referenced this pull request May 11, 2017
Rollup of 5 pull requests
- Successful merges: #41192, #41724, #41873, #41877, #41889
- Failed merges:
@bors
bors merged commit 35812d1 into rust-lang:masterMay 11, 2017
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-reviewStatus: Awaiting review from the assignee but also interested parties.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants

@hackeryarn@aidanhs@nikomatsakis@bors