]> git.ipfire.org Git - thirdparty/gcc.git/log
thirdparty/gcc.git
6 days agosccp: Fix ICE during folding after proping const in some cases [PR122497]
Andrew Pinski [Fri, 31 Oct 2025 00:46:54 +0000 (17:46 -0700)] 
sccp: Fix ICE during folding after proping const in some cases [PR122497]

In this case we originally had:
```
  # g_4.3_21 = PHI <g_4.3_12(3)>
  _1 = g_4.3_21 + 2;
  _2 = g_2[_1][g_4.3_21];
```

SCCP figures out g_4.3_12/g_4.3_21 is 1.
final_value_replacement_loop would remove the phi defining _12.
do the constant prop of the const 1 but that would ICE as we try
to fold the reference `g_2[_1][g_4.3_21]` but that would try to see
the range of `_1` but since `_1` refers back to _21 there would be an
ICE as the phi is already been removed.

The obvious fix is to move the constant prop until after the new statement
for _21 is created.

This fixes the change done by r14-6010-g2dde9f326ded84 and r14-6114-gde0ab339a79535.

This does not fix gcc.dg/graphite/pr82819.c nor tr2/dynamic_bitset/pr92059.cc though;
I will look into those issues in a few.

Pushed as obvious after bootstrap/test.

PR tree-optimization/122497

gcc/ChangeLog:

* tree-scalar-evolution.cc (final_value_replacement_loop): Call replace_uses_by
only after the replacement statement was created.

gcc/testsuite/ChangeLog:

* gcc.dg/torture/pr122497-1.c: New test.

Signed-off-by: Andrew Pinski <andrew.pinski@oss.qualcomm.com>
6 days agoLoongArch: Remove the "-mlasx" compilation option from the test cases.
Lulu Cheng [Thu, 6 Mar 2025 08:28:08 +0000 (16:28 +0800)] 
LoongArch: Remove the "-mlasx" compilation option from the test cases.

Because LoongArch previously lacked support for 128-bit vectors
(vec_widen_{add/sub/mult}_{hi/lo}), the following test cases
needed to be enabled for 256-bit vectors to pass.
Now that 128-bit support has been added, "-mlasx" has been removed.

gcc/testsuite/ChangeLog:

* gcc.dg/vect/slp-widen-mult-half.c: Remove '-mlasx'.
* gcc.dg/vect/tree-vect.h: Check whether the runtime
environment supports LSX instructions.
* gcc.dg/vect/vect-widen-mult-const-s16.c: Dito.
* gcc.dg/vect/vect-widen-mult-const-u16.c: Dito.
* gcc.dg/vect/vect-widen-mult-half-u8.c: Dito.
* gcc.dg/vect/vect-widen-mult-half.c: Dito.
* gcc.dg/vect/vect-widen-mult-u16.c: Dito.
* gcc.dg/vect/vect-widen-mult-u8-s16-s32.c: Dito.
* gcc.dg/vect/vect-widen-mult-u8-u32.c: Dito.
* gcc.dg/vect/vect-widen-mult-u8.c: Dito.

6 days agoLoongArch: Support vec_widen_[s]{add/sub/mult}_{hi/lo}_{v4si/v8si}.
Lulu Cheng [Thu, 6 Mar 2025 06:33:14 +0000 (14:33 +0800)] 
LoongArch: Support vec_widen_[s]{add/sub/mult}_{hi/lo}_{v4si/v8si}.

gcc/ChangeLog:

* config/loongarch/lasx.md: Support.
* config/loongarch/loongarch.cc
(loongarch_expand_vec_widen_hilo): Remove unused code.
* config/loongarch/lsx.md: Support.

6 days agoLoongArch: Implement the vector dot product operation with quadruple width.
Lulu Cheng [Thu, 23 Oct 2025 09:14:19 +0000 (17:14 +0800)] 
LoongArch: Implement the vector dot product operation with quadruple width.

The logic for the vector dot product operation, where the destination
elements are quadruple the width of the source elements, is as
follows (Take sdot_prodv4siv16qi as an example.):

v16i8 src1, src2;
v4i32 src3, dest;

dest[0] = src1[0] * src2[0] + src1[1] * src2[1]
  + src1[2] * src2[2] + src1[3] * src2[3]
  + src3[0]
dest[1] = src1[4] * src2[4] + src1[5] * src2[5]
  + src1[6] * src2[6] + src1[7] * src2[7]
  + src3[1]
dest[2] = src1[8] * src2[8] + src1[9] * src2[9]
  + src1[10] * src2[10] + src1[11] * src2[11]
  + src3[2]
dest[3] = src1[12] * src2[12] + src1[13] * src2[13]
  + src1[14] * src2[14] + src1[15] * src2[15]
  + src3[3]

gcc/ChangeLog:

* config/loongarch/lasx.md (ILASX_HB): Move to ...
* config/loongarch/lsx.md (ILSX_HB): Move to ...
* config/loongarch/simd.md (ILSX_HB): ... here.
(ILASX_HB): ... here.
(IVEC_HB): New iterator.
(WVEC_QUARTER): New attr.
(wvec_quarter): Likewise.
(simdfmt_qw): Likewise.
(<su>dot_prod<wvec_quarter><mode>): New template.

6 days agoLoongArch: Implement vec_widen_<su>{add/sub/mult}_{hi/lo}_{v16qi/v8hi}.
Lulu Cheng [Wed, 5 Mar 2025 09:25:23 +0000 (17:25 +0800)] 
LoongArch: Implement vec_widen_<su>{add/sub/mult}_{hi/lo}_{v16qi/v8hi}.

This patch will cause gcc.dg/vect/bb-slp-35.c test to fail.

gcc/ChangeLog:

* config/loongarch/lasx.md (hi_lo): Move to ...
* config/loongarch/simd.md (hi_lo): ... here.
* config/loongarch/loongarch.cc
(loongarch_expand_vec_widen_hilo): Add 128-bit data processing.
* config/loongarch/lsx.md
(vec_widen_<su><optab>_<hi_lo>_<mode>): New define_expand.
(vec_widen_<su>mult_<hi_lo>_<mode>): Likewise.

6 days agoLoongArch: Simplify vec_widen_<su>{add/sub/mult}_{hi/lo}_m describe.
Lulu Cheng [Tue, 4 Mar 2025 01:49:53 +0000 (09:49 +0800)] 
LoongArch: Simplify vec_widen_<su>{add/sub/mult}_{hi/lo}_m describe.

gcc/ChangeLog:

* config/loongarch/lasx.md (vec_widen_<su>add_hi_<mode>):
Move.
(vec_widen_<su>add_lo_<mode>): Move.
(vec_widen_<su>sub_hi_<mode>): Move.
(vec_widen_<su>sub_lo_<mode>): Move.
(vec_widen_<su>mult_hi_<mode>): Move.
(vec_widen_<su>mult_lo_<mode>): Move.
(hi_lo): New define_int_attr.
(vec_widen_<su><optab>_<hi_lo>_<mode>): New define_expand.
(vec_widen_<su>mult_<hi_lo>_<mode>): Likewise.
* config/loongarch/loongarch-protos.h
(loongarch_expand_vec_widen_hilo): Modify the function
parameter list.
* config/loongarch/loongarch.cc
(loongarch_expand_vec_widen_hilo): Optimized.

6 days agoDaily bump.
GCC Administrator [Fri, 31 Oct 2025 00:22:18 +0000 (00:22 +0000)] 
Daily bump.

7 days agoc++: Fix up and tweak std-name-hint.gperf
Jakub Jelinek [Thu, 30 Oct 2025 21:37:33 +0000 (22:37 +0100)] 
c++: Fix up and tweak std-name-hint.gperf

When converting reflection metafunction evaluation into gperf, I had
a look at the other *.gperf files in gcc/cp/.
cfns.gperf doesn't have any hash conflicts, but std-name-hint.gperf
has 7, which I believe means that for 7 of the strings it falls back to some
slow loop over not sure how many entries.

Apparently, 2 out of the 7 conflicts are just because two lines are
identically duplicated in the file, the patch included below fixes that.

2025-10-30  Jakub Jelinek  <jakub@redhat.com>

* std-name-hint.gperf: Remove duplicate entries for ispanstream
and istringstream.
* std-name-hint.h: Regenerate.

7 days agogccrs: Improve ErrorPropagationExpr handling
Owen Avery [Thu, 2 Oct 2025 22:21:46 +0000 (18:21 -0400)] 
gccrs: Improve ErrorPropagationExpr handling

gcc/rust/ChangeLog:

* ast/rust-ast-pointer-visitor.cc (PointerVisitor::visit):
Handle the expression contained in an ErrorPropagationExpr.
* ast/rust-ast-visitor.cc (DefaultASTVisitor::visit): Likewise.

Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
7 days agogccrs: Attempt to resolve pattern items in tuple pattern with a rest pattern
Yap Zhi Heng [Sat, 18 Oct 2025 05:22:05 +0000 (13:22 +0800)] 
gccrs: Attempt to resolve pattern items in tuple pattern with a rest pattern

gcc/rust/ChangeLog:

* typecheck/rust-hir-type-check-pattern.cc (visit(TuplePattern)): Update HAS_REST
case to continue to attempt to resolve pattern items after emitting size error.

Signed-off-by: Yap Zhi Heng <yapzhhg@gmail.com>
7 days agogccrs: Fix ICE on enum in tuple struct pattern
Ryo Yoshida [Sun, 19 Oct 2025 13:45:17 +0000 (22:45 +0900)] 
gccrs: Fix ICE on enum in tuple struct pattern

When we typecheck a tuple struct pattern and the type of its path is
an enum, it may refer to the enum itself and not a variant. Emit an
E0532 error on such cases.

Fixes Rust-GCC/gccrs#3917
Fixes Rust-GCC/gccrs#3918
Fixes Rust-GCC/gccrs#3926

gcc/rust/ChangeLog:

* typecheck/rust-hir-type-check-pattern.cc (TypeCheckPattern::visit): Emit
an error when the path refers to an enum itself rather than its variant.

gcc/testsuite/ChangeLog:

* rust/compile/match-tuplestructpattern-non-variant.rs: New test.

Signed-off-by: Ryo Yoshida <low.ryoshida@gmail.com>
7 days agogccrs: Fix ICE for repr attribute malformation
Yap Zhi Heng [Sat, 18 Oct 2025 04:42:32 +0000 (12:42 +0800)] 
gccrs: Fix ICE for repr attribute malformation

gcc/rust/ChangeLog:

* typecheck/rust-hir-type-check-base.cc (parse_repr_options): Changed TOKEN_TREE
assert into error, update malformed repr attribute error message to be inline
with other attribute error messages.

Signed-off-by: Yap Zhi Heng <yapzhhg@gmail.com>
7 days agogccrs: fix inner attr derive doesn't show error
Lucas Ly Ba [Wed, 15 Oct 2025 15:28:36 +0000 (15:28 +0000)] 
gccrs: fix inner attr derive doesn't show error

gcc/rust/ChangeLog:

* ast/rust-ast.cc (Attribute::is_derive):
Change string derive to its definition.
* util/rust-attribute-values.h:
Add attribute definition derive.
* util/rust-attributes.cc (AttributeChecker::visit):
Add method check_inner_attributes.
(AttributeChecker::check_inner_attributes):
Check if there is a bad inner attribute.
* util/rust-attributes.h:
Add method check_inner_attributes in .h.

gcc/testsuite/ChangeLog:

* rust/compile/issue-4212.rs: New test.

Signed-off-by: Lucas Ly Ba <lucas.ly-ba@outlook.fr>
7 days agogccrs: fix ICE in TyVar constructor
lishin [Sat, 27 Sep 2025 01:10:42 +0000 (02:10 +0100)] 
gccrs: fix ICE in TyVar constructor

gcc/rust/ChangeLog:

* typecheck/rust-tyty-util.cc (TyVar::TyVar): Add null check to avoid ICE.
(TyVar::get_tyty): Return nullptr when lookup fails.
(TyVar::clone): Handle null base type safely.
(TyVar::monomorphized_clone): Add fallback for error types.

gcc/testsuite/ChangeLog:

* rust/compile/issue-3556.rs: New test.

Signed-off-by: lishin <lishin1008@gmail.com>
7 days agogccrs: Emit error when tuple-indexing on non-tuples
Ryo Yoshida [Sun, 12 Oct 2025 10:25:41 +0000 (19:25 +0900)] 
gccrs: Emit error when tuple-indexing on non-tuples

Fixes Rust-GCC#3927

gcc/rust/ChangeLog:

* typecheck/rust-hir-type-check-expr.cc (TypeCheckExpr::visit): check
and properly emit an error when the tuple index is on a non-tuple-struct.

gcc/testsuite/ChangeLog:

* rust/compile/tuple_index_on_non_tuple.rs: New test.

Signed-off-by: Ryo Yoshida <low.ryoshida@gmail.com>
7 days agogccrs: Refactor TyTy::ConstType into separate types
Philip Herron [Sat, 4 Oct 2025 20:53:40 +0000 (21:53 +0100)] 
gccrs: Refactor TyTy::ConstType into separate types

This patch refactors the const generic type system to follow the same pattern
as regular type parameters. The monolithic ConstType is split into four
distinct types:

  ConstParamType (generic parameter placeholder)
  ConstValueType (resolved constant value)
  ConstInferType (inference variable)
  ConstErrorType (error sentinel)

gcc/rust/ChangeLog:

* backend/rust-compile-expr.cc (CompileExpr::array_copied_expr): refactor to new classes
* backend/rust-compile-pattern.cc (CompilePatternCheckExpr::visit): likewise
(CompilePatternBindings::visit): likewise
* backend/rust-compile-type.cc (TyTyResolveCompile::visit): likewise
* backend/rust-compile-type.h: likewise
* typecheck/rust-hir-type-check-base.cc (TypeCheckBase::resolve_literal): likewise
* typecheck/rust-hir-type-check-expr.cc (TypeCheckExpr::visit): likewise
* typecheck/rust-hir-type-check-pattern.cc (TypeCheckPattern::visit): likewise
* typecheck/rust-hir-type-check-type.cc (TypeCheckType::visit): likewise
* typecheck/rust-substitution-mapper.cc (SubstMapperInternal::visit): likewise
* typecheck/rust-substitution-mapper.h: likewise
* typecheck/rust-type-util.cc (unify_site_and): remove bad delete (alpine32)
* typecheck/rust-tyty-call.h: refactor to new classes
* typecheck/rust-tyty-subst.cc (SubstitutionParamMapping::clone): likewise
(SubstitutionRef::infer_substitions): likewise
* typecheck/rust-tyty-util.cc (TyVar::get_implicit_const_infer_var): likewise
* typecheck/rust-tyty-util.h: likewise
* typecheck/rust-tyty-variance-analysis-private.h: likewise
* typecheck/rust-tyty-visitor.h: likewise
* typecheck/rust-tyty.cc (BaseType::destructure): likewise
(BaseType::monomorphized_clone): likewise
(BaseType::is_concrete): likewise
(VariantDef::clone): likewise
(VariantDef::monomorphized_clone): likewise
(ArrayType::as_string): likewise
(ArrayType::get_capacity): likewise
(ArrayType::handle_substitions): likewise
(generate_tree_str): likewise
(ConstType::ConstType): likewise
(ConstParamType::ConstParamType): likewise
(ConstType::accept_vis): likewise
(ConstParamType::const_kind): likewise
(ConstParamType::get_symbol): likewise
(ConstParamType::can_resolve): likewise
(ConstParamType::resolve): likewise
(ConstParamType::accept_vis): likewise
(ConstType::set_value): likewise
(ConstType::as_string): likewise
(ConstParamType::as_string): likewise
(ConstType::clone): likewise
(ConstParamType::clone): likewise
(ConstType::get_symbol): likewise
(ConstParamType::get_name): likewise
(ConstType::can_resolve): likewise
(ConstParamType::is_equal): likewise
(ConstType::resolve): likewise
(ConstValueType::ConstValueType): likewise
(ConstValueType::const_kind): likewise
(ConstValueType::accept_vis): likewise
(ConstValueType::as_string): likewise
(ConstValueType::clone): likewise
(ConstValueType::get_name): likewise
(ConstValueType::is_equal): likewise
(ConstValueType::get_value): likewise
(ConstInferType::ConstInferType): likewise
(ConstInferType::const_kind): likewise
(ConstInferType::accept_vis): likewise
(ConstType::get_name): likewise
(ConstInferType::as_string): likewise
(ConstInferType::clone): likewise
(ConstInferType::get_name): likewise
(ConstType::is_equal): likewise
(ConstInferType::is_equal): likewise
(ConstErrorType::ConstErrorType): likewise
(ConstErrorType::const_kind): likewise
(ConstType::handle_substitions): likewise
(ConstErrorType::accept_vis): likewise
(ConstErrorType::as_string): likewise
(ConstErrorType::clone): likewise
(ConstErrorType::get_name): likewise
(ConstErrorType::is_equal): likewise
* typecheck/rust-tyty.h (class BaseConstType): likewise
(class ConstType): likewise
(class ConstParamType): likewise
(class ConstValueType): likewise
(class ConstInferType): likewise
(class ConstErrorType): likewise
* typecheck/rust-unify.cc (UnifyRules::commit): likewise
(UnifyRules::go): likewise
(UnifyRules::expect_array): likewise
(UnifyRules::expect_const): likewise
* typecheck/rust-unify.h: likewise

Signed-off-by: Philip Herron <herron.philip@googlemail.com>
7 days agogccrs: test: add a regression test for issue Rust-GCC/gccrs#4145
0xllx0 [Tue, 30 Sep 2025 15:17:24 +0000 (15:17 +0000)] 
gccrs: test: add a regression test for issue Rust-GCC/gccrs#4145

gcc/testsuite/ChangeLog:

* rust/compile/issue-4145.rs: New test.

Signed-off-by: Elle Rhumsaa <elle@weathered-steel.dev>
7 days agogccrs: fix: add early return for empty module file
0xllx0 [Fri, 3 Oct 2025 03:17:54 +0000 (03:17 +0000)] 
gccrs: fix: add early return for empty module file

Converts an assert into an early return during AST parsing.

Resolves: Rust-GCC/gccrs#4145

gcc/rust/ChangeLog:

* ast/rust-ast.cc (Module::process_file_path): empty module early return

Signed-off-by: Elle Rhumsaa <elle@weathered-steel.dev>
7 days agogccrs: Add doc attribute checking on traits
Pierre-Emmanuel Patry [Wed, 1 Oct 2025 15:56:00 +0000 (17:56 +0200)] 
gccrs: Add doc attribute checking on traits

Doc attribute checking was not performed on traits.

gcc/rust/ChangeLog:

* util/rust-attributes.cc (check_doc_attribute): Change message.
(AttributeChecker::visit): Add doc attribute checking on traits.

gcc/testsuite/ChangeLog:

* rust/compile/attr_malformed_doc.rs: New test.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
7 days agogccrs: Avoid malformed attribute conversion
Pierre-Emmanuel Patry [Wed, 1 Oct 2025 14:35:37 +0000 (16:35 +0200)] 
gccrs: Avoid malformed attribute conversion

Add location for malformed attribute errors and avoid processing of
malformed attributes.

gcc/rust/ChangeLog:

* ast/rust-ast.cc (AttrInputMetaItemContainer::separate_cfg_attrs):
Avoid malformed attributes.
* util/rust-attributes.cc (AttributeChecker::visit): Change location.

gcc/testsuite/ChangeLog:

* rust/compile/attr_malformed_path.rs: New test.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
7 days agogccrs: Force crash when retrieving meta item location
Pierre-Emmanuel Patry [Wed, 1 Oct 2025 14:26:47 +0000 (16:26 +0200)] 
gccrs: Force crash when retrieving meta item location

We still don't know which location should be preferred over the other,
this means that nobody should rely on this function's return value.

gcc/rust/ChangeLog:

* ast/rust-expr.h: Force crash when retrieving locus.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
7 days agogccrs: Add override modifier
Pierre-Emmanuel Patry [Wed, 1 Oct 2025 14:24:18 +0000 (16:24 +0200)] 
gccrs: Add override modifier

gcc/rust/ChangeLog:

* ast/rust-ast.h: Add missing override modifier.
* ast/rust-path.h: Likewise.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
7 days agogccrs: Emit an error on malformed path
Pierre-Emmanuel Patry [Wed, 1 Oct 2025 10:36:45 +0000 (12:36 +0200)] 
gccrs: Emit an error on malformed path

Path must be made of a single literal item, otherwise an error should be
thrown.

gcc/rust/ChangeLog:

* util/rust-attributes.cc (AttributeChecker::check_attribute): Recurse
within attr input for additional attribute checking.
(AttributeChecker::visit): Remove empty definition in favor of default
ast visitor definition.
* util/rust-attributes.h: Remove now unused prototypes.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
7 days agogccrs: Use rich_location for TupleStructPattern type check num field error
Yap Zhi Heng [Tue, 2 Sep 2025 13:44:19 +0000 (21:44 +0800)] 
gccrs: Use rich_location for TupleStructPattern type check num field error

gcc/rust/ChangeLog:

* typecheck/rust-hir-type-check-pattern.cc (visit(TupleStructPattern)):
Update error for mismatched number of fields to use rich_location.

Signed-off-by: Yap Zhi Heng <yapzhhg@gmail.com>
7 days agogccrs: Implement compilation support for HIR::TupleStructItemsHasRest
Yap Zhi Heng [Mon, 25 Aug 2025 12:33:43 +0000 (20:33 +0800)] 
gccrs: Implement compilation support for HIR::TupleStructItemsHasRest

gcc/rust/ChangeLog:

* backend/rust-compile-pattern.cc: Add compilation support for TupleStructItemsHasRest
in CompilePatternCheckExpr(TupleStructPattern) & CompilePatternBindings(TupleStructPattern)

Signed-off-by: Yap Zhi Heng <yapzhhg@gmail.com>
7 days agogccrs: Implement lowering of AST::TupleStructItemsHasRest
Yap Zhi Heng [Mon, 25 Aug 2025 12:16:09 +0000 (20:16 +0800)] 
gccrs: Implement lowering of AST::TupleStructItemsHasRest

gcc/rust/ChangeLog:

* hir/rust-ast-lower-pattern.cc (ASTLoweringPattern::visit(TupleStructPattern)):
Implement lowering of AST::TupleStructItemsHasRest to HIR.
* typecheck/rust-hir-type-check-pattern.cc (TypeCheckPattern::visit(TupleStructPattern)):
Add the respective type checking for AST::TupleStructItemsHasRest
* checks/errors/rust-hir-pattern-analysis.cc (lower_tuple_pattern):
Add respective pattern for HAS_REST case.

Signed-off-by: Yap Zhi Heng <yapzhhg@gmail.com>
7 days agogccrs: tests: added extra parens compile test
0xllx0 [Tue, 30 Sep 2025 05:29:10 +0000 (05:29 +0000)] 
gccrs: tests: added extra parens compile test

Adds a test to verify extra parentheses are discarded, and the source is
compiled as expected.

Resolves: Rust-GCC/gccrs#2886

gcc/testsuite/ChangeLog:

* rust/compile/issue-4148.rs: New test.

Signed-off-by: Elle Rhumsaa <elle@weathered-steel.dev>
7 days agogccrs: Test libcore
Owen Avery [Wed, 17 Sep 2025 03:10:04 +0000 (23:10 -0400)] 
gccrs: Test libcore

This adds compilation of libcore up to the AST validation phase to the
testsuite.

gcc/testsuite/ChangeLog:

* rust/core/core.exp: New test.

Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
7 days agogccrs: Fix StructPattern type checking rejecting tuple struct scrutinee
Yap Zhi Heng [Sun, 28 Sep 2025 11:11:31 +0000 (19:11 +0800)] 
gccrs: Fix StructPattern type checking rejecting tuple struct scrutinee

Previously, type checking of StructPattern will throw an error if it is used
to match against a tuple struct, even though it is possible to do so in rustc.

gcc/rust/ChangeLog:

* typecheck/rust-hir-type-check-pattern.cc (visit(StructPattern)): Add type check
support for StructPatterns matching against a TUPLE type ADT.
* backend/rust-compile-pattern.cc(CompilePatternBindings::visit(StructPattern)):
Update assert to allow TUPLE type ADTs.
* hir/tree/rust-hir.cc (StructPatternField::as_string()): Improve info dumped.

Signed-off-by: Yap Zhi Heng <yapzhhg@gmail.com>
7 days agogccrs: Add HIR lowering support for rest pattern in struct patterns' AST
Yap Zhi Heng [Mon, 22 Sep 2025 13:29:41 +0000 (21:29 +0800)] 
gccrs: Add HIR lowering support for rest pattern in struct patterns' AST

