aboutsummaryrefslogtreecommitdiff
path: root/gcc
AgeCommit message (Collapse)AuthorFilesLines
2025-01-20derive(Copy): Use copy lang item when deriving Copy.Arthur Cohen1-6/+2
gcc/rust/ChangeLog: * expand/rust-derive-copy.cc: Use lang item path.
2025-01-20derive(Clone): Mark PhantomData as a lang itemArthur Cohen1-4/+1
gcc/testsuite/ChangeLog: * rust/compile/derive_macro4.rs: Make PhantomData a lang item.
2025-01-20derive(Clone): Manually generate AssertParamIsCopy struct for unionsArthur Cohen1-4/+34
gcc/rust/ChangeLog: * expand/rust-derive-clone.cc (DeriveClone::visit_union): Manually generate the struct used for asserting a union implements Copy.
2025-01-20builder: Allow generating struct statementsArthur Cohen2-0/+46
gcc/rust/ChangeLog: * ast/rust-ast-builder.cc (Builder::struct_struct): New function. * ast/rust-ast-builder.h (vec): New function.
2025-01-20lang-items: Mark Clone trait as a lang item in testsuiteArthur Cohen4-4/+6
gcc/testsuite/ChangeLog: * rust/compile/derive_macro1.rs: Add #[lang = "clone"] to Clone trait. * rust/compile/derive_macro3.rs: Likewise. * rust/compile/derive_macro6.rs: Likewise. * rust/execute/torture/derive_macro3.rs: Likewise.
2025-01-16ast-collector: Fix tuple struct pattern collectionArthur Cohen1-4/+1
gcc/rust/ChangeLog: * ast/rust-ast-collector.cc (TokenCollector::visit): Visit tuple pattern items as separated by commas.
2025-01-16ast-collector: Adapt to lang item type path segmentsArthur Cohen1-8/+15
gcc/rust/ChangeLog: * ast/rust-ast-collector.cc (TokenCollector::visit): Fix collector to better handle lang item type path segments.
2025-01-16mappings: Add get_lang_item_nodeArthur Cohen2-0/+11
This method errors out if the lang item has not been declared yet. gcc/rust/ChangeLog: * util/rust-hir-map.cc (Mappings::get_lang_item_node): New. * util/rust-hir-map.h: New function.
2025-01-16lang-item: Add LangItem::PrettyStringArthur Cohen2-0/+7
Which formats a lang item as it appears in source code. gcc/rust/ChangeLog: * util/rust-lang-item.cc (LangItem::PrettyString): New. * util/rust-lang-item.h: New.
2025-01-16lang-items: Collect struct lang items.Arthur Cohen2-0/+10
gcc/rust/ChangeLog: * ast/rust-collect-lang-items.cc (CollectLangItems::visit): New. * ast/rust-collect-lang-items.h: New.
2025-01-16lower: Properly lower non-generic lang item type path segments.Arthur Cohen1-26/+14
gcc/rust/ChangeLog: * hir/rust-ast-lower-type.cc (ASTLowerTypePath::visit): Adapt code to lang item type path segments.
2025-01-16tychk: resolve lang item type paths properlyArthur Cohen1-9/+17
gcc/rust/ChangeLog: * typecheck/rust-hir-type-check-type.cc (TypeCheckType::resolve_root_path): Adapt code to handle lang item type paths.
2025-01-16ast: Refactor how lang item paths are handled.Arthur Cohen26-546/+311
Lang item typepaths were not handled properly, and required a complete overhaul. All old classes that concerned lang item paths are now modified to use a simpler version of `AST::LangItemPath`, which has been removed. TypePath segments can now be lang items, as this is requied for having generic lang item paths such as PhantomData<T>. gcc/rust/ChangeLog: * ast/rust-path.h: Rework how lang item paths are represented. * ast/rust-path.cc: Likewise. * ast/rust-item.h: Likewise. * ast/rust-ast.cc: Likewise. * ast/rust-ast-collector.cc: Adapt to new lang item path system. * ast/rust-ast-collector.h: Likewise. * ast/rust-ast-visitor.cc (DefaultASTVisitor::visit): Likewise. * ast/rust-ast-visitor.h: Likewise. * expand/rust-derive-copy.cc: Likewise. * expand/rust-derive.h: Likewise. * hir/rust-ast-lower-base.cc (ASTLoweringBase::visit): Likewise. * hir/rust-ast-lower-base.h: Likewise. * hir/rust-ast-lower-type.cc (ASTLowerTypePath::translate): Likewise. (ASTLowerTypePath::visit): Likewise. * hir/rust-ast-lower-type.h: Likewise. * resolve/rust-ast-resolve-base.cc (ResolverBase::visit): Likewise. * resolve/rust-ast-resolve-base.h: Likewise. * resolve/rust-ast-resolve-item.cc (ResolveItem::visit): Likewise. * resolve/rust-ast-resolve-type.h: Likewise. * resolve/rust-ast-resolve-type.cc (ResolveRelativeTypePath::go): Likewise. * resolve/rust-late-name-resolver-2.0.cc (Late::visit): Likewise. * resolve/rust-late-name-resolver-2.0.h: Likewise. * hir/tree/rust-hir-path.cc (TypePathSegment::TypePathSegment): Likewise. (TypePathSegmentGeneric::TypePathSegmentGeneric): Likewise. * hir/tree/rust-hir-path.h: Likewise. * typecheck/rust-hir-type-check-type.cc (TypeCheckType::resolve_root_path): Likewise. * ast/rust-ast-builder.cc: Likewise. * ast/rust-ast-builder.h: Likewise.
2025-01-16collect-lang-items: Display attribute upon error finding itArthur Cohen1-1/+2
gcc/rust/ChangeLog: * ast/rust-collect-lang-items.cc (get_lang_item_attr): Show unknown attribute upon error.
2025-01-16attributes: Add #[derive] as a built-in attributeArthur Cohen2-0/+2
gcc/rust/ChangeLog: * util/rust-attribute-values.h: Declare new attribute value. * util/rust-attributes.cc: Use it.
2025-01-16ast: Fix warning about copy elision for moved exprArthur Cohen1-1/+1
gcc/rust/ChangeLog: * ast/rust-ast.cc (BlockExpr::normalize_tail_expr): Remove overzealous std::move
2025-01-13Remove dead code related to external functionsOwen Avery9-451/+0
gcc/rust/ChangeLog: * ast/rust-ast-collector.cc (TokenCollector::visit): Remove visitor for NamedFunctionParam. * ast/rust-ast-collector.h (TokenCollector::visit): Likewise. * ast/rust-ast-full-decls.h (class NamedFunctionParam): Remove forward declaration. * ast/rust-ast-visitor.cc (DefaultASTVisitor::visit): Remove visitor for NamedFunctionParam. * ast/rust-ast-visitor.h (DefaultASTVisitor::visit): Likewise. * ast/rust-ast.cc (NamedFunctionParam::as_string): Remove. * ast/rust-item.h (class NamedFunctionParam): Remove. (class ExternalFunctionItem): Remove. * parse/rust-parse-impl.h (Parser::parse_named_function_param): Remove. (Parser::parse_named_function_params): Remove. * parse/rust-parse.h (Parser::parse_named_function_param): Remove. (Parser::parse_named_function_params): Remove. Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
2025-01-13nr2.0: Early resolve pending eager macro invocationsOwen Avery2-5/+4
gcc/rust/ChangeLog: * resolve/rust-early-name-resolver-2.0.cc (Early::visit): Resolve the pending eager invocations inside builtin macro invocations. gcc/testsuite/ChangeLog: * rust/compile/nr2/exclude: Remove entries. Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
2025-01-13gccrs: Add missing name resolution to static items in blocksPhilip Herron5-0/+39
We need to add name resolution and hir lowering for items as part of blocks in order to typecheck and compile them correctly. Fixes Rust-GCC#3350 gcc/rust/ChangeLog: * hir/rust-ast-lower-stmt.cc (ASTLoweringStmt::visit): hir lowering * hir/rust-ast-lower-stmt.h: likewise * resolve/rust-ast-resolve-stmt.cc (ResolveStmt::visit): name resolution * resolve/rust-ast-resolve-stmt.h: likewise gcc/testsuite/ChangeLog: * rust/compile/issue-3350.rs: New test. Signed-off-by: Philip Herron <herron.philip@googlemail.com>
2025-01-10Revert "gcc/rust/ChangeLog:"CohenArthur3-11/+6
This reverts commit 600fd806b8821ea24103ea0f31d666077245c6b7.
2025-01-10gccrs: Fix scan-gimple testcases on LE platforms.Arthur Cohen2-3/+25
gcc/testsuite/ChangeLog: * rust/compile/macros/builtin/eager1.rs: Switch to scan-assembler directive as the GIMPLE dump does not contain strings on LE. * rust/compile/macros/builtin/recurse2.rs: Likewise.
2025-01-10testsuite: Fix missing handling of little endian.Arthur Cohen2-19/+9
Some failures occur in the testsuite because we did not account for the little-endian case. gcc/testsuite/ChangeLog: * rust/compile/issue-1446.rs: Add swap_bytes function. * rust/compile/iterators1.rs: Remove unused {to, from}_le functions.
2025-01-10Add ForeverStackStoreOwen Avery3-0/+470
ForeverStackStore is meant to partially unify the internal states of per-namespace ForeverStack instances. This commit does not contain modifications to ForeverStack which would allow it to rely on a ForeverStackStore to store nodes, but a future commit should address this. gcc/rust/ChangeLog: * Make-lang.in: Handle rust-forever-stack.cc. * resolve/rust-forever-stack.h (class ForeverStackStore): Add. * resolve/rust-forever-stack.cc: New file, based on rust-forever-stack.hxx. Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
2025-01-10gcc/rust/ChangeLog:Om Swaroop Nayak3-6/+11
* ast/rust-collect-lang-items.cc (get_lang_item_attr): "removed checker fn" * util/rust-attributes.cc (Attributes::is_lang_item): "added fn" * util/rust-attributes.h: "added fn" Signed-off-by: Om Swaroop Nayak <96killerat96@gmail.com>
2025-01-10gccrs: improve mutability checksPhilip Herron3-10/+61
This ensures that we handle var decls readonly checks much better Addresses: Rust-GCC#807 Rust-GCC#3287 gcc/rust/ChangeLog: * checks/errors/rust-readonly-check.cc (check_decl): improve mut check (emit_error): helper (check_modify_expr): likewise (readonly_walk_fn): reuse helper (ReadonlyCheck::Lint): cleanup context each run gcc/testsuite/ChangeLog: * rust/execute/torture/builtin_macro_include_bytes.rs: needs mut * rust/compile/mutability_checks1.rs: New test. Signed-off-by: Philip Herron <herron.philip@googlemail.com>
2025-01-10Visit the trait paths of trait implementationsOwen Avery2-46/+1
gcc/rust/ChangeLog: * ast/rust-ast-visitor.cc (DefaultASTVisitor::visit): When visiting a TraitImpl, visit its trait path. gcc/testsuite/ChangeLog: * rust/compile/nr2/exclude: Remove entries. Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
2025-01-10gccrs: add two more tests to test try-catch (unwind) code generationliushuyu2-0/+41
gcc/testsuite/ChangeLog: * rust/compile/try-catch-unwind-old.rs: add a test to test the older try intrinsics from plain old Rust to v1.78.0 * rust/compile/try-catch-unwind-new.rs: add a test to test the newer catch_unwind instrinsics since Rust v1.78.0
2025-01-10rust/intrinsic: add new "catch_unwind" variant of APIliushuyu1-10/+47
gcc/rust/ChangeLog: * backend/rust-compile-intrinsic.cc: add the new `catch_unwind` variant of the `try` intrinsic: this variant can be seen on Rust 1.78+ and returns `()` instead of `i32`.
2025-01-10rust/intrinsic: add try intrinsic and panic strategy optionsliushuyu5-0/+104
gcc/rust/ChangeLog: * backend/rust-compile-intrinsic.cc: add `try` intrinsic handler. * lang.opt: add `-frust-panic` option. * rust-lang.cc: enable exception handler code generation. * rust-session-manager.cc: add getter and setter for panic strategy option. * rust-session-manager.h: Likewise. Signed-off-by: Zixing Liu <liushuyu011@gmail.com>
2025-01-10gccrs: match arms are a LUBPhilip Herron3-14/+16
Unify rules are not the same as coercion rules. The coercion of ! is allowed to any type but not for a unify site which is different. Match arms are another least upper bound coercion. gcc/rust/ChangeLog: * backend/rust-compile-expr.cc (CompileExpr::visit): implement coercion * typecheck/rust-hir-type-check-expr.cc (TypeCheckExpr::visit): this is an LUB * typecheck/rust-unify.cc (UnifyRules::go): remove unify ! coercion Signed-off-by: Philip Herron <herron.philip@googlemail.com>
2025-01-10Allow float type to be casted as integer typeNobel2-0/+16
gccrs now should be able to cast float types as numeric. gcc/rust/ChangeLog: * typecheck/rust-casts.cc (TypeCastRules::cast_rules): Add rule. gcc/testsuite/ChangeLog: * rust/compile/cast_float_as_integer.rs: New test. Signed-off-by: Nobel Singh <nobel2073@gmail.com>
2025-01-10gccrs: cleanup our enum type layout to be closer to rustcPhilip Herron5-79/+128
This changes our enum type layout so for example: enum Foo { A, B, C(char), D { x: i32, y: i32 }, } Used to get layed out like this in gccrs: union { struct A { int RUST$ENUM$DISR; }; struct B { int RUST$ENUM$DISR; }; struct C { int RUST$ENUM$DISR; char __0; }; struct D { int RUST$ENUM$DISR; i64 x; i64 y; }; } This has some issues notably with the constexpr because this is just a giant union it means its not simple to constify what enum variant we are looking at because the discriminant is a mess. This now gets layed out as: struct { int RUST$ENUM$DISR; union { struct A { }; struct B { }; struct C { char __0; }; struct D { i64 x; i64 y; }; } payload; } This layout is much cleaner and allows for our constexpr to work properly. gcc/rust/ChangeLog: * backend/rust-compile-expr.cc (CompileExpr::visit): new layout * backend/rust-compile-pattern.cc (CompilePatternCheckExpr::visit): likewise (CompilePatternBindings::visit): likewise * backend/rust-compile-resolve-path.cc: likewise * backend/rust-compile-type.cc (TyTyResolveCompile::visit): implement new layout * rust-gcc.cc (constructor_expression): get rid of useless assert Signed-off-by: Philip Herron <herron.philip@googlemail.com>
2025-01-08nr2.0: Resolve Self inside impl blocksOwen Avery3-3/+28
gcc/rust/ChangeLog: * resolve/rust-toplevel-name-resolver-2.0.cc (TopLevel::visit): Insert a definition for Self when visiting InherentImpl and TraitImpl instances. * resolve/rust-toplevel-name-resolver-2.0.h (TopLevel::visit): Add visitors for InherentImpl and TraitImpl. gcc/testsuite/ChangeLog: * rust/compile/nr2/exclude: Remove entries. Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
2025-01-07gccrs: fix ICE with hir dump on closurePhilip Herron1-2/+6
Return type and parameter types are optional on closures. gcc/rust/ChangeLog: * hir/rust-hir-dump.cc (Dump::visit): add null guard Signed-off-by: Philip Herron <herron.philip@googlemail.com>
2025-01-07gccrs: add support for lang_item eq and PartialEq traitPhilip Herron11-13/+194
The Eq and Partial Ord are very similar to the operator overloads we support for add/sub/etc... but they differ in that usually the function call name matches the name of the lang item. This time we need to have support to send in a new path for the method call on the lang item we want instead of just the name of the lang item. NOTE: this test case doesnt work correctly yet we need to support the derive of partial eq on enums to generate the correct comparison code for that. Fixes Rust-GCC#3302 gcc/rust/ChangeLog: * backend/rust-compile-expr.cc (CompileExpr::visit): handle partial_eq possible call * backend/rust-compile-expr.h: handle case where lang item calls differ from name * hir/tree/rust-hir-expr.cc (OperatorExprMeta::OperatorExprMeta): new helper * hir/tree/rust-hir-expr.h: likewise * typecheck/rust-hir-type-check-expr.cc (TypeCheckExpr::visit): handle partial_eq (TypeCheckExpr::resolve_operator_overload): likewise * typecheck/rust-hir-type-check-expr.h: likewise * util/rust-lang-item.cc (LangItem::ComparisonToLangItem): map comparison to lang item (LangItem::ComparisonToSegment): likewise * util/rust-lang-item.h: new lang items PartialOrd and Eq * util/rust-operators.h (enum class): likewise gcc/testsuite/ChangeLog: * rust/compile/nr2/exclude: nr2 cant handle this * rust/compile/cmp1.rs: New test. Signed-off-by: Philip Herron <herron.philip@googlemail.com>
2025-01-07gccrs: fix ICE in borrows to invalid expressionsPhilip Herron5-10/+33
We need to check if the borrowed value is valid before creating the reference type. Otherwise this will lead to an ICE. Fixes Rust-GCC#3140 gcc/rust/ChangeLog: * typecheck/rust-hir-type-check-expr.cc (TypeCheckExpr::visit): check for error * typecheck/rust-tyty-call.cc (TypeCheckCallExpr::visit): likewise and remove debug error gcc/testsuite/ChangeLog: * rust/compile/issue-3046.rs: remove old error message * rust/compile/nr2/exclude: nr2 cant handle this * rust/compile/issue-3140.rs: New test. Signed-off-by: Philip Herron <herron.philip@googlemail.com>
2025-01-07nr2.0: Improve default, top-level, and late resolversOwen Avery7-65/+41
gcc/rust/ChangeLog: * resolve/rust-default-resolver.cc (DefaultResolver::visit): Make sure to scope visitation of the children of type definition items. * resolve/rust-default-resolver.h (DefaultResolver::visit): Add overrides for TupleStruct, Union, and TypeAlias. * resolve/rust-late-name-resolver-2.0.cc (Late::visit): Remove override for Enum. * resolve/rust-late-name-resolver-2.0.h (Late::visit): Likewise. * resolve/rust-toplevel-name-resolver-2.0.cc (TopLevel::visit): Rely more on DefaultResolver::visit. * resolve/rust-toplevel-name-resolver-2.0.h (TopLevel::visit): Remove override for BlockExpr. gcc/testsuite/ChangeLog: * rust/compile/nr2/exclude: Remove entries. Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
2025-01-06gccrs: fix ICE during HIR dumpPhilip Herron1-3/+6
These hir nodes have optional expressions which need guarded gcc/rust/ChangeLog: * hir/rust-hir-dump.cc (Dump::do_qualifiedpathtype): add guard (Dump::do_traitfunctiondecl): likewise (Dump::visit): likewise Signed-off-by: Philip Herron <herron.philip@googlemail.com>
2025-01-06gccrs: use StackedContexts for block contextPrajwal S N5-35/+15
Replaces the DIY vector stack with a StackedContexts object for block scopes in the type checker context. Fixes #3284. gcc/rust/ChangeLog: * typecheck/rust-hir-type-check.h (class TypeCheckContext): add header file and use StackedContexts for blocks * typecheck/rust-typecheck-context.cc: update methods * typecheck/rust-hir-trait-resolve.cc: refactor function calls * typecheck/rust-hir-type-check-implitem.cc: refactor function calls * typecheck/rust-hir-type-check-type.cc: refactor function calls Signed-off-by: Prajwal S N <prajwalnadig21@gmail.com>
2025-01-06ast: Add new Kind enums for more precise downcastingArthur Cohen11-55/+229
This commit adds things like Item::Kind, Expr::Kind, etc, and implements the associated `get_*_kind` functions. It also removes the more generic AST::Kind enum we were using, which was incomplete and painful to use. gcc/rust/ChangeLog: * ast/rust-ast.h: Add new Kind enums, remove Node class. * ast/rust-builtin-ast-nodes.h: Use new Kind enums. * ast/rust-expr.h (class LoopLabel): Likewise. * ast/rust-item.h: Likewise. * ast/rust-macro.h: Likewise. * ast/rust-path.h: Likewise. * expand/rust-macro-builtins-helpers.cc: Likewise. * expand/rust-macro-builtins-utility.cc (MacroBuiltin::concat_handler): Likewise. (MacroBuiltin::stringify_handler): Likewise. * resolve/rust-ast-resolve-expr.cc (ResolveExpr::visit): Likewise. * resolve/rust-early-name-resolver.cc: Likewise. * hir/rust-ast-lower.cc (ASTLoweringBlock::visit): Likewise.
2025-01-06nr2.0: Resolve type aliases inside trait definitionsOwen Avery3-5/+10
gcc/rust/ChangeLog: * resolve/rust-toplevel-name-resolver-2.0.cc (TopLevel::visit): Add visitor for TraitItemType. * resolve/rust-toplevel-name-resolver-2.0.h (TopLevel::visit): Likewise. gcc/testsuite/ChangeLog: * rust/compile/nr2/exclude: Remove entries. Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
2025-01-03tychk: Add more support for additional trait bounds in functionsArthur Cohen7-3/+78
This commit correctly lowers and typechecks parenthesized types, which are used for trait objects with additional bounds. gcc/rust/ChangeLog: * resolve/rust-ast-resolve-type.cc (ResolveType::visit): New visitor to handle ParenthesizedType. * resolve/rust-ast-resolve-type.h: Likewise. * typecheck/rust-hir-type-check-type.cc (TypeCheckType::visit): Likewise. * typecheck/rust-hir-type-check-type.h: Likewise. gcc/testsuite/ChangeLog: * rust/compile/auto_traits2.rs: New test. * rust/compile/auto_traits3.rs: New test. * rust/compile/nr2/exclude: Add auto_traits2 test.
2025-01-03lower: Correctly lower parenthesized typesArthur Cohen3-0/+48
This is useful for handling multiple trait bounds, and required for better handling of auto traits. gcc/rust/ChangeLog: * hir/rust-ast-lower-type.cc (ASTLoweringType::visit): Add implementation for ParenthesizedType. * hir/rust-ast-lower-type.h: Declare that new visitor. gcc/testsuite/ChangeLog: * rust/compile/auto_traits1.rs: New test.
2025-01-03Remove Rust::make_uniqueOwen Avery22-94/+50
Since our bootstrap requirement has been bumped to C++14, we don't need a custom implementation of std::make_unique anymore. gcc/rust/ChangeLog: * ast/rust-ast-builder-type.cc: Remove inclusion of rust-make-unique.h. * ast/rust-ast-builder.cc: Likewise. (Builder::array): Use std::make_unique instead of Rust::make_unique. * ast/rust-ast.cc (Attribute::get_traits_to_derive): Likewise. * ast/rust-macro.h: Remove inclusion of rust-make-unique.h. (MacroRulesDefinition::mbe): Use std::make_unique instead of Rust::make_unique. (MacroRulesDefinition::decl_macro): Likewise. * ast/rust-path.h (PathInExpression::PathInExpression): Likewise. (QualifiedPathInExpression::QualifiedPathInExpression): Likewise. * backend/rust-compile-pattern.cc (CompilePatternCheckExpr::visit): Likewise. * expand/rust-derive-copy.cc (DeriveCopy::copy_impl): Likewise. * expand/rust-expand-format-args.cc (expand_format_args): Likewise. * expand/rust-macro-builtins-asm.cc: Remove inclusion of rust-make-unique.h. (parse_asm): Use std::make_unique instead of Rust::make_unique. * hir/rust-ast-lower-expr.cc (ASTLoweringExpr::visit): Likewise. * hir/tree/rust-hir-expr.cc (StructExprStructFields::StructExprStructFields): Likewise. (StructExprStructFields::operator=): Likewise. * hir/tree/rust-hir.cc (TypePath::to_trait_bound): Likewise. * lex/rust-token.h: Remove inclusion of rust-make-unique.h. (Token::Token): Use std::make_unique instead of Rust::make_unique. * metadata/rust-import-archive.cc: Remove inclusion of rust-make-unique.h. (Import::find_archive_export_data): Use std::make_unique instead of Rust::make_unique. * metadata/rust-imports.cc: Remove inclusion of rust-make-unique.h. (Import::find_export_data): Use std::make_unique instead of Rust::make_unique. (Import::find_object_export_data): Likewise. * parse/rust-parse-impl.h: Remove inclusion of rust-make-unique.h. (Parser::parse_function_param): Use std::make_unique instead of Rust::make_unique. (Parser::parse_self_param): Likewise. (Parser::parse_array_expr): Likewise. * typecheck/rust-hir-type-check-enumitem.cc (TypeCheckEnumItem::visit): Likewise. * typecheck/rust-hir-type-check-implitem.cc (TypeCheckTopLevelExternItem::visit): Likewise. (TypeCheckImplItem::visit): Likewise. * typecheck/rust-hir-type-check-type.cc (TypeResolveGenericParam::visit): Likewise. * typecheck/rust-hir-type-check.cc: Remove inclusion of rust-make-unique.h. (TraitItemReference::get_type_from_fn): Use std::make_unique instead of Rust::make_unique. * typecheck/rust-tyty-bounds.cc (TypeCheckBase::get_predicate_from_bound): Likewise. * util/rust-make-unique.h: Removed. Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
2025-01-03ast: Add EnumItem::KindArthur Cohen1-0/+52
gcc/rust/ChangeLog: * ast/rust-item.h: Add EnumItem::Kind for differentiating all variants that may be used inside an enum declaration.
2025-01-02nr2.0: Handle "Self" properly in trait definitionsOwen Avery5-7/+18
gcc/rust/ChangeLog: * ast/rust-ast-visitor.cc (DefaultASTVisitor::visit): Visit implicit Self parameters of traits. * resolve/rust-late-name-resolver-2.0.cc (Late::visit): Resolve implicit Self parameters of traits. * resolve/rust-late-name-resolver-2.0.h: (Late::visit): Add trait visitor. * resolve/rust-toplevel-name-resolver-2.0.cc (TopLevel::visit): Insert resolutions for Self type parameters as well. gcc/testsuite/ChangeLog: * rust/compile/nr2/exclude: Remove entries. Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
2025-01-02Fix NR2.0 compiler ICE caused by Generics in EnumsLiam Naddell4-0/+27
gcc/rust/ChangeLog: * resolve/rust-late-name-resolver-2.0.cc: Change the late name resolver to enter proper lexical scope during typechecking * resolve/rust-late-name-resolver-2.0.h: Add needed prototype to header * resolve/rust-toplevel-name-resolver-2.0.cc: Add generic parameters to enum's scoped RIB to allow for proper name resolution on types. gcc/testsuite/ChangeLog: * rust/compile/issue-3304.rs: Add small test for generics+enums combination for NR2.0 Signed-off-by: Liam Naddell <liam.naddell@mail.utoronto.ca>
2024-12-31ast-builder: Add more methodsArthur Cohen2-0/+121
This commit adds new methods for building pattern nodes, match expressions and more precise call expressions. gcc/rust/ChangeLog: * ast/rust-ast-builder.cc: Add new functions. * ast/rust-ast-builder.h: Declare them.
2024-12-31ast: Add new constructors for PathInExpressionArthur Cohen1-1/+20
This commit adds two new constructors for AST::PathInExpression: One using a provided lang-item, and one with an already built std::unique_ptr<Path> gcc/rust/ChangeLog: * ast/rust-path.h: Add two new constructors.
2024-12-31lang-items: Collect trait functions that are lang itemsArthur Cohen2-0/+9
gcc/rust/ChangeLog: * ast/rust-collect-lang-items.cc (CollectLangItems::visit): Add visitor for collecting functions that might be lang items. * ast/rust-collect-lang-items.h: Likewise.