[COMMITTED 167/220] gccrs: Update SlicePattern typechecking against slice reference parents

2025-08-05 Thread arthur . cohen
From: Yap Zhi Heng gcc/rust/ChangeLog: * typecheck/rust-hir-type-check-pattern.cc (TypeCheckPattern::visit(SlicePattern)): Add new type check case for SliceType wrapped in ReferenceType. * backend/rust-compile-pattern.cc: Adjusted the asserts accordingly for

[COMMITTED 213/220] gccrs: Catch parse failure in parse_path_meta_item

2025-08-05 Thread arthur . cohen
From: Owen Avery gcc/rust/ChangeLog: * ast/rust-ast.cc (AttributeParser::parse_path_meta_item): Catch parse_expr returning nullptr and remove defunct comment. Signed-off-by: Owen Avery --- gcc/rust/ast/rust-ast.cc | 9 ++--- 1 file changed, 6 insertions(+), 3 deletions(-)

[COMMITTED 156/220] gccrs: Load modules during CfgStrip phase

2025-08-05 Thread arthur . cohen
From: Owen Avery TopLevel would ignore just-loaded modules but Early and ExpandVisitor wouldn't. The latter would produce errors when it hit attributes which should have been indirectly CfgStrip'd away. gcc/rust/ChangeLog: * expand/rust-cfg-strip.cc (CfgStrip::visit): Load unloaded

[COMMITTED 220/220] gccrs: Add read-only check on HIR

2025-08-05 Thread arthur . cohen
From: Ryutaro Okada <1015ry...@gmail.com> gcc/rust/ChangeLog: * Make-lang.in (rust-readonly-check2.cc): Add read-only check on HIR * checks/errors/rust-readonly-check2.cc (ReadonlyChecker): Add read-only check on HIR * checks/errors/rust-readonly-check2.h (

[COMMITTED 216/220] gccrs: Recognize rustc_args_required_const attribute

2025-08-05 Thread arthur . cohen
From: Owen Avery This doesn't handle rustc_args_required_const, but it does allow us to recognize it as a valid attribute. gcc/rust/ChangeLog: * util/rust-attribute-values.h (Attributes::RUSTC_ARGS_REQUIRED_CONST): New constexpr variable. * util/rust-attributes.cc (__def

[COMMITTED 190/220] gccrs: Refactor substitution param mapping to be more abstract

2025-08-05 Thread arthur . cohen
From: Philip Herron This is an initial patch required to refactor our generics code to be simpler and more abstract so we return the HIR::GenericParam in ParamMappings instead of assuming its a TypeParam so we can slowly introduce ConstGenericParam into this same flow. gcc/rust/ChangeLog:

[COMMITTED 179/220] gccrs: expand: Add parser for offset_of!() and builtin resolution.

2025-08-05 Thread arthur . cohen
From: Arthur Cohen gcc/rust/ChangeLog: * Make-lang.in: Compile the offset_of handler. * lang.opt: Add -frust-assume-builtin-offset-of option. * ast/rust-ast.h: Add has_str() for const_TokenPtr. * expand/rust-macro-builtins.cc: Map offset_of as builtin

[COMMITTED 203/220] gccrs: Initialize boolean flag correctly

2025-08-05 Thread arthur . cohen
From: Pierre-Emmanuel Patry gcc/rust/ChangeLog: * hir/rust-ast-lower-pattern.cc (ASTLoweringPattern::ASTLoweringPattern): flag was not initialized in the constructor. Signed-off-by: Pierre-Emmanuel Patry --- gcc/rust/hir/rust-ast-lower-pattern.cc | 4 +++- 1 file changed, 3 i

[COMMITTED 215/220] gccrs: Make AttributeParser rely more on Parser

2025-08-05 Thread arthur . cohen
From: Owen Avery gcc/rust/ChangeLog: * ast/rust-ast.cc (AttributeParser::parse_meta_item_inner): Handle removal of AttributeParser-specific functions. (AttributeParser::parse_path_meta_item): Likewise. (AttributeParser::parse_meta_item_seq): Likewise. (Att

[COMMITTED 173/220] gccrs: Add execute test for variable and identifiers

2025-08-05 Thread arthur . cohen
From: Pierre-Emmanuel Patry gcc/testsuite/ChangeLog: * rust/execute/inline_asm_inout_ident.rs: New test. * rust/execute/inline_asm_inout_var.rs: New test. Signed-off-by: Pierre-Emmanuel Patry --- .../rust/execute/inline_asm_inout_ident.rs| 23 ++ .../rust/e

[COMMITTED 184/220] gccrs: desugar: Cleanup for-loop desugar implementation.

2025-08-05 Thread arthur . cohen
From: Arthur Cohen gcc/rust/ChangeLog: * ast/rust-desugar-for-loops.cc: Remove functions implemented in AST::Builder. * ast/rust-desugar-for-loops.h: Likewise. --- gcc/rust/ast/rust-desugar-for-loops.cc | 23 --- gcc/rust/ast/rust-desugar-for-loops.h | 2

[COMMITTED 214/220] gccrs: offset_of: Compile the offset properly

2025-08-05 Thread arthur . cohen
From: Arthur Cohen gcc/rust/ChangeLog: * backend/rust-compile-expr.cc (CompileExpr::visit): Add proper handling of the node. * rust-backend.h (lookup_field): Declare it. * rust-gcc.cc (lookup_field): Add forked implementation from gcc/c/. gcc/testsuite/ChangeLog

[COMMITTED 208/220] gccrs: remove old debug

2025-08-05 Thread arthur . cohen
From: Philip Herron gcc/rust/ChangeLog: * typecheck/rust-tyty-subst.cc (SubstitutionRef::infer_substitions): remove debug Signed-off-by: Philip Herron --- gcc/rust/typecheck/rust-tyty-subst.cc | 7 --- 1 file changed, 7 deletions(-) diff --git a/gcc/rust/typecheck/rust-tyty-subs

[COMMITTED 217/220] gccrs: Remove undefined behavior with static_cast

2025-08-05 Thread arthur . cohen
From: Owen Avery gcc/rust/ChangeLog: * expand/rust-macro-builtins-helpers.cc (try_extract_string_literal_from_fragment): Perform static_cast to AST::LiteralExpr only after it's verified that an AST::Expr is a literal. Signed-off-by: Owen Avery --- gcc/rust/expa

[COMMITTED 206/220] gccrs: Remove more calls to the old TyTy::BaseType::can_eq interface

2025-08-05 Thread arthur . cohen
From: Philip Herron This old can_eq interface was an old method to try and check if types can match up by taking into account generics but its not maintained properly and we already have a new wrapper Resolver::types_compatable (type, type, locus, emit_errors) which just calls unify_site_and in

[COMMITTED 218/220] gccrs: Add check before calling `get_trait_ref()`

2025-08-05 Thread arthur . cohen
From: Ryutaro Okada <1015ry...@gmail.com> gcc/rust/ChangeLog: * hir/tree/rust-hir-visitor.cc (DefaultHIRVisitor::walk): Add check before calling `get_trait_ref()` Signed-off-by: Ryutaro Okada <1015ry...@gmail.com> --- gcc/rust/hir/tree/rust-hir-visitor.cc | 3 ++- 1 file change

[COMMITTED 219/220] gccrs: Call base class's accept_vis method

2025-08-05 Thread arthur . cohen
From: Ryutaro Okada <1015ry...@gmail.com> gcc/rust/ChangeLog: * hir/tree/rust-hir-visitor.cc (DefaultHIRVisitor::walk): Call base class's accept_vis method Signed-off-by: Ryutaro Okada <1015ry...@gmail.com> --- gcc/rust/hir/tree/rust-hir-visitor.cc | 8 1 file changed,

[COMMITTED 183/220] gccrs: lower: Add assertions for desugared nodes

2025-08-05 Thread arthur . cohen
From: Arthur Cohen gcc/rust/ChangeLog: * hir/rust-ast-lower-base.cc: Add rust_unreachable() when lowering desugared exprs. * hir/rust-ast-lower-base.h: Mention this. * hir/rust-ast-lower-block.h: Remove existing definitions. * hir/rust-ast-lower-expr.cc

[COMMITTED 193/220] gccrs: Add ConstType boiler plate to handle const generics

2025-08-05 Thread arthur . cohen
From: Philip Herron This patch is all about just putting in the boiler plate for the new BaseGeneric TyTy::ConstType. Nothing is really change but just the nessecary cogs added to the machine. gcc/rust/ChangeLog: * backend/rust-compile-type.cc (TyTyResolveCompile::visit): error_mark_no

[COMMITTED 180/220] gccrs: hir: Add OffsetOf node

2025-08-05 Thread arthur . cohen
From: Arthur Cohen gcc/rust/ChangeLog: * hir/tree/rust-hir-expr.h (class OffsetOf): New. * hir/tree/rust-hir-expr.cc: Define its methods. * hir/tree/rust-hir-expr-abstract.h: Add ExprType::OffsetOf. * hir/tree/rust-hir-full-decls.h (class OffsetOf): Declare it

[COMMITTED 205/220] gccrs: Ensure we track the const generic substitution on the param mappings

2025-08-05 Thread arthur . cohen
From: Philip Herron gcc/rust/ChangeLog: * typecheck/rust-tyty-subst.cc: track the const generic * typecheck/rust-tyty.cc (ConstType::is_equal): finish the is_equal Signed-off-by: Philip Herron --- gcc/rust/typecheck/rust-tyty-subst.cc | 7 +-- gcc/rust/typecheck/rust-tyty

[COMMITTED 185/220] gccrs: Fix AttrInputMacro operator= overloading.

2025-08-05 Thread arthur . cohen
From: Pierre-Emmanuel Patry gcc/rust/ChangeLog: * ast/rust-ast.cc (AttrInputMacro::operator=): Add return type. * ast/rust-expr.h: Likewise. Signed-off-by: Pierre-Emmanuel Patry --- gcc/rust/ast/rust-ast.cc | 3 ++- gcc/rust/ast/rust-expr.h | 8 ++-- 2 files changed, 8 ins

[COMMITTED 182/220] gccrs: desugar: Add assertions for try-blocks and question-mark

2025-08-05 Thread arthur . cohen
From: Arthur Cohen gcc/rust/ChangeLog: * ast/rust-desugar-question-mark.cc (DesugarQuestionMark::go): Add assertion for the expr's type. * ast/rust-desugar-try-block.cc (DesugarTryBlock::go): Likewise. --- gcc/rust/ast/rust-desugar-question-mark.cc | 3 ++- gcc

[COMMITTED 174/220] gccrs: nr1.0: Remove rust/typecheck support

2025-08-05 Thread arthur . cohen
From: Owen Avery gcc/rust/ChangeLog: * typecheck/rust-hir-type-check-base.cc (TypeCheckBase::TypeCheckBase): Remove initialization of resolver field. * typecheck/rust-hir-type-check-base.h (TypeCheckBase::resolver): Remove field. * typecheck/rust-h

[COMMITTED 160/220] gccrs: hir: Handle deferred const inference variables

2025-08-05 Thread arthur . cohen
From: Arthur Cohen gcc/rust/ChangeLog: * hir/rust-ast-lower-expr.cc (ASTLoweringExpr::visit): Handle defered consts. * hir/tree/rust-hir-expr.cc (AnonConst::AnonConst): Likewise. (AnonConst::operator=): Likewise. * hir/tree/rust-hir-expr.h: Likewise

[COMMITTED 210/220] gccrs: Parse expression instead of literal in attributes

2025-08-05 Thread arthur . cohen
From: Pierre-Emmanuel Patry gcc/rust/ChangeLog: * ast/rust-ast.cc (AttributeParser::parse_path_meta_item): Parse expression instead of literal. Update variant name. (MetaItemPathLit::to_attribute): Remove function. (AttributeParser::parse_path_meta_item): Update n

[COMMITTED 211/220] gccrs: Fix object copying issue causing pointer inconsistency

2025-08-05 Thread arthur . cohen
From: Ryutaro Okada <1015ry...@gmail.com> gcc/rust/ChangeLog: * hir/rust-ast-lower-implitem.cc (ASTLowerTraitItem::visit): Fix object copying issue causing pointer inconsistency Signed-off-by: Ryutaro Okada <1015ry...@gmail.com> --- gcc/rust/hir/rust-ast-lower-implitem.cc | 2 +-

[COMMITTED 165/220] gccrs: ast: Add Expr::Kind::Try

2025-08-05 Thread arthur . cohen
From: Arthur Cohen gcc/rust/ChangeLog: * ast/rust-ast.h: Add the new variant. * ast/rust-expr.h: Use it for TryExpr class. --- gcc/rust/ast/rust-ast.h | 1 + gcc/rust/ast/rust-expr.h | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/gcc/rust/ast/rust-ast.h

[COMMITTED 192/220] gccrs: Refactor the ParamType to a BaseGeneric base-type

2025-08-05 Thread arthur . cohen
From: Philip Herron In order to support const generics we need to abstract away some of the specific ParamType to a BaseGeneric type so we can easily reuse our existing substitution bits for const generics which will mean creating a TyTy::ConstType to wrap up the gcc tree but also represent a con

[COMMITTED 159/220] gccrs: ast: Use AnonConst for array type sizes

2025-08-05 Thread arthur . cohen
From: Arthur Cohen gcc/rust/ChangeLog: * ast/rust-expr.h: Add handling for deferred consts. * ast/rust-ast-visitor.cc (DefaultASTVisitor::visit): Likewise. * ast/rust-ast.cc (AnonConst::as_string): Likewise. (ArrayType::as_string): Likewise. * ast/rust

[COMMITTED 212/220] gccrs: Avoid including rust-parse-impl.h in rust-parse.h

2025-08-05 Thread arthur . cohen
From: Owen Avery This should reduce incremental compile times when modifying rust-parse-impl.h and not rust-parse.h. gcc/rust/ChangeLog: * Make-lang.in (GRS_OBJS): Add entries. * parse/rust-parse-impl.h: Adjust header comment. (Parser::parse_lifetime_params_objs): Fix bu

[COMMITTED 207/220] gccrs: improve debug logging for unify site

2025-08-05 Thread arthur . cohen
From: Philip Herron gcc/rust/ChangeLog: * typecheck/rust-type-util.cc (unify_site_and): improve debug Signed-off-by: Philip Herron --- gcc/rust/typecheck/rust-type-util.cc | 20 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/gcc/rust/typecheck/rust

[COMMITTED 151/220] gccrs: Add initial support for deffered operator overload resolution

2025-08-05 Thread arthur . cohen
From: Philip Herron In the test case: fn test (len: usize) -> u64 { let mut i = 0; let mut out = 0; if i + 3 < len { out = 123; } out } The issue is to determine the correct type of 'i', out is simple because it hits a coercion site in the resturn position

[COMMITTED 181/220] gccrs: desugar: Add for-loop desugar to ExpressionYeast

2025-08-05 Thread arthur . cohen
From: Arthur Cohen gcc/rust/ChangeLog: * ast/rust-desugar-for-loops.h: Adapt API and remove visitor. * ast/rust-desugar-for-loops.cc: Likewise. * ast/rust-expression-yeast.cc: Call DesugarForLoop. * ast/rust-expression-yeast.h: Declare dispatch_loops function

[COMMITTED 172/220] gccrs: Add input/output from inout and split in out

2025-08-05 Thread arthur . cohen
From: Pierre-Emmanuel Patry Inline assembly was incomplete and input/output from inout or split in out were not handled. gcc/rust/ChangeLog: * backend/rust-compile-asm.cc (get_out_expr): Return valid output from an operand. (CompileAsm::asm_construct_outputs): Handle eve

[COMMITTED 171/220] gccrs: Parse input and output expression

2025-08-05 Thread arthur . cohen
From: Pierre-Emmanuel Patry Previously inline assembly expected identifiers instead of expression. gcc/rust/ChangeLog: * expand/rust-macro-builtins-asm.cc (parse_reg_operand_inout): Parse expressions and build split in out. Signed-off-by: Pierre-Emmanuel Patry --- gcc/rust/ex

[COMMITTED 143/220] gccrs: attributes: Add #[test] and #[simd_test]

2025-08-05 Thread arthur . cohen
From: Arthur Cohen gcc/rust/ChangeLog: * util/rust-attribute-values.h: Add declarations for them. * util/rust-attributes.cc: Add definitions. --- gcc/rust/util/rust-attribute-values.h | 4 gcc/rust/util/rust-attributes.cc | 5 - 2 files changed, 8 insertions(+), 1

[COMMITTED 140/220] gccrs: add test case to show issue is fixed

2025-08-05 Thread arthur . cohen
From: Philip Herron Fixes Rust-GCC#3599 gcc/testsuite/ChangeLog: * rust/compile/issue-3599.rs: New test. Signed-off-by: Philip Herron --- gcc/testsuite/rust/compile/issue-3599.rs | 8 1 file changed, 8 insertions(+) create mode 100644 gcc/testsuite/rust/compile/issue-3599.r

[COMMITTED 139/220] gccrs: Fix ICE when handling bad constructor

2025-08-05 Thread arthur . cohen
From: Philip Herron We just had a typo returning ok true when it should have been false. Fixes Rust-GCC#3876 gcc/rust/ChangeLog: * typecheck/rust-hir-type-check-struct.cc (TypeCheckStructExpr::visit): fix typo gcc/testsuite/ChangeLog: * rust/compile/issue-3876.rs: New test.

[COMMITTED 198/220] gccrs: Support const generic inference variables

2025-08-05 Thread arthur . cohen
From: Philip Herron We already support const infer so this just creates a fresh tyty::infer_var for the const element type and then a ConstKind::Infer type for the const type wrapper and the existing plumbing handles this. Fixes Rust-GCC#3885 gcc/rust/ChangeLog: * typecheck/rust-hir-ty

[COMMITTED 135/220] gccrs: Fix narrowing of Loan (size_t) into LoanId (uint32)

2025-08-05 Thread arthur . cohen
From: Marc Poulhiès Fix narrowing: -../../gcc/rust/checks/errors/borrowck/rust-borrow-checker-diagnostics.cc:145:46: warning: narrowing conversion of ‘loan’ from ‘Rust::Polonius::Loan’ {aka ‘long unsigned int’} to ‘uint32_t’ {aka ‘unsigned int’} [-Wnarrowing] gcc/rust/ChangeLog:

[COMMITTED 131/220] gccrs: Do proper const folding during typechecking for array capacities

2025-08-05 Thread arthur . cohen
From: Philip Herron This patch adds proper folding to the const expression for array capacity we already have the const folding mechanics and the query system needed to handle cases where the capacity is a function call in a const context. This leverages and pulls the gcc tree capacity into the

[COMMITTED 199/220] gccrs: Fix ICE when extra const arguments supplied

2025-08-05 Thread arthur . cohen
From: Philip Herron The substitution code was not taking into account the const generic arguments for checking the max bounds of total available parameters. Fixes Rust-GCC#3546 gcc/rust/ChangeLog: * typecheck/rust-tyty-subst.cc: fix check for total arguments gcc/testsuite/ChangeLog:

[COMMITTED 125/220] gccrs: Remove reinterpret_cast usages in DefaultASTVisitor

2025-08-05 Thread arthur . cohen
From: Owen Avery gcc/rust/ChangeLog: * ast/rust-ast-visitor.cc (DefaultASTVisitor::visit): Replace usages of reinterpret_cast with static_cast. Signed-off-by: Owen Avery --- gcc/rust/ast/rust-ast-visitor.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --gi

[COMMITTED 202/220] gccrs: Prevent used after move on self param

2025-08-05 Thread arthur . cohen
From: Pierre-Emmanuel Patry gcc/rust/ChangeLog: * hir/rust-ast-lower-implitem.cc (ASTLowerTraitItem::visit): Remove use after move. Signed-off-by: Pierre-Emmanuel Patry --- gcc/rust/hir/rust-ast-lower-implitem.cc | 17 + 1 file changed, 9 insertions(+), 8 delet

[COMMITTED 121/220] gccrs: nr2.0: Enable by default

2025-08-05 Thread arthur . cohen
From: Owen Avery gcc/rust/ChangeLog: * lang.opt (frust-name-resolution-2.0): Enable by default. gcc/testsuite/ChangeLog: * rust/compile/nr2/compile.exp: Removed. * rust/compile/nr2/exclude: Removed. Signed-off-by: Owen Avery --- gcc/rust/lang.opt

[COMMITTED 169/220] gccrs: Add indexed positional argument support in asm

2025-08-05 Thread arthur . cohen
From: Pierre-Emmanuel Patry gcc/rust/ChangeLog: * expand/rust-macro-builtins-asm.cc (expand_inline_asm_strings): Handle transformation for indexed positional arguments. Signed-off-by: Pierre-Emmanuel Patry --- gcc/rust/expand/rust-macro-builtins-asm.cc | 5 + 1 file change

[COMMITTED 149/220] gccrs: Improve parsing of simple paths

2025-08-05 Thread arthur . cohen
From: Owen Avery gcc/rust/ChangeLog: * parse/rust-parse-impl.h (Parser::parse_simple_path): Be more careful about skipping SCOPE_RESOLUTION tokens. (Parser::parse_simple_path_segment): Allow parsing from a starting offset. (Parser::parse_use_tree): Handle

[COMMITTED 196/220] gccrs: Fix ICE for ast dump of deferred anon const

2025-08-05 Thread arthur . cohen
From: Philip Herron gcc/rust/ChangeLog: * ast/rust-ast-collector.cc (TokenCollector::visit): check for value Signed-off-by: Philip Herron --- gcc/rust/ast/rust-ast-collector.cc | 8 +++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/gcc/rust/ast/rust-ast-collector.c

[COMMITTED 186/220] gccrs: desugar: Add base for desugaring while-let loops

2025-08-05 Thread arthur . cohen
From: Arthur Cohen gcc/rust/ChangeLog: * Make-lang.in: * ast/rust-expression-yeast.cc (ExpressionYeast::dispatch_loops): Call DesugarWhileLet. * ast/rust-desugar-while-let.cc: New file. * ast/rust-desugar-while-let.h: New file. gcc/testsuite/ChangeLog

[COMMITTED 144/220] gccrs: Add test case showing all derives working on enum

2025-08-05 Thread arthur . cohen
From: Philip Herron We have more complex test cases already but this will close out this issue. Fixes Rust-GCC#2005 gcc/testsuite/ChangeLog: * rust/execute/torture/issue-2005.rs: New test. Signed-off-by: Philip Herron --- .../rust/execute/torture/issue-2005.rs| 465 +

[COMMITTED 178/220] gccrs: ast: Add OffsetOf node

2025-08-05 Thread arthur . cohen
From: Arthur Cohen gcc/rust/ChangeLog: * ast/rust-ast.h: Add OffsetOf expression kind. * ast/rust-builtin-ast-nodes.h (class OffsetOf): Add node. * ast/rust-ast.cc: Define it. * ast/rust-ast-collector.cc: Add visitor for OffsetOf. * ast/rust-ast

[COMMITTED 145/220] gccrs: Add size checking to SlicePattern

2025-08-05 Thread arthur . cohen
From: Yap Zhi Heng gcc/rust/ChangeLog: * typecheck/rust-hir-type-check-pattern.cc(TypeCheckPattern::visit(SlicePattern)): Implement size checking for SlicePattern when type checking against array parent Signed-off-by: Yap Zhi Heng --- .../typecheck/rust-hir-type-chec

[COMMITTED 164/220] gccrs: Handle IfLetExprConseqElse in DefaultResolver

2025-08-05 Thread arthur . cohen
From: Owen Avery This relies on the DefaultASTVisitor visitor for IfLetExprConseqElse performing a virtual call of the visitor for IfLetExpr, which doesn't hold when DefaultASTVisitor is generated by the X-macro-DSL-system I have in another patch. gcc/rust/ChangeLog: * resolve/rust-defa

[COMMITTED 163/220] gccrs: ast: Visit block labels if they are present

2025-08-05 Thread arthur . cohen
From: Arthur Cohen gcc/rust/ChangeLog: * ast/rust-ast-visitor.cc (DefaultASTVisitor::visit): Visit a block's loop label if it exists. --- gcc/rust/ast/rust-ast-visitor.cc | 5 + 1 file changed, 5 insertions(+) diff --git a/gcc/rust/ast/rust-ast-visitor.cc b/gcc/rus

[COMMITTED 113/220] gccrs: nr2.0: Adjust resolution of modules

2025-08-05 Thread arthur . cohen
From: Owen Avery This prioritizes resolution in the language prelude over resolution as a module. gcc/rust/ChangeLog: * resolve/rust-forever-stack.hxx (ForeverStack::resolve_path): Resolve final segments which point to modules. * resolve/rust-toplevel-name-resolver-2.0.c

[COMMITTED 162/220] gccrs: desugar: Add desugar dispatch for all desugars

2025-08-05 Thread arthur . cohen
From: Arthur Cohen Since we are doing more and more "external" desugars, as in desugars that take a pointer and replace it with another one, rather than modifying it from within, having an external visitor dispatch to the proper desugar helps with code clarity. gcc/rust

[COMMITTED 176/220] gccrs: Fix infinite loop with missing comma

2025-08-05 Thread arthur . cohen
From: Pierre-Emmanuel Patry A missing comma between inline assembly templates did not throw an error and looped indefinitely. gcc/rust/ChangeLog: * expand/rust-macro-builtins-asm.cc (parse_format_strings): Emit an error when expecting a comma. gcc/testsuite/ChangeLog:

[COMMITTED 154/220] gccrs: fix bad monomophization of generic paths

2025-08-05 Thread arthur . cohen
From: Philip Herron When we have generic paths like T::foobar during codegen sometimes we need to enforce an extra lookup for this generic parameter type to the mono morphized underlying type. Fixes Rust-GCC#3915 Fixes Rust-GCC#1247 gcc/rust/ChangeLog: * backend/rust-compile-resolve-pa

[COMMITTED 155/220] gccrs: Specialize ExpandVisitor::expand_macro_children

2025-08-05 Thread arthur . cohen
From: Owen Avery gcc/rust/ChangeLog: * expand/rust-expand-visitor.cc (ExpandVisitor::expand_inner_items): Adjust call to expand_macro_children. (ExpandVisitor::expand_inner_stmts): Likewise. (ExpandVisitor::visit): Likewise. * expand/rust-expand-vi

[COMMITTED 153/220] gccrs: Use MacroInvocLexer in AttributeParser

2025-08-05 Thread arthur . cohen
From: Owen Avery This should make it easier for us to handle attribute meta items of the form '=' where the expression isn't a literal. Some low hanging fruit remains here, but I think I should keep this patch small as I had some trouble debugging it as-is (see: Rust::Token::as_string vs Rust::

[COMMITTED 134/220] gccrs: Improve LiteralPattern type checking

2025-08-05 Thread arthur . cohen
From: Yap Zhi Heng This change is made to ensure that LiteralPatterns in SlicePattern are type-checked against the scrutinee array/slice's element type properly. gcc/rust/ChangeLog: * typecheck/rust-hir-type-check-pattern.cc(TypeCheckPattern::visit(LiteralPattern)): Ch

[COMMITTED 158/220] gccrs: nr2.0: Handle glob imports of enum variants.

2025-08-05 Thread arthur . cohen
From: Arthur Cohen gcc/rust/ChangeLog: * resolve/rust-early-name-resolver-2.0.cc (Early::resolve_glob_import): Adapt for enums. (Early::finalize_glob_import): Likewise. * resolve/rust-early-name-resolver-2.0.h: Likewise. * resolve/rust-finalize-imports-2.0.cc

[COMMITTED 150/220] gccrs: Fix ICE with duplicate root item main function

2025-08-05 Thread arthur . cohen
From: Philip Herron Rust seems to allow duplicate HIR::Item 'main' functions but it needs to be a root item to be the true main entry point. This means we can use the canonical path to determine if this is a root one where its CrateName::main or CrateName::Module::main. Fixes Rust-GCC#3978 gcc/

[COMMITTED 157/220] gccrs: mappings: Change mappings to allow other items as item containers.

2025-08-05 Thread arthur . cohen
From: Arthur Cohen This is important for importing enum variants as items. gcc/rust/ChangeLog: * util/rust-hir-map.cc (Mappings::insert_ast_module): Rename to... (Mappings::insert_glob_container): ...this. (Mappings::lookup_ast_module): Rename to... (Mappings

[COMMITTED 152/220] gccrs: return error node when this fails during constexpr case

2025-08-05 Thread arthur . cohen
From: Philip Herron Not adding the test case here we emit more errors than rustc for the error type node so its just noisy and dejagnu is being a pain. Fixes Rust-GCC#3933 gcc/rust/ChangeLog: * backend/rust-compile-resolve-path.cc (ResolvePathRef::resolve): return error_mark_node Sig

[COMMITTED 102/220] gccrs: Fix bug with non compiled const decl

2025-08-05 Thread arthur . cohen
From: Philip Herron There was a sily bug where if you reorder this test case to declare A before B this test would work but its meant to work in any order. So this fixes the bug during code gen to fall back to our query compile system if this is needed. Fixes Rust-GCC#3525 gcc/rust/ChangeLog:

[COMMITTED 098/220] gccrs: Add unify rules for fnptr and closures

2025-08-05 Thread arthur . cohen
From: Philip Herron Its valid to unify a closure to an fnptr as we are working on the fn traits. There are still other issues but this is part of the patch set. gcc/rust/ChangeLog: * typecheck/rust-unify.cc (UnifyRules::expect_fnptr): add unify rules Signed-off-by: Philip Herron ---

[COMMITTED 094/220] gccrs: Cleanup and refactor method resolution

2025-08-05 Thread arthur . cohen
From: Philip Herron Refactor the dot operator implementation to improve code organization and maintainability while preserving existing functionality. gcc/rust/ChangeLog: * typecheck/rust-hir-dot-operator.cc: Major refactoring and cleanup. * typecheck/rust-hir-dot-operator.h: Ad

[COMMITTED 095/220] gccrs: Refactor marker builtin trait assembly

2025-08-05 Thread arthur . cohen
From: Philip Herron Rename assemble_sized_builtin to assemble_marker_builtins and reorganize the type matching to properly handle function pointers and closures with their associated traits (Fn, FnMut, FnOnce). gcc/rust/ChangeLog: * typecheck/rust-hir-type-bounds.h: Rename method.

[COMMITTED 146/220] gccrs: Implement compilation for SlicePattern matching against ArrayType scrutinee

2025-08-05 Thread arthur . cohen
From: Yap Zhi Heng Example GIMPLE output from compiling testsuite/rust/compile/match-pattern-array.rs: ... a[0] = 0; a[1] = 1; RUSTTMP.3 = a; _1 = RUSTTMP.3[0]; _2 = _1 == 0; _3 = RUSTTMP.3[1]; _4 = _3 == 1; _5 = _2 & _4; if (_5 != 0) goto ; else goto ; : { {

[COMMITTED 093/220] gccrs: Fix cyclical projection to placeholder

2025-08-05 Thread arthur . cohen
From: Philip Herron Prevent infinite loops when projecting associated types by properly handling cyclical references with placeholder types. gcc/rust/ChangeLog: * typecheck/rust-hir-trait-resolve.cc: Add cyclical projection protection. --- gcc/rust/typecheck/rust-hir-trait-reso

[COMMITTED 142/220] gccrs: Add test case to show issue is fixed

2025-08-05 Thread arthur . cohen
From: Philip Herron Fixes Rust-GCC#1048 gcc/testsuite/ChangeLog: * rust/compile/issue-1048.rs: New test. Signed-off-by: Philip Herron --- gcc/testsuite/rust/compile/issue-1048.rs | 8 1 file changed, 8 insertions(+) create mode 100644 gcc/testsuite/rust/compile/issue-1048.r

[COMMITTED 091/220] gccrs: Move AST desugaring into expansion phase

2025-08-05 Thread arthur . cohen
From: Owen Avery This fixes some issues with name resolution 2.0. gcc/rust/ChangeLog: * rust-session-manager.cc (Session::compile_crate): Move AST desugaring to... (Session::expansion): ...here and add a final TopLevel pass afterwards. gcc/testsuite/ChangeLog:

[COMMITTED 148/220] gccrs: Add test case to show issue is fixed

2025-08-05 Thread arthur . cohen
From: Philip Herron Fixes Rust-GCC#3524 gcc/testsuite/ChangeLog: * rust/compile/issue-3524.rs: New test. Signed-off-by: Philip Herron --- gcc/testsuite/rust/compile/issue-3524.rs | 9 + 1 file changed, 9 insertions(+) create mode 100644 gcc/testsuite/rust/compile/issue-3524.

[COMMITTED 089/220] gccrs: Fix ICE when constant is missing and expression

2025-08-05 Thread arthur . cohen
From: Philip Herron This is an invalid test case and doesnt work with rustc, we dont fully pick up the errors. Nr2 does handle this and puts out an extra good diagnostic but the old NR doesnt so for now i added this to the exclude list and then when we remove old name resolver this issue goes awa

[COMMITTED 147/220] gccrs: Reject loop in const/static context

2025-08-05 Thread arthur . cohen
From: lishin gcc/rust/ChangeLog: * backend/rust-compile-expr.cc (CompileExpr::visit): Add a catch for const/static. gcc/testsuite/ChangeLog: * rust/compile/loop_constant_context.rs: New test. * rust/compile/issue-3618.rs: Signed-off-by: lishin --- gcc/rust/backend/r

[COMMITTED 141/220] gccrs: Add test case to show we emit better errors now

2025-08-05 Thread arthur . cohen
From: Philip Herron Fixes Rust-GCC#3144 gcc/testsuite/ChangeLog: * rust/compile/issue-3144.rs: New test. Signed-off-by: Philip Herron --- gcc/testsuite/rust/compile/issue-3144.rs | 29 1 file changed, 29 insertions(+) create mode 100644 gcc/testsuite/rust/co

[COMMITTED 200/220] gccrs: Add rest pattern support for AST::SlicePattern

2025-08-05 Thread arthur . cohen
From: Yap Zhi Heng The main change can be found in ast/rust-pattern.h, which introduces 2 item types for AST::SlicePattern - one without rest pattern (SlicePatternItemsNoRest) & the other with it (SlicePatternItemsHasRest). This led to a number of cascading changes as seen in the changelog. g

[COMMITTED 085/220] gccrs: nr2.0: Update IdentifierPattern's subpattern name resolution

2025-08-05 Thread arthur . cohen
From: Zhi Heng gcc/rust/ChangeLog: * resolve/rust-late-name-resolver-2.0.cc (Late::visit(IdentifierPattern)): Remove redundant subpattern check. Signed-off-by: Yap Zhi Heng --- gcc/rust/resolve/rust-late-name-resolver-2.0.cc | 5 + 1 file changed, 1 insertion(+), 4 deleti

[COMMITTED 115/220] gccrs: ast: Add reconstruct() method for Type nodes

2025-08-05 Thread arthur . cohen
From: Arthur Cohen gcc/rust/ChangeLog: * ast/rust-ast.h: Add reconstruct() and reconstruct_impl() for Type nodes. * ast/rust-type.h: Implement them. * ast/rust-macro.h: Likewise. * ast/rust-path.h: Likewise. --- gcc/rust/ast/rust-ast.h | 45

[COMMITTED 137/220] gccrs: nr2.0: Check before visiting a for-loop's label

2025-08-05 Thread arthur . cohen
From: Arthur Cohen gcc/rust/ChangeLog: * resolve/rust-late-name-resolver-2.0.cc (Late::visit): Check for a label before visiting it. --- gcc/rust/resolve/rust-late-name-resolver-2.0.cc | 5 - 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/gcc/rust/resolve

[COMMITTED 114/220] gccrs: ast: reconstruct: Add base for reconstructing and asserting different IDs

2025-08-05 Thread arthur . cohen
From: Arthur Cohen gcc/rust/ChangeLog: * ast/rust-ast.h (reconstruct): New function for calling the `reconstruct_*_impl` method and asserting that the new NodeId is different, and then wrap it in a unique_ptr. (reconstruct_vec): Likewise, but for vectors of unique_ptr

[COMMITTED 188/220] gccrs: Remove warning for unused `self` parameter

2025-08-05 Thread arthur . cohen
From: Ryutaro Okada <1015ry...@gmail.com> gcc/testsuite/ChangeLog: * rust/compile/auto_traits2.rs: emove warning for unused `self` parameter * rust/compile/derive-debug1.rs: emove warning for unused `self` parameter * rust/compile/derive_macro1.rs:

[COMMITTED 109/220] gccrs: Implement type checking for ItemType::RANGED in TuplePattern

2025-08-05 Thread arthur . cohen
From: Zhi Heng This patch implements the previously unimplemented type checking for RANGED item type for TuplePattern, which serves as the start for implementing compilation of RestPattern. gcc/rust/ChangeLog: * typecheck/rust-hir-type-check-pattern.cc (TypeCheckPattern::visit(TuplePat

[COMMITTED 170/220] gccrs: Add pretty hir dump for inline assembly

2025-08-05 Thread arthur . cohen
From: Pierre-Emmanuel Patry gcc/rust/ChangeLog: * hir/rust-hir-dump.cc (Dump::visit): Dump inline assembly fields * hir/tree/rust-hir-expr.h: Add non const getter and avoid operand copy from getters. * hir/tree/rust-hir-visitor.cc (DefaultHIRVisitor::walk): Use no

[COMMITTED 161/220] gccrs: chore: ast: Fix formatting in rust-expr.h

2025-08-05 Thread arthur . cohen
From: Arthur Cohen gcc/rust/ChangeLog: * ast/rust-expr.h: Fix formatting. --- gcc/rust/ast/rust-expr.h | 89 +++- 1 file changed, 43 insertions(+), 46 deletions(-) diff --git a/gcc/rust/ast/rust-expr.h b/gcc/rust/ast/rust-expr.h index c875d6914b3

[COMMITTED 133/220] gccrs: Add type checking for SlicePattern

2025-08-05 Thread arthur . cohen
From: Yap Zhi Heng This commit implements basic type checking support for SlicePattern, based on rustc's check_pat_slice function. gcc/rust/ChangeLog: * typecheck/rust-hir-type-check-pattern.cc (TypeCheckPattern::visit(SlicePattern)): Implement initial type checking fo

[COMMITTED 105/220] gccrs: Add getter for non const lifetime object

2025-08-05 Thread arthur . cohen
From: Ryutaro Okada <1015ry...@gmail.com> gcc/rust/ChangeLog: * hir/tree/rust-hir-item.h (SelfParam::get_lifetime): Add getter for non const lifetime object Signed-off-by: Ryutaro Okada <1015ry...@gmail.com> --- gcc/rust/hir/tree/rust-hir-item.h | 2 ++ 1 file changed, 2 inserti

[COMMITTED 128/220] gccrs: Parse try expressions

2025-08-05 Thread arthur . cohen
From: Owen Avery This doesn't do anything beyond creating TryExpr and parsing them, so try expressions shouldn't be able to make it past AST lowering yet. gcc/rust/ChangeLog: * ast/rust-ast-collector.cc (TokenCollector::visit): Add visitor for TryExpr. * ast/rust-ast-col

[COMMITTED 201/220] gccrs: Retrieve token stream before vector move

2025-08-05 Thread arthur . cohen
From: Pierre-Emmanuel Patry gcc/rust/ChangeLog: * expand/rust-macro-builtins-helpers.cc: Remove use after move. Signed-off-by: Pierre-Emmanuel Patry --- gcc/rust/expand/rust-macro-builtins-helpers.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/gcc/rust/expand

[COMMITTED 129/220] gccrs: ast: Check before visiting a while-let's label

2025-08-05 Thread arthur . cohen
From: Arthur Cohen gcc/rust/ChangeLog: * ast/rust-ast-visitor.cc (DefaultASTVisitor::visit): Check that the WhileLet has a label before visiting it. gcc/testsuite/ChangeLog: * rust/compile/while_let_without_label.rs: New test. --- gcc/rust/ast/rust-ast-visitor.cc

[COMMITTED 127/220] gccrs: Allow format_args to accept a raw string literal

2025-08-05 Thread arthur . cohen
From: Owen Avery gcc/rust/ChangeLog: * expand/rust-macro-builtins-format-args.cc (format_args_parse_arguments): Accept a RAW_STRING_LITERAL token as the first argument. Signed-off-by: Owen Avery --- gcc/rust/expand/rust-macro-builtins-format-args.cc | 11 +-- 1

[COMMITTED 195/220] gccrs: fix clang formatting

2025-08-05 Thread arthur . cohen
From: Philip Herron gcc/rust/ChangeLog: * typecheck/rust-hir-type-check-expr.cc (TypeCheckExpr::visit): formatting * typecheck/rust-tyty-variance-analysis-private.h: likewise * typecheck/rust-tyty.cc (VariantDef::clone): likewise (VariantDef::monomorphized_clone)

[COMMITTED 079/220] gccrs: chore: Fix formatting

2025-08-05 Thread arthur . cohen
From: Arthur Cohen gcc/rust/ChangeLog: * expand/rust-derive.cc: Fix formatting after fork update. --- gcc/rust/expand/rust-derive.cc | 9 ++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/gcc/rust/expand/rust-derive.cc b/gcc/rust/expand/rust-derive.cc index

[COMMITTED 191/220] gccrs: simplify the is_eq on ADTType

2025-08-05 Thread arthur . cohen
From: Philip Herron We dont need to do this resolve we can just let the ParamType's sort this out. gcc/rust/ChangeLog: * typecheck/rust-tyty.cc (ADTType::is_equal): let param::is_eq do this (FnType::is_equal): remove whitespace Signed-off-by: Philip Herron --- gcc/rust/typech

[COMMITTED 189/220] gccrs: Fix ICE during const eval of const capacity

2025-08-05 Thread arthur . cohen
From: Philip Herron We assert that struct expressions during code-gen must be of TyTy::ADTType but we can simply just check for this and return error_mark_node to make this safe. Fixes Rust-GCC#3960 gcc/rust/ChangeLog: * backend/rust-compile-expr.cc (CompileExpr::visit): check for ADTT

[COMMITTED 124/220] gccrs: Remove Late visitor override for StructStruct

2025-08-05 Thread arthur . cohen
From: Owen Avery DefaultResolver already handles StructStruct in a more correct fashion. gcc/rust/ChangeLog: * resolve/rust-late-name-resolver-2.0.cc (Late::visit): Remove override for StructStruct visitor. * resolve/rust-late-name-resolver-2.0.h (Late::visit): Likewise.

[COMMITTED 187/220] gccrs: Do not warn about unused `self` parameter

2025-08-05 Thread arthur . cohen
From: Ryutaro Okada <1015ry...@gmail.com> gcc/rust/ChangeLog: * checks/lints/rust-lint-unused-var.cc (check_decl): Do not warn about unused `self` parameter. Signed-off-by: Ryutaro Okada <1015ry...@gmail.com> --- gcc/rust/checks/lints/rust-lint-unused-var.cc | 4 +++- 1 file cha

[COMMITTED 072/220] gccrs: derive-cmp: Add EnumMatchBuilder class

2025-08-05 Thread arthur . cohen
From: Arthur Cohen gcc/rust/ChangeLog: * expand/rust-derive-cmp-common.h (class EnumMatchBuilder): New helper class. * expand/rust-derive-cmp-common.cc (EnumMatchBuilder::tuple): New function. (EnumMatchBuilder::strukt): New function. --- gcc/rust/expand/rust-derive

  1   2   3   4   5   6   7   8   9   10   >