gcc/rust/ChangeLog:

* ast/rust-pattern.h (StructPatternElements): Rename has_struct_pattern_etc
to has_rest_pattern, and has_etc to has_rest to signify presense of rest
patterns more clearly.
* ast/rust-pattern.cc (StructPatternElements::as_string): Rename variables
accordingly.
* ast/rust-ast-collector.cc: Rename variables accordingly.
* expand/rust-cfg-strip.cc: Rename variables accordingly.
* parse/rust-parse-impl.h: Rename variable accordingly.
* hir/tree/rust-hir-pattern.h (StructPatternElements): Add a boolean to track
presense of rest pattern.
* hir/rust-ast-lower-pattern.cc (visit(StructPattern)): Add support for
lowering rest pattern to HIR.
* typecheck/rust-hir-type-check-pattern.cc (visit(StructPattern)): Remove
size check when rest pattern is present.

Signed-off-by: Yap Zhi Heng <yapzhhg@gmail.com>
7 days agogccrs: Handle link_name attribute
Owen Avery [Sun, 14 Sep 2025 20:57:49 +0000 (16:57 -0400)] 
gccrs: Handle link_name attribute

gcc/rust/ChangeLog:

* backend/rust-compile-extern.h: Add includes.
(CompileExternItem::visit): Use get_link_name.
(CompileExternItem::get_link_name): New static member function.
* util/rust-attribute-values.h (Attributes::LINK_NAME): New
static constexpr member variable.
* util/rust-attributes.cc (__definitions): New entry for
LINK_NAME.
* util/rust-ggc.cc: Include "rust-ast.h".
(Ident::Ident): Add overload for Rust::Identifier.
* util/rust-ggc.h (class Identifier): Forward declare.
(Ident::Ident): Add overload for Rust::Identifier.

gcc/testsuite/ChangeLog:

* rust/execute/torture/link-name.rs: New test.

Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
7 days agogccrs: expand: Inherit from PointerVisitor
Arthur Cohen [Fri, 22 Aug 2025 09:48:49 +0000 (11:48 +0200)] 
gccrs: expand: Inherit from PointerVisitor

gcc/rust/ChangeLog:

* expand/rust-expand-visitor.cc: Remove old visitors.
* expand/rust-expand-visitor.h: Likewise, plus inherit from PointerVisitor.

7 days agogccrs: Add origin location to expanded tokens
Pierre-Emmanuel Patry [Thu, 18 Sep 2025 15:47:54 +0000 (17:47 +0200)] 
gccrs: Add origin location to expanded tokens

gcc/rust/ChangeLog:

* expand/rust-macro-expand.cc: Forward invocation tree locus to
substitution context.
* expand/rust-macro-substitute-ctx.cc: Use origin location for expanded
tokens.
* expand/rust-macro-substitute-ctx.h (class SubstituteCtx): Save
invocation location.

gcc/testsuite/ChangeLog:

* rust/compile/macros/mbe/macro58.rs: New test.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
7 days agogccrs: Emit errors from the transcriber when they occur
Pierre-Emmanuel Patry [Thu, 18 Sep 2025 14:57:15 +0000 (16:57 +0200)] 
gccrs: Emit errors from the transcriber when they occur

Emitting the errors later means some error could be emitted multiple
times.

gcc/rust/ChangeLog:

* expand/rust-macro-expand.cc (transcribe_expression): Emit error
early.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
7 days agogccrs: Prevent segfault on builtin metavars
Pierre-Emmanuel Patry [Thu, 18 Sep 2025 14:08:30 +0000 (16:08 +0200)] 
gccrs: Prevent segfault on builtin metavars

Builtin metavars are not in the fragment, the compiler should not emit
an error message.

gcc/rust/ChangeLog:

* expand/rust-macro-substitute-ctx.cc (is_builtin_metavariable): Add
function to check builtin metavars knowledge.
(SubstituteCtx::check_repetition_amount): Do not process missing
fragment.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
7 days agogccrs: Fix ICE where we expect a num enum variant
Philip Herron [Mon, 22 Sep 2025 19:29:28 +0000 (20:29 +0100)] 
gccrs: Fix ICE where we expect a num enum variant

This changes the assertion into a valid error diagnostic.

Fixes Rust-GCC#3538

gcc/rust/ChangeLog:

* backend/rust-compile-resolve-path.cc: add error diag

gcc/testsuite/ChangeLog:

* rust/compile/issue-3538.rs: New test.

Signed-off-by: Philip Herron <herron.philip@googlemail.com>
7 days agogccrs: Add error diag for self params on plain functions
Philip Herron [Mon, 22 Sep 2025 10:09:56 +0000 (11:09 +0100)] 
gccrs: Add error diag for self params on plain functions

self params dont have a type unless used within impl blocks. Rustc as far as I
can tell in this senario generics a synthetic param of type Self in this senario
so that it keeps consistent error diagnostic for number of parameters but the
logic for what the parameter typpe should be seems unclear.

Fixes Rust-GCC#3592

gcc/rust/ChangeLog:

* hir/rust-ast-lower-item.cc (ASTLoweringItem::visit): add error diagnostic

gcc/testsuite/ChangeLog:

* rust/compile/issue-3592.rs: New test.

Signed-off-by: Philip Herron <herron.philip@googlemail.com>
7 days agogccrs: Fix ICE on copied array expressions
Philip Herron [Sun, 21 Sep 2025 17:56:55 +0000 (18:56 +0100)] 
gccrs: Fix ICE on copied array expressions

We need to check for errors on the number of copies expression before
trying to const fold it otherwise it will just fail in the const evaluator.

Fixes Rust-GCC#4165

gcc/rust/ChangeLog:

* typecheck/rust-hir-type-check-expr.cc (TypeCheckExpr::visit): check for error

gcc/testsuite/ChangeLog:

* rust/compile/issue-4165.rs: New test.

Signed-off-by: Philip Herron <herron.philip@googlemail.com>
7 days agogccrs: Remove old hack from resolve operator overload
Philip Herron [Wed, 3 Sep 2025 09:21:06 +0000 (10:21 +0100)] 
gccrs: Remove old hack from resolve operator overload

This was an old chunk of code to try and sort out the Self type on resolving
methods for impl blocks. But this is not required when our unify code works
properly.

gcc/rust/ChangeLog:

* typecheck/rust-hir-type-check-expr.cc: remove old hack

Signed-off-by: Philip Herron <herron.philip@googlemail.com>
7 days agogccrs: fnptr types can hold onto generic params so it needs to handle substs
Philip Herron [Wed, 3 Sep 2025 11:27:36 +0000 (12:27 +0100)] 
gccrs: fnptr types can hold onto generic params so it needs to handle substs

This patch adds support to recursively walk fnptr types to do generic
substitutions.

Fixes Rust-GCC/gccrs#4090

gcc/rust/ChangeLog:

* typecheck/rust-substitution-mapper.cc (SubstMapperInternal::visit): handle fnptr
* typecheck/rust-tyty.cc (FnPtr::handle_substitions): new
* typecheck/rust-tyty.h: likewise

gcc/testsuite/ChangeLog:

* rust/compile/issue-4090-1.rs: New test.
* rust/compile/issue-4090-2.rs: New test.

Signed-off-by: Philip Herron <herron.philip@googlemail.com>
7 days agogccrs: Improve FFIOpt
Owen Avery [Tue, 16 Sep 2025 23:31:39 +0000 (19:31 -0400)] 
gccrs: Improve FFIOpt

Also fixes https://github.com/Rust-GCC/gccrs/issues/4171.

gcc/rust/ChangeLog:

* ast/rust-fmt.h (class FFIOpt): Adjust internal structure to
match a repr(C) rust enum.

libgrust/ChangeLog:

* libformat_parser/src/lib.rs (struct FFIOpt): Likewise and
remove some now-redundant methods.

Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
7 days agogccrs: Implement TokenCollector::visit(AST::FormatArgs&)
Magnus-Mage [Sun, 7 Sep 2025 15:40:20 +0000 (21:10 +0530)] 
gccrs: Implement TokenCollector::visit(AST::FormatArgs&)

This allows visiting format_args! during token collection.

gcc/rust/ChangeLog:

* ast/rust-ast-collector.cc (TokenCollector::visit): Implement
FormatArgs visitor to reconstruct format_args! macro syntax.
* ast/rust-builtin-ast-nodes.h (FormatArguments): Add get_args(),
size(), and empty() accessor methods.

Signed-off-by: Magnus-Mage <romescha123@gmail.com>
7 days agogccrs: Fix ICE for invalid const capacity expression handling
Philip Herron [Wed, 17 Sep 2025 13:24:38 +0000 (14:24 +0100)] 
gccrs: Fix ICE for invalid const capacity expression handling

When we have an invalid capacity expression we can't try to then also
const fold it as GCC will assert on invalid conversions.

Fixes Rust-GCC#4168

gcc/rust/ChangeLog:

* typecheck/rust-hir-type-check-type.cc (TypeCheckType::visit): check for invalid capacity

gcc/testsuite/ChangeLog:

* rust/compile/issue-4168.rs: New test.

Signed-off-by: Philip Herron <herron.philip@googlemail.com>
7 days agogccrs: Import stdarch 1.49.0
Owen Avery [Wed, 17 Sep 2025 02:34:57 +0000 (22:34 -0400)] 
gccrs: Import stdarch 1.49.0

This commit imports stdarch 1.49.0 into libgrust/rustc-lib/stdarch. This
is necessary for compiling libcore, as libcore attempts to reuse some
files from stdarch.

libgrust/ChangeLog:

