Skip to content

ast_map only treats items as parents #25005

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

Closed
Manishearth opened this issue Apr 30, 2015 · 1 comment
Closed

ast_map only treats items as parents #25005

Manishearth opened this issue Apr 30, 2015 · 1 comment

Comments

@Manishearth
Copy link
Member

ast_map::Map::get_parent seems to only get the nearest ancestor Item.

This is because the visitor for NodeCollector tweaks the parent tracking only in visit_*_item. This makes it not so useful for lints and such, which might want to determine what context something is in.

As far as I can tell, internally it's only called on nodes which were items in the first place (and thus their real parents will also be items except in cases where the item is inside a block) so perhaps this wasn't designed with lints in mind.

Can we make it consider all node types as possible parents? We can add an nearest_parent_item which can be used to replace all internal usage of the method if necessary.

cc @nrc

@Manishearth
Copy link
Member Author

#26688

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants