[COMMITTED 066/144] gccrs: Strong type LoanId

2025-03-19 Thread arthur . cohen
From: Kushal Pal gcc/rust/ChangeLog: * checks/errors/borrowck/rust-bir-dump.cc (Dump::visit): Use new API, i.e get_loan_id() instead of get_loan(). * checks/errors/borrowck/rust-bir-fact-collector.h (points): Use value of LoanId in Polonius facts. * checks

[COMMITTED 023/144] gccrs: Map locations to placeholder regions

2025-03-19 Thread arthur . cohen
From: Kushal Pal Mapped placeholder regions to their respective HIR nodes so we can fetch locations during error reporting. gcc/rust/ChangeLog: * checks/errors/borrowck/rust-bir-builder.h: Map regions to their respective HIR nodes. * checks/errors/borrowck/rust-bir.h (st

[COMMITTED 025/144] gccrs: Move errors with locations

2025-03-19 Thread arthur . cohen
From: Kushal Pal gcc/rust/ChangeLog: * checks/errors/borrowck/rust-borrow-checker-diagnostics.cc (BorrowCheckerDiagnostics::report_move_errors): Specify locations for code causing errors and related moves. gcc/testsuite/ChangeLog: * rust/borrowck/test_move.rs: T

[COMMITTED 027/144] gccrs: ast: PathPattern: Remove `remove_all_segments` method

2025-03-19 Thread arthur . cohen
From: Arthur Cohen This method was used only for stripping PathPattern AST nodes during `cfg-strip`, which seems like a misnomer and makes it a good candidate for simplification. gcc/rust/ChangeLog: * ast/rust-path.h (class PathInExpression): Remove `remove_all_segments` method

[COMMITTED 038/144] gccrs: Fix the parser's operand and flags storage

2025-03-19 Thread arthur . cohen
From: badumbatish gcc/rust/ChangeLog: * expand/rust-macro-builtins-asm.cc (parse_reg_operand): Fix parsing logic & reassignment logic (parse_reg_operand_in): Fix parsing (parse_reg_operand_out): Fix parsing (parse_reg_operand_inout): Fix parsing (p

[COMMITTED 042/144] gccrs: Setting up interfaces for codegen

2025-03-19 Thread arthur . cohen
From: jjasmine gcc/rust/ChangeLog: * backend/rust-compile-expr.cc (CompileExpr::visit): Setting up interfaces for codegen * hir/tree/rust-hir-expr.h: Likewise. --- gcc/rust/backend/rust-compile-expr.cc | 6 -- gcc/rust/hir/tree/rust-hir-expr.h | 26 +

[COMMITTED 082/144] gccrs: Create new test system for name resolution 2.0

2025-03-19 Thread arthur . cohen
From: Owen Avery This runs the standard compile/**.rs tests with name resolution 2.0 enabled. The exclude file can be used to exclude tests which are not yet working with name resolution 2.0. gcc/testsuite/ChangeLog: * rust/compile/nr2/compile.exp: New test. * rust/compile/nr2/e

[COMMITTED 049/144] gccrs: Added counting to check for asm_construct_outputs

2025-03-19 Thread arthur . cohen
From: badumbatish gcc/rust/ChangeLog: * backend/rust-compile-asm.cc (CompileAsm::asm_construct_outputs): Set up counting to check --- gcc/rust/backend/rust-compile-asm.cc | 7 +++ 1 file changed, 7 insertions(+) diff --git a/gcc/rust/backend/rust-compile-asm.cc b/gcc/rust/

[COMMITTED 041/144] gccrs: Local testing for build_string and debug()

2025-03-19 Thread arthur . cohen
From: jjasmine gcc/rust/ChangeLog: * backend/rust-compile-expr.cc (CompileExpr::visit): Local testing for build_string and debug() --- gcc/rust/backend/rust-compile-expr.cc | 5 - 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/gcc/rust/backend/rust-compile-expr

[COMMITTED 014/144] gccrs: Add location support to BIR::Statement

2025-03-19 Thread arthur . cohen
From: Kushal Pal This commit adds location_t to BIR::Statement where type is ASSIGNMENT this information will be later used for reporting borrow-checking errors. gcc/rust/ChangeLog: * checks/errors/borrowck/rust-bir-builder-expr-stmt.cc (ExprStmtBuilder::visit): Added location p

[COMMITTED 031/144] gccrs: attributes: Start handling prelude_import properly

2025-03-19 Thread arthur . cohen
From: Arthur Cohen This commit adds basic handling for the `#[prelude_import]` attribute, without doing anything functionality wise. gcc/rust/ChangeLog: * checks/errors/rust-feature-gate.cc (FeatureGate::visit): Add base feature gating for `#[feature(prelude_import

[COMMITTED 050/144] gccrs: Start work on expand inline asm

2025-03-19 Thread arthur . cohen
From: badumbatish gcc/rust/ChangeLog: * expand/rust-macro-builtins-asm.cc (parse_reg_operand): Remove warnings (parse_reg_operand_out): Remove warnings (expand_inline_asm): New function for eventual expansion (parse_asm): Use expand_inline_asm gcc/testsui

[COMMITTED 059/144] gccrs: Rehaul, Apply code review from Arthur

2025-03-19 Thread arthur . cohen
From: badumbatish gcc/rust/ChangeLog: * backend/rust-compile-asm.cc (CompileAsm::visit): Change API, public/private, comments, formatting from code review (CompileAsm::asm_build_expr): Likewise. (CompileAsm::tree_codegen_asm): Likewise. * backend/r

[COMMITTED 143/144] gccrs: Use name resolver 2.0 in pattern checker

2025-03-19 Thread arthur . cohen
From: Owen Avery gcc/rust/ChangeLog: * checks/errors/rust-hir-pattern-analysis.cc: Add includes. (PatternChecker::visit): Use name resolver 2.0 when enabled. Signed-off-by: Owen Avery --- .../checks/errors/rust-hir-pattern-analysis.cc | 16 +++- 1 file changed, 1

[COMMITTED 063/144] gccrs: Strong type PlaceId

2025-03-19 Thread arthur . cohen
From: Kushal Pal gcc/rust/ChangeLog: * checks/errors/borrowck/rust-bir-dump.cc (renumber_places): Use value of PlaceId as index. (Dump::visit_place): Likewise. (Dump::visit_scope): Likewise. (Dump::go): Refill `place_map` with for loop instead of u

[COMMITTED 108/144] gccrs: Add default resolver parent functions by default

2025-03-19 Thread arthur . cohen
From: Pierre-Emmanuel Patry gcc/rust/ChangeLog: * resolve/rust-finalize-imports-2.0.h: Add parent member functions from default resolver. Signed-off-by: Pierre-Emmanuel Patry --- gcc/rust/resolve/rust-finalize-imports-2.0.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a

[COMMITTED 070/144] gccrs: Used `IndexVec` for Scopes

2025-03-19 Thread arthur . cohen
From: Kushal Pal gcc/rust/ChangeLog: * checks/errors/borrowck/rust-bir-place.h: Used `IndexVec` with ScopeId as index. Signed-off-by: Kushal Pal --- .../checks/errors/borrowck/rust-bir-place.h | 25 +-- 1 file changed, 12 insertions(+), 13 deletions(-) diff

[COMMITTED 067/144] gccrs: Strong type ScopeId

2025-03-19 Thread arthur . cohen
From: Kushal Pal gcc/rust/ChangeLog: * checks/errors/borrowck/rust-bir-builder-expr-stmt.cc (ExprStmtBuilder::setup_loop): Use value of ScopeId. (ExprStmtBuilder::visit): Use continue scope id instead of continue basic block id. * checks/errors/borrowck/ru

[COMMITTED 141/144] gccrs: Use name resolver 2.0 in const checker

2025-03-19 Thread arthur . cohen
From: Owen Avery gcc/rust/ChangeLog: * checks/errors/rust-const-checker.cc: Add includes. (ConstChecker::visit): Use name resolver 2.0 to lookup function definitions when name resolution 2.0 is enabled. gcc/testsuite/ChangeLog: * rust/compile/nr2/exclude: Remove

[COMMITTED 117/144] gccrs: Add box definition to avoid error

2025-03-19 Thread arthur . cohen
From: Pierre-Emmanuel Patry Box definition is part of the standard library and cannot be found during name resolution. This simple definition prevent any error from being emitted. gcc/testsuite/ChangeLog: * rust/compile/box_syntax_feature_gate.rs: Add box land item definition.

[COMMITTED 019/145] gccrs: Change lookup_hir_to_node return type to optional

2025-03-17 Thread arthur . cohen
From: Pierre-Emmanuel Patry Optional are more convenient to use and avoid uninitialized data. gcc/rust/ChangeLog: * backend/rust-compile-expr.cc (CompileExpr::generate_closure_function): Adapt code for new optional return type. * checks/errors/privacy/rust-privacy-report

[COMMITTED 018/145] gccrs: Change lookup_node_to_hir return type to optional

2025-03-17 Thread arthur . cohen
From: Pierre-Emmanuel Patry Previous API was using a boolean and a pointer, this was not practical and could be replaced with an optional. gcc/rust/ChangeLog: * backend/rust-compile-expr.cc (CompileExpr::visit): Change call to use the returned optional. (CompileExpr::gen

[COMMITTED 022/145] gccrs: Change return type of lookup_hir_trait_item

2025-03-17 Thread arthur . cohen
From: Pierre-Emmanuel Patry Change the return type to an optional instead of returning a null pointer. This allows easier tracking of rogue null pointers in the map. This commit also fixes a bug in trait associated function mangling, the function was using an already invalidated pointer. gcc/rus

[COMMITTED 015/145] gccrs: Add testcases for handling struct as scrutinee for match expr

2025-03-17 Thread arthur . cohen
From: Nobel Singh gcc/testsuite/ChangeLog: * rust/compile/issue-2906.rs: New test. * rust/execute/torture/issue-2906.rs: New test. Signed-off-by: Nobel Singh --- gcc/testsuite/rust/compile/issue-2906.rs | 10 ++ .../rust/execute/torture/issue-2906.rs| 34 +

[COMMITTED 026/145] gccrs: Change return type of lookup_crate_name

2025-03-17 Thread arthur . cohen
From: Pierre-Emmanuel Patry Change the function's return type to use an optional. gcc/rust/ChangeLog: * resolve/rust-ast-resolve-toplevel.h: Adapt the code to the new return type. * resolve/rust-toplevel-name-resolver-2.0.cc (TopLevel::visit): Likewise. *

[COMMITTED 106/145] gccrs: Scaffolding HIRFullVisitor for inline asm

2025-03-17 Thread arthur . cohen
From: jjasmine gcc/rust/ChangeLog: * ast/rust-ast-visitor.h: Scaffolding HIRFullVisitor for inline asm * ast/rust-ast.cc (InlineAsm::accept_vis): Likewise. * hir/tree/rust-hir-visitor.h (RUST_HIR_VISITOR_H): Likewise. * hir/tree/rust-hir.cc (InlineAsm::acc

[COMMITTED 100/145] gccrs: Refactoring for inline asm pr

2025-03-17 Thread arthur . cohen
From: jjasmine gcc/rust/ChangeLog: * ast/rust-expr.h (struct AnonConst): major refactoring of inline asm, mostly concerns naming convention, trinary conditionals, warnings, adding rust_unreachables in not-yet supported errors. (struct InlineAsmRegOrRegClas

[COMMITTED 117/145] gccrs: Fix optional trait parsing

2025-03-17 Thread arthur . cohen
From: dave gcc/rust/ChangeLog: * typecheck/rust-hir-type-check-item.cc (TypeCheckItem::visit): Check for ?Trait in visitor gcc/testsuite/ChangeLog: * rust/compile/issue-2725.rs: New test. Signed-off-by: Dave Evans --- gcc/rust/typecheck/rust-hir-type-check-item.cc | 18

[COMMITTED 096/145] gccrs: Big Refactor after meeting

2025-03-17 Thread arthur . cohen
From: jjasmine gcc/rust/ChangeLog: * ast/rust-expr.h (struct InlineAsmRegOrRegClass): Remove union (struct InlineAsmOperand): Make instances of inside struct. * expand/rust-macro-builtins-asm.cc (parse_clobber_abi): Change signature with inlineAsmCtx.

[COMMITTED 097/145] gccrs: Renamed parseAsmArg to conform to other function names

2025-03-17 Thread arthur . cohen
From: jjasmine gcc/rust/ChangeLog: * expand/rust-macro-builtins-asm.cc (parseAsmArg): Renamed parseAsmArg to conform to other function names (parse_asm_arg): Likewise. (parse_asm): Likewise. * expand/rust-macro-builtins-asm.h (parseAsmArg): Likewise.

[COMMITTED 103/145] gccrs: Partial unsafe support for inline asm

2025-03-17 Thread arthur . cohen
From: jjasmine gcc/rust/ChangeLog: * checks/errors/rust-unsafe-checker.cc (UnsafeChecker::visit): Partial unsafe support for inline asm * checks/errors/rust-unsafe-checker.h: Likewise. * hir/tree/rust-hir-expr.h: Likewise. * hir/tree/rust-hir.cc (InlineAsm

[COMMITTED 101/145] gccrs: Slim down the test cases

2025-03-17 Thread arthur . cohen
From: jjasmine gcc/testsuite/ChangeLog: * rust/compile/inline_asm_faulty_clobber.rs: compress the test * rust/compile/inline_asm_nop.rs: compress the test * rust/compile/inline_asm_faulty_clobber_1.rs: Removed. * rust/compile/inline_asm_faulty_clob

[COMMITTED 088/144] gccrs: Remove some overloaded methods from DefaultResolver.

2025-03-19 Thread arthur . cohen
From: Owen Avery gcc/rust/ChangeLog: * resolve/rust-default-resolver.cc (DefaultResolver::visit): Remove some empty overloads which DefaultASTVisitor::visit should be able to handle. * resolve/rust-default-resolver.h (DefaultResolver::visit): Likewise. gc

[PATCHSET] Update Rust frontend 21/03/2024 3/4

2025-03-21 Thread arthur . cohen
Hi everyone, This is our the third patchset in the series for updating upstream GCC with the latest changes in our development repository. Most notably this contains handling for if-let statements by Marc Poulhiès, changes to our name-resolution pass rewrite, and massive changes to our AST and HI

[COMMITTED 010/146] rust: Desugar IfLet* into MatchExpr

2025-03-21 Thread arthur . cohen
From: Marc Poulhiès Replace the "regular" AST->HIR lowering for IfLet* with a desugaring into a MatchExpr. Desugar a simple if let: if let Some(y) = some_value { bar(); } into: match some_value { Some(y) => {bar();}, _ => () } Same applies for IfLetExprConseqElse (

[COMMITTED 002/146] gccrs: Insert trait names during toplevel resolution 2.0

2025-03-21 Thread arthur . cohen
From: Owen Avery gcc/rust/ChangeLog: * resolve/rust-toplevel-name-resolver-2.0.cc (TopLevel::visit): Insert trait names into the type namespace. Signed-off-by: Owen Avery --- gcc/rust/resolve/rust-toplevel-name-resolver-2.0.cc | 3 +++ 1 file changed, 3 insertions(+) diff --g

[COMMITTED 005/146] gccrs: Rename some PathIdentSegment functions

2025-03-21 Thread arthur . cohen
From: Owen Avery This makes PathIdentSegment more similar to other classes used to represent path segments. gcc/rust/ChangeLog: * ast/rust-path.h (PathIdentSegment::is_super_segment): Rename to... (PathIdentSegment::is_super_path_seg): ...here. (PathIdentSegment:

[COMMITTED 009/146] gccrs: Fix name resolution 2.0 definition lookups in unsafe checker

2025-03-21 Thread arthur . cohen
From: Owen Avery gcc/rust/ChangeLog: * checks/errors/rust-unsafe-checker.cc: Add includes. (UnsafeChecker::visit): Use 2.0 version of resolver when name resolution 2.0 is enabled. gcc/testsuite/ChangeLog: * rust/compile/nr2/exclude: Remove entries. Signed-off-b

[COMMITTED 012/146] gccrs: Resolve SelfParam in name resolution 2.0

2025-03-21 Thread arthur . cohen
From: Owen Avery gcc/rust/ChangeLog: * resolve/rust-late-name-resolver-2.0.cc (Late::visit): Handle SelfParam. * resolve/rust-late-name-resolver-2.0.h (Late::visit): Likewise. gcc/testsuite/ChangeLog: * rust/compile/nr2/exclude: Remove entries. Signed-o

[COMMITTED 109/146] gccrs: rust/intrinsic: add new "catch_unwind" variant of API

2025-03-23 Thread arthur . cohen
From: liushuyu gcc/rust/ChangeLog: * backend/rust-compile-intrinsic.cc: add the new `catch_unwind` variant of the `try` intrinsic: this variant can be seen on Rust 1.78+ and returns `()` instead of `i32`. --- gcc/rust/backend/rust-compile-intrinsic.cc | 57 +++

[COMMITTED 105/146] gccrs: cleanup our enum type layout to be closer to rustc

2025-03-21 Thread arthur . cohen
From: Philip Herron This changes our enum type layout so for example: enum Foo { A, B, C(char), D { x: i32, y: i32 }, } Used to get layed out like this in gccrs: union { struct A { int RUST$ENUM$DISR; }; struct B { int RUST$ENUM$DISR; }; struct C { int

[COMMITTED 070/146] gccrs: ast: Add LangItemPath class

2025-03-21 Thread arthur . cohen
From: Arthur Cohen This commit adds a new kind of Path, changes the base Path class and turns TypePath into a child of the base Path class. gcc/rust/ChangeLog: * ast/rust-path.h (class LangItemPath): New. (class TypePath): Adapt to accomodate LangItemPath. * ast/rust

[COMMITTED 072/146] gccrs: hir: Start adapting visitors to accept multiple kinds of Paths

2025-03-21 Thread arthur . cohen
From: Arthur Cohen gcc/rust/ChangeLog: * ast/rust-item.h: Add new method to specifically get a type-path. * ast/rust-path.cc (LangItemPath::as_string): Implement properly. * hir/rust-ast-lower-type.cc (ASTLowerTypePath::translate): Adapt visitor to use the new

[COMMITTED 142/146] gccrs: ast-builder: Add new methods for building structs

2025-03-21 Thread arthur . cohen
From: Arthur Cohen gcc/rust/ChangeLog: * ast/rust-ast-builder.cc: Add new methods for constructing struct exprs. * ast/rust-ast-builder.h: Mention how to build tuple expressions. --- gcc/rust/ast/rust-ast-builder.cc | 12 ++-- gcc/rust/ast/rust-ast-builder.h | 5

[COMMITTED 141/146] gccrs: derive(Clone): Add deriving of simple enum variants

2025-03-21 Thread arthur . cohen
From: Arthur Cohen gcc/rust/ChangeLog: * expand/rust-derive-clone.cc: Clone enum identifier variants properly * expand/rust-derive-clone.h: Declare new functions used. --- gcc/rust/expand/rust-derive-clone.cc | 52 ++-- gcc/rust/expand/rust-derive

[COMMITTED 133/146] gccrs: builder: Allow generating struct statements

2025-03-21 Thread arthur . cohen
From: Arthur Cohen gcc/rust/ChangeLog: * ast/rust-ast-builder.cc (Builder::struct_struct): New function. * ast/rust-ast-builder.h (vec): New function. --- gcc/rust/ast/rust-ast-builder.cc | 15 +++ gcc/rust/ast/rust-ast-builder.h | 31

[COMMITTED 100/146] gccrs: nr2.0: Improve default, top-level, and late resolvers

2025-03-21 Thread arthur . cohen
From: Owen Avery gcc/rust/ChangeLog: * resolve/rust-default-resolver.cc (DefaultResolver::visit): Make sure to scope visitation of the children of type definition items. * resolve/rust-default-resolver.h (DefaultResolver::visit): Add overrides for TupleStr

[COMMITTED 090/146] gccrs: Fix NR2.0 compiler ICE caused by Generics in Enums

2025-03-21 Thread arthur . cohen
From: Liam Naddell gcc/rust/ChangeLog: * resolve/rust-late-name-resolver-2.0.cc: Change the late name resolver to enter proper lexical scope during typechecking * resolve/rust-late-name-resolver-2.0.h: Add needed prototype to header * resolve/rust-toplevel

[COMMITTED 077/146] gccrs: fix bad not expression in rust

2025-03-21 Thread arthur . cohen
From: Philip Herron Fixes Rust-GCC#3229 gcc/rust/ChangeLog: * rust-gcc.cc (operator_to_tree_code): ! expressions are BIT_NOT_EXPR Signed-off-by: Philip Herron --- gcc/rust/rust-gcc.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gcc/rust/rust-gcc.cc b/gcc/rust/

[COMMITTED 114/146] gccrs: Add ForeverStackStore

2025-03-21 Thread arthur . cohen
From: Owen Avery ForeverStackStore is meant to partially unify the internal states of per-namespace ForeverStack instances. This commit does not contain modifications to ForeverStack which would allow it to rely on a ForeverStackStore to store nodes, but a future commit should address this. gcc/

[COMMITTED 096/146] gccrs: nr2.0: Resolve type aliases inside trait definitions

2025-03-21 Thread arthur . cohen
From: Owen Avery gcc/rust/ChangeLog: * resolve/rust-toplevel-name-resolver-2.0.cc (TopLevel::visit): Add visitor for TraitItemType. * resolve/rust-toplevel-name-resolver-2.0.h (TopLevel::visit): Likewise. gcc/testsuite/ChangeLog: * rust/compile/nr2/exclu

[COMMITTED 087/146] gccrs: lang-items: Collect trait functions that are lang items

2025-03-21 Thread arthur . cohen
From: Arthur Cohen gcc/rust/ChangeLog: * ast/rust-collect-lang-items.cc (CollectLangItems::visit): Add visitor for collecting functions that might be lang items. * ast/rust-collect-lang-items.h: Likewise. --- gcc/rust/ast/rust-collect-lang-items.cc | 8 gcc

[COMMITTED 020/146] gccrs: Use name resolver 2.0 for module descendance checks

2025-03-21 Thread arthur . cohen
From: Owen Avery gcc/rust/ChangeLog: * checks/errors/privacy/rust-privacy-reporter.cc: Include rust-immutable-name-resolution-context.h. (is_child_module): Use ForeverStack::is_module_descendant if name resolution 2.0 is enabled. * resolve/rust-forever-sta

[COMMITTED 033/146] gccrs: Refactor HIR with optionals, references & newtypes

2025-03-21 Thread arthur . cohen
From: Pierre-Emmanuel Patry The HIR made heavy use of pair and other unamed types which can be difficult to read. gcc/rust/ChangeLog: * backend/rust-compile-base.cc: Use FnParam getter. * backend/rust-compile-expr.cc (CompileExpr::visit): Likewise. * backend/rust-compile

[COMMITTED 029/146] gccrs: Fix bad handling for recursive type query

2025-03-21 Thread arthur . cohen
From: Philip Herron When resolving a type like this which is generic it causes the argument substitution to go through bounds checking which is expected. But this can call a type bounds probe which again calls a type query which will be on the Impl Type on an impl block which can result in a recu

[COMMITTED 036/146] gccrs: Fix Generic type retrieval

2025-03-21 Thread arthur . cohen
From: Pierre-Emmanuel Patry gcc/rust/ChangeLog: * hir/rust-ast-lower-type.cc (ASTLowerGenericParam::visit): Forward an optional to the constructor. * hir/tree/rust-hir-item.cc (TypeParam::TypeParam): Use an optional in the constructor. (TypeParam::operator

[COMMITTED 016/146] gccrs: Remove usage of Resolver::get_builtin_types

2025-03-21 Thread arthur . cohen
From: Owen Avery gcc/rust/ChangeLog: * backend/rust-compile-context.cc (Context::setup_builtins): Use TypeCheckContext::get_builtins instead of Resolver::get_builtin_types, TypeCheckContext::lookup_type_by_node_id, and TypeCheckContext::lookup_type.

[COMMITTED 019/146] gccrs: Use name resolver 2.0 in VisibilityResolver

2025-03-21 Thread arthur . cohen
From: Owen Avery gcc/rust/ChangeLog: * checks/errors/privacy/rust-visibility-resolver.cc: Add includes. (VisibilityResolver::resolve_module_path): Use name resolver 2.0 (when enabled) to lookup path resolutions. Signed-off-by: Owen Avery --- .../privacy/rust-vi

[COMMITTED 021/146] gccrs: Reorganize the CPU feature detection

2025-03-21 Thread arthur . cohen
From: Antoni Boucher Move the code from i386-rust.cc to i386-rust-and-jit.inc so that it can be reused by libgccjit. gcc/ChangeLog: * config/i386/i386-rust-and-jit.inc: New file. * config/i386/i386-rust.cc: Move code to i386-rust-and-jit.inc. --- gcc/config/i386/i386-rust-and-j

[COMMITTED 018/146] gccrs: fix bad type inference on local patterns

2025-03-21 Thread arthur . cohen
From: Philip Herron We do not need to inject inference variables on generic patterns with generic blocks. This will just cause unconstrained inference variables as they may not unify against something. Fixes Rust-GCC#2323 gcc/rust/ChangeLog: * typecheck/rust-hir-type-check-path.cc (Ty

[COMMITTED 023/146] gccrs: fix typechecking of Fn trait calls using ADT types

2025-03-21 Thread arthur . cohen
From: Philip Herron Fixes RustGcc#2953 gcc/rust/ChangeLog: * typecheck/rust-hir-type-check-item.cc (TypeCheckItem::visit): fix the ty_id gcc/testsuite/ChangeLog: * rust/compile/nr2/exclude: nr2 cant handle these * rust/compile/issue-2953-1.rs: New test. * rust

[COMMITTED 025/146] gccrs: add test case to show issue is fixed

2025-03-21 Thread arthur . cohen
From: Philip Herron The original test case 1773 has been moved to a new issue 3242 which is still open and test-case is skipped. The original issue in 1773 is fixed so this will close out that issue Fixes Rust-Gcc#1773 gcc/testsuite/ChangeLog: * rust/compile/issue-1773.rs: new test cas

[COMMITTED 030/146] gccrs: Push ribs by kind rather than by value

2025-03-21 Thread arthur . cohen
From: Owen Avery gcc/rust/ChangeLog: * resolve/rust-forever-stack.h (ForeverStack::push): Accept argument of type Rib::Kind rather than Rib. * resolve/rust-forever-stack.hxx (ForeverStack::push): Likewise. * resolve/rust-name-resolution-context.cc

[COMMITTED 043/146] gccrs: Use nr2.0 in PrivacyReporter

2025-03-21 Thread arthur . cohen
From: Owen Avery gcc/rust/ChangeLog: * checks/errors/privacy/rust-privacy-reporter.cc (PrivacyReporter::check_for_privacy_violation): Use name resolver 2.0. gcc/testsuite/ChangeLog: * rust/compile/nr2/exclude: Remove entries. Signed-off-by: Owen Avery --- ...

[COMMITTED 052/146] gccrs: improve handling of Self Type paths

2025-03-21 Thread arthur . cohen
From: Philip Herron TypePaths have special handling for Self where we can look at the current ctx for more acurate TypeAlias information if required. We cant do this for Impl contexts but not for Traits as we might as well fall back to the TypePathProbe. The other issue was the dyn type comming

[COMMITTED 045/146] gccrs: Use nr2.0 in typechecker

2025-03-21 Thread arthur . cohen
From: Owen Avery I probably missed a few spots, but this should cover most of the type checker. gcc/rust/ChangeLog: * typecheck/rust-hir-type-check-expr.cc: Add includes. (TypeCheckExpr::visit): Use name resolver 2.0. (TypeCheckExpr::resolve_operator_overload): Likewise.

[COMMITTED 054/146] gccrs: ensure packed and aligned is applied properly

2025-03-21 Thread arthur . cohen
From: Philip Herron We cannot apply aligned or packed after layout_type is called you need to set this up first then call it. Fixes Rust-GCC#3260 gcc/rust/ChangeLog: * backend/rust-compile-type.cc (TyTyResolveCompile::visit): call lauout type directly * rust-backend.h (struct_

[COMMITTED 055/146] gccrs: lang-items: Move comment about arithmetic lang items

2025-03-21 Thread arthur . cohen
From: Arthur Cohen gcc/rust/ChangeLog: * util/rust-lang-item.h: Fix comment location to align with other comments. --- gcc/rust/util/rust-lang-item.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gcc/rust/util/rust-lang-item.h b/gcc/rust/util/rust-lang-item.h

[COMMITTED 064/146] gccrs: fix crash in hir dump

2025-03-21 Thread arthur . cohen
From: Philip Herron gcc/rust/ChangeLog: * hir/rust-hir-dump.cc (Dump::visit): add missing check for no return value Signed-off-by: Philip Herron --- gcc/rust/hir/rust-hir-dump.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/gcc/rust/hir/rust-hir-dump.cc b/gcc

[COMMITTED 062/146] gccrs: add checks for division by zero and left shift overflow

2025-03-21 Thread arthur . cohen
From: Philip Herron These are ported from the c-family code c-warn.cc and c/c-typchk.cc Fixes Rust-GCC#2394 gcc/rust/ChangeLog: * backend/rust-constexpr.cc (eval_store_expression): check for null (eval_call_expression): remove bad warning * rust-gcc.cc (arithmetic_or_lo

[COMMITTED 079/146] gccrs: Made changes to AST::TraitImpl constructor for TypePath

2025-03-21 Thread arthur . cohen
From: Sri Ganesh Thota gcc/rust/ChangeLog: * ast/rust-item.h: I have changed helper constructor for typepath to be a delegating constructor. Signed-off-by: Sri Ganesh Thota --- gcc/rust/ast/rust-item.h | 13 ++--- 1 file changed, 6 insertions(+), 7 deletions(-) diff -

[COMMITTED 083/146] gccrs: resolve: Name resolve trait bounds properly

2025-03-21 Thread arthur . cohen
From: Arthur Cohen gcc/rust/ChangeLog: * resolve/rust-ast-resolve-type.cc (ResolveTypeToCanonicalPath::visit): Resolve additional trait bounds. * resolve/rust-late-name-resolver-2.0.cc (Late::visit): Error out properly on unresolved type-path instead of

[COMMITTED 089/146] gccrs: ast-builder: Add more methods

2025-03-21 Thread arthur . cohen
From: Arthur Cohen This commit adds new methods for building pattern nodes, match expressions and more precise call expressions. gcc/rust/ChangeLog: * ast/rust-ast-builder.cc: Add new functions. * ast/rust-ast-builder.h: Declare them. --- gcc/rust/ast/rust-ast-builder.cc | 91

[COMMITTED 059/146] gccrs: ast: Use StackedContexts class in ContextualASTVisitor

2025-03-21 Thread arthur . cohen
From: Arthur Cohen gcc/rust/ChangeLog: * ast/rust-ast-visitor.h: Replace context with StackedContexts. * ast/rust-ast-visitor.cc (ContextualASTVisitor::visit): Use new APIs. * checks/errors/rust-ast-validation.cc (ASTValidation::visit): Likewise. --- gcc/rust/ast/rust

[COMMITTED 058/146] gccrs: stacked-contexts: Add peek() method

2025-03-21 Thread arthur . cohen
From: Arthur Cohen gcc/rust/ChangeLog: * util/rust-stacked-contexts.h: Add new method to see what context we are currently in. --- gcc/rust/util/rust-stacked-contexts.h | 7 +++ 1 file changed, 7 insertions(+) diff --git a/gcc/rust/util/rust-stacked-contexts.h b/gcc/rust/util

[COMMITTED 080/146] gccrs: add ptr to int and int to ptr type cast rules

2025-03-21 Thread arthur . cohen
From: Nobel Added rules to allow type casting pointer as integer types (u*,i*) and integer types to be casted as pointer. gcc/rust/ChangeLog: * typecheck/rust-casts.cc (TypeCastRules::cast_rules): Add rule. gcc/testsuite/ChangeLog: * rust/compile/ptr_int_cast.rs: New test. Si

[COMMITTED 061/146] gccrs: constant evaluation like these are coercion sites

2025-03-21 Thread arthur . cohen
From: Philip Herron The code here was wrongly assuming the decl type from the folding of the expression would be the type of the constant decl. This is not the case for unsized coercions for slices, where the expression here is a reference to an array then we require the coercion to fix the resul

[COMMITTED 112/146] gccrs: improve mutability checks

2025-03-21 Thread arthur . cohen
From: Philip Herron This ensures that we handle var decls readonly checks much better Addresses: Rust-GCC#807 Rust-GCC#3287 gcc/rust/ChangeLog: * checks/errors/rust-readonly-check.cc (check_decl): improve mut check (emit_error): helper (check_modify_expr): likewise

[COMMITTED 063/146] gccrs: add test case to show issue is fixed

2025-03-21 Thread arthur . cohen
From: Philip Herron Fixes Rust-GCC#266 gcc/testsuite/ChangeLog: * rust/compile/nr2/exclude: nr2 cant handle this * rust/compile/issue-266.rs: New test. Signed-off-by: Philip Herron --- gcc/testsuite/rust/compile/issue-266.rs | 3 +++ gcc/testsuite/rust/compile/nr2/exclude |

[COMMITTED 073/146] gccrs: nr1.0: Resolve lang item paths properly.

2025-03-21 Thread arthur . cohen
From: Arthur Cohen gcc/rust/ChangeLog: * resolve/rust-ast-resolve-item.cc (ResolveItem::visit): Adapt resolver to lang item paths. * resolve/rust-ast-resolve-type.h: Likewise. --- gcc/rust/resolve/rust-ast-resolve-item.cc | 30 +-- gcc/rust/resolve

[COMMITTED 069/146] gccrs: Fix ForeverStack::find_starting_point output parameter

2025-03-21 Thread arthur . cohen
From: Owen Avery gcc/rust/ChangeLog: * resolve/rust-forever-stack.h (ForeverStack::find_starting_point): Use type 'std::reference_wrapper &' instead of 'Node &' for parameter starting_point. * resolve/rust-forever-stack.hxx (ForeverStack::find_star

[COMMITTED 126/146] gccrs: lower: Properly lower non-generic lang item type path segments.

2025-03-21 Thread arthur . cohen
From: Arthur Cohen gcc/rust/ChangeLog: * hir/rust-ast-lower-type.cc (ASTLowerTypePath::visit): Adapt code to lang item type path segments. --- gcc/rust/hir/rust-ast-lower-type.cc | 40 ++--- 1 file changed, 14 insertions(+), 26 deletions(-) diff --git

[COMMITTED 118/146] gccrs: Add missing name resolution to static items in blocks

2025-03-21 Thread arthur . cohen
From: Philip Herron We need to add name resolution and hir lowering for items as part of blocks in order to typecheck and compile them correctly. Fixes Rust-GCC#3350 gcc/rust/ChangeLog: * hir/rust-ast-lower-stmt.cc (ASTLoweringStmt::visit): hir lowering * hir/rust-ast-lower-stm

[COMMITTED 101/146] gccrs: fix ICE in borrows to invalid expressions

2025-03-21 Thread arthur . cohen
From: Philip Herron We need to check if the borrowed value is valid before creating the reference type. Otherwise this will lead to an ICE. Fixes Rust-GCC#3140 gcc/rust/ChangeLog: * typecheck/rust-hir-type-check-expr.cc (TypeCheckExpr::visit): check for error * typecheck/rust-

[COMMITTED 123/146] gccrs: collect-lang-items: Display attribute upon error finding it

2025-03-21 Thread arthur . cohen
From: Arthur Cohen gcc/rust/ChangeLog: * ast/rust-collect-lang-items.cc (get_lang_item_attr): Show unknown attribute upon error. --- gcc/rust/ast/rust-collect-lang-items.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/gcc/rust/ast/rust-collect-lang-items.cc b

[COMMITTED 131/146] gccrs: ast-collector: Fix tuple struct pattern collection

2025-03-21 Thread arthur . cohen
From: Arthur Cohen gcc/rust/ChangeLog: * ast/rust-ast-collector.cc (TokenCollector::visit): Visit tuple pattern items as separated by commas. --- gcc/rust/ast/rust-ast-collector.cc | 5 + 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/gcc/rust/ast/rust-ast

[COMMITTED 128/146] gccrs: lang-item: Add LangItem::PrettyString

2025-03-21 Thread arthur . cohen
From: Arthur Cohen Which formats a lang item as it appears in source code. gcc/rust/ChangeLog: * util/rust-lang-item.cc (LangItem::PrettyString): New. * util/rust-lang-item.h: New. --- gcc/rust/util/rust-lang-item.cc | 6 ++ gcc/rust/util/rust-lang-item.h | 1 + 2 files

[COMMITTED 134/146] gccrs: derive(Clone): Manually generate AssertParamIsCopy struct for unions

2025-03-21 Thread arthur . cohen
From: Arthur Cohen gcc/rust/ChangeLog: * expand/rust-derive-clone.cc (DeriveClone::visit_union): Manually generate the struct used for asserting a union implements Copy. --- gcc/rust/expand/rust-derive-clone.cc | 38 +--- 1 file changed, 34 insertions

[COMMITTED 107/146] gccrs: match arms are a LUB

2025-03-21 Thread arthur . cohen
From: Philip Herron Unify rules are not the same as coercion rules. The coercion of ! is allowed to any type but not for a unify site which is different. Match arms are another least upper bound coercion. gcc/rust/ChangeLog: * backend/rust-compile-expr.cc (CompileExpr::visit): implemen

[COMMITTED 103/146] gccrs: fix ICE with hir dump on closure

2025-03-21 Thread arthur . cohen
From: Philip Herron Return type and parameter types are optional on closures. gcc/rust/ChangeLog: * hir/rust-hir-dump.cc (Dump::visit): add null guard Signed-off-by: Philip Herron --- gcc/rust/hir/rust-hir-dump.cc | 8 ++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --

[COMMITTED 116/146] gccrs: Fix scan-gimple testcases on LE platforms.

2025-03-21 Thread arthur . cohen
From: Arthur Cohen gcc/testsuite/ChangeLog: * rust/compile/macros/builtin/eager1.rs: Switch to scan-assembler directive as the GIMPLE dump does not contain strings on LE. * rust/compile/macros/builtin/recurse2.rs: Likewise. --- .../rust/compile/macros/builtin/eager1.rs

[COMMITTED 110/146] gccrs: add two more tests to test try-catch (unwind) code generation

2025-03-21 Thread arthur . cohen
From: liushuyu gcc/testsuite/ChangeLog: * rust/compile/try-catch-unwind-old.rs: add a test to test the older try intrinsics from plain old Rust to v1.78.0 * rust/compile/try-catch-unwind-new.rs: add a test to test the newer catch_unwind instrinsics since Rust v1.78

[COMMITTED 046/146] gccrs: Clean up some system includes

2025-03-21 Thread arthur . cohen
From: Pierre-Emmanuel Patry System includes shall use rust-system header instead. gcc/rust/ChangeLog: * ast/rust-stmt.h: Remove stdlib include and use rust-system instead. * backend/rust-compile-expr.cc: Likewise. * backend/rust-mangle-legacy.cc: Likewise. * back

[COMMITTED 146/146] gccrs: nr2.0: late: Better format PathInExpression resolution

2025-03-21 Thread arthur . cohen
From: Arthur Cohen gcc/rust/ChangeLog: * resolve/rust-late-name-resolver-2.0.cc (Late::visit): Improve formatting. --- .../resolve/rust-late-name-resolver-2.0.cc | 18 ++ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/gcc/rust/resolve/rust-late-name

[COMMITTED 057/146] gccrs: hir: Remove duplicate function in TraitItemFunc

2025-03-21 Thread arthur . cohen
From: Arthur Cohen Both TraitItemFunc::has_definition() and TraitItemFunc::has_block_defined() were exactly the same implementation, so remove one. gcc/rust/ChangeLog: * hir/tree/rust-hir-item.h: Remove TraitItemFunc::has_block_defined() * backend/rust-compile-implitem.cc

[COMMITTED 140/146] gccrs: derive(Clone): Improve existing testcase

2025-03-21 Thread arthur . cohen
From: Arthur Cohen gcc/testsuite/ChangeLog: * rust/compile/derive_macro4.rs: Mark Copy and Clone as lang items. --- gcc/testsuite/rust/compile/derive_macro4.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/gcc/testsuite/rust/compile/derive_macro4.rs b/gcc/testsuite/rust

[COMMITTED 124/146] gccrs: ast: Refactor how lang item paths are handled.

2025-03-21 Thread arthur . cohen
From: Arthur Cohen Lang item typepaths were not handled properly, and required a complete overhaul. All old classes that concerned lang item paths are now modified to use a simpler version of `AST::LangItemPath`, which has been removed. TypePath segments can now be lang items, as this is

[COMMITTED 119/146] gccrs: nr2.0: Early resolve pending eager macro invocations

2025-03-21 Thread arthur . cohen
From: Owen Avery gcc/rust/ChangeLog: * resolve/rust-early-name-resolver-2.0.cc (Early::visit): Resolve the pending eager invocations inside builtin macro invocations. gcc/testsuite/ChangeLog: * rust/compile/nr2/exclude: Remove entries. Signed-off-by: Owen Avery

[COMMITTED 132/146] gccrs: lang-items: Mark Clone trait as a lang item in testsuite

2025-03-21 Thread arthur . cohen
From: Arthur Cohen gcc/testsuite/ChangeLog: * rust/compile/derive_macro1.rs: Add #[lang = "clone"] to Clone trait. * rust/compile/derive_macro3.rs: Likewise. * rust/compile/derive_macro6.rs: Likewise. * rust/execute/torture/derive_macro3.rs: Likewise

[COMMITTED 135/146] gccrs: derive(Clone): Mark PhantomData as a lang item

2025-03-21 Thread arthur . cohen
From: Arthur Cohen gcc/testsuite/ChangeLog: * rust/compile/derive_macro4.rs: Make PhantomData a lang item. --- gcc/testsuite/rust/compile/derive_macro4.rs | 5 + 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/gcc/testsuite/rust/compile/derive_macro4.rs b/gcc

<    3   4   5   6   7   8   9   10   11   12   >