* rustc-lib/stdarch/.cirrus.yml: New file.
* rustc-lib/stdarch/.github/workflows/main.yml: New file.
* rustc-lib/stdarch/.gitignore: New file.
* rustc-lib/stdarch/CONTRIBUTING.md: New file.
* rustc-lib/stdarch/Cargo.toml: New file.
* rustc-lib/stdarch/LICENSE-APACHE: New file.
* rustc-lib/stdarch/LICENSE-MIT: New file.
* rustc-lib/stdarch/README.md: New file.
* rustc-lib/stdarch/ci/android-install-ndk.sh: New file.
* rustc-lib/stdarch/ci/android-install-sdk.sh: New file.
* rustc-lib/stdarch/ci/android-sysimage.sh: New file.
* rustc-lib/stdarch/ci/docker/aarch64-linux-android/Dockerfile: New file.
* rustc-lib/stdarch/ci/docker/aarch64-unknown-linux-gnu/Dockerfile: New file.
* rustc-lib/stdarch/ci/docker/arm-linux-androideabi/Dockerfile: New file.
* rustc-lib/stdarch/ci/docker/arm-unknown-linux-gnueabihf/Dockerfile: New file.
* rustc-lib/stdarch/ci/docker/armv7-unknown-linux-gnueabihf/Dockerfile: New file.
* rustc-lib/stdarch/ci/docker/i586-unknown-linux-gnu/Dockerfile: New file.
* rustc-lib/stdarch/ci/docker/i686-unknown-linux-gnu/Dockerfile: New file.
* rustc-lib/stdarch/ci/docker/mips-unknown-linux-gnu/Dockerfile: New file.
* rustc-lib/stdarch/ci/docker/mips64-unknown-linux-gnuabi64/Dockerfile: New file.
* rustc-lib/stdarch/ci/docker/mips64el-unknown-linux-gnuabi64/Dockerfile: New file.
* rustc-lib/stdarch/ci/docker/mipsel-unknown-linux-musl/Dockerfile: New file.
* rustc-lib/stdarch/ci/docker/nvptx64-nvidia-cuda/Dockerfile: New file.
* rustc-lib/stdarch/ci/docker/powerpc-unknown-linux-gnu/Dockerfile: New file.
* rustc-lib/stdarch/ci/docker/powerpc64-unknown-linux-gnu/Dockerfile: New file.
* rustc-lib/stdarch/ci/docker/powerpc64le-unknown-linux-gnu/Dockerfile: New file.
* rustc-lib/stdarch/ci/docker/s390x-unknown-linux-gnu/Dockerfile: New file.
* rustc-lib/stdarch/ci/docker/wasm32-wasi/Dockerfile: New file.
* rustc-lib/stdarch/ci/docker/x86_64-linux-android/Dockerfile: New file.
* rustc-lib/stdarch/ci/docker/x86_64-unknown-linux-gnu-emulated/Dockerfile: New file.
* rustc-lib/stdarch/ci/docker/x86_64-unknown-linux-gnu/Dockerfile: New file.
* rustc-lib/stdarch/ci/dox.sh: New file.
* rustc-lib/stdarch/ci/gba.json: New file.
* rustc-lib/stdarch/ci/run-docker.sh: New file.
* rustc-lib/stdarch/ci/run.sh: New file.
* rustc-lib/stdarch/ci/runtest-android.rs: New file.
* rustc-lib/stdarch/ci/style.sh: New file.
* rustc-lib/stdarch/crates/assert-instr-macro/Cargo.toml: New file.
* rustc-lib/stdarch/crates/assert-instr-macro/build.rs: New file.
* rustc-lib/stdarch/crates/assert-instr-macro/src/lib.rs: New file.
* rustc-lib/stdarch/crates/core_arch/Cargo.toml: New file.
* rustc-lib/stdarch/crates/core_arch/LICENSE-APACHE: New file.
* rustc-lib/stdarch/crates/core_arch/LICENSE-MIT: New file.
* rustc-lib/stdarch/crates/core_arch/README.md: New file.
* rustc-lib/stdarch/crates/core_arch/avx512f.md: New file.
* rustc-lib/stdarch/crates/core_arch/build.rs: New file.
* rustc-lib/stdarch/crates/core_arch/rustfmt.toml: New file.
* rustc-lib/stdarch/crates/core_arch/src/aarch64/crc.rs: New file.
* rustc-lib/stdarch/crates/core_arch/src/aarch64/crypto.rs: New file.
* rustc-lib/stdarch/crates/core_arch/src/aarch64/mod.rs: New file.
* rustc-lib/stdarch/crates/core_arch/src/aarch64/neon/generated.rs: New file.
* rustc-lib/stdarch/crates/core_arch/src/aarch64/neon/mod.rs: New file.
* rustc-lib/stdarch/crates/core_arch/src/aarch64/prefetch.rs: New file.
* rustc-lib/stdarch/crates/core_arch/src/aarch64/test_support.rs: New file.
* rustc-lib/stdarch/crates/core_arch/src/aarch64/tme.rs: New file.
* rustc-lib/stdarch/crates/core_arch/src/aarch64/v8.rs: New file.
* rustc-lib/stdarch/crates/core_arch/src/acle/barrier/common.rs: New file.
* rustc-lib/stdarch/crates/core_arch/src/acle/barrier/cp15.rs: New file.
* rustc-lib/stdarch/crates/core_arch/src/acle/barrier/mod.rs: New file.
* rustc-lib/stdarch/crates/core_arch/src/acle/barrier/not_mclass.rs: New file.
* rustc-lib/stdarch/crates/core_arch/src/acle/barrier/v8.rs: New file.
* rustc-lib/stdarch/crates/core_arch/src/acle/dsp.rs: New file.
* rustc-lib/stdarch/crates/core_arch/src/acle/ex.rs: New file.
* rustc-lib/stdarch/crates/core_arch/src/acle/hints.rs: New file.
* rustc-lib/stdarch/crates/core_arch/src/acle/mod.rs: New file.
* rustc-lib/stdarch/crates/core_arch/src/acle/registers/aarch32.rs: New file.
* rustc-lib/stdarch/crates/core_arch/src/acle/registers/mod.rs: New file.
* rustc-lib/stdarch/crates/core_arch/src/acle/registers/v6m.rs: New file.
* rustc-lib/stdarch/crates/core_arch/src/acle/registers/v7m.rs: New file.
* rustc-lib/stdarch/crates/core_arch/src/acle/sat.rs: New file.
* rustc-lib/stdarch/crates/core_arch/src/acle/simd32.rs: New file.
* rustc-lib/stdarch/crates/core_arch/src/arm/armclang.rs: New file.
* rustc-lib/stdarch/crates/core_arch/src/arm/crc.rs: New file.
* rustc-lib/stdarch/crates/core_arch/src/arm/mod.rs: New file.
* rustc-lib/stdarch/crates/core_arch/src/arm/neon/generated.rs: New file.
* rustc-lib/stdarch/crates/core_arch/src/arm/neon/mod.rs: New file.
* rustc-lib/stdarch/crates/core_arch/src/arm/neon/table_lookup_tests.rs: New file.
* rustc-lib/stdarch/crates/core_arch/src/arm/test_support.rs: New file.
* rustc-lib/stdarch/crates/core_arch/src/arm/v6.rs: New file.
* rustc-lib/stdarch/crates/core_arch/src/arm/v7.rs: New file.
* rustc-lib/stdarch/crates/core_arch/src/core_arch_docs.md: New file.
* rustc-lib/stdarch/crates/core_arch/src/lib.rs: New file.
* rustc-lib/stdarch/crates/core_arch/src/macros.rs: New file.
* rustc-lib/stdarch/crates/core_arch/src/mips/mod.rs: New file.
* rustc-lib/stdarch/crates/core_arch/src/mips/msa.rs: New file.
* rustc-lib/stdarch/crates/core_arch/src/mips/msa/macros.rs: New file.
* rustc-lib/stdarch/crates/core_arch/src/mod.rs: New file.
* rustc-lib/stdarch/crates/core_arch/src/nvptx/mod.rs: New file.
* rustc-lib/stdarch/crates/core_arch/src/powerpc/altivec.rs: New file.
* rustc-lib/stdarch/crates/core_arch/src/powerpc/mod.rs: New file.
* rustc-lib/stdarch/crates/core_arch/src/powerpc/vsx.rs: New file.
* rustc-lib/stdarch/crates/core_arch/src/powerpc64/mod.rs: New file.
* rustc-lib/stdarch/crates/core_arch/src/simd.rs: New file.
* rustc-lib/stdarch/crates/core_arch/src/simd_llvm.rs: New file.
* rustc-lib/stdarch/crates/core_arch/src/v64.rs: New file.
* rustc-lib/stdarch/crates/core_arch/src/wasm32/atomic.rs: New file.
* rustc-lib/stdarch/crates/core_arch/src/wasm32/memory.rs: New file.
* rustc-lib/stdarch/crates/core_arch/src/wasm32/mod.rs: New file.
* rustc-lib/stdarch/crates/core_arch/src/wasm32/simd128.rs: New file.
* rustc-lib/stdarch/crates/core_arch/src/x86/abm.rs: New file.
* rustc-lib/stdarch/crates/core_arch/src/x86/adx.rs: New file.
* rustc-lib/stdarch/crates/core_arch/src/x86/aes.rs: New file.
* rustc-lib/stdarch/crates/core_arch/src/x86/avx.rs: New file.
* rustc-lib/stdarch/crates/core_arch/src/x86/avx2.rs: New file.
* rustc-lib/stdarch/crates/core_arch/src/x86/avx512f.rs: New file.
* rustc-lib/stdarch/crates/core_arch/src/x86/avx512ifma.rs: New file.
* rustc-lib/stdarch/crates/core_arch/src/x86/bmi1.rs: New file.
* rustc-lib/stdarch/crates/core_arch/src/x86/bmi2.rs: New file.
* rustc-lib/stdarch/crates/core_arch/src/x86/bswap.rs: New file.
* rustc-lib/stdarch/crates/core_arch/src/x86/bt.rs: New file.
* rustc-lib/stdarch/crates/core_arch/src/x86/cpuid.rs: New file.
* rustc-lib/stdarch/crates/core_arch/src/x86/eflags.rs: New file.
* rustc-lib/stdarch/crates/core_arch/src/x86/f16c.rs: New file.
* rustc-lib/stdarch/crates/core_arch/src/x86/fma.rs: New file.
* rustc-lib/stdarch/crates/core_arch/src/x86/fxsr.rs: New file.
* rustc-lib/stdarch/crates/core_arch/src/x86/macros.rs: New file.
* rustc-lib/stdarch/crates/core_arch/src/x86/mod.rs: New file.
* rustc-lib/stdarch/crates/core_arch/src/x86/pclmulqdq.rs: New file.
* rustc-lib/stdarch/crates/core_arch/src/x86/rdrand.rs: New file.
* rustc-lib/stdarch/crates/core_arch/src/x86/rdtsc.rs: New file.
* rustc-lib/stdarch/crates/core_arch/src/x86/rtm.rs: New file.
* rustc-lib/stdarch/crates/core_arch/src/x86/sha.rs: New file.
* rustc-lib/stdarch/crates/core_arch/src/x86/sse.rs: New file.
* rustc-lib/stdarch/crates/core_arch/src/x86/sse2.rs: New file.
* rustc-lib/stdarch/crates/core_arch/src/x86/sse3.rs: New file.
* rustc-lib/stdarch/crates/core_arch/src/x86/sse41.rs: New file.
* rustc-lib/stdarch/crates/core_arch/src/x86/sse42.rs: New file.
* rustc-lib/stdarch/crates/core_arch/src/x86/sse4a.rs: New file.
* rustc-lib/stdarch/crates/core_arch/src/x86/ssse3.rs: New file.
* rustc-lib/stdarch/crates/core_arch/src/x86/tbm.rs: New file.
* rustc-lib/stdarch/crates/core_arch/src/x86/test.rs: New file.
* rustc-lib/stdarch/crates/core_arch/src/x86/xsave.rs: New file.
* rustc-lib/stdarch/crates/core_arch/src/x86_64/abm.rs: New file.
* rustc-lib/stdarch/crates/core_arch/src/x86_64/adx.rs: New file.
* rustc-lib/stdarch/crates/core_arch/src/x86_64/avx.rs: New file.
* rustc-lib/stdarch/crates/core_arch/src/x86_64/avx2.rs: New file.
* rustc-lib/stdarch/crates/core_arch/src/x86_64/avx512f.rs: New file.
* rustc-lib/stdarch/crates/core_arch/src/x86_64/bmi.rs: New file.
* rustc-lib/stdarch/crates/core_arch/src/x86_64/bmi2.rs: New file.
* rustc-lib/stdarch/crates/core_arch/src/x86_64/bswap.rs: New file.
* rustc-lib/stdarch/crates/core_arch/src/x86_64/bt.rs: New file.
* rustc-lib/stdarch/crates/core_arch/src/x86_64/cmpxchg16b.rs: New file.
* rustc-lib/stdarch/crates/core_arch/src/x86_64/fxsr.rs: New file.
* rustc-lib/stdarch/crates/core_arch/src/x86_64/mod.rs: New file.
* rustc-lib/stdarch/crates/core_arch/src/x86_64/rdrand.rs: New file.
* rustc-lib/stdarch/crates/core_arch/src/x86_64/sse.rs: New file.
* rustc-lib/stdarch/crates/core_arch/src/x86_64/sse2.rs: New file.
* rustc-lib/stdarch/crates/core_arch/src/x86_64/sse41.rs: New file.
* rustc-lib/stdarch/crates/core_arch/src/x86_64/sse42.rs: New file.
* rustc-lib/stdarch/crates/core_arch/src/x86_64/xsave.rs: New file.
* rustc-lib/stdarch/crates/core_arch/tests/cpu-detection.rs: New file.
* rustc-lib/stdarch/crates/simd-test-macro/Cargo.toml: New file.
* rustc-lib/stdarch/crates/simd-test-macro/src/lib.rs: New file.
* rustc-lib/stdarch/crates/std_detect/Cargo.toml: New file.
* rustc-lib/stdarch/crates/std_detect/LICENSE-APACHE: New file.
* rustc-lib/stdarch/crates/std_detect/LICENSE-MIT: New file.
* rustc-lib/stdarch/crates/std_detect/README.md: New file.
* rustc-lib/stdarch/crates/std_detect/src/detect/arch/aarch64.rs: New file.
* rustc-lib/stdarch/crates/std_detect/src/detect/arch/arm.rs: New file.
* rustc-lib/stdarch/crates/std_detect/src/detect/arch/mips.rs: New file.
* rustc-lib/stdarch/crates/std_detect/src/detect/arch/mips64.rs: New file.
* rustc-lib/stdarch/crates/std_detect/src/detect/arch/powerpc.rs: New file.
* rustc-lib/stdarch/crates/std_detect/src/detect/arch/powerpc64.rs: New file.
* rustc-lib/stdarch/crates/std_detect/src/detect/arch/x86.rs: New file.
* rustc-lib/stdarch/crates/std_detect/src/detect/bit.rs: New file.
* rustc-lib/stdarch/crates/std_detect/src/detect/cache.rs: New file.
* rustc-lib/stdarch/crates/std_detect/src/detect/error_macros.rs: New file.
* rustc-lib/stdarch/crates/std_detect/src/detect/macros.rs: New file.
* rustc-lib/stdarch/crates/std_detect/src/detect/mod.rs: New file.
* rustc-lib/stdarch/crates/std_detect/src/detect/os/aarch64.rs: New file.
* rustc-lib/stdarch/crates/std_detect/src/detect/os/freebsd/aarch64.rs: New file.
* rustc-lib/stdarch/crates/std_detect/src/detect/os/freebsd/arm.rs: New file.
* rustc-lib/stdarch/crates/std_detect/src/detect/os/freebsd/auxvec.rs: New file.
* rustc-lib/stdarch/crates/std_detect/src/detect/os/freebsd/mod.rs: New file.
* rustc-lib/stdarch/crates/std_detect/src/detect/os/freebsd/powerpc.rs: New file.
* rustc-lib/stdarch/crates/std_detect/src/detect/os/linux/aarch64.rs: New file.
* rustc-lib/stdarch/crates/std_detect/src/detect/os/linux/arm.rs: New file.
* rustc-lib/stdarch/crates/std_detect/src/detect/os/linux/auxvec.rs: New file.
* rustc-lib/stdarch/crates/std_detect/src/detect/os/linux/cpuinfo.rs: New file.
* rustc-lib/stdarch/crates/std_detect/src/detect/os/linux/mips.rs: New file.
* rustc-lib/stdarch/crates/std_detect/src/detect/os/linux/mod.rs: New file.
* rustc-lib/stdarch/crates/std_detect/src/detect/os/linux/powerpc.rs: New file.
* rustc-lib/stdarch/crates/std_detect/src/detect/os/other.rs: New file.
* rustc-lib/stdarch/crates/std_detect/src/detect/os/windows/aarch64.rs: New file.
* rustc-lib/stdarch/crates/std_detect/src/detect/os/x86.rs: New file.
* rustc-lib/stdarch/crates/std_detect/src/detect/test_data/linux-rpi3.auxv: New file.
* rustc-lib/stdarch/crates/std_detect/src/detect/test_data/linux-x64-i7-6850k.auxv:
New file.
* rustc-lib/stdarch/crates/std_detect/src/detect/test_data/macos-virtualbox-linux-x86-4850HQ.auxv:
New file.
* rustc-lib/stdarch/crates/std_detect/src/lib.rs: New file.
* rustc-lib/stdarch/crates/std_detect/src/mod.rs: New file.
* rustc-lib/stdarch/crates/std_detect/tests/cpu-detection.rs: New file.
* rustc-lib/stdarch/crates/std_detect/tests/macro_trailing_commas.rs: New file.
* rustc-lib/stdarch/crates/std_detect/tests/x86-specific.rs: New file.
* rustc-lib/stdarch/crates/stdarch-gen/Cargo.toml: New file.
* rustc-lib/stdarch/crates/stdarch-gen/README.md: New file.
* rustc-lib/stdarch/crates/stdarch-gen/neon.spec: New file.
* rustc-lib/stdarch/crates/stdarch-gen/src/main.rs: New file.
* rustc-lib/stdarch/crates/stdarch-test/Cargo.toml: New file.
* rustc-lib/stdarch/crates/stdarch-test/src/disassembly.rs: New file.
* rustc-lib/stdarch/crates/stdarch-test/src/lib.rs: New file.
* rustc-lib/stdarch/crates/stdarch-test/src/wasm.rs: New file.
* rustc-lib/stdarch/crates/stdarch-verify/.gitattributes: New file.
* rustc-lib/stdarch/crates/stdarch-verify/Cargo.toml: New file.
* rustc-lib/stdarch/crates/stdarch-verify/arm-intrinsics.html: New file.
* rustc-lib/stdarch/crates/stdarch-verify/build.rs: New file.
* rustc-lib/stdarch/crates/stdarch-verify/mips-msa.h: New file.
* rustc-lib/stdarch/crates/stdarch-verify/src/lib.rs: New file.
* rustc-lib/stdarch/crates/stdarch-verify/tests/arm.rs: New file.
* rustc-lib/stdarch/crates/stdarch-verify/tests/mips.rs: New file.
* rustc-lib/stdarch/crates/stdarch-verify/tests/x86-intel.rs: New file.
* rustc-lib/stdarch/crates/stdarch-verify/x86-intel.xml: New file.
* rustc-lib/stdarch/examples/Cargo.toml: New file.
* rustc-lib/stdarch/examples/hex.rs: New file.
* rustc-lib/stdarch/examples/wasm.rs: New file.
* rustc-lib/stdarch/triagebot.toml: New file.
* rustc-lib/stdarch/vendor.yml: New file.

Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
7 days agogccrs: Fix ICE handling division by zero in const eval
Philip Herron [Mon, 15 Sep 2025 16:00:58 +0000 (17:00 +0100)] 
gccrs: Fix ICE handling division by zero in const eval

