aboutsummaryrefslogtreecommitdiff
path: root/gcc/rust
AgeCommit message (Collapse)AuthorFilesLines
2024-01-16gccrs: Emit an error on associated const without valuesPierre-Emmanuel Patry2-3/+48
Associated const with no value that are not in trait impl are prohibited. gcc/rust/ChangeLog: * checks/errors/rust-ast-validation.cc (ASTValidation::check): Launch check over the whole given crate. (ASTValidation::visit): Implement visitor for some members of the ast. * checks/errors/rust-ast-validation.h: Update some prototype according to implemented visitor functions. Also add a context tracker. Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
2024-01-16gccrs: Add call to ast validation checkerPierre-Emmanuel Patry1-0/+9
Add call to ast validation check, also add appropriate step to this pass and the feature gating. gcc/rust/ChangeLog: * rust-session-manager.cc (Session::compile_crate): Add call to ast validation. Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
2024-01-16gccrs: Add two new steps to compile processPierre-Emmanuel Patry2-10/+18
Add the ast validation and feature gating steps to the compile pipeline. gcc/rust/ChangeLog: * lang.opt: Add the new compile options and update the enum values. * rust-session-manager.h (struct CompileOptions): Add the new steps to the enumeration. Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
2024-01-16gccrs: Add ast validation checkerPierre-Emmanuel Patry3-0/+245
Add a new visitor to validate a given ast after the expansion pass. gcc/rust/ChangeLog: * Make-lang.in: Add the new object file the list. * checks/errors/rust-ast-validation.cc: New file. * checks/errors/rust-ast-validation.h: New file. Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
2024-01-16gccrs: Add more checks for expr value in early visitorsPierre-Emmanuel Patry3-8/+13
Early passes visitors may encounter constant item without a value, this is expected as the pass rejecting a constant without an expression is done later during the ast validation. gcc/rust/ChangeLog: * expand/rust-cfg-strip.cc (CfgStrip::visit): Add expr value check. * expand/rust-expand-visitor.cc (ExpandVisitor::visit): Likewise. * resolve/rust-early-name-resolver.cc (EarlyNameResolver::visit): Likewise. Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
2024-01-16gccrs: Move SingleASTNode implementation out of headerPierre-Emmanuel Patry2-164/+179
Those functions implementation put additional constraints on the headers which makes the codebase harder to work with. gcc/rust/ChangeLog: * ast/rust-ast.h: Move implementation from here... * ast/rust-ast.cc (SingleASTNode::SingleASTNode): ...to here. (SingleASTNode::operator=): ...and here... (SingleASTNode::accept_vis): ...and here... (SingleASTNode::is_error): ...and here... (SingleASTNode::as_string): ...also here. Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
2024-01-16gccrs: Add missing override specifierPierre-Emmanuel Patry2-2/+2
Some function lacked the override specifier, this made the compiler emit several warning. gcc/rust/ChangeLog: * ast/rust-ast.h: Add override specifier. * ast/rust-item.h: Likewise. Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
2024-01-16gccrs: Fix token lexed as a float literalPierre-Emmanuel Patry7-0/+71
The lexer cannot distinguish the difference between a float literal and a tuple index in some cases. This means we should fix this while parsing depending on the context. gcc/rust/ChangeLog: * expand/rust-macro-invoc-lexer.cc (MacroInvocLexer::split_current_token): Add implementation for multiple token split. * expand/rust-macro-invoc-lexer.h: Add function prototype. * expand/rust-proc-macro-invoc-lexer.cc (ProcMacroInvocLexer::split_current_token): Add implementation for 2+ token split for procedural macros. * expand/rust-proc-macro-invoc-lexer.h: Add function prototype. * lex/rust-lex.cc (Lexer::split_current_token): Add function to split a token in multiple other tokens. * lex/rust-lex.h: Add function prototype for split_current_token. * parse/rust-parse-impl.h (Parser::left_denotation): Handle float tuple index identified as a float literal. Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
2024-01-16gccrs: HIR: remove obsole double borrow memberJakub Dupak3-9/+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: fix typoJakub Dupak1-3/+3
gcc/rust/ChangeLog: * hir/rust-ast-lower-expr.cc (ASTLoweringExpr::visit): Fix typo. Signed-off-by: Jakub Dupak <dev@jakubdupak.com>
2024-01-16gccrs: Compile pattern match statements into conditional statementsOwen Avery4-520/+357
gcc/rust/ChangeLog: * backend/rust-compile-expr.cc (patterns_mergeable): Remove. (struct PatternMerge): Remove. (sort_tuple_patterns): Remove. (simplify_tuple_match): Remove. (CompileExpr::visit): Modify compilation of MatchExpr. * backend/rust-compile-pattern.cc (CompilePatternCaseLabelExpr::visit): Replace with... (CompilePatternCheckExpr::visit): ...this. * backend/rust-compile-pattern.h (class CompilePatternCaseLabelExpr): Replace with... (class CompilePatternCheckExpr): ...this. * backend/rust-compile-type.cc (TyTyResolveCompile::get_implicit_enumeral_node_type): Make enumeral type equivalent to isize. Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
2024-01-16gccrs: Document proc macro token tree indicesPierre-Emmanuel Patry1-4/+23
Multiple references to procedural macro token trees were left as magic number in the code. This commit introduces some constexpr for those along some explanation for the selected value. gcc/rust/ChangeLog: * backend/rust-compile-base.cc (get_attributes): Add documentation for indices 3 and 4. (get_trait_name): Add documentation for index 1. Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
2024-01-16gccrs: Move proc macro builders to their own filePierre-Emmanuel Patry3-384/+394
The code to build the required procedural macro symbols is rather long and could be placed in it's own file. gcc/rust/ChangeLog: * Make-lang.in: Add gcc/rust/backend/rust-compile-proc-macro.cc to the list of file to compile. * backend/rust-compile.cc (attribute_array): Move to rust-compile-proc-macro.cc (derive_proc_macro): Likewise. (bang_proc_macro): Likewise. (attribute_proc_macro): Likewise. (proc_macro_payload): Likewise. (proc_macro): Likewise. (proc_macro_buffer): Likewise. (entrypoint): Likewise. (proc_macro_array): Likewise. (CompileCrate::add_proc_macro_symbols): Likewise. * backend/rust-compile-proc-macro.cc: New file. Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
2024-01-16gccrs: Add array length to the proc macro bufferPierre-Emmanuel Patry1-4/+17
The compiler cannot infer the array length from the type, we should therefore hand it the information. The proc macro buffer missed that information. gcc/rust/ChangeLog: * backend/rust-compile.cc (proc_macro_buffer): Update type builder with array length information. (proc_macro_array): Update type initializer with array length information. Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
2024-01-16gccrs: Put common functions in their own namespacePierre-Emmanuel Patry1-60/+102
Half of the functions introduced recently had a similar goal while the other half had a similar goal too. Introducing some namespace to separate those will keep the code cleaner and avoid confusion. gcc/rust/ChangeLog: * backend/rust-compile.cc (build_attribute_array): Renamed from... (attribute_array): ...to attribute array. (build_derive_proc_macro): Likewise from... (derive_proc_macro): ... to derive_proc_macro. (build_bang_proc_macro): Likewise from... (bang_proc_macro): ...to bang_proc_macro. (build_attribute_proc_macro): Likewise from... (attribute_proc_macro): ... to attribute_proc_macro. (build_proc_macro_payload): Likewise from... (proc_macro_payload): to proc_macro_payload. (build_proc_macro): Likewise from... (proc_macro): ...to proc_macro. (build_proc_macro_buffer): Likewise from... (proc_macro_buffer): ... to proc_macro_buffer. (build_entrypoint): Likewise from... (entrypoint): ...to entrypoint. (init_derive_proc_macro): Renamed to it's shorter counterpart. (init_attribute_proc_macro): Likewise. (init_bang_proc_macro): Likewise. (init_proc_macro): Likewise. (initialize_proc_macro_array): Likewise. (proc_macro_array): Likewise. (CompileCrate::add_proc_macro_symbols): Update function calls. Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
2024-01-16gccrs: Add macro buffer global variable exportPierre-Emmanuel Patry2-50/+206
Export a new symbol containing the proc macros. gcc/rust/ChangeLog: * backend/rust-compile-base.h: Make static function address_expression public. * backend/rust-compile.cc (CompileCrate::add_proc_macro_symbols): Add new global variable in export function. (build_bang_proc_macro): Add a function to build the bang proc macro structure type. (build_proc_macro): Add a function to build the proc macro structure type. (build_proc_macro_payload): Add a function to build the proc macro union used in proc macro structures. (init_derive_proc_macro): Add a function to initialize custom derive proc macros. (init_attribute_proc_macro): Add a function to initialize attribute proc macros. (init_bang_proc_macro): Add a function to initialize bang proc macros. (init_proc_macro): Add a function to initialize proc macro structures. (initialize_proc_macro_array): Add a function to initialize the proc macro buffer array. (CompileCrate::add_proc_macro_symbols): Add call to the new functions to correctly initialize proc macros as well as their entrypoint. Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
2024-01-16gccrs: Change proc macro entrypointPierre-Emmanuel Patry3-3/+19
Change proc macro entrypoint from a fixed constant declaration to a proper generation from the stable crate id. Although the stable crate id is not in use yet, the mechanism to handle it is. gcc/rust/ChangeLog: * expand/rust-proc-macro.cc (CustomDeriveProcMacro::CustomDeriveProcMacro): Remove constant string declaration. (load_macros_array): Add call to the new generation function. (generate_proc_macro_decls_symbol): Add a new function to generate the entrypoint symbol name from the stable crate id. (PROC_MACRO_DECLS_FMT_ARGS): New macro to keep formats arguments in sync between each call. * expand/rust-proc-macro.h (generate_proc_macro_decls_symbol): Add function prototype. * rust-system.h: Include <iomanip>. Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
2024-01-16gccrs: Add utility function to build proc macro typesPierre-Emmanuel Patry2-0/+180
Add some utility function to build proc macro entrypoint related types. Those functions will help generate all required metadata in order for proc macros to be expanded properly. gcc/rust/ChangeLog: * backend/rust-compile.cc (build_attribute_array): Add a function to build the attribute array type. (build_derive_proc_macro): Add a function to build the derive proc macro type. (build_bang_proc_macro): Add a function to build the bang proc macro type. (build_attribute_proc_macro): Add a function to build the attribute proc macro type. (build_proc_macro): Add a function to build the proc macro tagged union type. (build_proc_macro_buffer): Add a function to build the proc macro buffer type. (build_entrypoint): Add a function to build the proc macro entrypoint type. * backend/rust-compile.h: Add function prototype. Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
2024-01-16gccrs: Add getters for proc macro mappingsPierre-Emmanuel Patry1-0/+10
Add three different getters, one for each proc macro type. gcc/rust/ChangeLog: * backend/rust-compile-context.h: Add getters. Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
2024-01-16gccrs: Collect procedural macros in the cratePierre-Emmanuel Patry2-17/+63
Collect informations on procedural macros in the compiled crate. For attribute and bang procedural macros we only require the final address as well as the name of the function. Derive procedural macros are a bit different, we collect the fonction's address through it's fndecl tree as well as the trait's name and the multiple attributes. gcc/rust/ChangeLog: * backend/rust-compile-base.cc (HIRCompileBase::setup_fndecl): Make the function non static in order to be able to access the compile context. Also add the whole proc macro infomrmation collection. (get_attributes): Add a function to retrieve the different attributes from a derive procedural macro definition attribute. (get_trait_name): Add a function to retrieve the trait name from a derive procedural macro definition attribute. * backend/rust-compile-base.h: Add function prototypes. Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
2024-01-16gccrs: Reformat commentsPierre-Emmanuel Patry1-6/+6
gcc/rust/ChangeLog: * backend/rust-compile-base.cc (HIRCompileBase::setup_abi_options): Reformat uncorrectly formatted comments. Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
2024-01-16gccrs: Add containers for proc macro collection mappingsPierre-Emmanuel Patry1-0/+23
Add one container for each kind of procedural macro mapping. Also add a new structure to gather informations required for derive procedural macros. Add different functions to fill those new containers. gcc/rust/ChangeLog: * backend/rust-compile-context.h (struct CustomDeriveInfo): Add new derive procedural macro metadata information holder for mappings. Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
2024-01-16gccrs: Add const getter for tokentreesPierre-Emmanuel Patry1-0/+5
We often need to retrieve the underlying tokentree without modifying it, this getter will help achieve this. gcc/rust/ChangeLog: * ast/rust-ast.h: Add const getter. Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
2024-01-16gccrs: Change ABI setup and add gccrs_proc_macro attrPierre-Emmanuel Patry1-3/+18
Change the way the ABI is setup on a function to avoid duplicates. ABI is setup by the setup function only now. Add a new attribute to the function "gccrs_proc_macro" in order to differentiate it from another type of function. gcc/rust/ChangeLog: * backend/rust-compile-base.cc (handle_proc_macro_common): Add new attribute "gccrs_proc_macro" to all procedural macro functions. (get_abi): Add a function to retrieve the correct ABI depending on wether the function is a proc macro or not. Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
2024-01-16gccrs: Make proc macro definition cdeclPierre-Emmanuel Patry2-0/+59
We need to make sure proc macros have the C abi in order to be called by the compiler with dlopen. gcc/rust/ChangeLog: * backend/rust-compile-base.cc (HIRCompileBase::setup_fndecl): Add proc macro handlers dispatch. (handle_proc_macro_common): Add a function for common behavior between all kinds of proc macros. * backend/rust-compile-base.h: Add function prototypes. Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
2024-01-16gccrs: borrowck: Refactor and BIR improvementsJakub Dupak10-415/+508
gcc/rust/ChangeLog: * checks/errors/borrowck/rust-bir-builder-expr-stmt.cc (ExprStmtBuilder::setup_loop): Move. (ExprStmtBuilder::get_label_ctx): Move. (ExprStmtBuilder::get_unnamed_loop_ctx): Moved. (ExprStmtBuilder::visit): BIR improvements. * checks/errors/borrowck/rust-bir-builder-expr-stmt.h: Refactor. * checks/errors/borrowck/rust-bir-builder-internal.h (class LifetimeResolver): Refactor. (struct BuilderContext): Move.Refactor. (optional_from_ptr): Map on null ptr. * checks/errors/borrowck/rust-bir-builder-lazyboolexpr.h (class LazyBooleanExprBuilder): Refactor. * checks/errors/borrowck/rust-bir-builder-pattern.h: Refactor. * checks/errors/borrowck/rust-bir-builder-struct.h (class StructBuilder): Refactor. * checks/errors/borrowck/rust-bir-builder.h: Refactor. * checks/errors/borrowck/rust-bir-dump.cc (Dump::go): Refactor. (Dump::visit): Refactor. (Dump::visit_place): Refactor. (Dump::visit_move_place): Refactor. (Dump::visit_lifetime): Refactor. * checks/errors/borrowck/rust-bir-dump.h: Refactor. * checks/errors/borrowck/rust-bir-place.h: Refactor. Signed-off-by: Jakub Dupak <dev@jakubdupak.com>
2024-01-16gccrs: borrowck: Dev notesJakub Dupak1-0/+40
gcc/rust/ChangeLog: * checks/errors/borrowck/dev-notes.md: New file. Signed-off-by: Jakub Dupak <dev@jakubdupak.com>
2024-01-16gccrs: borrowck: DocsJakub Dupak1-0/+188
gcc/rust/ChangeLog: * checks/errors/borrowck/bir-design-notes.md: New file. Signed-off-by: Jakub Dupak <dev@jakubdupak.com>
2024-01-16gccrs: borrowck: Make goto explicit.Jakub Dupak3-15/+32
gcc/rust/ChangeLog: * checks/errors/borrowck/rust-bir-builder-expr-stmt.cc (ExprStmtBuilder::visit): Use goto. * checks/errors/borrowck/rust-bir-builder-internal.h: Explicit goto. * checks/errors/borrowck/rust-bir-builder-lazyboolexpr.h: Explicit goto. Signed-off-by: Jakub Dupak <dev@jakubdupak.com>
2024-01-16gccrs: borrowck: BIR continueJakub Dupak1-18/+32
gcc/rust/ChangeLog: * checks/errors/borrowck/rust-bir-builder-expr-stmt.cc (ExprStmtBuilder::visit): Continue. (ExprStmtBuilder::setup_loop): Continue. Signed-off-by: Jakub Dupak <dev@jakubdupak.com>
2024-01-16gccrs: borrowck: Dump: handle infinite loopsJakub Dupak1-1/+16
gcc/rust/ChangeLog: * checks/errors/borrowck/rust-bir-dump.cc (simplify_cfg): Detech infinite loops. Signed-off-by: Jakub Dupak <dev@jakubdupak.com>
2024-01-16gccrs: borrowck: BIR: handle breakJakub Dupak3-68/+168
gcc/rust/ChangeLog: * checks/errors/borrowck/rust-bir-builder-expr-stmt.cc (ExprStmtBuilder::visit): Push ctx. (ExprStmtBuilder::setup_loop): Common loop infractructure setup. * checks/errors/borrowck/rust-bir-builder-expr-stmt.h: Loop ctx. * checks/errors/borrowck/rust-bir-builder-internal.h (struct BuilderContext): Loop ctx. Signed-off-by: Jakub Dupak <dev@jakubdupak.com>
2024-01-16gccrs: borrowck: Dump improve jumpsJakub Dupak2-25/+56
gcc/rust/ChangeLog: * checks/errors/borrowck/rust-bir-dump.cc (Dump::go): Improve jumps dump. (Dump::visit): Improve jumps dump. * checks/errors/borrowck/rust-bir-dump.h (class Dump): Improve jumps dump. Signed-off-by: Jakub Dupak <dev@jakubdupak.com>
2024-01-16gccrs: borrowck: Dump: simplify cfgJakub Dupak2-6/+41
Add option to simplify cfg for better readability. Off by default. gcc/rust/ChangeLog: * checks/errors/borrowck/rust-bir-dump.cc (simplify_cfg): Simplify cfg logic. (Dump::go): Run simplify cfg. * checks/errors/borrowck/rust-bir-dump.h: Option to simplify cfg. Signed-off-by: Jakub Dupak <dev@jakubdupak.com>
2024-01-16gccrs: borrowck: Dump: proper comma separationJakub Dupak1-10/+24
gcc/rust/ChangeLog: * checks/errors/borrowck/rust-bir-dump.cc (Dump::go): Use new print. (print_comma_separated): Comma separation print. (Dump::visit): Use new print. Signed-off-by: Jakub Dupak <dev@jakubdupak.com>
2024-01-16gccrs: borrowck: BIR dumpJakub Dupak4-1/+357
gcc/rust/ChangeLog: * Make-lang.in: Build BIR dump. * checks/errors/borrowck/rust-borrow-checker.cc (mkdir_wrapped): Cross-platform mkdir. (dump_function_bir): Save dump to file. (BorrowChecker::go): Run dump during borrowck. * checks/errors/borrowck/rust-bir-dump.cc: New file. * checks/errors/borrowck/rust-bir-dump.h: New file. Signed-off-by: Jakub Dupak <dev@jakubdupak.com>
2024-01-16gccrs: borrowck: Create BIR builders (visitors)Jakub Dupak10-631/+2815
gcc/rust/ChangeLog: * Make-lang.in: Compile BIR expr visitor. * checks/errors/borrowck/rust-borrow-checker.cc (BorrowChecker::go): Use BIR builder. * rust-session-manager.cc (Session::compile_crate): Run borrow checker. * checks/errors/borrowck/rust-bir-builder-expr-stmt.cc: New file. * checks/errors/borrowck/rust-bir-builder-expr-stmt.h: New file. * checks/errors/borrowck/rust-bir-builder-internal.h: New file. * checks/errors/borrowck/rust-bir-builder-lazyboolexpr.h: New file. * checks/errors/borrowck/rust-bir-builder-pattern.h: New file. * checks/errors/borrowck/rust-bir-builder-struct.h: New file. * checks/errors/borrowck/rust-bir-builder.h: New file. Signed-off-by: Jakub Dupak <dev@jakubdupak.com>
2024-01-16gccrs: borrowck: Create Borrow-checker IR (BIR)Jakub Dupak4-0/+521
gcc/rust/ChangeLog: * checks/errors/borrowck/rust-borrow-checker.cc: Include to compile new code. * checks/errors/borrowck/rust-bir-place.h: New file. * checks/errors/borrowck/rust-bir-visitor.h: New file. * checks/errors/borrowck/rust-bir.h: New file. Signed-off-by: Jakub Dupak <dev@jakubdupak.com>
2024-01-16gccrs: borrowck: Execute only with CLI flagJakub Dupak2-3/+9
gcc/rust/ChangeLog: * lang.opt: CLI flag. * rust-session-manager.cc (Session::compile_crate): Guard execution. Signed-off-by: Jakub Dupak <dev@jakubdupak.com>
2024-01-16gccrs: borrowck: Add CLI option for borrowckJakub Dupak5-768/+642
gcc/rust/ChangeLog: * checks/errors/borrowck/rust-borrow-checker.cc (BorrowChecker::BorrowChecker): Opt dump. (BorrowChecker::go): Opt dump. * checks/errors/borrowck/rust-borrow-checker.h (class BorrowChecker): Opt dump. * lang.opt: Add compile until borrowcheck. * rust-session-manager.cc (Session::enable_dump): Add BIR. (Session::compile_crate): Handle new options. * rust-session-manager.h (struct CompileOptions): Add BIR. Signed-off-by: Jakub Dupak <dev@jakubdupak.com>
2024-01-16gccrs: borrowck: Add initial structure for borrowcheckingJakub Dupak4-0/+288
gcc/rust/ChangeLog: * Make-lang.in: Build borrowck. * checks/errors/borrowck/rust-borrow-checker.cc: New file. * checks/errors/borrowck/rust-borrow-checker.h: New file. * checks/errors/borrowck/rust-function-collector.h: New file. Signed-off-by: Jakub Dupak <dev@jakubdupak.com>
2024-01-16gccrs: Fix warning with overridden virtual methodsPierre-Emmanuel Patry1-11/+11
Overridden virtual methods were not marked as such. gcc/rust/ChangeLog: * ast/rust-pattern.h: Add override modifier to overriding methods. Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
2024-01-16gccrs: Parse const with no value expressionPierre-Emmanuel Patry2-0/+17
Const with no value expression may exist either in trait or in disabled blocks. This means we should be able to parse those correctly. gcc/rust/ChangeLog: * ast/rust-item.h: Add a new constructor for const with no value expression. * parse/rust-parse-impl.h (Parser::parse_const_item): Allow const with no expression value. Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.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 Dupak8-19/+19
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 Dupak13-69/+66
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: ast: Handle tuplestruct pattern with indicesJakub Dupak2-7/+21
gcc/rust/ChangeLog: * hir/rust-ast-lower-pattern.cc (ASTLoweringPattern::visit): Implement for tuple pat. * resolve/rust-ast-resolve-pattern.cc (PatternDeclaration::visit): Implement for tupple pat. gcc/testsuite/ChangeLog: * rust/compile/tupple_struct_pattern_tuple.rs: New test. 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: Make resolution of AssociatedItem instances polymorphicOwen Avery3-40/+8
gcc/rust/ChangeLog: * resolve/rust-ast-resolve-implitem.h (ResolveToplevelImplItem::go): Take AssociatedItem as parameter. (ResolveTopLevelTraitItems::go): Likewise. * resolve/rust-ast-resolve-item.cc (ResolveTraitItems::go): Likewise. (ResolveItem::resolve_impl_item): Likewise. (ResolveImplItems::go): Likewise. * resolve/rust-ast-resolve-item.h (ResolveTraitItems::go): Likewise. (ResolveItem::resolve_impl_item): Likewise. (ResolveImplItems::go): Likewise. Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>