aboutsummaryrefslogtreecommitdiff
path: root/gcc
AgeCommit message (Collapse)AuthorFilesLines
2025-08-05gccrs: Parse try expressionsOwen Avery14-0/+157
This doesn't do anything beyond creating TryExpr and parsing them, so try expressions shouldn't be able to make it past AST lowering yet. gcc/rust/ChangeLog: * ast/rust-ast-collector.cc (TokenCollector::visit): Add visitor for TryExpr. * ast/rust-ast-collector.h (TokenCollector::visit): Likewise. * ast/rust-ast-visitor.cc (DefaultASTVisitor::visit): Likewise. * ast/rust-ast-visitor.h (ASTVisitor::visit): Likewise. (DefaultASTVisitor::visit): Likewise. * expand/rust-derive.h (DeriveVisitor::visit): Likewise. * hir/rust-ast-lower-base.cc (ASTLoweringBase::visit): Likewise. * hir/rust-ast-lower-base.h (ASTLoweringBase::visit): Likewise. * resolve/rust-ast-resolve-base.cc (ResolverBase::visit): Likewise. * resolve/rust-ast-resolve-base.h (ResolverBase::visit): Likewise. * ast/rust-ast-full-decls.h (class TryExpr): New forward class declaration. * ast/rust-ast.cc (TryExpr::as_string): New function. (TryExpr::accept_vis): Likewise. * ast/rust-expr.h (class TryExpr): New class. * parse/rust-parse.h (Parser::parse_try_expr): New function. * parse/rust-parse-impl.h (Parser::parse_try_expr): Likewise. (Parser::null_denotation_not_path): Use parse_try_expr to parse try expressions. Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
2025-08-05gccrs: Allow format_args to accept a raw string literalOwen Avery1-2/+9
gcc/rust/ChangeLog: * expand/rust-macro-builtins-format-args.cc (format_args_parse_arguments): Accept a RAW_STRING_LITERAL token as the first argument. Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
2025-08-05gccrs: Change enum to enum classPierre-Emmanuel Patry2-3/+5
gcc/rust/ChangeLog: * parse/rust-parse-impl.h: Add enum prefix. * parse/rust-parse.h (enum ParseSelfError): Change from enum... (enum class): To enum class. Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
2025-08-05gccrs: Remove reinterpret_cast usages in DefaultASTVisitorOwen Avery1-3/+3
gcc/rust/ChangeLog: * ast/rust-ast-visitor.cc (DefaultASTVisitor::visit): Replace usages of reinterpret_cast with static_cast. Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
2025-08-05gccrs: Remove Late visitor override for StructStructOwen Avery2-8/+0
DefaultResolver already handles StructStruct in a more correct fashion. gcc/rust/ChangeLog: * resolve/rust-late-name-resolver-2.0.cc (Late::visit): Remove override for StructStruct visitor. * resolve/rust-late-name-resolver-2.0.h (Late::visit): Likewise. Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
2025-08-05gccrs: nr1.0: Remove rust/backend supportOwen Avery6-155/+51
This is the first patch in a set intended to fully remove name resolution 1.0. As such, it should leave name resolution 1.0 technically available but broken. gcc/rust/ChangeLog: * backend/rust-compile-context.cc (Context::Context): Remove initialization of resolver field. * backend/rust-compile-context.h (Context::get_resolver): Remove function. (Context::resolver): Remove field. * backend/rust-compile-expr.cc (CompileExpr::visit): Assume name resolution 2.0 is always enabled. (CompileExpr::generate_closure_function): Likewise. * backend/rust-compile-implitem.cc (CompileTraitItem::visit): Likewise. * backend/rust-compile-item.cc (CompileItem::visit): Likewise. * backend/rust-compile-resolve-path.cc (ResolvePathRef::resolve): Likewise. Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
2025-08-05gccrs: Remove -frust-name-resolution-2.0 usage in testsOwen Avery34-51/+9
gcc/testsuite/ChangeLog: * rust/compile/additional-trait-bounds2nr2.rs: Remove -frust-name-resolution-2.0 usage. * rust/compile/const_generics_3.rs: Likewise. * rust/compile/enum_variant_name.rs: Likewise. * rust/compile/generics9.rs: Likewise. * rust/compile/invalid_label_name.rs: Likewise. * rust/compile/issue-3304.rs: Likewise. * rust/compile/macros/mbe/macro-issue3708.rs: Likewise. * rust/compile/macros/mbe/macro-issue3709-2.rs: Likewise. * rust/compile/name_resolution10.rs: Likewise. * rust/compile/name_resolution11.rs: Likewise. * rust/compile/name_resolution12.rs: Likewise. * rust/compile/name_resolution13.rs: Likewise. * rust/compile/name_resolution14.rs: Likewise. * rust/compile/name_resolution15.rs: Likewise. * rust/compile/name_resolution16.rs: Likewise. * rust/compile/name_resolution17.rs: Likewise. * rust/compile/name_resolution18.rs: Likewise. * rust/compile/name_resolution20.rs: Likewise. * rust/compile/name_resolution22.rs: Likewise. * rust/compile/name_resolution23.rs: Likewise. * rust/compile/name_resolution24.rs: Likewise. * rust/compile/name_resolution25.rs: Likewise. * rust/compile/name_resolution6.rs: Likewise. * rust/compile/name_resolution7.rs: Likewise. * rust/compile/name_resolution8.rs: Likewise. * rust/compile/name_resolution9.rs: Likewise. * rust/compile/nested_macro_definition.rs: Likewise. * rust/compile/pub_restricted_1.rs: Likewise. * rust/compile/pub_restricted_2.rs: Likewise. * rust/compile/self-in-impl.rs: Likewise. * rust/compile/self_import_namespace.rs: Likewise. * rust/compile/use_1.rs: Likewise. * rust/compile/xfail/name_resolution21.rs: Likewise. * rust/execute/torture/name_resolution.rs: Likewise. Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
2025-08-05gccrs: nr2.0: Enable by defaultOwen Avery3-151/+1
gcc/rust/ChangeLog: * lang.opt (frust-name-resolution-2.0): Enable by default. gcc/testsuite/ChangeLog: * rust/compile/nr2/compile.exp: Removed. * rust/compile/nr2/exclude: Removed. Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
2025-08-05gccrs: Implement compilation support for TuplePatternItems::RANGEDZhi Heng4-2/+87
Example GIMPLE output of the match statement for match-restpattern-tuple-1.rs: ... RUSTTMP.2 = x; _1 = RUSTTMP.2.__0; _2 = _1 == 1; _3 = RUSTTMP.2.__3; _4 = _3 == 4; _5 = _2 & _4; if (_5 != 0) goto <D.109>; else goto <D.110>; <D.109>: { { } goto <D.104>; } <D.110>: if (1 != 0) goto <D.111>; else goto <D.112>; <D.111>: { { } goto <D.104>; } <D.112>: <D.104>: ... gcc/rust/ChangeLog: * backend/rust-compile-pattern.cc (CompilePatternCheckExpr::visit(TuplePattern)): Implement check expression compilation for TuplePatternItems::RANGED. Signed-off-by: Yap Zhi Heng <yapzhhg@gmail.com>
2025-08-05gccrs: Fix type checking logic for TuplePatternZhi Heng2-2/+3
gcc/rust/ChangeLog: * typecheck/rust-hir-type-check-pattern.cc (visit(TuplePattern)): Fix incorrect logic for field size checking. gcc/testsuite/ChangeLog: * rust/compile/tuple_mismatch.rs: Include RestPattern in test. Signed-off-by: Yap Zhi Heng <yapzhhg@gmail.com>
2025-08-05gccrs: chore: ast: Fix formatting and includesArthur Cohen1-1/+0
gcc/rust/ChangeLog: * ast/rust-ast-builder.cc: Remove extra include, fix new formatting.
2025-08-05gccrs: reconstruct_vec: Allocate size when creating the vectorArthur Cohen1-0/+1
gcc/rust/ChangeLog: * ast/rust-ast.h (reconstruct_vec): Pre-allocate size of vector.
2025-08-05gccrs: ast: builder: Remove ASTTypeBuilderArthur Cohen7-266/+22
gcc/rust/ChangeLog: * Make-lang.in: Remove object file for ASTTypeBuilder. * ast/rust-ast-builder.h: Remove function. * ast/rust-ast-builder.cc (Builder::new_type): Likewise. (Builder::new_const_param): Use reconstruct_type() instead. (Builder::new_generic_args): Likewise. * expand/rust-derive-default.cc (DeriveDefault::visit_struct): Likewise. (DeriveDefault::visit_tuple): Likewise. * expand/rust-derive-eq.cc (DeriveEq::visit_tuple): Likewise. (DeriveEq::visit_struct): Likewise. (DeriveEq::visit_enum): Likewise. (DeriveEq::visit_union): Likewise. * ast/rust-ast-builder-type.cc: Removed. * ast/rust-ast-builder-type.h: Removed.
2025-08-05gccrs: ast: Add reconstruct() method for Type nodesArthur Cohen4-31/+167
gcc/rust/ChangeLog: * ast/rust-ast.h: Add reconstruct() and reconstruct_impl() for Type nodes. * ast/rust-type.h: Implement them. * ast/rust-macro.h: Likewise. * ast/rust-path.h: Likewise.
2025-08-05gccrs: ast: reconstruct: Add base for reconstructing and asserting different IDsArthur Cohen1-0/+36
gcc/rust/ChangeLog: * ast/rust-ast.h (reconstruct): New function for calling the `reconstruct_*_impl` method and asserting that the new NodeId is different, and then wrap it in a unique_ptr<T>. (reconstruct_vec): Likewise, but for vectors of unique_ptr<T>
2025-08-05gccrs: nr2.0: Adjust resolution of modulesOwen Avery3-4/+41
This prioritizes resolution in the language prelude over resolution as a module. gcc/rust/ChangeLog: * resolve/rust-forever-stack.hxx (ForeverStack::resolve_path): Resolve final segments which point to modules. * resolve/rust-toplevel-name-resolver-2.0.cc (TopLevel::visit): Avoid inserting module names into ribs in the type namespace. gcc/testsuite/ChangeLog: * rust/compile/nr2/exclude: Remove issue-3315-2.rs. Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
2025-08-05gccrs: nr2.0: Add more checks for alternate patternsOwen Avery4-14/+83
gcc/rust/ChangeLog: * resolve/rust-late-name-resolver-2.0.cc (visit_identifier_as_pattern): Handle is_ref and is_mut. (Late::visit): Likewise. * resolve/rust-name-resolution-context.cc (BindingLayer::insert_ident): Likewise. (BindingLayer::bind_test): Handle changes to BindingLayer fields. (BindingLayer::merge): Likewise and emit more error messages. * resolve/rust-name-resolution-context.h (struct IdentifierMode): New. (Binding::has_expected_bindings): New field. (Binding::set): Rename field to... (Binding::idents): ...here and convert from a set to a map. (Binding::Binding): Initialize has_expected_bindings. (BindingLayer::insert_ident): Adjust parameters. gcc/testsuite/ChangeLog: * rust/compile/nr2/exclude: Remove torture/alt_patterns1.rs. Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
2025-08-05gccrs: Add locus gettersPierre-Emmanuel Patry4-1/+11
gcc/rust/ChangeLog: * ast/rust-expr.h: Add getter to locus field. * ast/rust-pattern.h (tokenid_to_rangekind): Likewise. * hir/tree/rust-hir-item.h: Likewise. * hir/tree/rust-hir-visibility.h: Likewise. Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
2025-08-05gccrs: nr2.0: Adjust resolution of external cratesOwen Avery5-47/+74
This ensures Session::load_extern_crate doesn't try to use the old name resolver when nr2.0 is enabled, while also ensuring that nr2.0 handles external crates. gcc/rust/ChangeLog: * resolve/rust-default-resolver.cc (DefaultResolver::visit_extern_crate): New function. (DefaultResolver::visit): New visitor function for ExternCrate. * resolve/rust-default-resolver.h (DefaultResolver::visit_extern_crate): New function. (DefaultResolver::visit): New visitor function for ExternCrate. * resolve/rust-toplevel-name-resolver-2.0.cc (TopLevel::visit): Adjust ExternCrate visitor and rename to... (TopLevel::visit_extern_crate): ...here. * resolve/rust-toplevel-name-resolver-2.0.h (TopLevel::visit): Remove ExternCrate visitor override. (TopLevel::visit_extern_crate): New function. * rust-session-manager.cc (Session::load_extern_crate): Only run name resolution 1.0 if name resolution 2.0 is disabled. Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
2025-08-05gccrs: Implement type checking for ItemType::RANGED in TuplePatternZhi Heng1-15/+58
This patch implements the previously unimplemented type checking for RANGED item type for TuplePattern, which serves as the start for implementing compilation of RestPattern. gcc/rust/ChangeLog: * typecheck/rust-hir-type-check-pattern.cc (TypeCheckPattern::visit(TuplePattern)): Implement type checking for ItemType::RANGED. Signed-off-by: Yap Zhi Heng <yapzhhg@gmail.com>
2025-08-05gccrs: Update C++ version check in rust-lang.ccOwen Avery1-3/+3
gcc/rust/ChangeLog: * rust-lang.cc: Move version check from C++11 to C++14. Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
2025-08-05gccrs: Implement default HIR visitor classRyutaro Okada3-0/+1485
gcc/rust/ChangeLog: * Make-lang.in: Scaffolding new rust-hir-visitor files * hir/tree/rust-hir-visitor.h (DefaultHIRVisitor): Declare default HIR visitor * hir/tree/rust-hir-visitor.cc (DefaultHIRVisitor): Define default HIR visitor Signed-off-by: Ryutaro Okada <1015ryu88@gmail.com>
2025-08-05gccrs: Create Rust::GGC::IdentOwen Avery8-65/+164
This should make it easier for us to hand identifiers off to the back end. gcc/rust/ChangeLog: * Make-lang.in (GRS_OBJS): Add rust-ggc.o. * backend/rust-compile-base.cc (HIRCompileBase::compile_function): Adjust call to Backend::function. (HIRCompileBase::compile_constant_item): Likewise and adjust initialization of Backend::typed_identifier. * backend/rust-compile-expr.cc (CompileExpr::visit): Adjust call to Backend::label. * backend/rust-compile-type.cc (TyTyResolveCompile::visit): Adjust initialization of Backend::typed_identifier. * rust-backend.h: Add includes. (Backend::GGC::Ident): Use Rust::GGC::Ident. (struct typed_identifier): Store name as a GGC::Ident rather than a std::string and adjust constructors. (named_type): Take GGC::Ident/tl::optional<GGC::Ident> rather than std::string. (global_variable): Likewise. (local_variable): Likewise. (parameter_variable): Likewise. (static_chain_variable): Likewise. (label): Likewise. (function): Likewise. * rust-gcc.cc (named_type): Likewise. (global_variable): Likewise. (local_variable): Likewise. (parameter_variable): Likewise. (static_chain_variable): Likewise. (label): Likewise. (function): Likewise. (function_defer_statement): Adjust call to Backend::label. (get_identifier_from_string): Remove function. (fill_in_fields): Handle adjustments to typed_identifier. * util/rust-ggc.cc: New file. * util/rust-ggc.h: New file. Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
2025-08-05gccrs: Add getter for non const lifetime objectRyutaro Okada1-0/+2
gcc/rust/ChangeLog: * hir/tree/rust-hir-item.h (SelfParam::get_lifetime): Add getter for non const lifetime object Signed-off-by: Ryutaro Okada <1015ryu88@gmail.com>
2025-08-05gccrs: Add getter for outer attributionsRyutaro Okada1-0/+2
gcc/rust/ChangeLog: * hir/tree/rust-hir-expr.h (MatchArm::get_outer_attrs): Add getter for outer attributions Signed-off-by: Ryutaro Okada <1015ryu88@gmail.com>
2025-08-05gccrs: Fix scan-assembler regexp in recurse2.rsOwen Avery1-1/+1
gcc/testsuite/ChangeLog: * rust/compile/macros/builtin/recurse2.rs: Match "abheyho\0" as well as "abheyho", to handle slight differences in assembly output for null-terminated strings. Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
2025-08-05gccrs: Fix bug with non compiled const declPhilip Herron2-4/+15
There was a sily bug where if you reorder this test case to declare A before B this test would work but its meant to work in any order. So this fixes the bug during code gen to fall back to our query compile system if this is needed. Fixes Rust-GCC#3525 gcc/rust/ChangeLog: * backend/rust-compile-resolve-path.cc: if this fails fall back to query compile gcc/testsuite/ChangeLog: * rust/compile/issue-3525.rs: New test. Signed-off-by: Philip Herron <herron.philip@googlemail.com>
2025-08-05gccrs: check for invalid const calls during code-genPhilip Herron5-11/+114
Closure calls are not const so this is invalid. This patch fixes two bugs 1. Make the look at the parent context optional for generics 2. Ensure we look for non const calls during call expr code-gen Fixes Rust-GCC#3551 gcc/rust/ChangeLog: * backend/rust-compile-expr.cc (CompileExpr::visit): add const call check * backend/rust-compile-item.cc (CompileItem::visit): ensure we upfront compile types where possible * backend/rust-compile-item.h: update header * typecheck/rust-hir-type-check-expr.cc (TypeCheckExpr::visit): make parent ctx optional gcc/testsuite/ChangeLog: * rust/compile/issue-3551.rs: New test. Signed-off-by: Philip Herron <herron.philip@googlemail.com>
2025-08-05gccrs: Fix TupleStructPattern compilation throwing errorZhi Heng3-19/+64
Code for TupleStructPattern compilation previously only assumes that it is derived from an enum. This commit adds a check for that, and compiles non-enum TupleStructPatterns similarly to TuplePatterns if it is not an enum. gcc/rust/ChangeLog: * backend/rust-compile-pattern.cc(CompilePatternCheckExpr::visit(TupleStructPattern)): Fix error thrown when compiling non-enum TupleStructPattern. Signed-off-by: Yap Zhi Heng <yapzhhg@gmail.com>
2025-08-05gccrs: nr2.0: Fix resolution of constant itemsOwen Avery2-14/+9
gcc/rust/ChangeLog: * resolve/rust-default-resolver.cc (DefaultResolver::visit): Call DefaultASTVisitor::visit even on ConstantItem instances without expressions. gcc/testsuite/ChangeLog: * rust/compile/nr2/exclude: Remove issue-3642.rs. Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
2025-08-05gccrs: Add unify rules for fnptr and closuresPhilip Herron1-1/+37
Its valid to unify a closure to an fnptr as we are working on the fn traits. There are still other issues but this is part of the patch set. gcc/rust/ChangeLog: * typecheck/rust-unify.cc (UnifyRules::expect_fnptr): add unify rules Signed-off-by: Philip Herron <herron.philip@googlemail.com>
2025-08-05gccrs: Fix silly ordering bug in trait reference resolutionPhilip Herron3-3/+18
Ensure proper ordering when resolving trait references to prevent incorrect type resolution in certain contexts. gcc/rust/ChangeLog: * typecheck/rust-hir-trait-reference.cc (TraitReference::on_resolved): ensure associated types are done first * typecheck/rust-hir-type-check-type.cc: Update call site. gcc/testsuite/ChangeLog: * rust/compile/silly-order-bug.rs: New test. Signed-off-by: Philip Herron <herron.philip@googlemail.com>
2025-08-05gccrs: Fix bug with bad type bindings not looking at super traitsPhilip Herron2-7/+28
When resolving type bounds, we need to examine super traits to properly determine if type bindings are valid in the current context. gcc/rust/ChangeLog: * typecheck/rust-tyty-bounds.cc: Check super traits for type bindings. * typecheck/rust-tyty.h: Add helper methods for bound checking.
2025-08-05gccrs: Refactor marker builtin trait assemblyPhilip Herron2-5/+11
Rename assemble_sized_builtin to assemble_marker_builtins and reorganize the type matching to properly handle function pointers and closures with their associated traits (Fn, FnMut, FnOnce). gcc/rust/ChangeLog: * typecheck/rust-hir-type-bounds.h: Rename method. * typecheck/rust-tyty-bounds.cc: Refactor marker trait assembly and add proper Fn trait handling for function types.
2025-08-05gccrs: Cleanup and refactor method resolutionPhilip Herron2-91/+127
Refactor the dot operator implementation to improve code organization and maintainability while preserving existing functionality. gcc/rust/ChangeLog: * typecheck/rust-hir-dot-operator.cc: Major refactoring and cleanup. * typecheck/rust-hir-dot-operator.h: Add new helper methods.
2025-08-05gccrs: Fix cyclical projection to placeholderPhilip Herron1-0/+16
Prevent infinite loops when projecting associated types by properly handling cyclical references with placeholder types. gcc/rust/ChangeLog: * typecheck/rust-hir-trait-resolve.cc: Add cyclical projection protection.
2025-08-05gccrs: Ensure we look at the bounds behind a referencePhilip Herron2-7/+33
When type checking expressions that involve references, we need to examine the bounds of the referenced type to properly resolve traits and methods. gcc/rust/ChangeLog: * typecheck/rust-hir-type-check-expr.cc: Look at bounds behind references. * typecheck/rust-hir-type-check-expr.h: Add helper method.
2025-08-05gccrs: Move AST desugaring into expansion phaseOwen Avery2-8/+14
This fixes some issues with name resolution 2.0. gcc/rust/ChangeLog: * rust-session-manager.cc (Session::compile_crate): Move AST desugaring to... (Session::expansion): ...here and add a final TopLevel pass afterwards. gcc/testsuite/ChangeLog: * rust/compile/nr2/exclude: Remove entries. Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
2025-08-05gccrs: Add test case showing RPIT working to close issuePhilip Herron1-0/+35
Fixes Rust-GCC#1486 gcc/testsuite/ChangeLog: * rust/execute/torture/issue-1481.rs: New test. Signed-off-by: Philip Herron <herron.philip@googlemail.com>
2025-08-05gccrs: Fix ICE when constant is missing and expressionPhilip Herron8-4/+27
This is an invalid test case and doesnt work with rustc, we dont fully pick up the errors. Nr2 does handle this and puts out an extra good diagnostic but the old NR doesnt so for now i added this to the exclude list and then when we remove old name resolver this issue goes away. Fixes Rust-GCC#3642 gcc/rust/ChangeLog: * hir/rust-ast-lower-item.cc (ASTLoweringItem::visit): check for has_expr * hir/rust-hir-dump.cc (Dump::visit): likewise * hir/tree/rust-hir-item.h: add has_expr helper * resolve/rust-ast-resolve-item.cc (ResolveItem::visit): check for has_expr * resolve/rust-ast-resolve-stmt.h: likewise * typecheck/rust-hir-type-check-stmt.cc (TypeCheckStmt::visit): likewise gcc/testsuite/ChangeLog: * rust/compile/nr2/exclude: nr2 puts out an extra error * rust/compile/issue-3642.rs: New test. Signed-off-by: Philip Herron <herron.philip@googlemail.com>
2025-08-05gccrs: Adjust external crate lowering and type checkingOwen Avery5-9/+40
The 2.0 name resolver is provided through ImmutableNameResolutionContext after it is done being mutated. The typechecker attempts to use ImmutableNameResolutionContext, so it needs to be run after ImmutableNameResolutionContext has been initialized (after all name resolution has been completed). Additionally, although I haven't seen any issues with lowering AST to HIR before name resolution 2.0 is complete, it makes sense to perform all lowering in lockstep as well. gcc/rust/ChangeLog: * hir/rust-ast-lower-item.cc (ASTLoweringItem::visit): Add visitor for ExternCrate. * hir/rust-ast-lower-item.h (ASTLoweringItem::visit): Likewise. * rust-session-manager.cc (Session::load_extern_crate): Avoid lowering or type resolving external crates here. * typecheck/rust-hir-type-check-item.cc (TypeCheckItem::visit): Add visitor for ExternCrate. * typecheck/rust-hir-type-check-item.h (TypeCheckItem::visit): Replace empty definition with a declaration. Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
2025-08-05gccrs: Fix execute testsuiteOwen Avery3-1/+35
Our non-torture execute tests haven't actually been running. gcc/testsuite/ChangeLog: * rust/execute/black_box.rs: Return 0 from main. * rust/execute/match-identifierpattern-enum.rs: Move to... * rust/execute/xfail/match-identifierpattern-enum.rs: ...here. * rust/execute/execute.exp: New file. Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
2025-08-05gccrs: Fix issues around PartialEq Eq Ord Partial OrdPhilip Herron11-5/+2758
There is still an issue with derive on PartialOrd but this adds good tests and fixes a bug we had handling the default Rhs = Self generic type param substitutions on the comparison traits. gcc/rust/ChangeLog: * typecheck/rust-tyty.cc (ParamType::handle_substitions): make this consistent gcc/testsuite/ChangeLog: * rust/compile/bug-with-default-generic.rs: New test. * rust/execute/torture/partial-eq-1.rs: New test. * rust/execute/torture/partial-eq-2.rs: New test. * rust/execute/torture/partial-eq-3.rs: New test. * rust/execute/torture/partial-eq-4.rs: New test. * rust/execute/torture/partial-ord-1.rs: New test. * rust/execute/torture/partial-ord-2.rs: New test. * rust/execute/torture/partial-ord-3.rs: New test. * rust/execute/torture/partial-ord-4.rs: New test. * rust/execute/torture/partial-ord-5.rs: New test. Signed-off-by: Philip Herron <herron.philip@googlemail.com>
2025-08-05gccrs: nr2.0: Update IdentifierPattern's subpattern name resolutionZhi Heng1-4/+1
gcc/rust/ChangeLog: * resolve/rust-late-name-resolver-2.0.cc (Late::visit(IdentifierPattern)): Remove redundant subpattern check. Signed-off-by: Yap Zhi Heng <yapzhhg@gmail.com>
2025-08-05gccrs: Implement compilation of IdentifierPattern's subpattern bindingsZhi Heng3-0/+33
gcc/rust/ChangeLog: * backend/rust-compile-pattern.cc: Add support for IdentifierPattern's subpattern under CompilePatternBindings. Signed-off-by: Yap Zhi Heng <yapzhhg@gmail.com>
2025-08-05gccrs: Implement name resolution for IdentifierPattern's subpatternZhi Heng2-0/+10
gcc/rust/ChangeLog: * resolve/rust-ast-resolve-pattern.cc: Implement name resolution for IdentifierPattern's subpattern. * resolve/rust-late-name-resolver-2.0.cc: Ditto, but for nr2. Signed-off-by: Yap Zhi Heng <yapzhhg@gmail.com>
2025-08-05gccrs: Rename get_pattern_to_bind to get_subpatternZhi Heng5-6/+5
gcc/rust/ChangeLog: * ast/rust-ast-collector.cc: Rename get_pattern_to_bind to get_subpattern * ast/rust-ast-visitor.cc: Ditto. * ast/rust-pattern.h: Ditto. * expand/rust-cfg-strip.cc: Ditto. * hir/rust-ast-lower-pattern.cc: Ditto. Signed-off-by: Yap Zhi Heng <yapzhhg@gmail.com>
2025-08-05gccrs: nr2.0: Adjust lookup of associated itemsOwen Avery3-6/+34
gcc/rust/ChangeLog: * resolve/rust-default-resolver.cc (DefaultResolver::visit): Adjust scoping of trait definitions and their generic parameters. * resolve/rust-forever-stack.hxx (ForeverStack::get): Prevent lookups inside TraitOrImpl ribs. (ForeverStack::resolve_segments): Prevent lookups of the first segment inside TraitOrImpl ribs. gcc/testsuite/ChangeLog: * rust/compile/nr2/exclude: Remove entries. Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
2025-08-05gccrs: Improve HIR dumps for patternsZhi Heng1-2/+2
gcc/rust/ChangeLog: * hir/rust-hir-dump.cc: Change pattern dumps to use visit_field. Signed-off-by: Yap Zhi Heng <yapzhhg@gmail.com>
2025-08-05gccrs: chore: Fix formattingArthur Cohen1-3/+6
gcc/rust/ChangeLog: * expand/rust-derive.cc: Fix formatting after fork update.