This pulls over more constexpr support from C++ front-end.

Fixes Rust-GCC#4146

gcc/rust/ChangeLog:

* backend/rust-constexpr.cc (eval_constant_expression): port over missing bits
(eval_store_expression): likewise
(eval_call_expression): likewise
(eval_binary_expression): likewise
(eval_bit_field_ref): likewise
(eval_check_shift_p): likewise
(fold_pointer_plus_expression): likewise
(maybe_fold_addr_pointer_plus): likewise
(fold_expr): likewise
(union_active_member): likewise
(fold_indirect_ref_1): likewise
(rs_fold_indirect_ref): likewise
(rs_eval_indirect_ref): likewise
(eval_logical_expression): likewise
(eval_vector_conditional_expression): likewise
(eval_bare_aggregate): likewise
(cxx_eval_trinary_expression): likewise
(eval_and_check_array_index): likewise
(eval_array_reference): likewise
(eval_component_reference): likewise
(rs_bind_parameters_in_call): likewise
(eval_builtin_function_call): likewise
(constexpr_fn_retval): likewise
(verify_constant): likewise
(get_array_or_vector_nelts): likewise
(eval_conditional_expression): likewise
(eval_switch_expr): likewise
(eval_unary_expression): likewise
(cxx_eval_outermost_constant_expr): likewise
(potential_constant_expression_1): likewise

gcc/testsuite/ChangeLog:

* rust/compile/issue-2394.rs: Update test case
* rust/compile/issue-4146.rs: New test.

Signed-off-by: Philip Herron <herron.philip@googlemail.com>
7 days agogccrs: Fix ICE with invalid const expression
Philip Herron [Fri, 12 Sep 2025 15:37:32 +0000 (16:37 +0100)] 
gccrs: Fix ICE with invalid const expression

This patch handles the overflowed var expression in the const block, so that
we error properly in the const expr code. It was missing some stuff from the
c++ implementation in how this should be handled properly.

Fixes Rust-GCC#4139

gcc/rust/ChangeLog:

* backend/rust-compile-expr.cc (CompileExpr::compile_integer_literal): cleanup
* backend/rust-constexpr.cc (struct constexpr_global_ctx): port over c++ helpers
(decl_really_constant_value): likewise
(eval_constant_expression): likewise
(non_const_var_error): likewise

gcc/testsuite/ChangeLog:

* rust/compile/issue-4139.rs: New test.

Signed-off-by: Philip Herron <herron.philip@googlemail.com>
7 days agogccrs: Protect from errors in alternate pattern parsing
Owen Avery [Sun, 14 Sep 2025 22:05:35 +0000 (18:05 -0400)] 
gccrs: Protect from errors in alternate pattern parsing

Fixes https://github.com/Rust-GCC/gccrs/issues/4155.

gcc/rust/ChangeLog:

* parse/rust-parse-impl.h (Parser::parse_pattern): Ignore
inner patterns which fail to parse.

gcc/testsuite/ChangeLog:

* rust/compile/issue-4155.rs: New test.

Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
7 days agogccrs: Remove AST::TraitItemConst
Owen Avery [Mon, 15 Sep 2025 03:23:56 +0000 (23:23 -0400)] 
gccrs: Remove AST::TraitItemConst

gcc/rust/ChangeLog:

* ast/rust-ast-collector.cc (TokenCollector::visit): Remove
overload for TraitItemConst.
* ast/rust-ast-collector.h (TokenCollector::visit): Likewise.
* ast/rust-ast-pointer-visitor.cc (PointerVisitor::visit):
Likewise.
* ast/rust-ast-pointer-visitor.h (PointerVisitor::visit):
Likewise.
* ast/rust-ast-visitor.cc (DefaultASTVisitor::visit): Likewise.
* ast/rust-ast-visitor.h (ASTVisitor::visit): Likewise.
(DefaultASTVisitor::visit): Likewise.
* expand/rust-cfg-strip.cc (CfgStrip::visit): Likewise.
* expand/rust-cfg-strip.h (CfgStrip::visit): Likewise.
* expand/rust-derive.h (DeriveVisitor::visit): Likewise.
* expand/rust-expand-visitor.cc (ExpandVisitor::visit):
Likewise.
* expand/rust-expand-visitor.h (ExpandVisitor::visit): Likewise.
* hir/rust-ast-lower-base.cc (ASTLoweringBase::visit): Likewise.
* hir/rust-ast-lower-base.h (ASTLoweringBase::visit): Likewise.
* util/rust-attributes.cc (AttributeChecker::visit): Likewise.
* util/rust-attributes.h (AttributeChecker::visit): Likewise.
* ast/rust-ast.cc (ConstantItem::as_string): Handle missing
expression.
(TraitItemConst::as_string): Remove function definition.
(TraitItemConst::accept_vis): Remove function definition.
* ast/rust-item.h (ConstantItem::mark_for_strip): Adjust
comment.
(ConstantItem::has_expr): Make const.
(class TraitItemConst): Remove definition.
* ast/rust-ast-full-decls.h (class TraitItemConst): Remove
declaration.
* hir/rust-ast-lower-implitem.cc (ASTLowerTraitItem::visit):
Handle ConstantItem instead of TraitItemConst.
* hir/rust-ast-lower-implitem.h (ASTLowerTraitItem::visit):
Likewise.
* parse/rust-parse-impl.h (Parser::parse_trait_const): Return
pointer to ConstantItem instead of TraitItemConst.
* parse/rust-parse.h (Parser::parse_trait_const): Likewise.

Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
7 days agogccrs: Create subdirectory checks/errors/feature
Owen Avery [Wed, 27 Aug 2025 22:21:08 +0000 (18:21 -0400)] 
gccrs: Create subdirectory checks/errors/feature

gcc/rust/ChangeLog:

* Make-lang.in: Handle source files in checks/errors/feature.
* checks/errors/rust-feature-gate.cc: Move to...
* checks/errors/feature/rust-feature-gate.cc: ...here.
* checks/errors/rust-feature-gate.h: Move to...
* checks/errors/feature/rust-feature-gate.h: ...here.
* checks/errors/rust-feature.cc: Move to...
* checks/errors/feature/rust-feature.cc: ...here.
* checks/errors/rust-feature.h: Move to...
* checks/errors/feature/rust-feature.h: ...here.

Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
7 days agogccrs: nr1.0: Remove EarlyNameResolver
Owen Avery [Mon, 1 Sep 2025 23:36:33 +0000 (19:36 -0400)] 
gccrs: nr1.0: Remove EarlyNameResolver

gcc/rust/ChangeLog:

* Make-lang.in (GRS_OBJS): Remove rust-early-name-resolver.o.
* expand/rust-macro-builtins-helpers.h: Remove inclusion of
rust-early-name-resolver.h.
* expand/rust-macro-builtins.cc: Likewise.
* expand/rust-macro-expand.cc: Likewise.
* expand/rust-macro-expand.h: Likewise.
* resolve/rust-early-name-resolver.cc: Removed.
* resolve/rust-early-name-resolver.h: Removed.

Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
7 days agogccrs: Import libcore 1.49.0
Owen Avery [Mon, 11 Aug 2025 01:34:28 +0000 (21:34 -0400)] 
gccrs: Import libcore 1.49.0

This commit imports libcore 1.49.0 into a new directory,
"libgrust/rustc-lib/core". LICENSE-* files are taken from the rustc
1.49.0 repository root.

libgrust/ChangeLog:

