-
Notifications
You must be signed in to change notification settings - Fork 162
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
Collect lang items in the AST #3289
Collect lang items in the AST #3289
Conversation
gcc/rust/ChangeLog: * util/rust-hir-map.h: Keep a NodeId mappings for lang items. * util/rust-hir-map.cc (Mappings::insert_lang_item_node): New function. (Mappings::lookup_lang_item_node): Likewise.
gcc/rust/ChangeLog: * Make-lang.in: Add new object file. * rust-session-manager.cc (Session::compile_crate): Call CollectLangItems. * ast/rust-collect-lang-items.cc: New file. * ast/rust-collect-lang-items.h: New file.
514c1f4
to
89425cf
Compare
gcc/rust/ChangeLog: * util/rust-attributes.h (class Attributes): New. * util/rust-attributes.cc: Implement Attributes::is_known(). * ast/rust-collect-lang-items.cc (is_known_attribute): Remove. (get_lang_item_attr): Call Attributes::is_known() instead. * hir/rust-ast-lower-base.cc (ASTLoweringBase::handle_outer_attributes): Likewise. (ASTLoweringBase::is_known_attribute): Remove.
// FIXME: Before merging: Should we remove the `locus` parameter here? since | ||
// lang items are looked up mostly for code generation, it doesn't make sense to | ||
// error out on the locus of the node trying to access an inexistant lang item |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This would require changes in a lot of code which fetches lang items, such as the typechecker and codegen. It would be done in a later PR
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks good, I only put a small comment but it could be merged as is.
continue; | ||
} | ||
|
||
bool is_lang_item = str_path == Values::Attributes::LANG |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should introduce some helper function here instead, I'm sure it would be reused elsewhere and it would ease this function a bit.
Probably within rust-attributes.cc
since we already have some similar functions there ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah I think it'd be good but in a different PR. it would be a good good-first-pr
issue too
In order to have lang items paths, we need to be able to resolve these lang items to their definition point which is impossible in the current system, as lang items are only saved in the mappings during lowering (and thus after name resolution). This small visitor collects lang items and stores their NodeIds in the mappings for an easy resolution.