Cleanup creation of lang items#2880
Conversation
c96d7b9 to
b7f14e9
Compare
|
we could also rename the methods in |
b7f14e9 to
8aadbbc
Compare
gcc/rust/ChangeLog: * Make-lang.in: Compile new rust-lang-item.o. * util/rust-lang-item.h: Split into header and source. * util/rust-lang-item.cc: Cleanup parsing of lang items by using a hashmap and returning optional values, cleanup handling of exhaustive lang item lookups. * hir/rust-ast-lower-base.cc (ASTLoweringBase::handle_lang_item_attribute): Use new optional API.
8aadbbc to
fe5f56c
Compare
gcc/rust/ChangeLog: * util/rust-lang-item.h (class RustLangItem): Renamed to... (class LangItem): ...this. Rename ItemType enum to Kind * util/rust-lang-item.cc: Rename methods to use new class name. * backend/rust-compile-expr.cc (CompileExpr::visit): Use new lang-item API. (CompileExpr::resolve_operator_overload): Likewise. * backend/rust-compile-expr.h: Likewise. * hir/rust-ast-lower-base.cc (ASTLoweringBase::handle_lang_item_attribute): Likewise. * typecheck/rust-autoderef.cc (Adjuster::try_deref_type): Likewise. (AutoderefCycle::cycle): Likewise. * typecheck/rust-autoderef.h: Likewise. * typecheck/rust-hir-type-bounds.h: Likewise. * typecheck/rust-hir-type-check-base.cc (TypeCheckBase::get_marker_predicate): Likewise. * typecheck/rust-hir-type-check-base.h: Likewise. * typecheck/rust-hir-type-check-expr.cc (TypeCheckExpr::visit): Likewise. * typecheck/rust-hir-type-check-expr.h: Likewise. * typecheck/rust-hir-type-check-type.cc (TypeResolveGenericParam::visit): Likewise. * typecheck/rust-tyty-bounds.cc (TypeBoundsProbe::assemble_sized_builtin): Likewise. (TypeBoundsProbe::assemble_builtin_candidate): Likewise. (TypeCheckBase::get_predicate_from_bound): Likewise. * typecheck/rust-tyty.cc (ClosureType::setup_fn_once_output): Likewise. * util/rust-hir-map.cc (Mappings::get_lang_item): Likewise. (Mappings::lookup_trait_item_lang_item): Likewise. * util/rust-hir-map.h: Likewise.
We should probably keep those lowercase for now |
| item.get_mappings ().get_defid ()); | ||
| auto lang_item_type = LangItem::Parse (lang_item_type_str); | ||
|
|
||
| if (lang_item_type) |
There was a problem hiding this comment.
I'd prefer we keep the condition explicit instead of relying on the underlying value.
There was a problem hiding this comment.
do you mean using if (lang_item_type.has_value()) instead?
There was a problem hiding this comment.
No sorry, I read too fast and thought we kept the Unknown item kind. Given it is an optional we can keep this.
This cleans up the handling and creation of lang items. The second commit is more of a nitpick, which renames the class and enum to make it easier to use - but we can definitely drop it if it's too many changes at once.
std::less/std::hashforLangItem::Kindfor the C++almost11 standard