* rustc-lib/LICENSE-APACHE: New file.
* rustc-lib/LICENSE-MIT: New file.
* rustc-lib/version-info: New file.

Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
7 days agogccrs: Add libcore to the list of ignored prefixes
Owen Avery [Mon, 11 Aug 2025 01:20:29 +0000 (21:20 -0400)] 
gccrs: Add libcore to the list of ignored prefixes

contrib/ChangeLog:

* gcc-changelog/git_commit.py (ignored_prefixes): Add
'libgrust/rustc-lib/core/'.

Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
7 days agogccrs: track abi and unsafety on fnptrs for proper type checking
Philip Herron [Wed, 3 Sep 2025 19:50:59 +0000 (20:50 +0100)] 
gccrs: track abi and unsafety on fnptrs for proper type checking

We need to distinguish between abi's and unsafety on fnptrs. There is
a commented out check because there is a regression in:

  rust/compile/try-catch-unwind-{new/old}.rs

But i think this is because the test case should be taking an FnOnce
from reading std::panic in rust 1.49. Where as we are passing an fnptr
which is probably because we didnt support fnonce at all then.

Addresses Rust-GCC/gccrs#4090

gcc/rust/ChangeLog:

* hir/tree/rust-hir-item.h: add unsafe helper
* typecheck/rust-hir-type-check-type.cc (TypeCheckType::visit): pass in abi and unsafe
* typecheck/rust-tyty.cc (BaseType::monomorphized_clone): likewise
(FnPtr::as_string): emit more info
(FnPtr::clone): update ctor call
* typecheck/rust-tyty.h: new ctor params
* typecheck/rust-unify.cc (UnifyRules::expect_fnptr): check abi and unsafe

Signed-off-by: Philip Herron <herron.philip@googlemail.com>
7 days agogccrs: get rid of more clones in unify path
Philip Herron [Wed, 3 Sep 2025 13:26:11 +0000 (14:26 +0100)] 
gccrs: get rid of more clones in unify path

gcc/rust/ChangeLog:

* typecheck/rust-unify.cc (UnifyRules::expect_reference): remove clone
(UnifyRules::expect_pointer): likewise
(UnifyRules::expect_slice): likewise
(UnifyRules::expect_tuple): likewise
(UnifyRules::expect_int): likewise
(UnifyRules::expect_uint): likewise
(UnifyRules::expect_float): likewise

Signed-off-by: Philip Herron <herron.philip@googlemail.com>
7 days agogccrs: Add test to confirm Rust-GCC/gccrs#3922 fix
Pierre-Emmanuel Patry [Tue, 2 Sep 2025 19:28:00 +0000 (21:28 +0200)] 
gccrs: Add test to confirm Rust-GCC/gccrs#3922 fix

gcc/testsuite/ChangeLog:

* rust/compile/issue-3922.rs: New test.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
7 days agogccrs: Add test to confirm Rust-GCC/gccrs#3924 fix
Pierre-Emmanuel Patry [Tue, 2 Sep 2025 11:56:24 +0000 (13:56 +0200)] 
gccrs: Add test to confirm Rust-GCC/gccrs#3924 fix

gcc/testsuite/ChangeLog:

* rust/compile/issue-3924.rs: New test.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
7 days agogccrs: nr1.0: Remove chunks of resolution phase
Owen Avery [Thu, 28 Aug 2025 02:14:08 +0000 (22:14 -0400)] 
gccrs: nr1.0: Remove chunks of resolution phase

This removes large chunks of the 1.0 resolution phase, not the nr1.0
resolver itself quite yet.

gcc/rust/ChangeLog:

* Make-lang.in (GRS_OBJS): Remove entries.
* rust-lang.cc: Remove inclusion of "rust-ast-resolve-item.h".
(run_rust_tests): Remove call to rust_simple_path_resolve_test.
* resolve/rust-ast-resolve-base.cc: Removed.
* resolve/rust-ast-resolve-base.h: Removed.
* resolve/rust-ast-resolve-expr.cc: Removed.
* resolve/rust-ast-resolve-expr.h: Removed.
* resolve/rust-ast-resolve-implitem.h: Removed.
* resolve/rust-ast-resolve-item.cc: Removed.
* resolve/rust-ast-resolve-item.h: Removed.
* resolve/rust-ast-resolve-path.cc: Removed.
* resolve/rust-ast-resolve-path.h: Removed.
* resolve/rust-ast-resolve-pattern.cc: Removed.
* resolve/rust-ast-resolve-pattern.h: Removed.
* resolve/rust-ast-resolve-stmt.cc: Removed.
* resolve/rust-ast-resolve-stmt.h: Removed.
* resolve/rust-ast-resolve-struct-expr-field.cc: Removed.
* resolve/rust-ast-resolve-struct-expr-field.h: Removed.
* resolve/rust-ast-resolve-toplevel.h: Removed.
* resolve/rust-ast-resolve-type.cc: Removed.
* resolve/rust-ast-resolve-type.h: Removed.
* resolve/rust-ast-resolve.cc: Removed.

Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
7 days agogccrs: Unify path-to-type handling in Late resolver
Owen Avery [Tue, 1 Jul 2025 20:39:42 +0000 (16:39 -0400)] 
gccrs: Unify path-to-type handling in Late resolver

gcc/rust/ChangeLog:

* resolve/rust-late-name-resolver-2.0.cc (Late::visit): Use
resolve_type_path_like in overloads for TypePath,
StructExprStruct, StructExprStructBase, and
StructExprStructFields.
(resolve_type_path_like): New static function based off
Late::visit overload for TypePath.
* util/rust-unwrap-segment.h (unwrap_segment_error_string): New
inline static function definitions.

Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
7 days agogccrs: Fix crash on break outside of loop context
Philip Herron [Sun, 31 Aug 2025 22:20:03 +0000 (23:20 +0100)] 
gccrs: Fix crash on break outside of loop context

We need to add a guard to catch the case when there is no loop context
for break outside of loop.

Fixes Rust-GCC#3969

gcc/rust/ChangeLog:

* backend/rust-compile-expr.cc (CompileExpr::visit): add guard

gcc/testsuite/ChangeLog:

* rust/compile/issue-3969.rs: New test.

Signed-off-by: Philip Herron <herron.philip@googlemail.com>
7 days agogccrs: Fix segv when handling invalid array capacities
Philip Herron [Sun, 31 Aug 2025 21:57:05 +0000 (22:57 +0100)] 
gccrs: Fix segv when handling invalid array capacities

We need to catch the error node for the array capacity and return early.
Otherwise we try to const evaluate something thats just silly. Also
when compiling array expressions we can simply reuse the array capacity
expression we already have cons folded.

Fixes Rust-GCC#3965

gcc/rust/ChangeLog:

* backend/rust-compile-context.h: add assertions for context peeks
* backend/rust-compile-expr.cc (CompileExpr::visit): check for valid loop context
(CompileExpr::array_copied_expr): just reuse array tyty capacity value
* typecheck/rust-hir-type-check-expr.cc (TypeCheckExpr::visit): catch error

gcc/testsuite/ChangeLog:

* rust/compile/issue-3965-1.rs: New test.
* rust/compile/issue-3965-2.rs: New test.

Signed-off-by: Philip Herron <herron.philip@googlemail.com>
7 days agogccrs: Implement missing read-only checker case for TuplePatternItemsHasRest
Yap Zhi Heng [Thu, 28 Aug 2025 03:26:03 +0000 (11:26 +0800)] 
gccrs: Implement missing read-only checker case for TuplePatternItemsHasRest

gcc/rust/ChangeLog:

* checks/errors/rust-readonly-check.cc (collect_assignment_tuple): Implement
read-only checker for tuple patterns with rest pattern.

Signed-off-by: Yap Zhi Heng <yapzhhg@gmail.com>
7 days agogccrs: Implement missing var decl case for TuplePatternItemsHasRest
Yap Zhi Heng [Wed, 27 Aug 2025 13:47:34 +0000 (21:47 +0800)] 
gccrs: Implement missing var decl case for TuplePatternItemsHasRest

GIMPLE dump from compiling issue-3930.rs:

...
  const i32 b;
  const i32 a;

  D.114.__0 = 2;
  D.114.__1 = 3;
  RUSTTMP.1 = D.114;
  a = RUSTTMP.1.__0;
  b = RUSTTMP.1.__1;
...

gcc/rust/ChangeLog:

* backend/rust-compile-var-decl.h (CompileVarDecl::visit(TuplePattern)): Implement
variable declaration bindings for tuple patterns with rest pattern (i.e.
TuplePatternItemsHasRest).

Signed-off-by: Yap Zhi Heng <yapzhhg@gmail.com>
7 days agogccrs: Recognize rustc_allow_const_fn_unstable
Owen Avery [Thu, 3 Jul 2025 01:39:10 +0000 (21:39 -0400)] 
gccrs: Recognize rustc_allow_const_fn_unstable

This doesn't actually handle the attribute, although it does allow us to
recognize it as valid.

gcc/rust/ChangeLog:

* util/rust-attribute-values.h
(Attributes::RUSTC_ALLOW_CONST_FN_UNSTABLE): New static
constexpr member variable.
* util/rust-attributes.cc (__definitions): Add entry for
RUSTC_ALLOW_CONST_FN_UNSTABLE.

Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
7 days agogccrs: Add implicit infer support for unify on const types
Philip Herron [Tue, 19 Aug 2025 18:34:38 +0000 (19:34 +0100)] 
gccrs: Add implicit infer support for unify on const types

gcc/rust/ChangeLog:

* typecheck/rust-unify.cc (UnifyRules::commit): commit hook update
(UnifyRules::go): insert implicit infer const types

Signed-off-by: Philip Herron <herron.philip@googlemail.com>
7 days agogccrs: allow unifications against non const types
Philip Herron [Sun, 3 Aug 2025 18:53:23 +0000 (19:53 +0100)] 
gccrs: allow unifications against non const types

When type resolving a function which returns a const generic for example
this means its unifying the ConstType vs the the specified type so this
mean unwrapping the type of the const.

gcc/rust/ChangeLog:

* typecheck/rust-unify.cc (UnifyRules::go): unwrap the const type

Signed-off-by: Philip Herron <herron.philip@googlemail.com>
7 days agogccrs: Fix bug with unconstrained const generic
Philip Herron [Sun, 3 Aug 2025 18:43:13 +0000 (19:43 +0100)] 
gccrs: Fix bug with unconstrained const generic

gcc/rust/ChangeLog:

* typecheck/rust-hir-type-check-base.cc (walk_types_to_constrain): track the ref as well

Signed-off-by: Philip Herron <herron.philip@googlemail.com>
7 days agogccrs: track generic const generics properly
Philip Herron [Sun, 3 Aug 2025 18:30:18 +0000 (19:30 +0100)] 
gccrs: track generic const generics properly

gcc/rust/ChangeLog:

* typecheck/rust-tyty-subst.cc: const generic arguments dont have a value yet

Signed-off-by: Philip Herron <herron.philip@googlemail.com>
7 days agogccrs: Fix formatting of tyty code
Philip Herron [Fri, 29 Aug 2025 17:08:56 +0000 (18:08 +0100)] 
gccrs: Fix formatting of tyty code

gcc/rust/ChangeLog:

* typecheck/rust-tyty.cc (VariantDef::clone): fix formatting
(VariantDef::monomorphized_clone): likewise
* typecheck/rust-tyty.h: likewise

Signed-off-by: Philip Herron <herron.philip@googlemail.com>
7 days agogccrs: Remove fully the can_eq TyTy::BaseType::can_eq interface
Philip Herron [Fri, 29 Aug 2025 16:54:54 +0000 (17:54 +0100)] 
gccrs: Remove fully the can_eq TyTy::BaseType::can_eq interface

This was an initial helper from back in the day which was not maintained
but was a nice const simple way to check if types are compatable. But
reusing our unify code is much much more acurate and single source of
truth on the type system.

gcc/rust/ChangeLog:

