aboutsummaryrefslogtreecommitdiff
path: root/gcc/rust
AgeCommit message (Collapse)AuthorFilesLines
2024-01-16gccrs: Make lowering of AssociatedItem instances polymorphicOwen Avery1-26/+2
gcc/rust/ChangeLog: * hir/rust-ast-lower-implitem.h (ASTLoweringImplItem::translate): Take AssociatedItem as parameter. (ASTLoweringTraitItem::translate): Likewise. Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
2024-01-16gccrs: compile: bail on labelled blockJakub Dupak1-0/+6
gcc/rust/ChangeLog: * backend/rust-compile-expr.cc (CompileExpr::visit): Bail on labelled block. Signed-off-by: Jakub Dupak <dev@jakubdupak.com>
2024-01-16gccrs: typecheck: add loop ctx for labelled blockJakub Dupak1-0/+18
gcc/rust/ChangeLog: * typecheck/rust-hir-type-check-expr.cc (TypeCheckExpr::visit): Add loop ctx. Signed-off-by: Jakub Dupak <dev@jakubdupak.com>
2024-01-16gccrs: resolve: Resolve labelled blockJakub Dupak1-0/+22
gcc/rust/ChangeLog: * resolve/rust-ast-resolve-expr.cc (ResolveExpr::visit): Resolve using loop logic. Signed-off-by: Jakub Dupak <dev@jakubdupak.com>
2024-01-16gccrs: hir: Lower labelled blockJakub Dupak2-35/+41
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: ast: Parse labelled blockJakub Dupak5-45/+58
gcc/rust/ChangeLog: * ast/rust-ast-builder.cc (AstBuilder::block): Add label arg to constructor call. * ast/rust-expr.h (class LoopLabel): Move before BlockExpr. (class BlockExpr): Add LoopLabel member. * expand/rust-derive-clone.cc (DeriveClone::clone_fn): Add label arg to constructor call. * parse/rust-parse-impl.h (Parser::parse_block_expr): Add label parameter. (Parser::parse_labelled_loop_expr): Add label arg to constructor call. * parse/rust-parse.h: Add label arg to constructor call. Signed-off-by: Jakub Dupak <dev@jakubdupak.com>
2024-01-16gccrs: Create base class AssociatedItemOwen Avery3-72/+40
gcc/rust/ChangeLog: * ast/rust-ast.h (class AssociatedItem): New, based on TraitItem, InherentImplItem, and TraitImplItem classes. (class TraitItem): Inherit from AssociatedItem. (class InherentImplItem): Likewise. (class TraitImplItem): Likewise. * ast/rust-item.h (class Method): Update cloning functions. (class Function): Likewise. (class TypeAlias): Likewise. (class ConstantItem): Likewise. (class TraitItemFunc): Likewise. (class TraitItemMethod): Likewise. (class TraitItemConst): Likewise. (class TraitItemType): Likewise. * ast/rust-macro.h (class MacroInvocation): Likewise. Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
2024-01-16gccrs: Add tests for v0 manglingRaiki Tamura1-22/+19
gcc/rust/ChangeLog: * backend/rust-mangle.cc (v0_identifier): Fix broken encoding. (v0_scope_path): Modify paramter. (v0_path): Fix namespace for modules. gcc/testsuite/ChangeLog: * rust/compile/v0-mangle1.rs: New test. Signed-off-by: Raiki Tamura <tamaron1203@gmail.com>
2024-01-16gccrs: Break OR tokens in closure parameter list contextPierre-Emmanuel Patry1-0/+5
The parser was unable to process as closure inside a closure because the lexer could not differentiate an OR from two PIPE tokens. gcc/rust/ChangeLog: * parse/rust-parse-impl.h (Parser::parse_closure_expr_pratt): Fix closure parsing function to handle consecutive parameter lists. Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
2024-01-16gccrs: Add path to macro fragment follow restrictionsPierre-Emmanuel Patry1-0/+1
The previous follow set rules did not allow PATH fragment, changing this allow gccrs to accept more valid rust macros. gcc/rust/ChangeLog: * ast/rust-macro.h: Add PATH fragment to follow set restrictions. Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
2024-01-16gccrs: Allow macro named macro_rulesPierre-Emmanuel Patry2-3/+15
Change the constraints around macro rules declaration in order to allow macro_rules named macro as well as tighter constraint around macro rules definitions. gcc/rust/ChangeLog: * parse/rust-parse-impl.h (Parser::is_macro_rules_def): Add a function that checks tokens given by the lexer represents an accurate macro definition. This will reduce code duplication. (Parser::parse_item): Replace condition with call to new checking function. (Parser::parse_stmt): Likewise. * parse/rust-parse.h: Add function prototype for is_macro_rules_def. Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
2024-01-16gccrs: Fix RangeFromExpr parsing in for loopsPierre-Emmanuel Patry1-1/+2
Those ranges were looking for a curly brace after the brace, leading to an error when using range from expr in for loops. gcc/rust/ChangeLog: * parse/rust-parse-impl.h (Parser::parse_expr): Fix range from expr. Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
2024-01-16gccrs: Allow call to macro named "default" at item levelPierre-Emmanuel Patry1-1/+2
The parser was too agressive and did reject any line beginning with default even if this was a macro call. gcc/rust/ChangeLog: * parse/rust-parse-impl.h (Parser::parse_item): Relax constraints around default identifier at item scope to accept "default" macros. Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
2024-01-16gccrs: Fix path expr segment parsing with generic pathPierre-Emmanuel Patry1-1/+3
When a token was identified as bit left shift it slipped through the parser and resulted in an error. gcc/rust/ChangeLog: * parse/rust-parse-impl.h (Parser::parse_path_expr_segment): Accept left shift tokens in order to let generic parsing function split the token. Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
2024-01-16gccrs: Replace get_pattern_node_id with get_node_idOwen Avery5-30/+4
gcc/rust/ChangeLog: * ast/rust-ast.h (Pattern::get_pattern_node_id): Rename to... (Pattern::get_node_id): ...here. * ast/rust-macro.h (MacroInvocation::get_pattern_node_id): Rename to... (MacroInvocation::get_node_id): ...here. * ast/rust-path.h (PathInExpression::get_pattern_node_id): Remove. (QualifiedPathInExpression::get_pattern_node_id): Remove. * ast/rust-pattern.h (LiteralPattern::get_pattern_node_id): Remove. (IdentifierPattern::get_pattern_node_id): Remove. (WildcardPattern::get_pattern_node_id): Remove. (RestPattern::get_pattern_node_id): Rename to... (RestPattern::get_node_id): ...here. (RangePattern::get_pattern_node_id): Remove. (ReferencePattern::get_pattern_node_id): Remove. (StructPattern::get_pattern_node_id): Remove. (TupleStructPattern::get_pattern_node_id): Remove. (TuplePattern::get_pattern_node_id): Remove. (GroupedPattern::get_pattern_node_id): Remove. (SlicePattern::get_pattern_node_id): Remove. (AltPattern::get_pattern_node_id): Remove. * resolve/rust-early-name-resolver.cc (EarlyNameResolver::visit): Use get_node_id instead of get_pattern_node_id. Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
2024-01-16gccrs: Add comma for expr delimiter to fix match armsPierre-Emmanuel Patry1-1/+1
Add a comma as an expr delimiter, this will allow correct parsing of match arm expressions. gcc/rust/ChangeLog: * parse/rust-parse-impl.h (Parser::parse_expr): Add comma delimiter. Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
2024-01-16gccrs: Fix pub unit type parsingPierre-Emmanuel Patry1-2/+5
Public unit types where not parsed correctly due to visibility specifiers within parenthesis. Fixes #2648. gcc/rust/ChangeLog: * parse/rust-parse-impl.h (Parser::parse_visibility): Relax constraints over public visibility return condition in order to accept pub unit types. Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
2024-01-16gccrs: TyTy: use new subclass APIJakub Dupak1-316/+226
gcc/rust/ChangeLog: * typecheck/rust-tyty.cc (BaseType::is_unit): Refactor. (BaseType::satisfies_bound): Refactor. (BaseType::get_root): Refactor. (BaseType::destructure): Refactor. (BaseType::monomorphized_clone): Refactor. (BaseType::is_concrete): Refactor. (InferType::InferType): Refactor. (InferType::clone): Refactor. (InferType::apply_primitive_type_hint): Refactor. (StructFieldType::is_equal): Refactor. (ADTType::is_equal): Refactor. (handle_substitions): Refactor. (ADTType::handle_substitions): Refactor. (TupleType::TupleType): Refactor. (TupleType::is_equal): Refactor. (TupleType::handle_substitions): Refactor. Signed-off-by: Jakub Dupak <dev@jakubdupak.com>
2024-01-16gccrs: TyTy: TyTy improved subclass casting and checkingJakub Dupak2-38/+154
Associate each subclass with its kind and create cast/match+cast methods. gcc/rust/ChangeLog: * typecheck/rust-tyty.cc (InferType::InferType): Use static constant for kind information. (ErrorType::ErrorType): Use static constant for kind information. (TupleType::TupleType): Use static constant for kind information. (BoolType::BoolType): Use static constant for kind information. (IntType::IntType): Use static constant for kind information. (UintType::UintType): Use static constant for kind information. (FloatType::FloatType): Use static constant for kind information. (USizeType::USizeType): Use static constant for kind information. (ISizeType::ISizeType): Use static constant for kind information. (CharType::CharType): Use static constant for kind information. (ReferenceType::ReferenceType): Use static constant for kind information. (PointerType::PointerType): Use static constant for kind information. (ParamType::ParamType): Use static constant for kind information. (StrType::StrType): Use static constant for kind information. (NeverType::NeverType): Use static constant for kind information. (PlaceholderType::PlaceholderType): Use static constant for kind information. * typecheck/rust-tyty.h: Add static kind information to all TyTy classes. Create safe cast and check methods. Signed-off-by: Jakub Dupak <dev@jakubdupak.com>
2024-01-16gccrs: Fix type param bound parsing with opening scopePierre-Emmanuel Patry1-0/+1
The function parsing type param bounds had a problem with scope resolution opening token. gcc/rust/ChangeLog: * parse/rust-parse-impl.h (Parser::parse_type_param_bound): Add missing case for lifetime switch. Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
2024-01-16gccrs: Change debug log call to as_string functionPierre-Emmanuel Patry2-1/+3
This will ensure an accurate representation of the token. Also update the as_string function to represent accurately scope resolution tokens. gcc/rust/ChangeLog: * lex/rust-token.cc (Token::as_string): Update function to output scope resolution tokens correctly. * parse/rust-parse-impl.h (Parser::parse_generic_param): Change call to as_string. Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
2024-01-16gccrs: Initial implementation of v0 manglingRaiki Tamura4-51/+344
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 Avery4-6/+6
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: minor changes (typo and minor refactor)Marc Poulhiès2-10/+4
Fix a typo and merge 2 if clauses using the same condition. gcc/rust/ChangeLog: * backend/rust-compile-expr.cc (CompileExpr::visit): Merge 2 if clauses. * backend/rust-compile-extern.h: Fix typo in comment. Signed-off-by: Marc Poulhiès <dkm@kataplop.net>
2024-01-16gccrs: Fix parser bug on tupplestruct patternJakub Dupak1-0/+2
gcc/rust/ChangeLog: * parse/rust-parse-impl.h: Add missing token consumption Signed-off-by: Jakub Dupak <dev@jakubdupak.com>
2024-01-16gccrs: Removed unnecessary commentsMohammed Rizan Farooqui1-4/+0
gcc/rust/ChangeLog: * expand/rust-macro-builtins.cc (MacroBuiltin::include_str_handler): Comment removed (MacroBuiltin::env_handler): Comment removed (MacroBuiltin::cfg_handler): Comment removed (MacroBuiltin::line_handler): Comment removed Signed-off-by: Mohammed Rizan Farooqui <rizanfarooqui@gmail.com>
2024-01-16gccrs: Fix type confusion in coercionJakub Dupak1-2/+2
There was a mismatch between a manual discriminant test and the static cast. gcc/rust/ChangeLog: * backend/rust-compile.cc (HIRCompileBase::coercion_site1): Fix wrong cast Signed-off-by: Jakub Dupak <dev@jakubdupak.com>
2024-01-16gccrs: Fix ICE when emitting an error during cfg stripPierre-Emmanuel Patry1-0/+3
When an error was emitted during the cfg strip pass by the crate loader, it was ignored and the error state propagated until another pass (name resolver). gcc/rust/ChangeLog: * rust-session-manager.cc (Session::expansion): Add early break on error. Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
2024-01-16gccrs: Fix CanonicalPath for inherent implRaiki Tamura3-4/+17
gcc/rust/ChangeLog: * util/rust-canonical-path.h: Add new segment kind for inherent impl. * resolve/rust-ast-resolve-item.cc (ResolveItem::visit): Use it. * resolve/rust-ast-resolve-toplevel.h: Use it. Signed-off-by: Raiki Tamura <tamaron1203@gmail.com>
2024-01-16gccrs: Fix spellingOwen Avery4-6/+6
gcc/rust/ChangeLog: * ast/rust-expr.h: Fix spelling of "doesn't". * backend/rust-compile-expr.cc: Fix spelling of "accessors". * backend/rust-compile-implitem.h: Fix spelling of "normal". * backend/rust-constexpr.cc: Fix spelling of "actual". Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
2024-01-16gccrs: Add debug helper to dump HIRMarc Poulhiès2-0/+25
Add simple debug wrapper to dump HIR nodes on stderr. Similar to what we already have for AST. gcc/rust/ChangeLog: * hir/rust-hir-dump.cc (Dump::debug): New. (debug): New. * hir/rust-hir-dump.h (debug): New. Signed-off-by: Marc Poulhiès <dkm@kataplop.net>
2024-01-16gccrs: port over readonly_error from c-family for lvalue assignment checksPhilip Herron6-105/+215
Fixes #2391 gcc/rust/ChangeLog: * Make-lang.in: fixup formatting * resolve/rust-ast-resolve-expr.cc (ResolveExpr::visit): remove old check * rust-session-manager.cc (Session::compile_crate): call new lint * resolve/rust-ast-verify-assignee.h: Removed. * checks/errors/rust-readonly-check.cc: New file. * checks/errors/rust-readonly-check.h: New file. gcc/testsuite/ChangeLog: * rust/compile/wrong_lhs_assignment.rs: update error message * rust/compile/issue-2391.rs: New test. Signed-off-by: Philip Herron <herron.philip@googlemail.com>
2024-01-16gccrs: [E0617] attempt for invalid type variable in variadic functionMuhammad Mahad1-10/+25
There are some certain rust types must be cast before passing them to a variadic function, because of arcane ABI rules dictated by the C standard. To fix the error, cast the value to the type specified by the error message. gcc/rust/ChangeLog: * typecheck/rust-tyty-call.cc (TypeCheckCallExpr::visit): Added ErrorCode & more fixit hints. gcc/testsuite/ChangeLog: * rust/compile/variadic.rs: Added new checks. Signed-off-by: Muhammad Mahad <mahadtxt@gmail.com>
2024-01-16gccrs: Remove HIR::ForLoopExprPhilip Herron17-176/+20
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: Minor typo fixMarc Poulhiès6-16/+17
Fix varadic -> variadic gcc/rust/ChangeLog: * backend/rust-compile-expr.cc (CompileExpr::visit): Fix typo in varIadic. * backend/rust-compile-type.cc (TyTyResolveCompile::visit): Likewise. * rust-backend.h (function_type_varadic): Rename into ... (function_type_variadic): ... this. * rust-gcc.cc (function_type_varadic): Rename into ... (function_type_variadic): ... this. * typecheck/rust-tyty-call.cc (TypeCheckCallExpr::visit): Likewise. * typecheck/rust-tyty.h (is_varadic): Renamed into ... (is_variadic): ... this. Signed-off-by: Marc Poulhiès <dkm@kataplop.net>
2024-01-16gccrs: trivial typo fix.Marc Poulhiès12-24/+24
Fix subsititions -> substitutions gcc/rust/ChangeLog: * backend/rust-compile-base.cc (HIRCompileBase::compile_function): Fix typo in substitutions. (HIRCompileBase::resolve_method_address): Likewise. * backend/rust-compile-extern.h (CompileExternItem::visit): Likewise. * backend/rust-compile-implitem.cc (CompileTraitItem::visit): Likewise. * backend/rust-compile-intrinsic.cc (maybe_override_ctx): Likewise. * backend/rust-compile-item.cc (CompileItem::visit): Likewise. * backend/rust-compile-resolve-path.cc (HIRCompileBase::query_compile): Likewise. * typecheck/rust-coercion.cc (TypeCoercionRules::do_coercion): Likewise. * typecheck/rust-hir-type-check-item.cc (TypeCheckItem::ResolveImplBlockSelfWithInference): Likewise. * typecheck/rust-hir-type-check-path.cc (TypeCheckExpr::visit): Likewise. * typecheck/rust-hir-type-check-type.cc (TypeCheckType::visit): Likewise. * typecheck/rust-tyty.cc (BaseType::has_subsititions_defined): Renamed into ... (BaseType::has_substitutions_defined): ... this. (ADTType::is_equal): Fix typo in substitutions. (handle_substitions): Likewise. (FnType::is_equal): Likewise. (FnType::handle_substitions): Likewise. * typecheck/rust-tyty.h (has_subsititions_defined): Renamed into ... (has_substitutions_defined): ... this. Signed-off-by: Marc Poulhiès <dkm@kataplop.net>
2024-01-16gccrs: Add intrinsics::assumeOwen Avery1-0/+53
gcc/rust/ChangeLog: * backend/rust-compile-intrinsic.cc (get_identifier): Add declaration. (assume_handler): New. (generic_intrinsics): Add assume_handler entry. gcc/testsuite/ChangeLog: * rust/compile/assume.rs: New test. Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
2024-01-16gccrs: Memoize Backend::wchar_typeOwen Avery1-2/+8
gcc/rust/ChangeLog: * rust-gcc.cc (Backend::wchar_type): Store static wchar tree. Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
2024-01-16gccrs: Remove unused complex number supportOwen Avery2-110/+0
gcc/rust/ChangeLog: * rust-backend.h (complex_type): Remove. (complex_constant_expression): Remove. (real_part_expression): Remove. (imag_part_expression): Remove. (complex_expression): Remove. * rust-gcc.cc (complex_type): Remove. (complex_constant_expression): Remove. (real_part_expression): Remove. (imag_part_expression): Remove. (complex_expression): Remove. Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
2024-01-16gccrs: Use namespace definition to simplify function declarationsOwen Avery1-126/+119
gcc/rust/ChangeLog: * rust-gcc.cc (namespace Backend): Use namespace definition instead of qualified names. Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
2024-01-16gccrs: rust-compile-intrinsic: add `copy` intrinsics ...liushuyu1-6/+19
... also made `copy_nonoverlapping` handler more generic gcc/rust/ChangeLog: * backend/rust-compile-intrinsic.cc: add `copy` intrinsics and make `copy_nonoverlapping` handler more generic Signed-off-by: Zixing Liu <liushuyu011@gmail.com>
2024-01-16gccrs: rust-builtins: add likely and unlikey intrinsicsliushuyu2-0/+63
gcc/rust/ChangeLog: * backend/rust-builtins.cc: add `expect` builtin definition. * backend/rust-compile-intrinsic.cc: add `likely` and `unlikely` intrinsics handler. Signed-off-by: Zixing Liu <liushuyu011@gmail.com>
2024-01-16gccrs: Rename "rust_error_codes.def" to "rust-error-codes.def"Owen Avery2-2/+2
gcc/rust/ChangeLog: * rust_error_codes.def: Moved to... * rust-error-codes.def: ...here... * rust-diagnostics.h: ...and update references. Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
2024-01-16gccrs: Shorten `make_unsigned_long_tree` code and remove ↵Guillaume Gomez3-21/+1
`Backend::integer_constant_expression` gcc/rust/ChangeLog: * backend/rust-compile-intrinsic.cc: Simplify `make_unsigned_long_tree` * rust-backend.h: Remove `integer_constant_expression` * rust-gcc.cc: Remove `integer_constant_expression`
2024-01-16gccrs: Fix typechecking (and compilation) error for alt patterns in match ↵Dave Evans3-16/+35
expressions. gcc/rust/ChangeLog: * backend/rust-compile-pattern.cc (CompilePatternCaseLabelExpr::visit): Add AltPattern visitor function * backend/rust-compile-pattern.h: Update CompilePatternCaseLabelExpr::visit(AltPattern&). * typecheck/rust-hir-type-check-pattern.cc (TypeCheckPattern::visit): Update AltPattern visitor gcc/testsuite/ChangeLog: * rust/compile/issue-2431.rs: New test. Signed-off-by: Dave Evans <dave@dmetwo.org>
2024-01-16gccrs: Remove unused `ctx` argument in `make_unsigned_long_tree` functionGuillaume Gomez1-4/+4
gcc/rust/ChangeLog: * backend/rust-compile-intrinsic.cc: Remove unused argument
2024-01-16gccrs: [E0599] Failed to resovle method implementationMuhammad Mahad1-2/+4
gcc/rust/ChangeLog: * typecheck/rust-hir-type-check-expr.cc (TypeCheckExpr::visit): Added new error message, rich location and error code. gcc/testsuite/ChangeLog: * rust/compile/cfg2.rs: Updated according to new message. * rust/compile/issue-2139.rs: likewise. * rust/compile/issue-2190-1.rs: likewise. * rust/compile/method1.rs: likewise. Signed-off-by: Muhammad Mahad <mahadtxt@gmail.com>
2024-01-16gccrs: Convert class Backend into namespaceOwen Avery18-985/+946
gcc/rust/ChangeLog: * rust-backend.h (class Backend): Convert to ... (namespace Backend): ... namespace. * rust-gcc.cc (Backend::Backend): Rename to ... (Backend::init): ... here. (rust_get_backend): Remove. * rust-session-manager.cc (rust_get_backend): Remove. (Session::init): Use Backend::init instead of rust_get_backend. (Session::compile_crate): Initialize Context without pointer to Backend. * rust-session-manager.h (Session::backend): Remove. * backend/rust-compile-context.cc (Context::Context): Remove pointer to Backend. * backend/rust-compile-context.h (class Context): Remove pointer to Backend, update function calls. * backend/rust-compile-base.cc: Update function calls. * backend/rust-compile-block.cc: Likewise. * backend/rust-compile-expr.cc: Likewise. * backend/rust-compile-extern.h: Likewise. * backend/rust-compile-fnparam.cc: Likewise. * backend/rust-compile-intrinsic.cc: Likewise. * backend/rust-compile-item.cc: Likewise. * backend/rust-compile-pattern.cc: Likewise. * backend/rust-compile-resolve-path.cc: Likewise. * backend/rust-compile-type.cc: Likewise. * backend/rust-compile-var-decl.h: Likewise. * backend/rust-compile.cc: Likewise. Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
2024-01-16gccrs: Unify raw attribute valuesPierre-Emmanuel Patry17-62/+131
Attribute values were used as raw string, this is error prone and makes renaming harder. Using a constexpr instead will leverage the power of the compiler and emit an error when an incorrect builtin attribute value is used. gcc/rust/ChangeLog: * ast/rust-ast.cc (Attribute::check_cfg_predicate): Change raw string to constexpr call. (Attribute::separate_cfg_attrs): Likewise. * backend/rust-compile-base.cc (should_mangle_item): Likewise. (HIRCompileBase::setup_fndecl): Likewise. (HIRCompileBase::handle_cold_attribute_on_fndecl): Likewise. * checks/errors/privacy/rust-privacy-reporter.cc (find_proc_macro_attribute): Likewise. * checks/errors/rust-unsafe-checker.cc (check_target_attr): Likewise. * expand/rust-cfg-strip.cc (fails_cfg): Likewise. (fails_cfg_with_expand): Likewise. (expand_cfg_attrs): Likewise. * expand/rust-macro-builtins.cc: Likewise. * hir/rust-ast-lower-base.cc (ASTLoweringBase::handle_outer_attributes): Likewise. (ASTLoweringBase::lower_macro_definition): Likewise. * hir/rust-hir-dump.cc (Dump::visit): Likewise. * parse/rust-parse-impl.h (Parser::parse_doc_comment): Likewise. * parse/rust-parse.cc (extract_module_path): Likewise. * resolve/rust-early-name-resolver.cc (is_macro_use_module): Likewise. (EarlyNameResolver::visit): Likewise. * resolve/rust-toplevel-name-resolver-2.0.cc (is_macro_export): Likwise. * rust-session-manager.cc (Session::injection): Likewise. * typecheck/rust-hir-type-check-base.cc (TypeCheckBase::parse_repr_options): Likewise. * util/rust-attributes.cc (is_proc_macro_type): Likewise. (AttributeChecker::check_attribute): Likewise. (AttributeChecker::visit): Likewise. * util/rust-hir-map.cc (Mappings::insert_macro_def): Likewise. * util/rust-attribute-values.h: New file. Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>