aboutsummaryrefslogtreecommitdiff
path: root/gcc
AgeCommit message (Collapse)AuthorFilesLines
2025-02-26session-manager: Call into DesugarQuestionMarkArthur Cohen1-0/+2
gcc/rust/ChangeLog: * rust-session-manager.cc (Session::compile_crate): Call DesugarQuestionMark::go().
2025-02-26lower: Error out when lowering ErrorPropagationExprArthur Cohen4-197/+188
Adapt functions for lowering nodes that should never reach the lowering phase to cause an unreachable, and mark them as final so as it not possible to override them in other visitors. gcc/rust/ChangeLog: * hir/rust-ast-lower-base.cc: Adapt functions for ErrorPropagationExpr and MacroInvocation. * hir/rust-ast-lower-base.h: Mark them as final. * hir/rust-ast-lower-expr.cc: Remove previous definition for those overrides. * hir/rust-ast-lower-expr.h: Likewise.
2025-02-26ast: Add base for desugaring try expressionsArthur Cohen4-0/+331
gcc/rust/ChangeLog: * Make-lang.in: Compile it. * ast/rust-desugar-question-mark.cc: New file. * ast/rust-desugar-question-mark.h: New file. gcc/testsuite/ChangeLog: * rust/compile/try-expr1.rs: New test.
2025-02-25Adjust unknown macro error messageOwen Avery6-7/+7
gcc/rust/ChangeLog: * resolve/rust-early-name-resolver-2.0.cc (Early::visit): Adjust error produced when macro resolution fails. * resolve/rust-early-name-resolver.cc (EarlyNameResolver::visit): Likewise. gcc/testsuite/ChangeLog: * rust/compile/macros/mbe/macro43.rs: Adjust expected errors. * rust/compile/macros/mbe/macro44.rs: Likewise. * rust/compile/nested_macro_use2.rs: Likewise. * rust/compile/nr2/exclude: Remove entries. Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
2025-02-25nr2.0: Handle lang item type path segmentsOwen Avery4-5/+66
gcc/rust/ChangeLog: * resolve/rust-forever-stack.hxx (ForeverStack::find_starting_point): Stop when hitting a lang item segment. (ForeverStack::resolve_segments): Resolve lang item segments. (ForeverStacl::resolve_path): Handle single segment lang item paths and add comment. * util/rust-unwrap-segment.cc (unwrap_segment_get_lang_item): Add. * util/rust-unwrap-segment.h (unwrap_segment_get_lang_item): Add. gcc/testsuite/ChangeLog: * rust/compile/nr2/exclude: Remove entries. Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
2025-02-25expansion: Expand generic args in generic type path segmentsArthur Cohen2-1/+22
gcc/rust/ChangeLog: * expand/rust-expand-visitor.cc (ExpandVisitor::visit): Correctly visit the generic args of a generic type path segment. gcc/testsuite/ChangeLog: * rust/compile/issue-2015.rs: New test.
2025-02-25name-resolution: early: Remove overzealous overridesArthur Cohen2-30/+1
Some empty overrides were incorrectly being set-up instead of using the correct behavior from DefaultASTVisitor. gcc/rust/ChangeLog: * resolve/rust-early-name-resolver.cc: Remove definitions. * resolve/rust-early-name-resolver.h: Remove declarations.
2025-02-25lower: Always crash when lowering macro invocationsArthur Cohen1-3/+8
gcc/rust/ChangeLog: * hir/rust-ast-lower-base.cc (ASTLoweringBase::visit): Add base implementation for visitor.
2025-02-25nr2.0: Implement macro_use for modulesOwen Avery2-5/+16
gcc/rust/ChangeLog: * resolve/rust-early-name-resolver-2.0.cc: Include rust-attribute-values.h. (Early::visit): If a module has a macro_use attribute, avoid pushing a new textual macro scope. gcc/testsuite/ChangeLog: * rust/compile/nr2/exclude: Remove entries. Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
2025-02-25Adjust type path resolution error messageOwen Avery10-23/+17
gcc/rust/ChangeLog: * resolve/rust-ast-resolve-type.cc (ResolveRelativeTypePath::go): Adjust error message to match the 2.0 name resolver. gcc/testsuite/ChangeLog: * rust/compile/additional-trait-bounds2.rs: Adjust expected errors. * rust/compile/const_generics_4.rs: Likewise. * rust/compile/const_generics_7.rs: Likewise. * rust/compile/generic-default1.rs: Likewise. * rust/compile/generics5.rs: Likewise. * rust/compile/generics9.rs: Likewise. * rust/compile/issue-2423.rs: Likewise. * rust/compile/method2.rs: Likewise. * rust/compile/nr2/exclude: Remove entries. Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
2025-02-25hir-dump: Fix more segfaults in the HIR dumpArthur Cohen2-3/+25
gcc/rust/ChangeLog: * hir/rust-hir-dump.cc: Check unique_ptr members are present before visiting them. * hir/tree/rust-hir-path.h: Add `has_{type, trait}` methods to QualifiedPathInType.
2025-02-24derive(Hash): Add implementation.Arthur Cohen6-9/+460
gcc/rust/ChangeLog: * Make-lang.in: Compile it. * expand/rust-derive.cc (DeriveVisitor::derive): Call it. * expand/rust-derive-hash.cc: New file. * expand/rust-derive-hash.h: New file. gcc/testsuite/ChangeLog: * rust/compile/derive-hash1.rs: New test. * rust/compile/nr2/exclude: Add testcase to exclusion list.
2025-02-24derive(Debug): Use builder's ptrify function insteadArthur Cohen1-8/+0
gcc/rust/ChangeLog: * expand/rust-derive-debug.cc (ptrify): Remove function.
2025-02-24ast: builder: Add new builder methodsArthur Cohen2-7/+56
gcc/rust/ChangeLog: * ast/rust-ast-builder.cc (Builder::statementify): New. (Builder::function): Add generic params optional argument. (Builder::path_in_expression): Add opening_scope_resolution optional argument. (Builder::block): Add function for creating empty blocks. (Builder::generic_type_param): New. * ast/rust-ast-builder.h (ptrify): New.
2025-02-24Remove some member functions from SingleASTNodeOwen Avery2-20/+4
gcc/rust/ChangeLog: * ast/rust-ast.h (SingleASTNode::take_trait_item): Remove. (SingleASTNode::take_impl_item): Remove. (SingleASTNode::take_trait_impl_item): Remove. * expand/rust-expand-visitor.cc (ExpandVisitor::visit): Replace calls to aforementioned functions with calls to SingleASTNode::take_assoc_item. Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
2025-02-23Fix expansion of macros inside modulesOwen Avery3-0/+18
gcc/rust/ChangeLog: * expand/rust-expand-visitor.cc (ExpandVisitor::visit): Override DefaultASTVisitor in order to expand a module's items, rather than directly visit them. * expand/rust-expand-visitor.h (ExpandVisitor::visit): Add override. gcc/testsuite/ChangeLog: * rust/compile/macros/mbe/macro-expand-module.rs: New test. Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
2025-02-23Remove PathInExpression::get_pattern_node_idOwen Avery1-2/+0
gcc/rust/ChangeLog: * ast/rust-path.h (PathInExpression::get_pattern_node_id): Remove. Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
2025-02-20derive(Eq): Create copies of Eq typepath to avoid NodeId confusionArthur Cohen1-1/+5
gcc/rust/ChangeLog: * expand/rust-derive-eq.cc: Copy `Eq` typepath.
2025-02-20derive(Eq): Also derive StructuralEqArthur Cohen3-37/+43
gcc/rust/ChangeLog: * expand/rust-derive-eq.cc: Adapt functions to return two generated impls. * expand/rust-derive-eq.h: Likewise. * expand/rust-derive.cc (DeriveVisitor::derive): Likewise.
2025-02-20derive(PartialEq): Also derive StructuralPartialEqArthur Cohen6-23/+44
gcc/rust/ChangeLog: * expand/rust-derive-partial-eq.cc: Adapt signatures to generate two impls. * expand/rust-derive-partial-eq.h: Likewise. * expand/rust-derive.cc (DeriveVisitor::derive): Adapt to multiple item generation. gcc/testsuite/ChangeLog: * rust/compile/derive-eq-invalid.rs: Declare StructuralPartialEq. * rust/compile/derive-partialeq1.rs: Likewise. * rust/execute/torture/derive-partialeq1.rs: Likewise.
2025-02-20expand: Allow built-in derives to generate multiple itemsArthur Cohen3-15/+22
gcc/rust/ChangeLog: * expand/rust-derive.cc (DeriveVisitor::derive): Return a vector of items. * expand/rust-derive.h: Change return type. * expand/rust-expand-visitor.cc: Insert all generated items into the AST.
2025-02-20derive(PartialEq): Add partial implementationArthur Cohen8-4/+519
We are still missing some deriving for enums, as part of our codegen and nameres for rebinding struct field patterns is missing. gcc/rust/ChangeLog: * expand/rust-derive-partial-eq.cc: New file. * expand/rust-derive-partial-eq.h: New file. * expand/rust-derive.cc (DeriveVisitor::derive): Call them. * Make-lang.in: Compile them. gcc/testsuite/ChangeLog: * rust/compile/derive-eq-invalid.rs: Mark PartialEq def as a lang item. * rust/compile/derive-partialeq1.rs: New test. * rust/execute/torture/derive-partialeq1.rs: New test. * rust/compile/nr2/exclude: Exclude all of them.
2025-02-20derive(Clone): chore: CleanupArthur Cohen2-25/+17
gcc/rust/ChangeLog: * expand/rust-derive-clone.cc: Cleanup implementation, avoid repetitions. * expand/rust-derive-clone.h: Likewise.
2025-02-20ast-builder: Add new methods for creating operator expressionsArthur Cohen2-0/+66
gcc/rust/ChangeLog: * ast/rust-ast-builder.cc (Builder::literal_bool): New method. (Builder::comparison_expr): Likewise. (Builder::boolean_operation): Likewise. * ast/rust-ast-builder.h: Declare them.
2025-02-20ast-builder: Improve function generation.Arthur Cohen2-17/+17
gcc/rust/ChangeLog: * ast/rust-ast-builder.cc (Builder::block): Change return type. (Builder::loop): Use new APIs. * ast/rust-ast-builder.h: Change return type of block functions.
2025-02-20derive(Eq): Add implementation.Arthur Cohen5-0/+337
gcc/rust/ChangeLog: * expand/rust-derive.cc (DeriveVisitor::derive): Call into DeriveEq. * expand/rust-derive-eq.cc: New file. * expand/rust-derive-eq.h: New file. * Make-lang.in: Compile them. gcc/testsuite/ChangeLog: * rust/compile/derive-eq-invalid.rs: New test.
2025-02-19nr2.0: Run DefaultResolver::visit on PathInExpressionOwen Avery2-11/+2
gcc/rust/ChangeLog: * resolve/rust-late-name-resolver-2.0.cc (Late::visit): When visiting a PathInExpression instance, call into DefaultResolver::visit, ensuring generic arguments are visited. gcc/testsuite/ChangeLog: * rust/compile/nr2/exclude: Remove entries. Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
2025-02-19nr2.0: Fix issue with external cratesOwen Avery2-4/+10
gcc/rust/ChangeLog: * resolve/rust-toplevel-name-resolver-2.0.cc (TopLevel::visit): When visiting an external crate declaration, handle failed crate name lookups. This can happen when Session::load_extern_crate fails to load a crate during the CfgStrip phase. gcc/testsuite/ChangeLog: * rust/compile/nr2/exclude: Remove entries. Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
2025-02-19Add comments to resolve_segmentsOwen Avery1-0/+11
gcc/rust/ChangeLog: * resolve/rust-forever-stack.hxx (ForeverStack::resolve_segments): Add comments explaining the behaviour of a while loop. Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
2025-02-17Add type check on if-exprBenjamin Thos4-5/+27
Check if an if-expr returns void type or a coercible type like an early return. gcc/rust/ChangeLog: * typecheck/rust-hir-type-check-expr.cc (TypeCheckExpr::visit): Add check on if-expr. gcc/testsuite/ChangeLog: * rust/compile/implicit_returns_err3.rs: Change test to be valid. * rust/compile/torture/if.rs: Likewise. * rust/compile/if-without-else.rs: New test. Signed-off-by: Benjamin Thos <benjamin.thos@epita.fr>
2025-02-17nr2.0: Resolve paths which start with SelfOwen Avery3-64/+56
gcc/rust/ChangeLog: * resolve/rust-forever-stack.hxx (ForeverStack::find_starting_point): Be more careful about applying ForeverStack::find_closest_module. (ForeverStack::resolve_segments): Allow traversal into parent nodes when not in a module node or root node, which ForeverStack::find_starting_point previously made moot through use of ForeverStack::find_closest_module. Also, when a child node lookup fails when resolving in the type namespace, attempt a rib lookup as a fallback. * resolve/rust-late-name-resolver-2.0.cc (Late::visit): Avoid throwing a resolution error for type paths when the typechecker may be able to finish the resolution. Also, throw an error when a resolution is ambiguous. gcc/testsuite/ChangeLog: * rust/compile/nr2/exclude: Remove entries. Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
2025-02-16gccrs: initial setup for new OpaqueType to represent Impl typesPhilip Herron18-14/+372
This completes the initial setup and boilerplate for the new type in the typesystem. This is not functional yet but its a big patch already. gcc/rust/ChangeLog: * backend/rust-compile-type.cc (TyTyResolveCompile::visit): new tyty::OpaqueType * backend/rust-compile-type.h: likewise * checks/errors/borrowck/rust-bir-fact-collector.h: likewise * checks/errors/borrowck/rust-bir-place.h: likewise * checks/errors/privacy/rust-privacy-reporter.cc (PrivacyReporter::check_base_type_privacy): likewise * typecheck/rust-hir-type-check-type.cc (TypeCheckType::visit): likewise * typecheck/rust-hir-type-check-type.h: likewise * typecheck/rust-substitution-mapper.cc (SubstMapperInternal::visit): likewise * typecheck/rust-substitution-mapper.h: likewise * typecheck/rust-tyty-bounds.cc (TypeBoundsProbe::assemble_sized_builtin): likewise * typecheck/rust-tyty-call.h: likewise * typecheck/rust-tyty-cmp.h (class OpaqueCmp): likewise * typecheck/rust-tyty-variance-analysis-private.h: likewise * typecheck/rust-tyty-visitor.h: likewise * typecheck/rust-tyty.cc (TypeKindFormat::to_string): likewise (BaseType::is_unit): likewise (BaseType::destructure): likewise (BaseType::has_substitutions_defined): likewise (BaseType::needs_generic_substitutions): likewise (OpaqueType::OpaqueType): likewise (OpaqueType::can_resolve): likewise (OpaqueType::accept_vis): likewise (OpaqueType::as_string): likewise (OpaqueType::get_name): likewise (OpaqueType::can_eq): likewise (OpaqueType::clone): likewise (OpaqueType::resolve): likewise (OpaqueType::is_equal): likewise (OpaqueType::handle_substitions): likewise * typecheck/rust-tyty.h (enum TypeKind): likewise (class OpaqueType): likewise * typecheck/rust-unify.cc (UnifyRules::go): likewise (UnifyRules::expect_inference_variable): likewise (UnifyRules::expect_adt): likewise (UnifyRules::expect_str): likewise (UnifyRules::expect_reference): likewise (UnifyRules::expect_pointer): likewise (UnifyRules::expect_param): likewise (UnifyRules::expect_array): likewise (UnifyRules::expect_slice): likewise (UnifyRules::expect_fndef): likewise (UnifyRules::expect_fnptr): likewise (UnifyRules::expect_tuple): likewise (UnifyRules::expect_bool): likewise (UnifyRules::expect_char): likewise (UnifyRules::expect_int): likewise (UnifyRules::expect_uint): likewise (UnifyRules::expect_float): likewise (UnifyRules::expect_isize): likewise (UnifyRules::expect_usize): likewise (UnifyRules::expect_placeholder): likewise (UnifyRules::expect_projection): likewise (UnifyRules::expect_dyn): likewise (UnifyRules::expect_opaque): likewise * typecheck/rust-unify.h: likewise Signed-off-by: Philip Herron <herron.philip@googlemail.com>
2025-02-15gccrs: Add name resolution and HIR lowering for ImplTraitType'sPhilip Herron19-135/+103
Our AST has ImplTraitType for multiple bounds and a singular ImplTraitTypeOneBound, this patch desugars these into a simple HIR::ImplTraitType. It also does the name resolution for this. gcc/rust/ChangeLog: * checks/errors/borrowck/rust-bir-builder-struct.h: remove HIR::ImplTraitTypeOneBound * checks/errors/borrowck/rust-function-collector.h: likewise * checks/errors/rust-const-checker.cc (ConstChecker::visit): likewise * checks/errors/rust-const-checker.h: likewise * checks/errors/rust-hir-pattern-analysis.cc (PatternChecker::visit): likewise * checks/errors/rust-hir-pattern-analysis.h: likewise * checks/errors/rust-unsafe-checker.cc (UnsafeChecker::visit): likewise * checks/errors/rust-unsafe-checker.h: likewise * hir/rust-ast-lower-type.cc (ASTLoweringType::translate): likewise (ASTLoweringType::visit): likewise * hir/rust-ast-lower-type.h: cleanup * hir/rust-hir-dump.cc (Dump::visit): remove ImplTraitTypeOneBound * hir/rust-hir-dump.h: likewise * hir/tree/rust-hir-full-decls.h (class ImplTraitTypeOneBound): likewise * hir/tree/rust-hir-type.h (class ImplTraitTypeOneBound): likewise * hir/tree/rust-hir-visitor.h: likewise * hir/tree/rust-hir.cc (ImplTraitTypeOneBound::as_string): likewise (ImplTraitTypeOneBound::accept_vis): likewise * resolve/rust-ast-resolve-type.cc (ResolveType::go): likewise (ResolveType::visit): likewise * resolve/rust-ast-resolve-type.h: add name resolution * typecheck/rust-hir-type-check-type.h: likewise Signed-off-by: Philip Herron <herron.philip@googlemail.com>
2025-02-14gccrs: improve error diagnostic for bad type-resolution in CallExprPhilip Herron6-8/+19
We have the type information for the resolved call lets tell the user about it in the diagnostic and apply the correct error code. Fixes Rust-GCC#2035 gcc/rust/ChangeLog: * typecheck/rust-hir-type-check-expr.cc (TypeCheckExpr::visit): improve error diag gcc/testsuite/ChangeLog: * rust/compile/generics4.rs: cleanup * rust/compile/generics6.rs: likewise * rust/compile/type-bindings1.rs: likewise * rust/compile/unconstrained_type_param.rs: likewise * rust/compile/issue-2035.rs: New test. Signed-off-by: Philip Herron <herron.philip@googlemail.com>
2025-02-13gccrs: self paths are patterns but we dont have mappings for itPhilip Herron3-1/+23
With simple patterns we dont introduce any more inference varaibles as they are already declared in a specific way. This would only lead to more unconstrained inference varaibles than is required. Fixes Rust-GCC#3022 gcc/rust/ChangeLog: * hir/rust-ast-lower-base.cc (ASTLoweringBase::lower_self): add location mappings * typecheck/rust-hir-type-check-path.cc (TypeCheckExpr::resolve_root_path): check for self gcc/testsuite/ChangeLog: * rust/compile/issue-3022.rs: New test. Signed-off-by: Philip Herron <herron.philip@googlemail.com>
2025-02-13gccrs: fix name resolution for generics where type param is declared laterPhilip Herron3-75/+86
Rust allows you to use generics within type bounds when they are declared later on. This changes the name resolution to walk the genric params in two passes to ensure the type parameters are setup before drilling down into the type parameters This issue has exposed another type checking issue which needs fixed in a subseqent patch. Addresses Rust-GCC#3022 gcc/rust/ChangeLog: * resolve/rust-ast-resolve-item.cc (ResolveTraitItems::visit): use new api (ResolveItem::visit): likewise (ResolveExternItem::visit): likewise * resolve/rust-ast-resolve-stmt.h: likewise * resolve/rust-ast-resolve-type.h (class ResolveGenericParam): remove (class ResolveGenericParams): added new api Signed-off-by: Philip Herron <herron.philip@googlemail.com>
2025-02-13gccrs: fix unconstrained generics check to handle recursive genericsPhilip Herron4-18/+82
Generics can be constrained within other generic types so this check needs to be recursive. Fixes Rust-GCC#3031 gcc/rust/ChangeLog: * typecheck/rust-hir-type-check-base.cc (walk_types_to_constrain): recursive walker * typecheck/rust-tyty.cc (BaseType::get_subst_argument_mappings): new helper * typecheck/rust-tyty.h: prototype gcc/testsuite/ChangeLog: * rust/compile/issue-3031.rs: New test. Signed-off-by: Philip Herron <herron.philip@googlemail.com>
2025-02-12gccrs: add diagnostic for E0229 no associated type arguments allowed herePhilip Herron4-4/+43
It seems bounds in qualified paths are not allowed to specify associated type bindings because its going to be associated with the impl block anyway. Fixes Rust-GCC#2369 gcc/rust/ChangeLog: * typecheck/rust-hir-type-check-base.h: add flag * typecheck/rust-hir-type-check-type.cc (TypeCheckType::visit): likewise * typecheck/rust-tyty-bounds.cc: new diagnostic gcc/testsuite/ChangeLog: * rust/compile/issue-2369.rs: New test. Signed-off-by: Philip Herron <herron.philip@googlemail.com>
2025-02-12gccrs: remove name resolution inserts from type-pathPhilip Herron2-135/+16
We resolve path segments and inserted their resolution into the name resolution space which was an old hack to use this as information in code-gen/check-passes in order to help things move forward but this is not nessecary gcc/rust/ChangeLog: * typecheck/rust-hir-type-check-type.cc (TypeCheckType::visit): remove name resolution info (TypeCheckType::resolve_root_path): likewise * typecheck/rust-hir-type-check-type.h: likewise Signed-off-by: Philip Herron <herron.philip@googlemail.com>
2025-02-11gccrs: enum type layout needs to respect the enum repr typePhilip Herron2-14/+5
Addresses Rust-GCC#3352 gcc/rust/ChangeLog: * backend/rust-compile-type.cc (TyTyResolveCompile::get_implicit_enumeral_node_type): use repr (TyTyResolveCompile::visit): update prototype * backend/rust-compile-type.h: likewise Signed-off-by: Philip Herron <herron.philip@googlemail.com>
2025-02-11gccrs: add variant_count intrinsicPhilip Herron2-1/+80
Addresses Rust-GCC#3348 gcc/rust/ChangeLog: * backend/rust-compile-intrinsic.cc (variant_count_handler): new intrinsic gcc/testsuite/ChangeLog: * rust/execute/torture/enum_intrinsics2.rs: New test. Signed-off-by: Philip Herron <herron.philip@googlemail.com>
2025-02-11gccrs: add discriminant value intrinsicPhilip Herron11-62/+235
This is pretty nasty piece of rust in my opinion the return type of this intrinsic results into a lang item associated type: <T as DiscriminantKind>::Discriminant This is a special case which needs to support mapping onto the repr type of the associated ADT that is passed in, but defaults to iszie otherwise. This patch assumes we only come accross this case in a HIR::CALL_EXPR, so and makes assumutions that its always of this function signiture. I will do some checking in libcore to verify that assumption. More work is needed to parse the repr type on enums but the code is there to support this when its in to change the types etc. Addresses Rust-GCC#3348 gcc/rust/ChangeLog: * backend/rust-compile-intrinsic.cc (discriminant_value_handler): new handler * typecheck/rust-hir-trait-resolve.cc (TraitItemReference::resolve_item): track the defid * typecheck/rust-hir-type-check-base.cc (TypeCheckBase::parse_repr_options): default isize * typecheck/rust-hir-type-check-expr.cc (TypeCheckExpr::visit): special case CallExpr * typecheck/rust-hir-type-check-item.cc (TypeCheckItem::visit): parse repr options enum * typecheck/rust-hir-type-check-type.cc (TypeCheckType::visit): remove bad diagnostic * typecheck/rust-tyty.cc (PlaceholderType::PlaceholderType): track defid (PlaceholderType::clone): likewise (PlaceholderType::get_def_id): likeiwse * typecheck/rust-tyty.h: placeholder track defid * util/rust-lang-item.cc: add new lang items * util/rust-lang-item.h: likewise gcc/testsuite/ChangeLog: * rust/execute/torture/enum_intrinsics1.rs: New test. Signed-off-by: Philip Herron <herron.philip@googlemail.com>
2025-02-08Get rid of duplicate interface #3396GS-GOAT5-11/+4
gcc/rust/ChangeLog: * typecheck/rust-autoderef.cc (insert_implicit_type): Update single-parameter call to pass explicit HirId. * typecheck/rust-hir-type-check-expr.cc: Same. * typecheck/rust-hir-type-check-pattern.cc: Same. * typecheck/rust-hir-type-check.h: Removed call to the duplicate interface. * typecheck/rust-typecheck-context.cc (TypeCheckContext::insert_implicit_type): Removed the interface with no HirId field. Signed-off-by: Guransh Singh <guransh766@gmail.com>
2025-02-04gccrs: remove bad type checking diagnosticPhilip Herron3-20/+40
This was a bad diagnostic added when I was working on slices and iterators also the name of the function is also bad. This is all about setting up associated types based on the current context of the bounds assocated with the associated trait bounds on this function. The tell tale is that this didnt have an associated rust error code so this is most definetly not the correct error diagnostic. Fixes Rust-GCC#3403 gcc/rust/ChangeLog: * typecheck/rust-tyty-subst.cc (SubstitutionRef::monomorphize): remove diagnostic gcc/testsuite/ChangeLog: * rust/compile/nr2/exclude: nr2 cant handle this * rust/compile/issue-3403.rs: New test. Signed-off-by: Philip Herron <herron.philip@googlemail.com>
2025-02-04session manager: Call into DesugarForLoopsArthur Cohen1-0/+4
gcc/rust/ChangeLog: * rust-session-manager.cc (Session::compile_crate): Call the visitor.
2025-02-04ast: Add DesugarForLoop classArthur Cohen9-1/+2493
gcc/rust/ChangeLog: * ast/rust-desugar-for-loops.cc: New file. * ast/rust-desugar-for-loops.h: New file. * hir/rust-ast-lower-expr.cc (ASTLoweringExpr::visit): Make lowering of for-loops an unreachable. * Make-lang.in: Compile it. gcc/testsuite/ChangeLog: * rust/compile/for-loop1.rs: New test. * rust/compile/for-loop2.rs: New test. * rust/execute/torture/for-loop1.rs: New test. * rust/execute/torture/for-loop2.rs: New test. * rust/compile/nr2/exclude: Exclude for-loop1.rs
2025-02-04ast: builder: Fix arguments of Builder::letArthur Cohen2-5/+5
gcc/rust/ChangeLog: * ast/rust-ast-builder.h: Mark all arguments as &&. * ast/rust-ast-builder.cc (Builder::let): Likewise.
2025-02-04nr2.0: Resolve instances of TypePath more accuratelyOwen Avery7-36/+170
gcc/rust/ChangeLog: * util/rust-unwrap-segment.cc: New file. * util/rust-unwrap-segment.h: New file. * Make-lang.in: Add rust-unwrap-segment.o to the object list. * resolve/rust-forever-stack.hxx: Include rust-unwrap-segment.h. (ForeverStack::find_starting_point): Use unwrap_type_segment. (ForeverStack::resolve_segments): Likewise. (ForeverStack::resolve_path): Likewise. * resolve/rust-late-name-resolver-2.0.cc (Late::visit): Resolve type paths using NameResolutionContext::resolve_path. * resolve/rust-name-resolution-context.h (NameResolutionContext::resolve_path): Use unwrap_segment_node_id. gcc/testsuite/ChangeLog: * rust/compile/nr2/exclude: Remove entries. Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
2025-02-04inline-asm: Fix some warningsArthur Cohen2-7/+21
gcc/rust/ChangeLog: * expand/rust-macro-builtins-asm.cc (strip_double_quotes): Special case empty strings ("\"\""). (parse_reg_operand): Remove use of the `struct` keyword. (parse_reg_operand_in): Likewise. (parse_reg_operand_out): Likewise. * expand/rust-macro-builtins.cc: Add llvm_asm! built-in macro as an alias to asm!.
2025-02-04Add warning about default visitor usagePierre-Emmanuel Patry1-0/+4
We already lost some time on this unusual pattern, a comment will hopefully prevent this from happening again. gcc/rust/ChangeLog: * resolve/rust-toplevel-name-resolver-2.0.cc (TopLevel::visit): Add warning about current code. Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>