* typecheck/rust-tyty.cc (InferType::can_eq): remove
(ErrorType::can_eq): likewise
(ADTType::can_eq): likewise
(TupleType::can_eq): likewise
(FnType::can_eq): likewise
(FnPtr::can_eq): likewise
(ClosureType::can_eq): likewise
(ArrayType::can_eq): likewise
(SliceType::can_eq): likewise
(BoolType::can_eq): likewise
(IntType::can_eq): likewise
(UintType::can_eq): likewise
(FloatType::can_eq): likewise
(USizeType::can_eq): likewise
(ISizeType::can_eq): likewise
(CharType::can_eq): likewise
(ReferenceType::can_eq): likewise
(PointerType::can_eq): likewise
(ParamType::can_eq): likewise
(ConstType::can_eq): likewise
(OpaqueType::can_eq): likewise
(StrType::can_eq): likewise
(NeverType::can_eq): likewise
(PlaceholderType::can_eq): likewise
(ProjectionType::can_eq): likewise
(DynamicObjectType::can_eq): likewise
* typecheck/rust-tyty.h: remove can_eq
* typecheck/rust-tyty-cmp.h: Removed.

Signed-off-by: Philip Herron <herron.philip@googlemail.com>
7 days agogccrs: get rid of last can_eq usage finally
Philip Herron [Fri, 29 Aug 2025 16:53:16 +0000 (17:53 +0100)] 
gccrs: get rid of last can_eq usage finally

gcc/rust/ChangeLog:

* typecheck/rust-tyty.cc (ParamType::is_equal): uses types_compatable

Signed-off-by: Philip Herron <herron.philip@googlemail.com>
7 days agogccrs: reuse an error mark node instead of new ones each failure
Philip Herron [Fri, 29 Aug 2025 16:48:39 +0000 (17:48 +0100)] 
gccrs: reuse an error mark node instead of new ones each failure

During unification we denote failures using a new error mark node. This
keeps a static one and reuses it instead.

gcc/rust/ChangeLog:

* typecheck/rust-unify.cc (unify_error_type_node): new static node
(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_never): likewise
(UnifyRules::expect_placeholder): likewise
(UnifyRules::expect_projection): likewise
(UnifyRules::expect_dyn): likewise
(UnifyRules::expect_closure): likewise
(UnifyRules::expect_opaque): likewise
(UnifyRules::expect_const): likewise

Signed-off-by: Philip Herron <herron.philip@googlemail.com>
7 days agogccrs: simplify cloning of types during unify
Philip Herron [Fri, 29 Aug 2025 16:42:10 +0000 (17:42 +0100)] 
gccrs: simplify cloning of types during unify

We should only clone when we commit and it was successful. With no
cloning there is a regression in min specialization 2. Probably because
it needs to know the unify site hirid and ensure we have it set there.

gcc/rust/ChangeLog:

* typecheck/rust-unify.cc (UnifyRules::Resolve): check for success
(UnifyRules::expect_inference_variable): dont clone
(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_never): likewise
(UnifyRules::expect_placeholder): likewise
(UnifyRules::expect_projection): likewise
(UnifyRules::expect_dyn): likewise
(UnifyRules::expect_closure): likewise

Signed-off-by: Philip Herron <herron.philip@googlemail.com>
7 days agogccrs: remove 2nd last usage of can_eq
Philip Herron [Fri, 29 Aug 2025 15:52:34 +0000 (16:52 +0100)] 
gccrs: remove 2nd last usage of can_eq

gcc/rust/ChangeLog:

* typecheck/rust-tyty.cc (BaseType::satisfies_bound): use types_compatable instead

gcc/testsuite/ChangeLog:

* rust/compile/issue-1725-2.rs: remove bad error message

Signed-off-by: Philip Herron <herron.philip@googlemail.com>
7 days agogccrs: Add check bounds flag to unify rules for compatability checks
Philip Herron [Fri, 29 Aug 2025 15:36:45 +0000 (16:36 +0100)] 
gccrs: Add check bounds flag to unify rules for compatability checks

We need to make the type bounds check a flag because it can turn into a
recursive type bounds check. This allows us to remove another can_eq usage

gcc/rust/ChangeLog:

* typecheck/rust-type-util.cc (types_compatable):  add check bounds flag
(unify_site_and): likewise
* typecheck/rust-type-util.h (types_compatable): likewise
(unify_site_and): likewise
* typecheck/rust-tyty-bounds.cc: likewise
* typecheck/rust-unify.cc (UnifyRules::UnifyRules): likewise
(UnifyRules::Resolve): likewise
(UnifyRules::resolve_subtype): likewise
(UnifyRules::go): likewise
* typecheck/rust-unify.h: likewise

Signed-off-by: Philip Herron <herron.philip@googlemail.com>
7 days agogccrs: Update can_eq to be a types_compatable interface
Philip Herron [Mon, 25 Aug 2025 19:52:29 +0000 (20:52 +0100)] 
gccrs: Update can_eq to be a types_compatable interface

Getting close to getting rid of can_eq and tyty-cmp soon.

gcc/rust/ChangeLog:

* typecheck/rust-hir-path-probe.cc (PathProbeType::process_impl_item_candidate):
refactor to types_compatable

Signed-off-by: Philip Herron <herron.philip@googlemail.com>
7 days agogccrs: respect the unify rules commit flag
Philip Herron [Mon, 25 Aug 2025 12:30:22 +0000 (13:30 +0100)] 
gccrs: respect the unify rules commit flag

We use the types compatable interface for unify here and so if
we dont respect the commit flag the interface can have unintended
side effects with infer type hints throwing things off down the line.

gcc/rust/ChangeLog:

* typecheck/rust-unify.cc (UnifyRules::expect_inference_variable): dont commit
(UnifyRules::expect_adt): 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

Signed-off-by: Philip Herron <herron.philip@googlemail.com>
7 days agogccrs: Remove some const usage so we can get rid of more can_eq usage
Philip Herron [Mon, 25 Aug 2025 10:34:25 +0000 (11:34 +0100)] 
gccrs: Remove some const usage so we can get rid of more can_eq usage

I needed to remove som usage of const so we can get rid of can_eq in
type bounds probe. This means we can use the types_compatable interface
instead. Which is much better.

gcc/rust/ChangeLog:

* backend/rust-compile-base.h: remove const
* backend/rust-compile-expr.cc: likewise
* backend/rust-compile.cc (HIRCompileBase::coerce_to_dyn_object): likewise
* typecheck/rust-hir-type-bounds.h: likewise
* typecheck/rust-type-util.cc (lookup_associated_impl_block): likewise
* typecheck/rust-type-util.h (lookup_associated_impl_block): likewise
* typecheck/rust-tyty-bounds.cc (TypeBoundsProbe::TypeBoundsProbe): likewise
(TypeBoundsProbe::Probe): likewise
* typecheck/rust-tyty-cmp.h: likewise
* typecheck/rust-tyty-subst.cc (SubstitutionRef::monomorphize): likewise
* typecheck/rust-tyty.cc (BaseType::satisfies_bound): likewise
(BaseType::bounds_compatible): likewise
(VariantDef::clone): likewise
(VariantDef::monomorphized_clone): likewise
(OpaqueType::is_equal): likewise
(DynamicObjectType::is_equal): likewise
* typecheck/rust-tyty.h: likewise

Signed-off-by: Philip Herron <herron.philip@googlemail.com>
7 days agogccrs: Make the coerce borrowed pointer consistent with try flag
Philip Herron [Mon, 25 Aug 2025 19:44:16 +0000 (20:44 +0100)] 
gccrs: Make the coerce borrowed pointer consistent with try flag

This interface is not respecting the coercion api commit is always false,
we need to ensure this is respected via the try flag like the rest of the
coercion logic.

gcc/rust/ChangeLog:

* typecheck/rust-coercion.cc (TypeCoercionRules::select): respect try flag

Signed-off-by: Philip Herron <herron.philip@googlemail.com>
7 days agogccrs: Error out on unsuffixed self list use declaration
Pierre-Emmanuel Patry [Tue, 26 Aug 2025 18:07:05 +0000 (20:07 +0200)] 
gccrs: Error out on unsuffixed self list use declaration

gcc/rust/ChangeLog:

* resolve/rust-early-name-resolver-2.0.cc (Early::finalize_rebind_import):
Replace assert with early break and remove early return.
(Early::visit): Check for unsuffixed lower self list.
* resolve/rust-early-name-resolver-2.0.h: Add visit function prototype.

gcc/testsuite/ChangeLog:

* rust/compile/use_self_alone_in_list.rs: New test.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
7 days agogccrs: Emit error on lonely self use declaration
Pierre-Emmanuel Patry [Tue, 26 Aug 2025 15:15:47 +0000 (17:15 +0200)] 
gccrs: Emit error on lonely self use declaration

gcc/rust/ChangeLog:

* resolve/rust-early-name-resolver-2.0.cc (Early::visit): Emit an error
on top level rebind self use declaration.

gcc/testsuite/ChangeLog:

* rust/compile/use_self_alone.rs: New test.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
7 days agogccrs: Allow early resolution to use the language prelude
Owen Avery [Sun, 10 Aug 2025 20:03:35 +0000 (16:03 -0400)] 
gccrs: Allow early resolution to use the language prelude

gcc/rust/ChangeLog:

* Make-lang.in (GRS_OBJS): Add "rust-resolve-builtins.o".
* resolve/rust-late-name-resolver-2.0.cc: Include
"rust-resolve-builtins.h".
(next_node_id): Remove function.
(next_hir_id): Likewise.
(Late::setup_builtin_types): Likewise.
(Late::go): Use Builtins::setup_type_ctx instead of
Late::setup_builtin_types.
* resolve/rust-late-name-resolver-2.0.h
(Late::setup_builtin_types): Remove function.
* rust-session-manager.cc: Include "rust-resolve-builtins.h".
(Session::expansion): Call Builtins::setup_lang_prelude.
* resolve/rust-resolve-builtins.cc: New file.
* resolve/rust-resolve-builtins.h: New file.

gcc/testsuite/ChangeLog:

* rust/compile/primitive-import.rs: New test.

Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
7 days agogccrs: Remove Parser::parse_tuple_index_expr_float
Owen Avery [Sat, 23 Aug 2025 19:32:13 +0000 (15:32 -0400)] 
gccrs: Remove Parser::parse_tuple_index_expr_float

Unlike in C, floating point literals can't start with a '.', and
therefore could never be split into a '.' followed by an integer.

gcc/rust/ChangeLog:

* parse/rust-parse-impl.h (Parser::left_denotation): Remove
usage of parse_tuple_index_expr_float.
(Parser::parse_closure_expr_pratt): Remove function.

gcc/testsuite/ChangeLog:

* rust/compile/parse_float_dot.rs: New test.

Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
7 days agogccrs: Do not dump the AST if the parser emit errors
Pierre-Emmanuel Patry [Tue, 26 Aug 2025 10:55:02 +0000 (12:55 +0200)] 
gccrs: Do not dump the AST if the parser emit errors

gcc/rust/ChangeLog:

* rust-session-manager.cc (Session::compile_crate): Move the AST dump
after parser error check.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
7 days agogccrs: desugar: Use PointerVisitor for ExpressionYeast
Arthur Cohen [Thu, 14 Aug 2025 08:29:57 +0000 (10:29 +0200)] 
gccrs: desugar: Use PointerVisitor for ExpressionYeast

gcc/rust/ChangeLog:

* ast/rust-expression-yeast.cc (ExpressionYeast::dispatch): Rename to...
(ExpressionYeast::reseat): ...this.
(ExpressionYeast::visit): Remove.
* ast/rust-expression-yeast.h: Inherit from PointerVisitor, override reseat instead
of declaring dispatch.

7 days agogccrs: ast: Add PointerVisitor
Arthur Cohen [Wed, 13 Aug 2025 12:32:41 +0000 (14:32 +0200)] 
gccrs: ast: Add PointerVisitor

gcc/rust/ChangeLog:

* Make-lang.in: Compile it.
* ast/rust-builtin-ast-nodes.h: Add missing methods for getting pointers.
* ast/rust-expr.h: Likewise.
* ast/rust-item.h: Likewise.
* ast/rust-path.h: Likewise.
* ast/rust-pattern.h: Likewise.
* ast/rust-type.h: Likewise.
* ast/rust-ast-pointer-visitor.cc: New file.
* ast/rust-ast-pointer-visitor.h: New file.

7 days agogccrs: Separate strip information from internal state
Pierre-Emmanuel Patry [Mon, 25 Aug 2025 15:16:24 +0000 (17:16 +0200)] 
gccrs: Separate strip information from internal state

Marking a TupleIndexExpr for strip makes it invalid for a generic visitor

gcc/rust/ChangeLog:

* ast/rust-expr.h (class TupleIndexExpr): Store strip information.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
7 days agogccrs: nr1.0: Remove support in borrow checker
Owen Avery [Sat, 23 Aug 2025 02:26:05 +0000 (22:26 -0400)] 
gccrs: nr1.0: Remove support in borrow checker

