aboutsummaryrefslogtreecommitdiff
path: root/gcc/rust/hir/tree
AgeCommit message (Collapse)AuthorFilesLines
2024-08-01gccrs: Store visibility properly in ExternalTypeItemjjasmine1-2/+2
Fix issue 2897 gcc/rust/ChangeLog: * hir/rust-ast-lower-extern.h: Add translate_visiblity * hir/tree/rust-hir-item.h: Fix constructor of ExternalTypeItem
2024-08-01gccrs: extern-types: Lower to HIR::ExternalTypeItem properlyArthur Cohen1-2/+8
gcc/rust/ChangeLog: * hir/rust-ast-lower-extern.h: Lower to HIR::ExternalTypeItem nodes. * hir/tree/rust-hir-item.h (class ExternalTypeItem): Create private visibility by default as extern types have no visibility - add a comment about the correctness of this.
2024-08-01gccrs: hir: Add ExternalTypeItem nodeArthur Cohen4-3/+65
gcc/rust/ChangeLog: * hir/tree/rust-hir-item.h (class ExternalTypeItem): New class. * hir/tree/rust-hir.cc (ExternalTypeItem::as_string): Likewise. * backend/rust-compile-extern.h: Add base for handling HIR::ExternalTypeItem node. * checks/errors/borrowck/rust-bir-builder-struct.h: Likewise. * checks/errors/borrowck/rust-function-collector.h: Likewise. * checks/errors/rust-const-checker.cc (ConstChecker::visit): Likewise. * checks/errors/rust-const-checker.h: Likewise. * checks/errors/rust-unsafe-checker.cc (UnsafeChecker::visit): Likewise. * checks/errors/rust-unsafe-checker.h: Likewise. * hir/rust-ast-lower-extern.h: Likewise. * hir/rust-hir-dump.cc (Dump::visit): Likewise. * hir/rust-hir-dump.h: Likewise. * hir/tree/rust-hir-full-decls.h (class ExternalTypeItem): Likewise. * hir/tree/rust-hir-visitor.h: Likewise. (ExternalTypeItem::accept_vis): Likewise. * typecheck/rust-hir-type-check-implitem.cc (TypeCheckTopLevelExternItem::visit): Likewise. * typecheck/rust-hir-type-check-implitem.h: Likewise.
2024-02-07gccrs: HIR: Add mising getterJakub Dupak1-0/+5
gcc/rust/ChangeLog: * hir/tree/rust-hir-item.h: Add missing getter Signed-off-by: Jakub Dupak <dev@jakubdupak.com>
2024-01-30gccrs: HIR: add missing gettersJakub Dupak3-1/+12
gcc/rust/ChangeLog: * hir/tree/rust-hir-item.h: Ad lifetime getter. * hir/tree/rust-hir-path.h: Make getter const ref. * hir/tree/rust-hir.h: Const ref and new getter. Signed-off-by: Jakub Dupak <dev@jakubdupak.com>
2024-01-30gccrs: Split async and const function qualifiersPierre-Emmanuel Patry2-25/+14
A function cannot be both async and const, however this should not be handled in the parser but rather at a later stage in the compiler. This commit change the AsyncConstStatus in the AST and the HIR to allows a function to be both async and const. gcc/rust/ChangeLog: * ast/rust-ast-builder.cc (AstBuilder::fn_qualifiers): Change constructor to match the new arguments. * ast/rust-ast-collector.cc (TokenCollector::visit): Change behavior to handle both const and async specifiers at the same time. * ast/rust-ast.cc (FunctionQualifiers::as_string): Likewise. * ast/rust-item.h (class FunctionQualifiers): Remove AsyncConstStatus and replace it with both Async and Const status. Also change the safety arguments to use an enum instead of a boolean. * hir/rust-ast-lower-base.cc (ASTLoweringBase::lower_qualifiers): Update constructor call. * hir/tree/rust-hir-item.h: Add Const and Async status, remove AsyncConstStatus, update the constructor. * hir/tree/rust-hir.cc (FunctionQualifiers::as_string): Update with the new status. * parse/rust-parse-impl.h (Parser::parse_function_qualifiers): Update constructor call. * util/rust-common.h (enum Mutability): Make an enum class. (enum class): Add Async and Const enum class to avoid booleans. (enum Unsafety): Change to an enum class. Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
2024-01-30gccrs: Create base class for TupleStructItems and TuplePatternItemsOwen Avery1-24/+23
gcc/rust/ChangeLog: * hir/tree/rust-hir-pattern.h (class TupleItems): New. (class TupleStructItems): Inherit from TupleItems. (class TuplePatternItems): Likewise. Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
2024-01-16gccrs: Adjust item kind enums for TupleStructItems and TuplePatternItemsOwen Avery1-14/+8
gcc/rust/ChangeLog: * hir/tree/rust-hir-pattern.h (TupleStructItems::ItemType::RANGE): Rename to... (TupleStructItems::ItemType::RANGED): ...here. (TupleStructItems::ItemType::NO_RANGE): Rename to... (TupleStructItems::ItemType::MULTIPLE): ...here. (TuplePatternItems::TuplePatternItemType): Rename to... (TuplePatternItems::ItemType): ...here. : Handle renames. * backend/rust-compile-pattern.cc: Likewise. * typecheck/rust-hir-type-check-pattern.cc: Likewise. * checks/errors/borrowck/rust-bir-builder-pattern.h: Likewise. Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
2024-01-16gccrs: HIR: remove obsole double borrow memberJakub Dupak2-8/+0
gcc/rust/ChangeLog: * hir/rust-hir-dump.cc (Dump::visit): Remove obsolete member. * hir/tree/rust-hir-expr.h (class BorrowExpr): Remove obsolete member. * hir/tree/rust-hir.cc (BorrowExpr::as_string): Remove obsolete member. Signed-off-by: Jakub Dupak <dev@jakubdupak.com>
2024-01-16gccrs: hir: Avoid copy in getter (PathPattern)Jakub Dupak1-1/+1
gcc/rust/ChangeLog: * hir/tree/rust-hir-path.h: Avoid copy in getter. Signed-off-by: Jakub Dupak <dev@jakubdupak.com>
2024-01-16gccrs: hir: Rename ComoundAssignment gettersJakub Dupak1-2/+2
Use more a consistent name. gcc/rust/ChangeLog: * backend/rust-compile-expr.cc (CompileExpr::visit): Rename method. * checks/errors/privacy/rust-privacy-reporter.cc (PrivacyReporter::visit): Rename method. * checks/errors/rust-const-checker.cc (ConstChecker::visit): Rename method. * checks/errors/rust-unsafe-checker.cc (UnsafeChecker::visit): Rename method. * hir/rust-hir-dump.cc (Dump::visit): Rename method. * hir/tree/rust-hir-expr.h: Rename method. * typecheck/rust-hir-type-check-expr.cc (TypeCheckExpr::visit): Rename method. * typecheck/rust-tyty.h: Rename method.
2024-01-16gccrs: hir: Rename get_pattern_mappings methodJakub Dupak3-15/+15
Unify with the name used in Expr to allow convenient template over everything that has mappings. gcc/rust/ChangeLog: * backend/rust-compile-base.cc: Rename method. * backend/rust-compile-expr.cc (sort_tuple_patterns): Rename method. * backend/rust-compile-pattern.cc (CompilePatternCaseLabelExpr::visit): Rename method. (CompilePatternBindings::visit): Rename method. (CompilePatternLet::visit): Rename method. * backend/rust-compile-stmt.cc (CompileStmt::visit): Rename method. * backend/rust-compile-var-decl.h: Rename method. * hir/rust-ast-lower-pattern.cc (ASTLoweringPattern::translate): Rename method. * hir/rust-hir-dump.cc (Dump::visit): Rename method. * hir/tree/rust-hir-path.h: Rename method. * hir/tree/rust-hir-pattern.h: Rename method. * hir/tree/rust-hir.h: Rename method. * typecheck/rust-hir-type-check-pattern.cc (TypeCheckPattern::Resolve): Rename method. (TypeCheckPattern::visit): Rename method. (ClosureParamInfer::visit): Rename method. * typecheck/rust-hir-type-check-stmt.cc (TypeCheckStmt::visit): Rename method. * util/rust-hir-map.cc (Mappings::insert_hir_pattern): Rename method. Signed-off-by: Jakub Dupak <dev@jakubdupak.com>
2024-01-16gccrs: hir: Add missing getterJakub Dupak1-0/+2
gcc/rust/ChangeLog: * hir/tree/rust-hir-expr.h: Add getter for name. Signed-off-by: Jakub Dupak <dev@jakubdupak.com>
2024-01-16gccrs: hir: Refactor - avoid copy in getterJakub Dupak3-13/+13
gcc/rust/ChangeLog: * hir/tree/rust-hir-path.h: Avoid copy in getter. * hir/tree/rust-hir-pattern.h: Avoid copy in getter. * hir/tree/rust-hir.h: Avoid copy in getter. Signed-off-by: Jakub Dupak <dev@jakubdupak.com>
2024-01-16gccrs: hir: Lower labelled blockJakub Dupak1-33/+37
gcc/rust/ChangeLog: * hir/rust-ast-lower.cc (ASTLoweringBlock::visit): Call loop lowering and add it to constr. * hir/tree/rust-hir-expr.h (class LoopLabel): Move before BlockExpr and add to BlockExpr.
2024-01-16gccrs: Initial implementation of v0 manglingRaiki Tamura1-0/+1
gcc/rust/ChangeLog: * backend/rust-compile-context.h: Modify declaration. * backend/rust-mangle.cc (struct V0Path): New struct. (v0_path): New function. (legacy_mangle_name): Take Context as argument. (v0_numeric_prefix): Fix type strings. (v0_complex_type_prefix): New function. (v0_add_integer_62): Deleted (v0_integer_62): New function. (v0_add_opt_integer_62): Deleted. (v0_opt_integer_62): New function. (v0_add_disambiguator): Deleted. (v0_disambiguator): New function. (v0_type_prefix): Support more types. (v0_generic_args): New function. (v0_add_identifier): Deleted. (v0_identifier): New function. (v0_type_path): New function. (v0_function_path): New function. (v0_scope_path): New function. (v0_crate_path): New function. (v0_inherent_or_trait_impl_path): New function. (v0_mangle_item): Use v0_path. (Mangler::mangle_item): Take Context as argument. * backend/rust-mangle.h (class Context): Add forward declaration. * hir/tree/rust-hir-item.h: Fix include. Signed-off-by: Raiki Tamura <tamaron1203@gmail.com>
2024-01-16gccrs: Rename cloning methods in TupleStructItems and TuplePatternItemsOwen Avery1-9/+8
gcc/rust/ChangeLog: * hir/tree/rust-hir-pattern.h (TupleStructItems::clone_tuple_struct_items_impl): Rename to... (TupleStructItems::clone_tuple_items_impl): ...here. (TupleStructItemsNoRange::clone_tuple_struct_items_impl): Rename to... (TupleStructItemsNoRange::clone_tuple_items_impl): ...here. (TupleStructItemsRange::clone_tuple_struct_items_impl): Rename to... (TupleStructItemsRange::clone_tuple_items_impl): ...here. (TuplePatternItems::clone_tuple_pattern_items_impl): Rename to... (TuplePatternItems::clone_tuple_items_impl): ...here. (TuplePatternItemsMultiple::clone_tuple_pattern_items_impl): Rename to... (TuplePatternItemsMultiple::clone_tuple_items_impl): ...here. (TuplePatternItemsRanged::clone_tuple_pattern_items_impl): Rename to... (TuplePatternItemsRanged::clone_tuple_items_impl): ...here. Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
2024-01-16gccrs: Adjust methods for TuplePatternItems to match TupleStructItemsOwen Avery1-3/+3
gcc/rust/ChangeLog: * hir/tree/rust-hir-pattern.h (TuplePatternItems::get_pattern_type): Rename to... (TuplePatternItems::get_item_type): ...here. (TuplePatternItemsMultiple::get_pattern_type): Rename to... (TuplePatternItemsMultiple::get_item_type): ...here. (TuplePatternItemsRanged::get_pattern_type): Rename to... (TuplePatternItemsRanged::get_item_type): ...here. * backend/rust-compile-expr.cc: Adjust calls to renamed methods. * backend/rust-compile-pattern.cc: Likewise. * typecheck/rust-hir-type-check-pattern.cc: Likewise. Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
2024-01-16gccrs: Remove HIR::ForLoopExprPhilip Herron4-107/+0
This will end up getting desugared into a LoopExpr with a MatchExpr body. gcc/rust/ChangeLog: * backend/rust-compile-block.h: remove HIR::ForLoopExpr * backend/rust-compile-expr.h: likewise * checks/errors/privacy/rust-privacy-reporter.cc (PrivacyReporter::visit): likewise * checks/errors/privacy/rust-privacy-reporter.h: likewise * checks/errors/rust-const-checker.cc (ConstChecker::visit): likewise * checks/errors/rust-const-checker.h: likewise * checks/errors/rust-unsafe-checker.cc (UnsafeChecker::visit): likewise * checks/errors/rust-unsafe-checker.h: likewise * checks/lints/rust-lint-marklive.h: likewise * hir/rust-ast-lower.cc (ASTLoweringExprWithBlock::visit): likewise * hir/rust-hir-dump.cc (Dump::visit): likewise * hir/rust-hir-dump.h: likewise * hir/tree/rust-hir-expr.h (class ForLoopExpr): likewise * hir/tree/rust-hir-full-decls.h (class ForLoopExpr): likewise * hir/tree/rust-hir-visitor.h: likewise * hir/tree/rust-hir.cc (ForLoopExpr::as_string): likewise (ForLoopExpr::accept_vis): likewise * typecheck/rust-hir-type-check-expr.h: likewise Signed-off-by: Philip Herron <herron.philip@googlemail.com>
2024-01-16gccrs: Track trait bound polarity properlyPhilip Herron3-14/+16
Trait bounds can have three forms in Rust the regular trait bound, '!' the negative trait bound to enforice that this trait must not be implmented and '?' the anti trait bound to remove this bound. This patch extends our Polarity enum to include the Anti trait bound and updates the HIR lowering code to track this properly. Addresses #2443 gcc/rust/ChangeLog: * hir/rust-ast-lower-item.cc (ASTLoweringItem::visit): use new BoundPolarity enum * hir/rust-ast-lower-type.cc (ASTLoweringTypeBounds::visit): likewise * hir/rust-hir-dump.cc (BoundPolarityString): new helper (Dump::visit): update hir dump * hir/tree/rust-hir-item.h (class ImplBlock): likewise * hir/tree/rust-hir-type.h (class TraitBound): likewise * hir/tree/rust-hir.cc (TraitBound::as_string): fix as string * util/rust-common.h (enum Polarity): add new anti bound (enum BoundPolarity): likewise * util/rust-hir-map.cc (Mappings::Mappings): update naming Signed-off-by: Philip Herron <herron.philip@googlemail.com>
2024-01-16gccrs: Replace usages of Location with location_t in the lexer, AST, and HIROwen Avery4-11/+11
gcc/rust/ChangeLog: * ast/rust-ast-builder.h: Replace Location with location_t. * ast/rust-ast.h: Likewise. * ast/rust-expr.h: Likewise. * ast/rust-item.h: Likewise. * ast/rust-macro.h: Likewise. * ast/rust-path.h: Likewise. * hir/tree/rust-hir-expr.h: Likewise. * hir/tree/rust-hir-item.h: Likewise. * hir/tree/rust-hir-path.h: Likewise. * hir/tree/rust-hir.h: Likewise. * lex/rust-lex.cc: Likewise. * lex/rust-lex.h: Likewise. Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
2024-01-16gccrs: rework the HIR dump passMarc Poulhiès3-0/+34
Nearly complete rewrite of the HIR dump pass. fixes #693 gcc/rust/ChangeLog: * hir/rust-hir-dump.cc (convert_param_kind_to_str): New. (convert_new_bind_type_to_str): New. (convert_mut_to_str): New. (Dump::go): New. (Dump::put): New. (Dump::begin): New. (Dump::end): New. (Dump::begin_field): New. (Dump::end_field): New. (Dump::put_field): New. (Dump::visit_field): New. (Dump::visit): Refactor. (Dump::visit_collection): New. (Dump::do_traititem): New. (Dump::do_vis_item): New. (Dump::do_functionparam): New. (Dump::do_pathpattern): New. (Dump::do_structexprstruct): New. (Dump::do_expr): New. (Dump::do_pathexpr): New. (Dump::do_typepathsegment): New. (Dump::do_typepathfunction): New. (Dump::do_qualifiedpathtype): New. (Dump::do_operatorexpr): New. (Dump::do_mappings): New. (Dump::do_inner_attrs): New. (Dump::do_outer_attrs): New. (Dump::do_baseloopexpr): New. (Dump::do_ifletexpr): New. (Dump::do_struct): New. (Dump::do_enumitem): New. (Dump::do_traitfunctiondecl): New. (Dump::do_externalitem): New. (Dump::do_namefunctionparam): New. (Dump::do_stmt): New. (Dump::do_type): New. (Dump::do_item): New. (Dump::do_tuplefield): New. (Dump::do_structfield): New. (Dump::do_genericargs): New. (Dump::do_maybenamedparam): New. * hir/rust-hir-dump.h: Refactor. * hir/tree/rust-hir-item.h (enum_to_str): New. * hir/tree/rust-hir-type.h (enum_to_str): New. * hir/tree/rust-hir.cc (enum_to_str): New. * util/rust-common.h (enum_to_str): New. Signed-off-by: Marc Poulhiès <dkm@kataplop.net>
2024-01-16gccrs: Replace some more usages of Location with location_tOwen Avery7-91/+91
gcc/rust/ChangeLog: * ast/rust-ast.h: Replace Location with location_t. * ast/rust-expr.h: Likewise. * ast/rust-item.h: Likewise. * ast/rust-macro.h: Likewise. * ast/rust-path.h: Likewise. * ast/rust-pattern.h: Likewise. * ast/rust-stmt.h: Likewise. * ast/rust-type.h: Likewise. * hir/rust-ast-lower-base.h: Likewise. * hir/tree/rust-hir-expr.h: Likewise. * hir/tree/rust-hir-item.h: Likewise. * hir/tree/rust-hir-path.h: Likewise. * hir/tree/rust-hir-pattern.h: Likewise. * hir/tree/rust-hir-stmt.h: Likewise. * hir/tree/rust-hir-type.h: Likewise. * hir/tree/rust-hir.h: Likewise. * lex/rust-token.h: Likewise. * resolve/rust-ast-resolve-pattern.h: Likewise. * typecheck/rust-hir-trait-reference.h: Likewise. * typecheck/rust-tyty-bounds.h: Likewise. * typecheck/rust-tyty-call.h: Likewise. * typecheck/rust-tyty-subst.h: Likewise. * typecheck/rust-tyty-util.h: Likewise. * typecheck/rust-tyty.h: Likewise. Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
2024-01-16gccrs: Replace some usages of Location with location_tOwen Avery8-241/+246
gcc/rust/ChangeLog: * ast/rust-ast-collector.cc: Replace Location with location_t. * ast/rust-ast.cc: Likewise. * ast/rust-ast.h: Likewise. * ast/rust-expr.h: Likewise. * ast/rust-item.h: Likewise. * ast/rust-macro.h: Likewise. * ast/rust-path.cc: Likewise. * ast/rust-path.h: Likewise. * ast/rust-pattern.h: Likewise. * ast/rust-stmt.h: Likewise. * ast/rust-type.h: Likewise. * backend/rust-compile-base.cc: Likewise. * backend/rust-compile-base.h: Likewise. * backend/rust-compile-block.cc: Likewise. * backend/rust-compile-expr.cc: Likewise. * backend/rust-compile-expr.h: Likewise. * backend/rust-compile-fnparam.cc: Likewise. * backend/rust-compile-fnparam.h: Likewise. * backend/rust-compile-intrinsic.cc: Likewise. * backend/rust-compile-pattern.cc: Likewise. * backend/rust-compile-resolve-path.h: Likewise. * backend/rust-compile.cc: Likewise. * checks/errors/rust-const-checker.cc: Likewise. * checks/errors/rust-const-checker.h: Likewise. * checks/errors/rust-unsafe-checker.cc: Likewise. * checks/errors/rust-unsafe-checker.h: Likewise. * expand/rust-macro-builtins.cc: Likewise. * expand/rust-macro-expand.h: Likewise. * hir/rust-ast-lower-base.h: Likewise. * hir/rust-ast-lower-implitem.h: Likewise. * hir/rust-ast-lower-item.cc: Likewise. * hir/tree/rust-hir-expr.h: Likewise. * hir/tree/rust-hir-item.h: Likewise. * hir/tree/rust-hir-path.h: Likewise. * hir/tree/rust-hir-pattern.h: Likewise. * hir/tree/rust-hir-stmt.h: Likewise. * hir/tree/rust-hir-type.h: Likewise. * hir/tree/rust-hir.cc: Likewise. * hir/tree/rust-hir.h: Likewise. * lex/rust-token.h: Likewise. * metadata/rust-extern-crate.cc: Likewise. * metadata/rust-extern-crate.h: Likewise. * parse/rust-parse-impl.h: Likewise. * parse/rust-parse.h: Likewise. * resolve/rust-ast-resolve-expr.cc: Likewise. * resolve/rust-ast-resolve-implitem.h: Likewise. * resolve/rust-ast-resolve-pattern.h: Likewise. * resolve/rust-ast-resolve-stmt.h: Likewise. * resolve/rust-ast-resolve-toplevel.h: Likewise. * resolve/rust-ast-resolve-type.h: Likewise. * resolve/rust-name-resolver.cc: Likewise. * resolve/rust-name-resolver.h: Likewise. * rust-diagnostics.cc: Likewise. * rust-diagnostics.h: Likewise. * rust-gcc.cc: Likewise. * rust-session-manager.cc: Likewise. * rust-session-manager.h: Likewise. * typecheck/rust-casts.cc: Likewise. * typecheck/rust-casts.h: Likewise. * typecheck/rust-coercion.cc: Likewise. * typecheck/rust-coercion.h: Likewise. * typecheck/rust-hir-path-probe.cc: Likewise. * typecheck/rust-hir-path-probe.h: Likewise. * typecheck/rust-hir-trait-reference.cc: Likewise. * typecheck/rust-hir-trait-reference.h: Likewise. * typecheck/rust-hir-trait-resolve.cc: Likewise. * typecheck/rust-hir-type-check-base.cc: Likewise. * typecheck/rust-hir-type-check-base.h: Likewise. * typecheck/rust-hir-type-check-item.cc: Likewise. * typecheck/rust-hir-type-check-item.h: Likewise. * typecheck/rust-hir-type-check-path.cc: Likewise. * typecheck/rust-hir-type-check-pattern.cc: Likewise. * typecheck/rust-hir-type-check-pattern.h: Likewise. * typecheck/rust-hir-type-check-type.cc: Likewise. * typecheck/rust-hir-type-check-type.h: Likewise. * typecheck/rust-hir-type-check.cc: Likewise. * typecheck/rust-hir-type-check.h: Likewise. * typecheck/rust-substitution-mapper.cc: Likewise. * typecheck/rust-substitution-mapper.h: Likewise. * typecheck/rust-type-util.cc: Likewise. * typecheck/rust-typecheck-context.cc: Likewise. * typecheck/rust-tyty-bounds.cc: Likewise. * typecheck/rust-tyty-call.h: Likewise. * typecheck/rust-tyty-subst.cc: Likewise. * typecheck/rust-tyty-subst.h: Likewise. * typecheck/rust-tyty-util.cc: Likewise. * typecheck/rust-tyty-util.h: Likewise. * typecheck/rust-tyty.cc: Likewise. * typecheck/rust-tyty.h: Likewise. * typecheck/rust-unify.cc: Likewise. * typecheck/rust-unify.h: Likewise. * util/rust-hir-map.cc: Likewise. * util/rust-hir-map.h: Likewise. * util/rust-identifier.h: Likewise. Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
2024-01-16gccrs: rust-unreachable: Add specific behavior for rust_unreachableArthur Cohen1-5/+5
As discussed during the community call, rust_unreachable() should always trigger an internal compiler error and should not offer the behavior of __builtin_unreachable when asserts are disabled, unlike gcc_unreachable(). gcc/rust/ChangeLog: * rust-system.h (rust_unreachable): Change definition to fancy_abort * ast/rust-ast-collector.cc (TokenCollector::visit): Use rust_unreachable instead of gcc_unreachable. (get_delimiters): Likewise. * ast/rust-ast-dump.h: Likewise. * ast/rust-ast-formatting.cc (get_string_in_delims): Likewise. (get_mode_dump_desc): Likewise. * ast/rust-ast.cc (Visibility::as_string): Likewise. (UseTreeGlob::as_string): Likewise. * ast/rust-ast.h: Likewise. * ast/rust-macro.h: Likewise. * ast/rust-path.h: Likewise. * backend/rust-compile-expr.cc (sort_tuple_patterns): Likewise. (CompileExpr::visit): Likewise. (CompileExpr::generate_closure_fntype): Likewise. * backend/rust-compile-intrinsic.cc (op_with_overflow_inner): Likewise. * backend/rust-compile-pattern.cc (CompilePatternBindings::visit): Likewise. (CompilePatternLet::visit): Likewise. * backend/rust-constexpr.cc (base_field_constructor_elt): Likewise. (eval_array_reference): Likewise. (label_matches): Likewise. (eval_store_expression): Likewise. (eval_call_expression): Likewise. (build_data_member_initialization): Likewise. (array_index_cmp): Likewise. (get_array_or_vector_nelts): Likewise. (eval_bit_field_ref): Likewise. (eval_loop_expr): Likewise. (potential_constant_expression_1): Likewise. * backend/rust-mangle.cc (v0_simple_type_prefix): Likewise. (v0_type_prefix): Likewise. (v0_mangle_item): Likewise. (Mangler::mangle_item): Likewise. * backend/rust-tree.cc (convert_to_void): Likewise. (type_memfn_quals): Likewise. (rs_tree_equal): Likewise. (fold_offsetof): Likewise. (fold_builtin_source_location): Likewise. (lvalue_error): Likewise. * backend/rust-tree.h (struct named_decl_hash): Likewise. (struct named_label_hash): Likewise. * checks/errors/privacy/rust-visibility-resolver.cc (VisibilityResolver::resolve_visibility): Likewise. (VisibilityResolver::visit): Likewise. * checks/errors/rust-const-checker.cc (ConstChecker::ctx_to_str): Likewise. * checks/errors/rust-feature.cc (Feature::create): Likewise. * expand/rust-expand-visitor.cc (get_traits_to_derive): Likewise. (derive_item): Likewise. (expand_item_attribute): Likewise. (expand_stmt_attribute): Likewise. * expand/rust-macro-expand.cc (MacroExpander::match_matcher): Likewise. (MacroExpander::match_repetition): Likewise. (transcribe_context): Likewise. (MacroExpander::import_proc_macros): Likewise. (MacroExpander::parse_proc_macro_output): Likewise. * expand/rust-macro-expand.h: Likewise. * expand/rust-macro-invoc-lexer.h: Likewise. * expand/rust-macro-substitute-ctx.cc (SubstituteCtx::substitute_token): Likewise. * expand/rust-proc-macro-invoc-lexer.h: Likewise. * expand/rust-proc-macro.cc (load_macros): Likewise. * hir/rust-ast-lower-base.cc (ASTLoweringBase::lower_generic_args): Likewise. (ASTLoweringBase::lower_literal): Likewise. * hir/rust-ast-lower-expr.cc (ASTLoweringExpr::visit): Likewise. * hir/rust-ast-lower-pattern.cc (ASTLoweringPattern::visit): Likewise. * hir/rust-ast-lower-type.cc (ASTLoweringType::visit): Likewise. * hir/rust-hir-dump.cc (Dump::visit): Likewise. * hir/tree/rust-hir.cc (get_string_in_delims): Likewise. (Visibility::as_string): Likewise. (UseTreeGlob::as_string): Likewise. (CompoundAssignmentExpr::as_string): Likewise. (ArithmeticOrLogicalExpr::as_string): Likewise. * lex/rust-lex.cc (Lexer::parse_byte_string): Likewise. (Lexer::parse_string): Likewise. * lex/rust-token.cc (RS_TOKEN): Likewise. * parse/rust-parse-impl.h (Parser::parse_simple_path_segment): Likewise. (Parser::parse_path_ident_segment): Likewise. (Parser::parse_attr_input): Likewise. (Parser::parse_inherent_impl_item): Likewise. (Parser::parse_trait_impl_item): Likewise. (Parser::parse_type_path_segment): Likewise. (Parser::parse_reference_type): Likewise. (get_lbp_for_comparison_expr): Likewise. * parse/rust-parse.cc (peculiar_fragment_match_compatible): Likewise. * resolve/rust-ast-resolve-path.cc (ResolvePath::resolve_path): Likewise. * resolve/rust-ast-resolve-pattern.cc (PatternDeclaration::visit): Likewise. * resolve/rust-ast-resolve-type.cc (ResolveRelativeTypePath::go): Likewise. (ResolveTypeToCanonicalPath::visit): Likewise. (ResolveGenericArgs::resolve_disambiguated_generic): Likewise. * rust-gcc.cc (operator_to_tree_code): Likewise. (fetch_overflow_builtins): Likewise. (Gcc_backend::non_zero_size_type): Likewise. (Gcc_backend::convert_tree): Likewise. * rust-lang.cc (grs_langhook_type_for_mode): Likewise. (grs_langhook_global_bindings_p): Likewise. (grs_langhook_pushdecl): Likewise. (grs_langhook_getdecls): Likewise. (convert): Likewise. * typecheck/rust-autoderef.h: Likewise. * typecheck/rust-hir-path-probe.cc: Likewise. * typecheck/rust-hir-trait-reference.cc (TraitItemReference::get_tyty): Likewise. * typecheck/rust-hir-type-check-base.cc (TypeCheckBase::resolve_literal): Likewise. * typecheck/rust-hir-type-check-expr.cc: Likewise. * typecheck/rust-hir-type-check-expr.h: Likewise. * typecheck/rust-hir-type-check-implitem.cc (TypeCheckImplItem::visit): Likewise. * typecheck/rust-hir-type-check-pattern.cc (TypeCheckPattern::visit): Likewise. * typecheck/rust-hir-type-check-stmt.h: Likewise. * typecheck/rust-hir-type-check.cc (TraitItemReference::get_type_from_fn): Likewise. * typecheck/rust-substitution-mapper.h: Likewise. * typecheck/rust-typecheck-context.cc (TypeCheckContextItem::get_context_type): Likewise. * typecheck/rust-tyty-call.h: Likewise. * typecheck/rust-tyty.cc (TypeKindFormat::to_string): Likewise. (BaseType::monomorphized_clone): Likewise. (VariantDef::variant_type_string): Likewise. (ClosureType::handle_substitions): Likewise. (IntType::as_string): Likewise. (UintType::as_string): Likewise. (FloatType::as_string): Likewise. * typecheck/rust-unify.cc (UnifyRules::expect_projection): Likewise. * util/rust-token-converter.cc (convert): Likewise. (from_literal): Likewise. (from_group): Likewise. (from_tokentree): Likewise.
2024-01-16gccrs: minor HIR cleanupMarc Poulhiès1-10/+2
Remove more rust_assert in accessors. gcc/rust/ChangeLog: * hir/tree/rust-hir-type.h (MaybeNamedParam::get_type): Remove rust_assert. (BareFunctionType::get_return_type): Likewise. Signed-off-by: Marc Poulhiès <dkm@kataplop.net>
2024-01-16gccrs: Change specifier of some forward declarationPierre-Emmanuel Patry1-4/+4
Change storage specifier of some forward declaration to satisfy compiler warning. gcc/rust/ChangeLog: * hir/tree/rust-hir-full-decls.h (struct Crate): Change to class. (class Crate): Likewise. (struct StructField): Likewise. (class StructField): Likewise. (struct TupleField): Likewise. (class TupleField): Likewise. (struct TraitFunctionDecl): Likewise. (class TraitFunctionDecl): Likewise. * rust-session-manager.h (struct Crate): Likewise. (class Crate): Likewise. Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
2024-01-16gccrs: minor HIR cleanupMarc Poulhiès5-138/+29
Add one more accessor and remove some rust_assert() in accessors for unique_ptr&. gcc/rust/ChangeLog: * hir/tree/rust-hir-expr.h (TypeCastExpr::get_casted_expr): Remove assert in accessor. (TypeCastExpr::get_type_to_convert_to): Likewise. (CompoundAssignmentExpr::get_left_expr): Likewise. (CompoundAssignmentExpr::get_right_expr): Likewise. (GroupedExpr::get_expr_in_parens): Likewise. (TupleIndexExpr::get_tuple_expr): Likewise. (FieldAccessExpr::get_receiver_expr): Likewise. (ClosureParam::get_pattern): Likewise. (ClosureParam::get_type): Likewise. (ExprType::get_return_type): Likewise. (IfLetExpr::get_scrutinee_expr): Likewise. (MatchArm::get_guard_expr): Likewise. (MatchExpr::get_scrutinee_expr): Likewise. * hir/tree/rust-hir-item.h (TypeParam::get_type): Likewise. (SelfParam::get_type): Likewise. (Function::get_return_type): Likewise. (TypeAlias::get_type_aliased): Likewise. (StructField::get_field_type): Likewise. (TraitFunctionDecl::get_block_expr): Likewise. (ImplBlock::get_trait_ref): Likewise. * hir/tree/rust-hir-path.h (ConstGenericArg::get_expression): New. (TypePathFunction::get_return_type): Remove assert in accessor. (QualifiedPathType::get_trait): Likewise. * hir/tree/rust-hir-pattern.h (PatternType::get_lower_bound): Likewise. (PatternType::get_upper_bound): Likewise. (ReferencePattern::get_referenced_pattern): Likewise. * hir/tree/rust-hir.h (ConstGenericParam::get_default_expression): Likewise. Signed-off-by: Marc Poulhiès <dkm@kataplop.net>
2024-01-16gccrs: Replace Linemap::unknown_location with UNKNOWN_LOCATIONOwen Avery1-1/+1
gcc/rust/ChangeLog: * rust-linemap.h (Linemap::unknown_location): Remove. * ast/rust-ast.cc: Replace Linemap::unknown_location with UNKNOWN_LOCATION. * ast/rust-path.cc: Likewise. * hir/tree/rust-hir.cc: Likewise. * metadata/rust-imports.cc: Likewise. * parse/rust-parse-impl.h: Likewise. * parse/rust-parse.h: Likewise. * rust-backend.h: Likewise. * rust-diagnostics.cc: Likewise. * rust-session-manager.cc: Likewise. * typecheck/rust-tyty.cc: Likewise. Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
2024-01-16gccrs: Replace value initialization of Location with UNDEF_LOCATIONOwen Avery5-13/+13
gcc/rust/ChangeLog: * rust-location.h (UNDEF_LOCATION): New. * ast/rust-ast-collector.cc: Replace Location () with UNDEF_LOCATION. * ast/rust-ast-fragment.cc: Likewise. * ast/rust-ast.h: Likewise. * ast/rust-expr.h: Likewise. * ast/rust-item.h: Likewise. * ast/rust-macro.h: Likewise. * ast/rust-path.h: Likewise. * ast/rust-type.h: Likewise. * backend/rust-compile-expr.cc: Likewise. * backend/rust-compile-extern.h: Likewise. * backend/rust-compile-implitem.h: Likewise. * backend/rust-compile-intrinsic.cc: Likewise. * backend/rust-compile-item.h: Likewise. * backend/rust-compile.cc: Likewise. * backend/rust-constexpr.cc: Likewise. * expand/rust-expand-visitor.cc: Likewise. * expand/rust-macro-expand.cc: Likewise. * expand/rust-macro-expand.h: Likewise. * expand/rust-macro-invoc-lexer.cc: Likewise. * expand/rust-proc-macro-invoc-lexer.cc: Likewise. * expand/rust-proc-macro.cc: Likewise. * hir/tree/rust-hir-expr.h: Likewise. * hir/tree/rust-hir-item.h: Likewise. * hir/tree/rust-hir-path.h: Likewise. * hir/tree/rust-hir-type.h: Likewise. * hir/tree/rust-hir.h: Likewise. * lex/rust-lex.cc: Likewise. * metadata/rust-export-metadata.cc: Likewise. * parse/rust-parse-impl.h: Likewise. * resolve/rust-ast-resolve-item.cc: Likewise. * resolve/rust-ast-resolve.cc: Likewise. * rust-diagnostics.h: Likewise. * rust-session-manager.cc: Likewise. * typecheck/rust-autoderef.cc: Likewise. * typecheck/rust-coercion.cc: Likewise. * typecheck/rust-hir-dot-operator.cc: Likewise. * typecheck/rust-hir-path-probe.cc: Likewise. * typecheck/rust-hir-trait-reference.cc: Likewise. * typecheck/rust-hir-trait-reference.h: Likewise. * typecheck/rust-hir-type-check-expr.cc: Likewise. * typecheck/rust-hir-type-check-implitem.cc: Likewise. * typecheck/rust-hir-type-check-type.cc: Likewise. * typecheck/rust-hir-type-check.cc: Likewise. * typecheck/rust-tyty-bounds.cc: Likewise. * typecheck/rust-tyty-subst.cc: Likewise. * typecheck/rust-tyty.cc: Likewise. * util/rust-hir-map.cc: Likewise. Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
2024-01-16gccrs: Add location info to `Rust::Identifier`Raiki Tamura1-1/+1
gcc/rust/ChangeLog: * ast/rust-ast.h: Modify constructors of `Rust::Identifier` * ast/rust-pattern.h: Likewise. * hir/tree/rust-hir-item.h: Likewise. * parse/rust-parse-impl.h (Parser::parse_macro_rules_def): Likewise. (Parser::parse_decl_macro_def): Likewise. (Parser::parse_macro_match_fragment): Likewise. (Parser::parse_module): Likewise. (Parser::parse_use_tree): Likewise. (Parser::parse_function): Likewise. (Parser::parse_type_param): Likewise. (Parser::parse_type_alias): Likewise. (Parser::parse_struct): Likewise. (Parser::parse_struct_field): Likewise. (Parser::parse_enum): Likewise. (Parser::parse_enum_item): Likewise. (Parser::parse_union): Likewise. (Parser::parse_static_item): Likewise. (Parser::parse_trait): Likewise. (Parser::parse_trait_item): Likewise. (Parser::parse_trait_type): Likewise. (Parser::parse_trait_const): Likewise. (Parser::parse_external_item): Likewise. (Parser::parse_generic_args_binding): Likewise. (Parser::parse_method): Likewise. (Parser::parse_maybe_named_param): Likewise. (Parser::parse_identifier_pattern): Likewise. (Parser::parse_struct_expr_field): Likewise. (ResolveItem::visit): Likewise. * typecheck/rust-hir-type-check-implitem.cc (TypeCheckImplItem::visit):Add comments * resolve/rust-ast-resolve-item.cc (ResolveTraitItems::visit): Likewise. * checks/lints/rust-lint-scan-deadcode.h: Fix error location Signed-off-by: Raiki Tamura <tamaron1203@gmail.com>
2024-01-16gccrs: HIR cleanupMarc Poulhiès6-23/+70
Some more HIR cleanup. gcc/rust/ChangeLog: * hir/tree/rust-hir-expr.h (BorrowExpr::is_double_borrow): New. (ArrayElemsCopied::get_elem_to_copy) (ArrayElemsCopied::get_num_copies_expr): Return unique_ptr. (CallExpr::get_fnexpr): Likewise. (ReturnExpr::get_expr): Likewise. (StructExprStructFields::get_struct_base): New. (MethodCallExpr::has_params): New. (ClosureExpr::has_params): New. (BlockExpr::get_inner_attrs): New. (WhileLoopExpr::get_patterns): New. (ForLoopExpr::get_pattern): New. (IfLetExpr::get_if_block): Return ref to unique_ptr. (IfLetExprConseqElse::get_else_block): Likewise. (MatchExpr::get_inner_attrs): New. * hir/tree/rust-hir-item.h (Module::get_module_name): New. (ExternCrate::get_referenced_crate) (ExternCrate::get_as_clause_name): New. (UseTreeGlob::get_glob_type, UseTreeGlob::get_path): New. (UseTreeList::get_path_type, UseTreeList::get_path) (UseTreeList::get_trees): New. (TraitItemKind::get_expr): Remove assert. unique_ptr can be "empty". Must be checked in caller. * hir/tree/rust-hir-pattern.h (IdentifierPattern::get_is_ref) (IdentifierPattern::get_to_bind): New. (RangePatternBoundType::get_has_minus): New. (RangePattern::get_has_ellipsis_syntax): New. (StructPatternField::get_outer_attrs): New. (StructPatternFieldTuplePat::get_index) (StructPatternFieldTuplePat::get_tuple_pattern): New. (StructPatternFieldIdent::get_has_ref): New. * hir/tree/rust-hir-stmt.h (LetStmt::get_outer_attrs): New. (LetStmt::get_type) (LetStmt::get_init_expr, LetStmt::get_pattern): Return unique_ptr. (ExprStmt::get_expr): Likewise. * hir/tree/rust-hir-type.h (TraitBound::get_for_lifetimes): New. (TraitBound::get_in_params): New. (TraitBound::get_opening_question_mark): New. (ImplTraitType::get_type_param_bounds): New. (TraitObjectType::get_has_dyn): New. (TraitBound::get_type_in_parens): New. (ImplTraitTypeOneBound::get_trait_bound): New. (BareFunctionType::get_for_lifetimes) (BareFunctionType::get_is_variadic) (BareFunctionType::get_function_qualifiers): New. * hir/tree/rust-hir.h (class Expr): Virtual inherit from FullVisitable. (class Pattern): Likewise. (ConstGenericParam::get_name): New. * typecheck/rust-hir-type-check-expr.cc (TypeCheckExpr::visit): Adjust call. (TypeCheckExpr::resolve_fn_trait_call): Likewise. * backend/rust-compile-expr.cc (CompileExpr::visit): Adjust call. (CompileExpr::array_copied_expr): Likewise. (CompileExpr::generate_possible_fn_trait_call): Likewise. * backend/rust-compile-stmt.cc (CompileStmt::visit): Likewise. * checks/errors/privacy/rust-privacy-reporter.cc (PrivacyReporter::visit): Likewise. * checks/errors/rust-const-checker.cc (ConstChecker::visit): Likewise. * checks/errors/rust-unsafe-checker.cc (UnsafeChecker::visit): Likewise. * hir/rust-hir-dump.cc (Dump::visit): Likewise. * typecheck/rust-hir-type-check-stmt.cc (TypeCheckStmt::visit): Likewise. Signed-off-by: Marc Poulhiès <dkm@kataplop.net>
2024-01-16gccrs: minor HIR interface cleanupMarc Poulhiès3-13/+23
Minor changes in HIR interface: add missing getters, make some classes inherit from FullVisitable. gcc/rust/ChangeLog: * hir/tree/rust-hir-expr.h (class ArrayElems): Inherit from FullVisitable. (class StructExprField): Likewise. * hir/tree/rust-hir-item.h (class WhereClauseItem): Likewise. (class UseTree): Likewise. (UseTreeRebind::get_path, UseTreeRebind::get_identifier) (UseTreeRebind::get_bind_type): New. (UseDeclaration::get_use_tree): New. (struct TraitFunctionDecl): Change struct to ... (class TraitFunctionDecl): ... class. (TraitFunctionDecl::get_where_clause): New. (StructField::get_outer_attrs): New. (struct TupleField): Change struct to ... (class TupleField): ... class. (TupleField::get_visibility, TupleField::get_outer_attrs): New. * hir/tree/rust-hir-pattern.h (class TupleStructItems): Inherit from FullVisitable. Signed-off-by: Marc Poulhiès <dkm@kataplop.net>
2024-01-16gccrs: refactor: make crate.items privateMarc Poulhiès1-3/+4
Introduce Crate::get_items () and fixup all callers. gcc/rust/ChangeLog: * hir/tree/rust-hir.h (struct Crate): Rename struct into ... (class Crate): ... class, and add get_items. * backend/rust-compile.cc (CompileCrate::go): Adapt to visibility change of items. * checks/errors/privacy/rust-privacy-check.cc (Resolver::resolve): Likewise. * checks/errors/privacy/rust-privacy-reporter.cc (PrivacyReporter::go): Likewise. * checks/errors/privacy/rust-pub-restricted-visitor.cc (PubRestrictedVisitor::go): Likewise. * checks/errors/privacy/rust-visibility-resolver.cc (VisibilityResolver::go): Likewise. * checks/errors/rust-const-checker.cc (ConstChecker::go): Likewise. * checks/errors/rust-unsafe-checker.cc (UnsafeChecker::go): Likewise. * checks/lints/rust-lint-marklive.cc (FindEntryPoint::find): Likewise. * checks/lints/rust-lint-scan-deadcode.h (ScanDeadCode::Scan): Likewise. * metadata/rust-export-metadata.cc (PublicInterface::gather_export_data): Likewise. * typecheck/rust-hir-type-check.cc (TypeResolution::Resolve): Likewise. * hir/rust-hir-dump.cc (CompileCrate::go): Likewise. Signed-off-by: Marc Poulhiès <dkm@kataplop.net>
2024-01-16gccrs: Add new gettersMarc Poulhiès2-0/+10
Some class members were not accessible from outside, which will be needed for the new HIR dump. gcc/rust/ChangeLog: * hir/tree/rust-hir-expr.h (AwaitExpr::get_awaited_expr): New. (AsyncBlockExpr::get_has_move, AsyncBlockExpr::get_block_expr): New. * hir/tree/rust-hir-item.h (Enum::get_where_clause): New. (Trait::get_where_clause, Trait::is_unsafe): New. (ExternalItem::get_visibility): New. Signed-off-by: Marc Poulhiès <dkm@kataplop.net>
2024-01-16gccrs: FullVisitable abstract classMarc Poulhiès1-18/+27
Introduce FullVisitable class. HIR nodes implementing the FullVisitor interface should inherit from this class. gcc/rust/ChangeLog: * hir/tree/rust-hir.h (class FullVisitable): New. (class Stmt): Adjust with new class. (class Expr): Likewise. (class Pattern): Likewise. (class Type): Likewise. (class TypeParamBound): Likewise. (class GenericParam): Likewise. (class TraitItem): Likewise. (class ImplItem): Likewise. Signed-off-by: Marc Poulhiès <dkm@kataplop.net>
2024-01-16gccrs: factor out inner attributes in a classMarc Poulhiès3-73/+63
Introduce WithInnerAttrs class that can be inherited instead of duplicating the same data/method in all HIR classes. gcc/rust/ChangeLog: * hir/tree/rust-hir.h (class WithInnerAttrs): New. (class Item): Adjust to new WithInnerAttrs class. (struct Crate): Likewise. * hir/rust-hir-dump.cc (Dump::go): Likewise. (Dump::visit): Likewise. * hir/tree/rust-hir-expr.h (class GroupedExpr): Likewise. (class ArrayExpr): Likewise. (class TupleExpr): Likewise. (class StructExprStruct): Likewise. (class BlockExpr): Likewise. (class MatchExpr): Likewise. * hir/tree/rust-hir-item.h (TypeParam::get_outer_attribute): New. (class Module): Adjust to new WithInnerAttrs class. (struct StructField): change struct to... (class StructField): ... a class. (class ImplBlock): Adjust to new WithInnerAttrs class. (class ExternBlock): Likewise. Signed-off-by: Marc Poulhiès <dkm@kataplop.net>
2024-01-16gccrs: cleanup getters to return &unique_ptr instead of pointerMarc Poulhiès3-24/+26
Make all getter methods in HIR classes return a unique_ptr reference instead of a pointer and adjust all callers. gcc/rust/ChangeLog: * hir/tree/rust-hir-type.h (ArrayType::get_element_type): Returns unique_ptr. * hir/tree/rust-hir-expr.h (ArithmeticOrLogicalExpr::get_lhs) (ArithmeticOrLogicalExpr::get_rhs): Likewise. (ComparisonExpr::get_lhs, ComparisonExpr::get_rhs): Likewise. (LazyBooleanExpr::get_lhs, LazyBooleanExpr::get_rhs): Likewise. (AssignmentExpr::get_lhs, AssignmentExpr::get_rhs): Likewise. (ArrayExpr::get_internal_elements): Likewise. (ArrayIndexExpr::get_index_expr, ArrayIndexExpr::get_array_expr): Likewise. (StructExprFieldWithVal::get_value): Likewise. (IfExpr::get_if_condition, IfExpr::get_if_block): Likewise. (ExprWithBlock::get_else_block): Likewise. * hir/tree/rust-hir-item.h (FunctionParam::get_param_name) (FunctionParam::get_type): Likewise. (ConstantItem::get_type, ConstantItem::get_expr): Likewise. (StaticItem::get_expr, StaticItem::get_type): Likewise. * typecheck/rust-hir-type-check-type.cc (TypeCheckType::visit): Adjust for previous change. * backend/rust-compile-block.cc (CompileConditionalBlocks::visit): Likewise. * backend/rust-compile-expr.cc (CompileExpr::visit): Likewise. * backend/rust-compile-item.cc (CompileItem::visit): Likewise. * backend/rust-compile-struct-field-expr.cc (CompileStructExprField::visit): Likewise. * checks/errors/privacy/rust-privacy-reporter.cc (PrivacyReporter::visit): Likewise. * typecheck/rust-hir-type-check-expr.cc (TypeCheckExpr::visit): Likewise. * typecheck/rust-hir-type-check-implitem.cc (TypeCheckImplItem::visit): Likewise. * typecheck/rust-hir-type-check-item.cc (TypeCheckItem::visit): Likewise. * typecheck/rust-hir-type-check-stmt.cc (TypeCheckStmt::visit): Likewise. * typecheck/rust-hir-type-check-struct.cc (TypeCheckStructExpr::visit): Likewise. * typecheck/rust-hir-type-check.cc (TraitItemReference::get_type_from_fn): Likewise. Signed-off-by: Marc Poulhiès <dkm@kataplop.net>
2024-01-16gccrs: ast: Change Identifier definitionPierre-Emmanuel Patry6-40/+49
Change Identifier type definition from a simple typedef to a whole class with it's own node id. gcc/rust/ChangeLog: * ast/rust-ast-collector.cc (TokenCollector::visit): Change with call to getter. * ast/rust-ast.cc (Module::as_string): Likewise. (StaticItem::as_string): Likewise. (TupleStruct::as_string): Likewise. (Method::as_string): Likewise. (StructStruct::as_string): Likewise. (UseTreeRebind::as_string): Likewise. (Enum::as_string): Likewise. (Trait::as_string): Likewise. (Union::as_string): Likewise. (Function::as_string): Likewise. (TypeAlias::as_string): Likewise. (MacroRulesDefinition::as_string): Likewise. (FieldAccessExpr::as_string): Likewise. (MacroMatchFragment::as_string): Likewise. (TypeParam::as_string): Likewise. (StructExprFieldIdentifierValue::as_string): Likewise. (EnumItem::as_string): Likewise. (StructField::as_string): Likewise. (ExternalTypeItem::as_string): Likewise. (ExternalStaticItem::as_string): Likewise. (ExternalFunctionItem::as_string): Likewise. (TraitFunctionDecl::as_string): Likewise. (TraitMethodDecl::as_string): Likewise. (TraitItemConst::as_string): Likewise. (TraitItemType::as_string): Likewise. (MaybeNamedParam::as_string): Likewise. (MetaListPaths::as_string): Likewise. (MetaListNameValueStr::as_string): Likewise. (Module::process_file_path): Likewise. (MetaListNameValueStr::check_cfg_predicate): Likewise. (MetaListPaths::check_cfg_predicate): Likewise. (MetaWord::check_cfg_predicate): Likewise. (MetaNameValueStr::check_cfg_predicate): Likewise. (MetaNameValueStr::to_attribute): Likewise. (MetaWord::to_attribute): Likewise. (MetaListPaths::to_attribute): Likewise. (MetaListNameValueStr::to_attribute): Likewise. (operator<<): Change Identifier class << operator overload for standard output stream. * ast/rust-ast.h (class Identifier): Change typedef to proper class definition. (operator<<): Add prototype for operator overload. (class Token): Change getter identifier. (class MetaListNameValueStr): Likewise. (class PathExpr): Likewise. * ast/rust-expr.h: Likewise. * ast/rust-item.h: Likewise. * ast/rust-macro.h: Likewise. * ast/rust-path.cc (GenericArg::disambiguate_to_type): Likewise. (GenericArgsBinding::as_string): Likewise. (ConstGenericParam::as_string): Likewise. * ast/rust-path.h: Likewise. * ast/rust-pattern.cc (IdentifierPattern::as_string): Likewise. (StructPatternFieldIdentPat::as_string): Likewise. (StructPatternFieldIdent::as_string): Likewise. * ast/rust-type.h: Likewise. * backend/rust-compile-base.cc: Likewise. * backend/rust-compile-expr.cc (CompileExpr::visit): Likewise. * backend/rust-compile-extern.h: Likewise. * backend/rust-compile-fnparam.cc (CompileFnParam::visit): Likewise. * backend/rust-compile-implitem.cc (CompileTraitItem::visit): Likewise. * backend/rust-compile-item.cc (CompileItem::visit): Likewise. * backend/rust-compile-pattern.cc (CompilePatternBindings::visit): Likewise. * backend/rust-compile-struct-field-expr.cc (CompileStructExprField::visit): Likewise. * backend/rust-compile-var-decl.h: Likewise. * backend/rust-compile.cc: Likewise. * checks/errors/rust-unsafe-checker.cc (check_extern_call): Likewise. * checks/lints/rust-lint-marklive.cc (MarkLive::visit): Likewise. * checks/lints/rust-lint-scan-deadcode.h: Likewise. * expand/rust-derive-clone.cc (DeriveClone::clone_fn): Likewise. (DeriveClone::visit_tuple): Likewise. (DeriveClone::visit_struct): Likewise. (DeriveClone::visit_union): Likewise. * expand/rust-derive-copy.cc (DeriveCopy::visit_struct): Likewise. (DeriveCopy::visit_tuple): Likewise. (DeriveCopy::visit_enum): Likewise. (DeriveCopy::visit_union): Likewise. * expand/rust-macro-expand.cc (MacroExpander::match_matcher): Likewise. (MacroExpander::match_n_matches): Likewise. (MacroExpander::match_repetition): Likewise. (MacroExpander::match_repetition_skipped_metavars): Likewise. * hir/rust-ast-lower-base.cc (struct_field_name_exists): Likewise. * hir/rust-ast-lower-expr.cc (ASTLoweringExpr::visit): Likewise. * hir/rust-ast-lower-type.cc (ASTLowerGenericParam::visit): Likewise. * hir/rust-hir-dump.cc (Dump::visit): Likewise. * hir/tree/rust-hir-expr.h: Likewise. * hir/tree/rust-hir-item.h: Likewise. * hir/tree/rust-hir-path.h: Likewise. * hir/tree/rust-hir-type.h: Likewise. * hir/tree/rust-hir.cc (Module::as_string): Likewise. (StaticItem::as_string): Likewise. (TupleStruct::as_string): Likewise. (ConstantItem::as_string): Likewise. (StructStruct::as_string): Likewise. (UseTreeRebind::as_string): Likewise. (Enum::as_string): Likewise. (Trait::as_string): Likewise. (Union::as_string): Likewise. (Function::as_string): Likewise. (TypeAlias::as_string): Likewise. (FieldAccessExpr::as_string): Likewise. (TypeParam::as_string): Likewise. (GenericArgsBinding::as_string): Likewise. (StructPatternFieldIdent::as_string): Likewise. (StructPatternFieldIdentPat::as_string): Likewise. (IdentifierPattern::as_string): Likewise. (StructExprFieldIdentifierValue::as_string): Likewise. (EnumItem::as_string): Likewise. (StructField::as_string): Likewise. (ExternalStaticItem::as_string): Likewise. (ExternalFunctionItem::as_string): Likewise. (NamedFunctionParam::as_string): Likewise. (TraitFunctionDecl::as_string): Likewise. (TraitItemConst::as_string): Likewise. (TraitItemType::as_string): Likewise. (MaybeNamedParam::as_string): Likewise. * hir/tree/rust-hir.h: Likewise. * parse/rust-parse-impl.h (Parser::parse_macro_match_fragment): Likewise. (Parser::parse_module): Likewise. (Parser::parse_use_tree): Likewise. (Parser::parse_maybe_named_param): Likewise. * resolve/rust-ast-resolve-implitem.h: Likewise. * resolve/rust-ast-resolve-item.cc (ResolveTraitItems::visit): Likewise. (ResolveItem::visit): Likewise. (flatten_rebind): Likewise. (ResolveExternItem::visit): Likewise. (rust_flatten_rebind): Likewise. (rust_flatten_rebind_nested): Likewise. * resolve/rust-ast-resolve-pattern.cc (PatternDeclaration::go): Likewise. (PatternDeclaration::visit): Likewise. (PatternDeclaration::add_new_binding): Likewise. * resolve/rust-ast-resolve-stmt.h: Likewise. * resolve/rust-ast-resolve-toplevel.h: Likewise. * resolve/rust-ast-resolve-type.h: Likewise. * resolve/rust-early-name-resolver.cc (EarlyNameResolver::visit): Likewise. * typecheck/rust-autoderef.cc: Likewise. * typecheck/rust-hir-dot-operator.cc (MethodResolver::select): Likewise. * typecheck/rust-hir-path-probe.cc (PathProbeType::visit): Likewise. * typecheck/rust-hir-trait-reference.cc (TraitReference::get_name): Likewise. * typecheck/rust-hir-trait-resolve.cc (ResolveTraitItemToRef::visit): Likewise. (TraitResolver::resolve_trait): Likewise. (TraitItemReference::resolve_item): Likewise. (AssociatedImplTrait::setup_raw_associated_types): Likewise. * typecheck/rust-hir-type-check-enumitem.cc (TypeCheckEnumItem::visit): Likewise. * typecheck/rust-hir-type-check-expr.cc (TypeCheckExpr::visit): Likewise. * typecheck/rust-hir-type-check-implitem.cc (TypeCheckTopLevelExternItem::visit): Likewise. (TypeCheckImplItem::visit): Likewise. (TypeCheckImplItemWithTrait::visit): Likewise. * typecheck/rust-hir-type-check-item.cc (TypeCheckItem::visit): Likewise. * typecheck/rust-hir-type-check-pattern.cc (TypeCheckPattern::visit): Likewise. * typecheck/rust-hir-type-check-struct.cc (TypeCheckStructExpr::visit): Likewise. * typecheck/rust-hir-type-check-type.cc (TypeResolveGenericParam::visit): Likewise. * typecheck/rust-hir-type-check.cc (TraitItemReference::get_type_from_fn): Likewise. * typecheck/rust-tyty-subst.cc (SubstitutionRef::get_mappings_from_generic_args): Likewise. * util/rust-attributes.cc (check_doc_attribute): Likewise. * util/rust-hir-map.cc (Mappings::insert_macro_def): Likewise. Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
2024-01-16gccrs: Fix parsing of block expressions followed by `.`Matthew Jasper1-11/+0
`{ ... }.f;` is parsed as a single statement in rust. This means that we can't determine whether an expression statement will need a semicolon terminator until we finish parsing it. To handle this we change expression parsing to check for this case by inspecting the expression returned from null_denotation and looking ahead for a `.` or `?` token. gcc/rust/ChangeLog: * ast/rust-ast.h (Expr::as_expr_without_block): Remove. (Expr::set_outer_attrs): Make public in base class. * expand/rust-macro-expand.cc: Add fixme comment for pre-existing bug. * hir/tree/rust-hir.h: Remove Expr::as_expr_without_block. * parse/rust-parse-impl.h (Parser::parse_lifetime): Use lifetime_from_token. (Parser::lifetime_from_token): New method. (Parser::null_denotation): Handle labelled loop expressions and for loop expressions. (Parser::parse_loop_label): Make initial token a parameter. (Parser::parse_labelled_loop_expr): Likewise. (Parser::parse_for_loop_expr): Allow FOR token to already be skipped. (Parser::parse_expr): Handle expr_can_be_stmt. (Parser::parse_expr_with_block): Remove. (Parser::parse_expr_stmt_with_block): Remove. (Parser::parse_expr_stmt_without_block): Remove. (Parser::parse_expr_without_block): Remove. (Parser::parse_stmt_or_expr_with_block): Remove. (Parser::parse_expr_stmt): Use parse_expr directly. (Parser::parse_match_expr): Likewise. (Parser::parse_stmt): Use parse_expr_stmt in more cases. (Parser::parse_stmt_or_expr): Rename from parse_stmt_or_expr_without_block, use parse_expr directly. (Parser::parse_block_expr): Update error message. * parse/rust-parse.h: Update declarations. gcc/testsuite/ChangeLog: * rust/compile/for_expr.rs: New test. * rust/compile/issue-407-2.rs: Update compiler output. * rust/compile/issue-407.rs: Update compiler output. * rust/compile/issue-867.rs: Update compiler output. * rust/compile/issue-2189.rs: New test. * rust/compile/macro_call_statement.rs: New test. * rust/compile/stmt_with_block_dot.rs: New test. * rust/compile/torture/loop8.rs: New test. Signed-off-by: Matthew Jasper <mjjasper1@gmail.com>
2024-01-16gccrs: Added HIR::InlineAsm nodeM V V S Manoj Kumar2-0/+92
Fixes Issue #1568 Added HIR node HIR::InlineAsm similar to the one found in rustc. In this I also changed the defination of the AST::InlineAsm node, so that we can reuse many of it's data members in the HIR::InlineAsm node. gcc/rust/ChangeLog: * ast/rust-ast-full-decls.h (enum class): Added declaration. (struct AnonConst): Added declaration. (struct InlineAsmRegOrRegClass): Added declaration. (struct InlineAsmOperand): Added declaration. (struct InlineAsmPlaceHolder): Added declaration. (struct InlineAsmTemplatePiece): Added declaration. (struct TupleClobber): Added declaration. (struct TupleTemplateStr): Added declaration. * ast/rust-expr.h (class InlineAsm): Defined all it's data members outside. (enum class InlineAsmOptions): Converted this to a enum class so we could use it in the HIR. (struct AnonConst): Defined it independent of the AST::InlineAsm node. (struct InlineAsmRegOrRegClass): Defined it independent of the AST::InlineAsm node. (struct InlineAsmOperand): Defined it independent of the AST::InlineAsm node. (struct InlineAsmPlaceHolder): Defined it independent of the AST::InlineAsm node. (struct InlineAsmTemplatePiece): Defined it independent of the AST::InlineAsm node. (struct TupleClobber): Defined it independent of the AST::InlineAsm node. (struct TupleTemplateStr): Defined it independent of the AST::InlineAsm node. * hir/tree/rust-hir-expr.h (class InlineAsmReg): Added defination. (class InlineAsmRegClass): Added defination. (struct InlineAsmRegOrRegClass): Added defination. (class InlineAsm): Added defination. * hir/tree/rust-hir-full-decls.h (class InlineAsmReg): Added declaration. (class InlineAsmRegClass): Added declaration. (struct InlineAsmRegOrRegClass): Added declaration. (class InlineAsm): Added declaration. Signed-off-by: M V V S Manoj Kumar <mvvsmanojkumar@gmail.com>
2024-01-16gccrs: Add missing TypeBoundWhereClauseItem::get_locusPhilip Herron1-0/+2
gcc/rust/ChangeLog: * hir/tree/rust-hir-item.h: add get_locus() const Signed-off-by: Philip Herron <herron.philip@googlemail.com>
2024-01-16gccrs: Add accessors to HIR::StructPatternFieldIdentPatOwen Avery1-0/+4
gcc/rust/ChangeLog: * hir/tree/rust-hir-pattern.h (StructPatternFieldIdentPat::get_identifier): New. (StructPatternFieldIdentPat::get_pattern): New. Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
2024-01-16gccrs: Add mechanism use pattern information to improve type infoPhilip Herron1-0/+2
When we have an untyped closure we assumed all parameters were inference variables but we can use the pattern type to try and improve the type info so if we have a reference pattern it must be a reference to an inference variables '&_'. This patch adds a new visitor to figure this out for untyped closure parameters. Note this test case does fully type resolve into the gimple: bool test::main::{{closure}} (struct test::main::{{closure}} $closure, struct (& u8) args) { ... } Though the Rustc version does fail type-resolution but we make some assumptions during comparison expressions here that they resolve to a bool this will change when we implement the comparison lang items. Fixes #2142 gcc/rust/ChangeLog: * hir/tree/rust-hir-pattern.h: add missing get_mutability * typecheck/rust-hir-type-check-expr.cc (TypeCheckExpr::visit): use new ClosureParamInfer on untyped parameters * typecheck/rust-hir-type-check-pattern.cc (ClosureParamInfer::Resolve): interface (ClosureParamInfer::ClosureParamInfer): constructor (ClosureParamInfer::visit): visitors for each pattern * typecheck/rust-hir-type-check-pattern.h (class ClosureParamInfer): new visitor gcc/testsuite/ChangeLog: * rust/compile/issue-2142.rs: New test. Signed-off-by: Philip Herron <herron.philip@googlemail.com>
2024-01-16gccrs: Add lowering for if-let expressionsOwen Avery1-1/+5
gcc/rust/ChangeLog: * typecheck/rust-hir-type-check-expr.cc (TypeCheckExpr::visit): Add implementation for IfLetExprConseqElse. * typecheck/rust-hir-type-check-expr.h: (TypeCheckExpr::visit): Remove stub implementation for IfLetExprConseqElse. * hir/rust-ast-lower-expr.cc (ASTLoweringExpr::visit): Lower IfLetExpr{,ConseqElse}. * hir/rust-ast-lower-expr.h: (ASTLoweringExpr::visit): Likewise. * hir/rust-ast-lower-block.h (ASTLoweringIfLetBlock::visit): Lower IfLetExprConseqElse. (ASTLoweringExprWithBlock::visit): Likewise. * hir/rust-ast-lower.cc (ASTLoweringIfLetBlock::visit): Lower IfLetExprConseqElse. * hir/tree/rust-hir-expr.h (IfLetExprConseqElse::IfLetExprConseqElse): Make constructor more general. (IfLetExprConseqElse::vis_else_block): Add. (IfLetExprConseqElse::get_else_block): Add. * resolve/rust-ast-resolve-expr.cc (ResolveExpr::visit): Add IfLetExprConseqElse visitor. * resolve/rust-ast-resolve-expr.h (ResolveExpr::visit): Add IfLetExprConseqElse visitor. gcc/testsuite/ChangeLog: * rust/compile/if_let_expr.rs: Increase test coverage. Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
2024-01-16gccrs: Fully unify deriving classes into HIR::ExprStmtOwen Avery2-49/+14
gcc/rust/ChangeLog: * hir/tree/rust-hir-full-decls.h (class ExprStmtWithoutBlock): Remove. (class ExprStmtWithBlock): Remove. * hir/tree/rust-hir-stmt.h (class ExprStmt): Add remaining ExprStmtWith{,out}Block functionality. (class ExprStmtWithoutBlock): Remove. (class ExprStmtWithBlock): Remove. * hir/rust-ast-lower-stmt.cc (ASTLoweringStmt::visit): Lower to HIR::ExprStmt instead of deriving class. Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
2024-01-16gccrs: Unify HIR::ExprStmt derived class visitingOwen Avery3-26/+8
gcc/rust/ChangeLog: * backend/rust-compile-stmt.cc (CompileStmt::visit): Unify ExprStmtWith{,out}Block visitors. * backend/rust-compile-stmt.h (CompileStmt::visit): Likewise. * backend/rust-compile-item.h (CompileItem::visit): Likewise. * hir/rust-hir-dump.cc (Dump::visit): Likewise. * hir/rust-hir-dump.h (Dump::visit): Likewise. * hir/tree/rust-hir-stmt.h (ExprStmt::accept_vis): Add. (ExprStmtWithoutBlock::accept_vis): Remove. (ExprStmtWithBlock::accept_vis): Remove. * hir/tree/rust-hir.cc (ExprStmt::accept_vis): Add. (ExprStmtWithoutBlock::accept_vis): Remove. (ExprStmtWithBlock::accept_vis): Remove. * hir/tree/rust-hir-visitor.h (HIRFullVisitor::visit): Likewise. (HIRFullVisitorBase::visit): Likewise. (HIRStmtVisitor::visit): Likewise. * checks/errors/rust-const-checker.cc (ConstChecker::visit): Likewise. * checks/errors/rust-const-checker.h (ConstChecker::visit): Likewise. * checks/errors/rust-unsafe-checker.cc (UnsafeChecker::visit): Likewise. * checks/errors/rust-unsafe-checker.h (UnsafeChecker::visit): Likewise. * checks/errors/privacy/rust-privacy-reporter.cc (PrivacyReporter::visit): Likewise. * checks/errors/privacy/rust-privacy-reporter.h (PrivacyReporter::visit): Likewise. * checks/lints/rust-lint-marklive.h (MarkLive::visit): Likewise. * typecheck/rust-hir-type-check-stmt.cc (TypeCheckStmt::visit): Likewise. * typecheck/rust-hir-type-check-stmt.h (TypeCheckStmt::visit): Likewise. * typecheck/rust-tycheck-dump.h (TypeResolverDump::visit): Likewise. Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
2024-01-16gccrs: Move functionality into HIR::ExprStmt from deriving classesOwen Avery2-72/+30
And move method as_string into HIR::ExprStmt from deriving classes gcc/rust/ChangeLog: * hir/tree/rust-hir-stmt.h (ExprStmt::expr): Add field. (ExprStmt::get_expr): Add method. (ExprStmt::ExprStmt): Add copy/move constructors, modify existing constructor. (ExprStmt::operator=): Add assignment operator. (ExprStmtWithoutBlock::expr): Remove field. (ExprStmtWithoutBlock::get_expr): Remove method. (ExprStmtWithoutBlock::ExprStmt): Remove copy/move constructors, modify existing constructor. (ExprStmtWithoutBlock::operator=): Remove assignment operator. (ExprStmtWithBlock::expr): Remove field. (ExprStmtWithBlock::get_expr): Remove method. (ExprStmtWithBlock::ExprStmt): Remove copy/move constructors, modify existing constructor. (ExprStmtWithBlock::operator=): Remove assignment operator. (ExprStmt::as_string): Add method. (ExprStmtWithBlock::as_string): Remove method. (ExprStmtWithoutBlock::as_string): Remove method. * hir/tree/rust-hir.cc (ExprStmt::as_string): Add method. (ExprStmtWithBlock::as_string): Remove method. (ExprStmtWithoutBlock::as_string): Remove method. Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
2024-01-16gccrs: Revert "hir: Add ExportedMacro node and handling."Arthur Cohen5-65/+0
This reverts commit a1f940d193c6cdb13483690a4f4a7d501ad7040e. It is easier and cleaner to store exported macros' NodeIds into our mappings rather than create a new HIR kind of node. gcc/rust/ChangeLog: * backend/rust-compile-item.h: Revert 1c946687239b86a92839d57dfbc928ad7ce35eae. * backend/rust-compile-stmt.h: Likewise. * checks/errors/privacy/rust-privacy-reporter.cc (PrivacyReporter::visit): Likewise. * checks/errors/privacy/rust-privacy-reporter.h: Likewise. * checks/errors/privacy/rust-pub-restricted-visitor.cc (PubRestrictedVisitor::visit): Likewise. * checks/errors/privacy/rust-pub-restricted-visitor.h: Likewise. * checks/errors/privacy/rust-reachability.cc (ReachabilityVisitor::visit): Likewise. * checks/errors/privacy/rust-reachability.h: Likewise. * checks/errors/privacy/rust-visibility-resolver.cc (VisibilityResolver::visit): Likewise. * checks/errors/privacy/rust-visibility-resolver.h: Likewise. * checks/errors/rust-const-checker.cc (ConstChecker::visit): Likewise. * checks/errors/rust-const-checker.h: Likewise. * checks/errors/rust-unsafe-checker.cc (UnsafeChecker::visit): Likewise. * checks/errors/rust-unsafe-checker.h: Likewise. * hir/rust-ast-lower-item.cc (ASTLoweringItem::visit): Likewise. * hir/rust-ast-lower-item.h: Likewise. * hir/rust-hir-dump.cc (Dump::visit): Likewise. * hir/rust-hir-dump.h: Likewise. * hir/tree/rust-hir-full-decls.h (class ExportedMacro): Likewise. * hir/tree/rust-hir-item.h (class ExportedMacro): Likewise. * hir/tree/rust-hir-visitor.h: Likewise. * hir/tree/rust-hir.cc (ExportedMacro::accept_vis): Likewise. (ExportedMacro::get_locus): Likewise. (ExportedMacro::get_item_kind): Likewise. (ExportedMacro::clone_item_impl): Likewise. * hir/tree/rust-hir.h: Likewise. * metadata/rust-export-metadata.cc: Likewise. * typecheck/rust-hir-type-check-item.h: Likewise. * typecheck/rust-hir-type-check-stmt.cc (TypeCheckStmt::visit): Likewise. * typecheck/rust-hir-type-check-stmt.h: Likewise. * typecheck/rust-tycheck-dump.h: Likewise. * util/rust-attributes.cc: Likewise.
2024-01-16gccrs: support use declaration to write the type into the correct namespacePhilip Herron1-0/+2
This builds upon the previous path resolution fixes so that it returns the resolved_node_id or UNKNOWN_NODEID on failure to resolve the use-path. It then exports the name to the current module namespace so it can be used. Fixes #850 #855 gcc/rust/ChangeLog: * ast/rust-ast.h: add const get_final_segment helper * hir/rust-ast-lower-enumitem.h: dont add an item mapping for enumitems * hir/rust-ast-lower-item.cc (ASTLoweringItem::visit): add enum to enum-items mappings * hir/rust-ast-lower-stmt.cc (ASTLoweringStmt::visit): likewise * hir/tree/rust-hir-item.h: add non const helper to get variants * resolve/rust-ast-resolve-item.cc (ResolveItem::visit): resolve the use declaration * resolve/rust-ast-resolve-path.cc (ResolvePath::resolve_path): handle self * resolve/rust-ast-resolve-toplevel.h: add enum item mappings to module mappings * typecheck/rust-hir-type-check-path.cc (TypeCheckExpr::resolve_root_path): ensure variant (TypeCheckExpr::resolve_segments): likewise * typecheck/rust-type-util.cc (query_type): lookup enum's * util/rust-hir-map.cc (Mappings::insert_hir_enumitem): enum item mappings (Mappings::lookup_hir_enumitem): likewise * util/rust-hir-map.h: likewise gcc/testsuite/ChangeLog: * rust/compile/issue-850.rs: New test. * rust/compile/issue-855.rs: New test. Signed-off-by: Philip Herron <herron.philip@googlemail.com>