gcc/rust/ChangeLog:

* checks/errors/borrowck/rust-bir-builder-internal.h: Remove
inclusion of "rust-name-resolver.h".
(BuilderContext::resolver): Change type to nr2.0 resolver.
(BuilderContext::BuilderContext): Change initialization of
resolver reference.
(AbstractBuilder::resolve_label): Assume name resolution 2.0 is
enabled.
(AbstractBuilder::resolve_variable): Likewise.
(AbstractBuilder::resolve_variable_or_fn): Likewise.

Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
7 days agogccrs: nr1.0: Remove support in pattern checker
Owen Avery [Sat, 23 Aug 2025 02:57:05 +0000 (22:57 -0400)] 
gccrs: nr1.0: Remove support in pattern checker

gcc/rust/ChangeLog:

* checks/errors/rust-hir-pattern-analysis.cc: Remove inclusion
of "options.h".
(PatternChecker::PatternChecker): Change initialization of
resolver reference.
(PatternChecker::visit): Assume name resolution 2.0 is enabled.
* checks/errors/rust-hir-pattern-analysis.h: Include nr2.0
header instead of nr1.0 header.
(PatternChecker::resolver): Change type to nr2.0 resolver.

Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
7 days agogccrs: nr1.0: Remove support in rust-session-manager.cc
Owen Avery [Sat, 23 Aug 2025 02:12:35 +0000 (22:12 -0400)] 
gccrs: nr1.0: Remove support in rust-session-manager.cc

gcc/rust/ChangeLog:

* rust-session-manager.cc: Remove inclusion of name resolution
1.0 headers.
(Session::compile_crate): Assume name resolution 2.0 is enabled.
(Session::expansion): Likewise.
(Session::load_extern_crate): Likewise.

Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
7 days agogccrs: nr1.0: Remove support in privacy checker
Owen Avery [Sat, 23 Aug 2025 17:29:54 +0000 (13:29 -0400)] 
gccrs: nr1.0: Remove support in privacy checker

gcc/rust/ChangeLog:

* checks/errors/privacy/rust-privacy-check.cc: Adjust includes.
(Resolver::resolve): Pass 2.0 name resolution context to
VisibilityResolver and PrivacyReporter.
* checks/errors/privacy/rust-privacy-reporter.cc
(PrivacyReporter::PrivacyReporter): Change type of resolver
parameter.
(is_child_module): Remove static function.
(PrivacyReporter::check_for_privacy_violation): Assume nr2.0 is
enabled and handle removal of is_child_module.
* checks/errors/privacy/rust-privacy-reporter.h: Adjust
includes.
(PrivacyReporter::PrivacyReporter): Change type of resolver
parameter.
(PrivacyReporter::resolver): Change member variable type.
* checks/errors/privacy/rust-visibility-resolver.cc: Adjust
includes.
(VisibilityResolver::VisibilityResolver): Change type of
resolver parameter.
(VisibilityResolver::resolve_module_path): Assume nr2.0 is
enabled.
* checks/errors/privacy/rust-visibility-resolver.h: Adjust
includes.
(VisibilityResolver::VisibilityResolver): Change type of
resolver parameter.
(VisibilityResolver::resolver): Change member variable type.

Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
7 days agogccrs: Refactor AST Patterns that hold multiple pattern items
Yap Zhi Heng [Sun, 24 Aug 2025 13:18:12 +0000 (21:18 +0800)] 
gccrs: Refactor AST Patterns that hold multiple pattern items

Patterns include TuplePattern, TupleStructPattern & SlicePattern. Besides making their pattern
items container class inherit from a common `PatternItems` base class just like in HIR for
better standardization, mentions of `Range` are also changed to `HasRest` or `NoRest`.

gcc/rust/ChangeLog:

* ast/rust-pattern.h:
- Add a new base abstract class `PatternItems` which are used by pattern items class
class derivatives for `TuplePattern`, `TupleStructPattern` & `SlicePattern`.
- Standardized the derived class names to have `HasRest` or `NoRest` as suffixes.
 - Values for the common `ItemType` enum is updated to `HAS_REST` or `NO_REST`.
* ast/rust-pattern.cc: Renamed the classes accordingly.
* ast/rust-ast-collector.cc: Renamed the classes accordingly.
* ast/rust-ast-collector.h: Renamed the classes accordingly.
* ast/rust-ast-full-decls.h: Renamed the classes accordingly.
* ast/rust-ast-visitor.cc: Renamed the classes accordingly.
* ast/rust-ast-visitor.h: Renamed the classes accordingly.
* ast/rust-desugar-for-loops.cc: Renamed the classes accordingly.
* ast/rust-desugar-question-mark.cc: Renamed the classes accordingly.
* expand/rust-cfg-strip.cc: Renamed the classes accordingly.
* expand/rust-cfg-strip.h: Renamed the classes accordingly.
* expand/rust-derive-clone.cc: Renamed the classes accordingly.
* expand/rust-derive-cmp-common.cc: Renamed the classes accordingly.
* expand/rust-derive-hash.cc: Renamed the classes accordingly.
* expand/rust-derive-ord.cc: Renamed the classes accordingly.
* expand/rust-derive-partial-eq.cc: Renamed the classes accordingly.
* expand/rust-derive.h: Renamed the classes accordingly.
* expand/rust-expand-visitor.cc: Renamed the classes accordingly.
* expand/rust-expand-visitor.h: Renamed the classes accordingly.
* hir/rust-ast-lower-base.cc: Renamed the classes accordingly.
* hir/rust-ast-lower-base.h: Renamed the classes accordingly.
* hir/rust-ast-lower-pattern.cc: Renamed the classes accordingly.
* hir/tree/rust-hir-pattern.h: Renamed the classes accordingly.
* parse/rust-parse-impl.h: Renamed the classes accordingly.
* resolve/rust-ast-resolve-base.cc: Renamed the classes accordingly.
* resolve/rust-ast-resolve-base.h: Renamed the classes accordingly.
* resolve/rust-ast-resolve-pattern.cc: Renamed the classes accordingly.
* util/rust-attributes.cc: Renamed the classes accordingly.
* util/rust-attributes.h: Renamed the classes accordingly.

Signed-off-by: Yap Zhi Heng <yapzhhg@gmail.com>
7 days agogccrs: Avoid std::unique_ptr<std::string> in Token
Owen Avery [Sun, 24 Aug 2025 23:37:45 +0000 (19:37 -0400)] 
gccrs: Avoid std::unique_ptr<std::string> in Token

gcc/rust/ChangeLog:

* ast/rust-ast-collector.cc (TokenCollector::visit): Use
should_have_str instead of has_str.
* ast/rust-ast.cc (Token::as_string): Likewise.
* expand/rust-macro-builtins-offset-of.cc
(MacroBuiltin::offset_of_handler): Likewise.
* lex/rust-lex.cc (Lexer::dump_and_skip): Likewise.
* ast/rust-ast.h (class Token): Remove dead code.
(Token::has_str): Remove function.
(Token::should_have_str): New function.
* lex/rust-token.cc (Token::get_str): Remove function
definition.
* lex/rust-token.h: Include "rust-diagnostics.h".
(Token::str): Change type from std::unique_ptr<std::string> to
std::string.
(Token::Token): Adjust initialization of str member variable and
the type of the parameter used to initialize it.
(Token::make_identifier): Accept std::string instead of rvalue
reference to std::string.
(Token::make_int): Likewise.
(Token::make_float): Likewise.
(Token::make_string): Likewise.
(Token::make_byte_string): Likewise.
(Token::make_raw_string): Likewise.
(Token::make_inner_doc_comment): Likewise.
(Token::make_outer_doc_comment): Likewise.
(Token::make_lifetime): Likewise.
(Token::get_str): Add definition to function declaration.
(Token::has_str): Remove member function.
(Token::should_have_str): Handle INNER_DOC_COMMENT and
OUTER_DOC_COMMENT.

Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
7 days agogccrs: Eagerly expand format_args macro
Owen Avery [Fri, 22 Aug 2025 02:22:36 +0000 (22:22 -0400)] 
gccrs: Eagerly expand format_args macro

This allows format_args!(some_macro!(...), ...) to compile.

gcc/rust/ChangeLog:

* expand/rust-macro-builtins-format-args.cc
(format_args_parse_arguments): Split format expression parsing
into...
(format_args_parse_expr): ...a new function here, while handling
eager expansion.
(MacroBuiltin::format_args_handler): Use format_args_parse_expr.

gcc/testsuite/ChangeLog:

* rust/compile/format_args_concat.rs: New test.

Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
7 days agogccrs: Remove Parser::parse_path_in_expression_pratt
Owen Avery [Thu, 21 Aug 2025 04:05:06 +0000 (00:05 -0400)] 
gccrs: Remove Parser::parse_path_in_expression_pratt

This improves our handling of PathInExpression and fixes
https://github.com/Rust-GCC/gccrs/issues/4056.

gcc/rust/ChangeLog:

* parse/rust-parse-impl.h (Parser::parse_expr): Avoid skipping
or splitting tokens.
(Parser::null_denotation): Assume initial token was not skipped
and adjust function signature to match. Use
parse_path_in_expression instead of
parse_path_in_expression_pratt and handle SCOPE_RESOLUTION.
(Parser::parse_path_in_expression_pratt): Remove function.
* parse/rust-parse.h (null_denotation): Remove initial token
parameter.
(parse_path_in_expression_pratt): Remove function.

gcc/testsuite/ChangeLog:

* rust/compile/global-path-array.rs: New test.

Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
7 days agogccrs: Add fn pointer implementation test
Pierre-Emmanuel Patry [Fri, 22 Aug 2025 10:35:58 +0000 (12:35 +0200)] 
gccrs: Add fn pointer implementation test

gcc/testsuite/ChangeLog:

* rust/compile/impl_fnptr.rs: New test.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
7 days agogccrs: Use as member function instead of static cast
Pierre-Emmanuel Patry [Fri, 22 Aug 2025 10:28:08 +0000 (12:28 +0200)] 
gccrs: Use as member function instead of static cast

gcc/rust/ChangeLog:

* typecheck/rust-coercion.cc (TypeCoercionRules::do_coercion): Use as
member function.
(TypeCoercionRules::coerce_borrowed_pointer): Likewise.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
7 days agogccrs: Put nevertype cercion into it's own function
Pierre-Emmanuel Patry [Thu, 21 Aug 2025 14:09:28 +0000 (16:09 +0200)] 
gccrs: Put nevertype cercion into it's own function

gcc/rust/ChangeLog:

* typecheck/rust-coercion.cc (TypeCoercionRules::do_coercion):
Move nevertype coercion from here...
(TypeCoercionRules::coerce_never): ... to here.
* typecheck/rust-coercion.h: Add function prototype.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
7 days agogccrs: Change coerce_unsize error handling
Pierre-Emmanuel Patry [Thu, 21 Aug 2025 13:00:02 +0000 (15:00 +0200)] 
gccrs: Change coerce_unsize error handling

Error kind were split between error state and out bool parameter.

gcc/rust/ChangeLog:

* typecheck/rust-coercion.cc (TypeCoercionRules::do_coercion): Adapt
call to new return type.
(TypeCoercionRules::coerce_unsized): Change error handling.
* typecheck/rust-coercion.h: Update function prototype and add new
CoerceUnsizedError error type.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
7 days agogccrs: Refactor return statements
Pierre-Emmanuel Patry [Thu, 21 Aug 2025 12:58:25 +0000 (14:58 +0200)] 
gccrs: Refactor return statements

gcc/rust/ChangeLog:

* typecheck/rust-coercion.cc (TypeCoercionRules::do_coercion): Refactor
common return statement.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
7 days agogccrs: Remove unused variable assignments
Pierre-Emmanuel Patry [Thu, 21 Aug 2025 11:15:39 +0000 (13:15 +0200)] 
gccrs: Remove unused variable assignments

Multiple local variables were not read beyond their assignments.

gcc/rust/ChangeLog:

* typecheck/rust-hir-type-check-expr.cc (TypeCheckExpr::visit): Remove
unused assignment.
* typecheck/rust-hir-type-check-path.cc (TypeCheckExpr::resolve_segments):
Likewise.
* typecheck/rust-tyty.cc (ParamType::handle_substitions): Likewise.
* typecheck/rust-unify.cc (UnifyRules::go): Likewise.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>