[COMMITTED 129/141] gccrs: Insert crate name in canonical path

2025-03-24 Thread arthur . cohen
From: Pierre-Emmanuel Patry gcc/rust/ChangeLog: * resolve/rust-forever-stack.hxx: Insert a new segment with the crate's name as canonical's path prefix. Signed-off-by: Pierre-Emmanuel Patry --- gcc/rust/resolve/rust-forever-stack.hxx | 7 ++- 1 file changed, 6 insertions(+

[COMMITTED 135/141] gccrs: nr2.0: Fix test self-path2.rs

2025-03-24 Thread arthur . cohen
From: Owen Avery gcc/rust/ChangeLog: * resolve/rust-ast-resolve-path.cc (ResolvePath::resolve_path): Adjust the error message for a lower self segment in the middle of a path. * resolve/rust-ast-resolve-type.cc (ResolveRelativeTypePath::go): Likewise. gcc

[COMMITTED 013/141] gccrs: Add environment capture to NR2

2025-03-24 Thread arthur . cohen
From: Pierre-Emmanuel Patry The compiler was still relying on NR1 for closure captures when using nr2 even though the resolver was not used and thus it's state empty. gcc/rust/ChangeLog: * resolve/rust-late-name-resolver-2.0.cc (Late::visit): Add environment collection.

[COMMITTED 002/141] gccrs: typecheck: Add basic handling for applying auto trait bounds

2025-03-24 Thread arthur . cohen
From: Arthur Cohen gcc/rust/ChangeLog: * hir/rust-ast-lower-item.cc (ASTLoweringItem::visit): Register auto traits in mappings. * util/rust-hir-map.cc (Mappings::insert_auto_trait): New. (Mappings::get_auto_traits): New. * util/rust-hir-map.h: Declare them

[COMMITTED 004/141] gccrs: hir-dump: Improve handling of typepathsegments that are lang items.

2025-03-24 Thread arthur . cohen
From: Arthur Cohen gcc/rust/ChangeLog: * hir/rust-hir-dump.cc (Dump::do_typepathsegment): Add handling for lang items. --- gcc/rust/hir/rust-hir-dump.cc | 5 - 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/gcc/rust/hir/rust-hir-dump.cc b/gcc/rust/hir/rust-hir

[COMMITTED 005/141] gccrs: ast-builder: Add extra parameter for TypeParam builder

2025-03-24 Thread arthur . cohen
From: Arthur Cohen gcc/rust/ChangeLog: * ast/rust-ast-builder.cc (Builder::new_type_param): Add optional extra trait bounds. * ast/rust-ast-builder.h: Likewise. --- gcc/rust/ast/rust-ast-builder.cc | 6 +- gcc/rust/ast/rust-ast-builder.h | 4 +++- 2 files changed, 8

[COMMITTED 006/141] gccrs: derive(Clone): Add Clone bound on generated impl blocks

2025-03-24 Thread arthur . cohen
From: Arthur Cohen gcc/rust/ChangeLog: * expand/rust-derive-clone.cc: Add extra bound when deriving generic Clone --- gcc/rust/expand/rust-derive-clone.cc | 17 +++-- 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/gcc/rust/expand/rust-derive-clone.cc b/gcc

[COMMITTED 014/141] gccrs: Add captures for ClosureExprInnerTyped with nr2

2025-03-24 Thread arthur . cohen
From: Pierre-Emmanuel Patry Captures were only processed for regular ClosureExprInner. gcc/rust/ChangeLog: * resolve/rust-late-name-resolver-2.0.cc (Late::visit): Add ClosureExprInnerTyped visit implementation. (add_captures): Add a function to avoid code duplication.

[COMMITTED 011/141] gccrs: backend: Allow anything as a match scrutinee

2025-03-24 Thread arthur . cohen
From: Arthur Cohen gcc/rust/ChangeLog: * backend/rust-compile-expr.cc (check_match_scrutinee): Allow anything to be used as a match scrutinee, not just ADTs. --- gcc/rust/backend/rust-compile-expr.cc | 6 +- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/gcc

[COMMITTED 028/141] gccrs: Add unit struct to name namespace in old resolver

2025-03-24 Thread arthur . cohen
From: Pierre-Emmanuel Patry We missed the name namespace for unit struct in the old resolver. gcc/rust/ChangeLog: * resolve/rust-ast-resolve-toplevel.h: Add struct to name namespace. Signed-off-by: Pierre-Emmanuel Patry --- gcc/rust/resolve/rust-ast-resolve-toplevel.h | 23 ++

[COMMITTED 059/141] gccrs: ast-builder: Add methods for QualifiedPathInExpressions

2025-03-24 Thread arthur . cohen
From: Arthur Cohen gcc/rust/ChangeLog: * ast/rust-ast-builder.cc (Builder::qualified_path_in_expression): New. (Builder::function): Change the return type. * ast/rust-ast-builder.h: Declare qualified_path_in_expression functions. * expand/rust-derive-debug.cc

[COMMITTED 055/141] gccrs: coercion sites allow for type inference as well.

2025-03-24 Thread arthur . cohen
From: Philip Herron Addresses Rust-GCC#3382 and Rust-GCC#3381 gcc/rust/ChangeLog: * typecheck/rust-type-util.cc (coercion_site): allow inference vars gcc/testsuite/ChangeLog: * rust/compile/reference1.rs: fix error message Signed-off-by: Philip Herron --- gcc/rust/typecheck

[COMMITTED 051/141] gccrs: nr2.0: Remove accidental copies of resolver

2025-03-24 Thread arthur . cohen
From: Owen Avery gcc/rust/ChangeLog: * backend/rust-compile-expr.cc (CompileExpr::generate_closure_function): Take NameResolutionContext by reference instead of by value. * backend/rust-compile-item.cc (CompileItem::visit): Likewise. * backend/rust

[COMMITTED 033/141] gccrs: Resolved item type shall be differentiated later

2025-03-24 Thread arthur . cohen
From: Pierre-Emmanuel Patry We need to query all namespaces and error out at a later stage if the retrieved item is wrong. gcc/rust/ChangeLog: * typecheck/rust-hir-trait-resolve.cc (TraitResolver::resolve_path_to_trait): Query all namespaces. Signed-off-by: Pierre-Emmanuel Pat

[COMMITTED 105/141] gccrs: name-resolution: early: Remove overzealous overrides

2025-03-24 Thread arthur . cohen
From: Arthur Cohen Some empty overrides were incorrectly being set-up instead of using the correct behavior from DefaultASTVisitor. gcc/rust/ChangeLog: * resolve/rust-early-name-resolver.cc: Remove definitions. * resolve/rust-early-name-resolver.h: Remove declarations

[COMMITTED 077/141] gccrs: self paths are patterns but we dont have mappings for it

2025-03-24 Thread arthur . cohen
From: Philip Herron With simple patterns we dont introduce any more inference varaibles as they are already declared in a specific way. This would only lead to more unconstrained inference varaibles than is required. Fixes Rust-GCC#3022 gcc/rust/ChangeLog: * hir/rust-ast-lower-base.cc

[COMMITTED 103/141] gccrs: nr2.0: Implement macro_use for modules

2025-03-24 Thread arthur . cohen
From: Owen Avery gcc/rust/ChangeLog: * resolve/rust-early-name-resolver-2.0.cc: Include rust-attribute-values.h. (Early::visit): If a module has a macro_use attribute, avoid pushing a new textual macro scope. gcc/testsuite/ChangeLog: * rust/compile/nr2/e

[COMMITTED 106/141] gccrs: expansion: Expand generic args in generic type path segments

2025-03-24 Thread arthur . cohen
From: Arthur Cohen gcc/rust/ChangeLog: * expand/rust-expand-visitor.cc (ExpandVisitor::visit): Correctly visit the generic args of a generic type path segment. gcc/testsuite/ChangeLog: * rust/compile/issue-2015.rs: New test. --- gcc/rust/expand/rust-expand-visitor.cc

[COMMITTED 044/141] gccrs: scan-deadcode: Do not warn unused fields if they start with '_'

2025-03-24 Thread arthur . cohen
From: Arthur Cohen gcc/rust/ChangeLog: * checks/lints/rust-lint-scan-deadcode.h: Check if the field name starts with an underscore before warning. --- gcc/rust/checks/lints/rust-lint-scan-deadcode.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/gcc/rust

[COMMITTED 046/141] gccrs: ast-builder: Add new methods for functions, traits and tuples.

2025-03-24 Thread arthur . cohen
From: Arthur Cohen gcc/rust/ChangeLog: * ast/rust-ast-builder.cc: New methods. * ast/rust-ast-builder.h: Declare them. --- gcc/rust/ast/rust-ast-builder.cc | 62 gcc/rust/ast/rust-ast-builder.h | 36 +-- 2 files changed, 96

[COMMITTED 111/141] gccrs: session-manager: Call into DesugarQuestionMark

2025-03-24 Thread arthur . cohen
From: Arthur Cohen gcc/rust/ChangeLog: * rust-session-manager.cc (Session::compile_crate): Call DesugarQuestionMark::go(). --- gcc/rust/rust-session-manager.cc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/gcc/rust/rust-session-manager.cc b/gcc/rust/rust-session-manager.cc

[COMMITTED 114/141] gccrs: expansion: Correctly expand $crate metavar

2025-03-24 Thread arthur . cohen
From: Arthur Cohen gcc/rust/ChangeLog: * expand/rust-macro-expand.cc: Use new SubstituteCtx API. * expand/rust-macro-expand.h: Likewise. * expand/rust-macro-substitute-ctx.cc: Implement proper expansion of $crate. * expand/rust-macro-substitute-ctx.h: Adapt APIs

[COMMITTED 047/141] gccrs: derive-visitor: Add method for setting up derived impl generics

2025-03-24 Thread arthur . cohen
From: Arthur Cohen gcc/rust/ChangeLog: * expand/rust-derive.cc (DeriveVisitor::setup_impl_generics): New method. * expand/rust-derive.h: Declare it, define DeriveVisitor::ImplGenerics struct. --- gcc/rust/expand/rust-derive.cc | 74 ++ gcc/rust

[COMMITTED 019/141] gccrs: lang-items: Add LangItem::IsEnumVariant

2025-03-24 Thread arthur . cohen
From: Arthur Cohen gcc/rust/ChangeLog: * util/rust-lang-item.cc (LangItem::IsEnumVariant): New function. * util/rust-lang-item.h: Declare it. --- gcc/rust/util/rust-lang-item.cc | 9 + gcc/rust/util/rust-lang-item.h | 5 - 2 files changed, 13 insertions(+), 1

[COMMITTED 052/141] gccrs: Fix bug in type resolution of paths

2025-03-24 Thread arthur . cohen
From: Owen Avery gcc/rust/ChangeLog: * resolve/rust-early-name-resolver-2.0.cc (Early::resolve_glob_import): Use NameResolutionContext::resolve_path instead of ForeverStack::resolve_path. (Early::visit): Likewise. (Early::visit_attributes): Likewis

[COMMITTED 029/141] gccrs: Remove query mode on CompileItem

2025-03-24 Thread arthur . cohen
From: Pierre-Emmanuel Patry Query mode was a hack to catch up some compile errors early, it was deemed to be removed at some time. Recent changes to NR1 highlighted an incompatibility with it hence it's removal. gcc/rust/ChangeLog: * backend/rust-compile-item.h: Remove query mode.

[COMMITTED 054/141] gccrs: Fix ICE during path probe

2025-03-24 Thread arthur . cohen
From: Philip Herron It is valid for the query to fail here so its valid to not assert here. gcc/rust/ChangeLog: * typecheck/rust-hir-path-probe.cc (PathProbeType::visit): remove assertion Signed-off-by: Philip Herron --- gcc/rust/typecheck/rust-hir-path-probe.cc | 12 ++-- 1

[COMMITTED 057/141] gccrs: Fix bad generic substitution error on fn/adt types

2025-03-24 Thread arthur . cohen
From: Philip Herron When passing generics around we try to adjust them because there are cases where the names are adjusted from other generics this can fail for traits because of the implicit Self and we just need to continue on without adjustment. Fxies Rust-GCC#3382 gcc/rust/ChangeLog:

[COMMITTED 040/141] gccrs: Add option_env! support

2025-03-24 Thread arthur . cohen
From: Liam Naddell gcc/rust/ChangeLog: * expand/rust-macro-builtins-utility.cc: Add macro expansion for option_env with eager expansion * expand/rust-macro-builtins.cc: Add option_env to builtin list * expand/rust-macro-builtins.h: Add option_env handler to header

[COMMITTED 093/141] gccrs: derive(Eq): Also derive StructuralEq

2025-03-24 Thread arthur . cohen
From: Arthur Cohen gcc/rust/ChangeLog: * expand/rust-derive-eq.cc: Adapt functions to return two generated impls. * expand/rust-derive-eq.h: Likewise. * expand/rust-derive.cc (DeriveVisitor::derive): Likewise. --- gcc/rust/expand/rust-derive-eq.cc | 68

[COMMITTED 117/141] gccrs: Keep definition provenance to skip enum variants

2025-03-24 Thread arthur . cohen
From: Pierre-Emmanuel Patry Enum variants shouldn't be accessed directly even from within an enum. This commit keeps the provenance for enum variants definition so we can skip them when resolving a value within an enum definition. gcc/rust/ChangeLog: * resolve/rust-forever-stack.h: Add

[COMMITTED 134/141] gccrs: emit an error for type or const parameters on foreign items

2025-03-24 Thread arthur . cohen
From: Ryutaro Okada <1015ry...@gmail.com> gcc/rust/ChangeLog: * typecheck/rust-hir-type-check-implitem.cc (TypeCheckTopLevelExternItem::visit): emit an error for type or const parameters on foreign items gcc/testsuite/ChangeLog: * rust/compile/extern_generics.rs

[COMMITTED 113/141] gccrs: nr2.0: Make sure PathInExpression is default resolved

2025-03-24 Thread arthur . cohen
From: Owen Avery gcc/rust/ChangeLog: * resolve/rust-late-name-resolver-2.0.cc (Late::visit): Call DefaultResolver::visit earlier, in order to ensure it is called even if Late::visit returns early. gcc/testsuite/ChangeLog: * rust/compile/nr2/exclude: Remove entri

[COMMITTED 128/141] gccrs: Add a function to get the crate number from node id

2025-03-24 Thread arthur . cohen
From: Pierre-Emmanuel Patry gcc/rust/ChangeLog: * util/rust-hir-map.cc (Mappings::lookup_crate_num): Add function to retrieve crate number from it's node id. (Mappings::node_is_crate): change function with call to lookup_crate_num to avoid looping through all crat

[COMMITTED 045/141] gccrs: ast-builder: Add new functions to create type paths.

2025-03-24 Thread arthur . cohen
From: Arthur Cohen gcc/rust/ChangeLog: * ast/rust-ast-builder.cc (Builder::type_path): New functions. * ast/rust-ast-builder.h: Declare them. --- gcc/rust/ast/rust-ast-builder.cc | 21 - gcc/rust/ast/rust-ast-builder.h | 4 2 files changed, 24

[COMMITTED 066/141] gccrs: ast: Add DesugarForLoop class

2025-03-24 Thread arthur . cohen
From: Arthur Cohen gcc/rust/ChangeLog: * ast/rust-desugar-for-loops.cc: New file. * ast/rust-desugar-for-loops.h: New file. * hir/rust-ast-lower-expr.cc (ASTLoweringExpr::visit): Make lowering of for-loops an unreachable. * Make-lang.in: Compile it. gcc

[COMMITTED 060/141] gccrs: derive(Default): Add implementation

2025-03-24 Thread arthur . cohen
From: Arthur Cohen gcc/rust/ChangeLog: * expand/rust-derive.cc (DeriveVisitor::derive): Call DeriveDefault. * expand/rust-derive-default.cc: New file. * expand/rust-derive-default.h: New file. * Make-lang.in: Compile them. gcc/testsuite/ChangeLog

[COMMITTED 026/141] gccrs: Labels shall be pushed within label namespace

2025-03-24 Thread arthur . cohen
From: Pierre-Emmanuel Patry Labels were using the wrong namespace. gcc/rust/ChangeLog: * resolve/rust-ast-resolve-expr.cc (ResolveExpr::visit): Change label push function from type rib to label rib. * resolve/rust-ast-resolve-item.cc (ResolveTraitItems::visit): L

[COMMITTED 095/141] gccrs: Remove PathInExpression::get_pattern_node_id

2025-03-24 Thread arthur . cohen
From: Owen Avery gcc/rust/ChangeLog: * ast/rust-path.h (PathInExpression::get_pattern_node_id): Remove. Signed-off-by: Owen Avery --- gcc/rust/ast/rust-path.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/gcc/rust/ast/rust-path.h b/gcc/rust/ast/rust-path.h index c253703

[COMMITTED 094/141] gccrs: derive(Eq): Create copies of Eq typepath to avoid NodeId confusion

2025-03-24 Thread arthur . cohen
From: Arthur Cohen gcc/rust/ChangeLog: * expand/rust-derive-eq.cc: Copy `Eq` typepath. --- gcc/rust/expand/rust-derive-eq.cc | 6 +- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/gcc/rust/expand/rust-derive-eq.cc b/gcc/rust/expand/rust-derive-eq.cc index 47a8350d2ff

[COMMITTED 091/141] gccrs: expand: Allow built-in derives to generate multiple items

2025-03-24 Thread arthur . cohen
From: Arthur Cohen gcc/rust/ChangeLog: * expand/rust-derive.cc (DeriveVisitor::derive): Return a vector of items. * expand/rust-derive.h: Change return type. * expand/rust-expand-visitor.cc: Insert all generated items into the AST. --- gcc/rust/expand/rust-derive.cc

[COMMITTED 039/141] gccrs: ast: Add new Expr::Kinds

2025-03-24 Thread arthur . cohen
From: Arthur Cohen Collapses all of the OperatorExprs into Expr instead of first having to check for OperatorExpr and then check for each OperatorExpr::Kind. gcc/rust/ChangeLog: * ast/rust-ast.h: Add new Expr::Kinds. * ast/rust-expr.h: Implement missing get_expr_kind(), Add

[COMMITTED 038/141] gccrs: add support for ref literal patterns

2025-03-24 Thread arthur . cohen
From: Philip Herron Fixes Rust-GCC#3174 gcc/rust/ChangeLog: * backend/rust-compile-pattern.cc (CompilePatternBindings::visit): make recursive * typecheck/rust-hir-type-check-pattern.cc (TypeCheckPattern::visit): handle ref flag gcc/testsuite/ChangeLog: * rust/compile

[COMMITTED 101/141] gccrs: hir-dump: Fix more segfaults in the HIR dump

2025-03-24 Thread arthur . cohen
From: Arthur Cohen gcc/rust/ChangeLog: * hir/rust-hir-dump.cc: Check unique_ptr members are present before visiting them. * hir/tree/rust-hir-path.h: Add `has_{type, trait}` methods to QualifiedPathInType. --- gcc/rust/hir/rust-hir-dump.cc | 19

[COMMITTED 104/141] gccrs: lower: Always crash when lowering macro invocations

2025-03-24 Thread arthur . cohen
From: Arthur Cohen gcc/rust/ChangeLog: * hir/rust-ast-lower-base.cc (ASTLoweringBase::visit): Add base implementation for visitor. --- gcc/rust/hir/rust-ast-lower-base.cc | 11 --- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/gcc/rust/hir/rust-ast

[COMMITTED 068/141] gccrs: remove bad type checking diagnostic

2025-03-24 Thread arthur . cohen
From: Philip Herron This was a bad diagnostic added when I was working on slices and iterators also the name of the function is also bad. This is all about setting up associated types based on the current context of the bounds assocated with the associated trait bounds on this function. The tell

[COMMITTED 041/141] gccrs: Fix an issue with ForeverStack::dfs_rib

2025-03-24 Thread arthur . cohen
From: Owen Avery gcc/rust/ChangeLog: * resolve/rust-forever-stack.hxx (ForeverStack::dfs_rib): Fix const implementation. Signed-off-by: Owen Avery --- gcc/rust/resolve/rust-forever-stack.hxx | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/gcc/rust/reso

[COMMITTED 017/141] gccrs: lang-items: Collect enum variants as lang items

2025-03-24 Thread arthur . cohen
From: Arthur Cohen gcc/rust/ChangeLog: * ast/rust-collect-lang-items.h: Declare visitor. * ast/rust-collect-lang-items.cc (CollectLangItems::visit): New. --- gcc/rust/ast/rust-collect-lang-items.cc | 9 + gcc/rust/ast/rust-collect-lang-items.h | 1 + 2 files changed

[COMMITTED 079/141] gccrs: Add name resolution and HIR lowering for ImplTraitType's

2025-03-24 Thread arthur . cohen
From: Philip Herron Our AST has ImplTraitType for multiple bounds and a singular ImplTraitTypeOneBound, this patch desugars these into a simple HIR::ImplTraitType. It also does the name resolution for this. gcc/rust/ChangeLog: * checks/errors/borrowck/rust-bir-builder-struct.h: remove

[COMMITTED 031/141] gccrs: Clone expr instead of taking it

2025-03-24 Thread arthur . cohen
From: Pierre-Emmanuel Patry We're reusing the value, it could therefore not be taken be should be cloned. gcc/rust/ChangeLog: * typecheck/rust-hir-type-check-enumitem.cc (TypeCheckEnumItem::visit): Clone expr instead of taking it. Signed-off-by: Pierre-Emmanuel Patry --- gcc/

[COMMITTED 083/141] gccrs: Add comments to resolve_segments

2025-03-24 Thread arthur . cohen
From: Owen Avery gcc/rust/ChangeLog: * resolve/rust-forever-stack.hxx (ForeverStack::resolve_segments): Add comments explaining the behaviour of a while loop. Signed-off-by: Owen Avery --- gcc/rust/resolve/rust-forever-stack.hxx | 11 +++ 1 file changed, 11 ins

[COMMITTED 042/141] gccrs: nr2.0: late: Add proper handling for lang item PathInExpressions

2025-03-24 Thread arthur . cohen
From: Arthur Cohen gcc/rust/ChangeLog: * resolve/rust-late-name-resolver-2.0.cc (Late::visit): Special case lang item paths. --- gcc/rust/resolve/rust-late-name-resolver-2.0.cc | 8 +++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/gcc/rust/resolve/rust-late-name

[COMMITTED 102/141] gccrs: Adjust type path resolution error message

2025-03-24 Thread arthur . cohen
From: Owen Avery gcc/rust/ChangeLog: * resolve/rust-ast-resolve-type.cc (ResolveRelativeTypePath::go): Adjust error message to match the 2.0 name resolver. gcc/testsuite/ChangeLog: * rust/compile/additional-trait-bounds2.rs: Adjust expected errors.

[COMMITTED 092/141] gccrs: derive(PartialEq): Also derive StructuralPartialEq

2025-03-24 Thread arthur . cohen
From: Arthur Cohen gcc/rust/ChangeLog: * expand/rust-derive-partial-eq.cc: Adapt signatures to generate two impls. * expand/rust-derive-partial-eq.h: Likewise. * expand/rust-derive.cc (DeriveVisitor::derive): Adapt to multiple item generation. gcc/testsuite/ChangeLog

[COMMITTED 074/141] gccrs: add diagnostic for E0229 no associated type arguments allowed here

2025-03-24 Thread arthur . cohen
From: Philip Herron It seems bounds in qualified paths are not allowed to specify associated type bindings because its going to be associated with the impl block anyway. Fixes Rust-GCC#2369 gcc/rust/ChangeLog: * typecheck/rust-hir-type-check-base.h: add flag * typecheck/rust-hi

[COMMITTED 022/146] gccrs: fix ICE for placeholder which is not setup

2025-03-24 Thread arthur . cohen
From: Philip Herron We can have a case where the placeholder is not configred and the can_resolve check is not detecting this case which can lead to ICE. gcc/rust/ChangeLog: * typecheck/rust-tyty.cc (PlaceholderType::can_resolve): check for empty mappings Signed-off-by: Philip Herron

[COMMITTED 075/146] gccrs: nr2.0: Resolve lang item paths properly.

2025-03-24 Thread arthur . cohen
From: Arthur Cohen gcc/rust/ChangeLog: * resolve/rust-late-name-resolver-2.0.cc (Late::visit): New. * resolve/rust-late-name-resolver-2.0.h: New. --- .../resolve/rust-late-name-resolver-2.0.cc| 20 +++ .../resolve/rust-late-name-resolver-2.0.h | 1 + 2

[COMMITTED 112/144] gccrs: Do not assert insertion result

2025-03-24 Thread arthur . cohen
From: Pierre-Emmanuel Patry We might have some duplicated name in some pattern and we should therefore not assert the non duplication of identifiers. gcc/rust/ChangeLog: * resolve/rust-late-name-resolver-2.0.cc (Late::visit): Remove assertion and explicitely tells why we ignore

[PATCHSET] Update Rust frontend 17/03/2024 1/4

2025-03-17 Thread arthur . cohen
Hi everyone, This patchset is the first of four similarly-sized patchsets aimed at updating upstream with our most recent changes to the Rust frontend. We plan on upstreaming small patchsets every week up to the release of 15.1. This first set's main change is the addition of the polonius borrow

[COMMITTED 005/145] gccrs: borrowck: Polonius dump

2025-03-17 Thread arthur . cohen
From: Jakub Dupak gcc/rust/ChangeLog: * checks/errors/borrowck/polonius/rust-polonius.h (struct FullPoint): Polonius facts dump. (struct Facts): Polonius facts dump. * checks/errors/borrowck/rust-bir-dump.cc (Dump::go): Polonius facts dump. (Dump::

[COMMITTED 002/145] gccrs: git: Ignore libgrust build folders

2025-03-17 Thread arthur . cohen
From: Arthur Cohen ChangeLog: * .gitignore: Add libgrust target folders to the ignore list. --- .gitignore | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitignore b/.gitignore index f044fe16b5f..7150fc3b29c 100644 --- a/.gitignore +++ b/.gitignore @@ -71,3 +71,6 @@ stamp

[COMMITTED 055/145] gccrs: Corrected access specifiers

2025-03-17 Thread arthur . cohen
From: Kushal Pal gcc/rust/ChangeLog: * ast/rust-expr.h (class OperatorExpr): Location should be private. * hir/tree/rust-hir-expr.h (class OperatorExpr): Likewise. Signed-off-by: Kushal Pal --- gcc/rust/ast/rust-expr.h | 2 +- gcc/rust/hir/tree/rust-hir-expr.h

[COMMITTED 060/145] gccrs: Add new test for box syntax

2025-03-17 Thread arthur . cohen
From: Pierre-Emmanuel Patry Add a new test to prevent regressions on the box syntax as well as its feature gate. gcc/testsuite/ChangeLog: * rust/compile/box_syntax.rs: New test. * rust/compile/box_syntax_feature_gate.rs: New test. Signed-off-by: Pierre-Emmanuel Patry --- gcc/

[COMMITTED 044/145] gccrs: Change lookup_hir_pattern return type

2025-03-17 Thread arthur . cohen
From: Pierre-Emmanuel Patry Wrap the function's return type within an optional in order to differentiate between a null pointer and a missing value. gcc/rust/ChangeLog: * util/rust-hir-map.cc (Mappings::insert_hir_pattern): Change call site in order to accomodate new return type

[COMMITTED 065/145] gccrs: Add outer attributes to struct expr fields

2025-03-17 Thread arthur . cohen
From: Pierre-Emmanuel Patry Struct fields can have outer attributes on their field for various purpose, this behavior should be reflected upon struct expr fields. gcc/rust/ChangeLog: * ast/rust-ast-collector.cc (TokenCollector::visit): Output field attributes. * ast/rust

[COMMITTED 058/145] gccrs: Parse box expressions

2025-03-17 Thread arthur . cohen
From: Pierre-Emmanuel Patry Add support for old box expression syntax. gcc/rust/ChangeLog: * ast/rust-ast-collector.cc (TokenCollector::visit): Add visit member function for BoxExpr nodes. * ast/rust-ast-collector.h: Add visit function prototype. * ast/rust-ast-v

[COMMITTED 051/145] gccrs: Remove useless cstddef header from rust-fmt

2025-03-17 Thread arthur . cohen
From: jjasmine gcc/rust/ChangeLog: * ast/rust-fmt.h: Remove useless cstddef header from rust-fmt --- gcc/rust/ast/rust-fmt.h | 1 - 1 file changed, 1 deletion(-) diff --git a/gcc/rust/ast/rust-fmt.h b/gcc/rust/ast/rust-fmt.h index fe933eabdd3..31100ea8f84 100644 --- a/gcc/rust/ast/rus

[COMMITTED 054/145] gccrs: Make gccrs recognize negative_impls

2025-03-17 Thread arthur . cohen
From: jjasmine gcc/rust/ChangeLog: * checks/errors/rust-feature-gate.cc (FeatureGate::visit): make gccrs recognize negative_impls * checks/errors/rust-feature-gate.h: likewise. * checks/errors/rust-feature.cc (Feature::create): likewise. * checks/errors/ru

[COMMITTED 068/145] gccrs: Prevent raw reference from being lowered silently

2025-03-17 Thread arthur . cohen
From: Pierre-Emmanuel Patry We do not handle those kind of references yet, we shall not let them pass as a regular reference. gcc/rust/ChangeLog: * ast/rust-expr.h: Add a getter for mutability. * hir/rust-ast-lower-expr.cc (ASTLoweringExpr::visit): Panic when a raw refer

[COMMITTED 052/145] gccrs: Add call and method call default visitors

2025-03-17 Thread arthur . cohen
From: Owen Avery gcc/rust/ChangeLog: * resolve/rust-default-resolver.cc (DefaultResolver::visit): New for AST::CallExpr and AST::MethodCallExpr. * resolve/rust-default-resolver.h (DefaultResolver::visit): Likewise. Signed-off-by: Owen Avery --- gcc/rust

[COMMITTED 048/145] gccrs: Change lookup_visibility's return type

2025-03-17 Thread arthur . cohen
From: Pierre-Emmanuel Patry Wrap the return type within an optional. gcc/rust/ChangeLog: * checks/errors/privacy/rust-privacy-reporter.cc: Change call site to accomodate new return type. * checks/errors/privacy/rust-pub-restricted-visitor.cc: Likewise. * util/rus

[COMMITTED 047/145] gccrs: Change lookup_macro_invocation's return type

2025-03-17 Thread arthur . cohen
From: Pierre-Emmanuel Patry Wrap the function's return type within an optional and remove the out reference argument. gcc/rust/ChangeLog: * expand/rust-macro-expand.cc (MacroExpander::expand_invoc): Adapt the function call to match its new prototype. * resolve/rust-early

[COMMITTED 049/145] gccrs: Change lookup_ast_item's return type

2025-03-17 Thread arthur . cohen
From: Pierre-Emmanuel Patry Wrap the function's return type within an optional. gcc/rust/ChangeLog: * metadata/rust-export-metadata.cc (ExportContext::emit_trait): Adapt call site to the new return type. (ExportContext::emit_function): Likewise. (ExportContext::e

[COMMITTED 056/145] gccrs: Allow rustc_const_stable and rustc_const_unstable

2025-03-17 Thread arthur . cohen
From: Owen Avery gcc/rust/ChangeLog: * expand/rust-macro-builtins.cc (MacroBuiltin::builtin_transcribers): Add entries for "rustc_const_stable" and "rustc_const_unstable". * util/rust-attributes.cc (__definitions): Add entries for RUSTC_CONST_STABLE and

[COMMITTED 059/145] gccrs: Add feature gate for box syntax

2025-03-17 Thread arthur . cohen
From: Pierre-Emmanuel Patry The box syntax is experimental even though it is used in the standard library. It should be feature gated to prevent anyone from using it in stable rust. gcc/rust/ChangeLog: * checks/errors/rust-feature-gate.cc (FeatureGate::visit): Allow visitor recu

[COMMITTED 057/145] gccrs: Improve handling of ConstantItem during name resolution 2.0

2025-03-17 Thread arthur . cohen
From: Owen Avery gcc/rust/ChangeLog: * resolve/rust-default-resolver.cc (DefaultResolver::visit): Scope with Rib::Kind::ConstantItem instead of Rib::Kind::Item. * resolve/rust-toplevel-name-resolver-2.0.cc (TopLevel::visit): Remove redundancy in ov

[COMMITTED 062/145] gccrs: Allow multiple outer attributes on generic params

2025-03-17 Thread arthur . cohen
From: Pierre-Emmanuel Patry Previously generic params only allowed one outer attribute in front of them. gcc/rust/ChangeLog: * ast/rust-ast-collector.cc (TokenCollector::visit): Visit outer attributes. * ast/rust-ast-visitor.cc (DefaultASTVisitor::visit): Change outer

[COMMITTED 063/145] gccrs: Add dropck_eyepatch feature gate for may_dangle

2025-03-17 Thread arthur . cohen
From: Pierre-Emmanuel Patry Add a new feature gate for may_dangle generic param outer attributes. gcc/rust/ChangeLog: * checks/errors/rust-feature-gate.cc: Visit and gate may_dangle attributes. * checks/errors/rust-feature-gate.h: Update visit function prototype

[COMMITTED 061/145] gccrs: Fix generic parameter parsing

2025-03-17 Thread arthur . cohen
From: Pierre-Emmanuel Patry Generic parameter parsing failed when an outer attribute was used on it. gcc/rust/ChangeLog: * parse/rust-parse-impl.h (Parser::parse_generic_param): Change token reference to be the last token after all outer attributes have been parsed. Sig

[COMMITTED 064/145] gccrs: Add two new tests related to may_dangle attribute

2025-03-17 Thread arthur . cohen
From: Pierre-Emmanuel Patry First test checks the may_dangle outer atttribute on generic params can be parsed. The second one tests whether may_dangle attributes are correctly feature gated. gcc/testsuite/ChangeLog: * rust/compile/dropck_eyepatch_feature_gate.rs: New test. * rus

[COMMITTED 072/145] gccrs: Add exclusive_range_pattern feature gate

2025-03-17 Thread arthur . cohen
From: Pierre-Emmanuel Patry This syntax is experimental and shall be explicitely enabled in the crate attributes as it cannot be used in stable rust. gcc/rust/ChangeLog: * checks/errors/rust-feature-gate.cc (FeatureGate::visit): Gate the excluded pattern. * checks/errors

[COMMITTED 076/145] gccrs: Introduce first implementation of parse_clobber_abi

2025-03-17 Thread arthur . cohen
From: jjasmine gcc/rust/ChangeLog: * expand/rust-macro-builtins-asm.cc (parse_clobber_abi): title. (parseAsmArg): title. * expand/rust-macro-builtins-asm.h (parse_clobber_abi): title. --- gcc/rust/expand/rust-macro-builtins-asm.cc | 76 +- gcc/rust/ex

[COMMITTED 077/145] gccrs: Working on parse_options for a bit more

2025-03-17 Thread arthur . cohen
From: jjasmine gcc/rust/ChangeLog: * expand/rust-macro-builtins-asm.cc (parse_options): title. --- gcc/rust/expand/rust-macro-builtins-asm.cc | 14 +- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/gcc/rust/expand/rust-macro-builtins-asm.cc b/gcc/rust/expand/

[COMMITTED 071/145] gccrs: Parse exclusive range pattern

2025-03-17 Thread arthur . cohen
From: Pierre-Emmanuel Patry Exclusive range pattern were not handled by the parser as this an experimental feature. gcc/rust/ChangeLog: * ast/rust-pattern.cc (tokenid_to_rangekind): Add a new function to get a range kind from the current token type. (RangePattern::as_str

[COMMITTED 119/145] gccrs: expand: Switch semicolon boolean to an enum instead.

2025-03-17 Thread arthur . cohen
From: Arthur Cohen gcc/rust/ChangeLog: * ast/rust-ast-fragment.h (enum class): Add InvocKind and AsmKind enums. * ast/rust-macro.h: Switch semicolon boolean to InvocKind enum. * expand/rust-expand-visitor.cc (ExpandVisitor::visit): Likewise. * expand/rust-macro

[COMMITTED 122/145] gccrs: Add RAW_STRING_LITERAL

2025-03-17 Thread arthur . cohen
From: ansh gcc/rust/ChangeLog: * ast/rust-ast-collector.cc (TokenCollector::visit): Handle case for RAW_STRING_LITERAL. * ast/rust-ast.cc (AttributeParser::parse_meta_item_inner): Likewise. (AttributeParser::parse_literal): Likewise. * ast/rust-ast

[COMMITTED 2/2] rust: force cargo to build offline

2025-03-18 Thread arthur . cohen
From: Marc Poulhiès gcc/rust/Changelog: PR rust/119333 * Make-lang.in: Force offline mode for cargo Signed-off-by: Marc Poulhiès --- gcc/rust/Make-lang.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gcc/rust/Make-lang.in b/gcc/rust/Make-lang.in index ef

[COMMITTED 1/2] gccrs: polonius: Vendor Rust dependencies

2025-03-18 Thread arthur . cohen
From: Arthur Cohen Resent to cut out the patch's content, as it did not pass the ML filters. This fixes PR #119333 by allowing our borrow-checker interface to be built offline. This was already done for our components in libgrust/, but had never been done for the borrow-checker.

[COMMITTED 115/144] gccrs: Make node id getter const.

2025-03-19 Thread arthur . cohen
From: Pierre-Emmanuel Patry gcc/rust/ChangeLog: * ast/rust-ast.h: Node id getter could be const. Signed-off-by: Pierre-Emmanuel Patry --- gcc/rust/ast/rust-ast.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gcc/rust/ast/rust-ast.h b/gcc/rust/ast/rust-ast.h index

[COMMITTED 138/144] gccrs: Use name resolver 2.0 in MarkLive

2025-03-19 Thread arthur . cohen
From: Owen Avery gcc/rust/ChangeLog: * checks/lints/rust-lint-marklive.cc (MarkLive::visit_path_segment): Use name resolver 2.0 when enabled. (MarkLive::visit): Likewise. Signed-off-by: Owen Avery --- gcc/rust/checks/lints/rust-lint-marklive.cc | 31 +++

[COMMITTED 110/144] gccrs: Move failing test to xfail

2025-03-19 Thread arthur . cohen
From: Pierre-Emmanuel Patry We want to begin experimenting with this new name resolution 2.0 algorithm as soon as possible. This test highlight a problem where the compiler should emit an error and should be fixed soon. gcc/testsuite/ChangeLog: * rust/compile/name_resolution21.rs: Move

[COMMITTED 078/144] gccrs: Emit error on auto-traits

2025-03-19 Thread arthur . cohen
From: "benjamin.thos" Throw an error when auto-traits used without feature attribute. gcc/rust/ChangeLog: * checks/errors/rust-feature-gate.cc (FeatureGate::visit): Emit error on trait when auto field member true. * checks/errors/rust-feature-gate.h: add prototype of tra

[COMMITTED 134/144] gccrs: Provide input operand for gccrs

2025-03-19 Thread arthur . cohen
From: badumbatish gcc/rust/ChangeLog: * backend/rust-compile-asm.cc (CompileAsm::asm_construct_inputs): Provide input operand for gccrs * expand/rust-macro-builtins-asm.cc (parse_reg_operand_in): Move expr to In (expand_inline_asm_strings): Add com

[COMMITTED 135/144] gccrs: Fix compiler error on ast wrong implicit construct push_back

2025-03-19 Thread arthur . cohen
From: badumbatish gcc/rust/ChangeLog: * expand/rust-macro-builtins-asm.cc (parse_reg_operand_in): Fix compiler error on ast wrong implicit construct push_back --- gcc/rust/expand/rust-macro-builtins-asm.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/gcc

[COMMITTED 139/144] gccrs: Make const references to ForeverStack more useful

2025-03-19 Thread arthur . cohen
From: Owen Avery gcc/rust/ChangeLog: * resolve/rust-forever-stack.h (ForeverStack::to_canonical_path): Make const. (ForeverStack::to_rib): Add const overload. (ForeverStack::reverse_iter): Add const overloads. (ForeverStack::ConstDfsResult): Add. (

[COMMITTED 144/144] gccrs: Handle external static items in toplevel resolver 2.0

2025-03-19 Thread arthur . cohen
From: Owen Avery gcc/rust/ChangeLog: * resolve/rust-toplevel-name-resolver-2.0.cc (TopLevel::visit): Handle ExternalStaticItem. * resolve/rust-toplevel-name-resolver-2.0.h (TopLevel::visit): Likewise. Signed-off-by: Owen Avery --- gcc/rust/resolve/rust-toplevel

[COMMITTED 083/144] gccrs: Check if the type has been correctly resolved

2025-03-19 Thread arthur . cohen
From: Pierre-Emmanuel Patry We did not check the optional was valid, this lead to rogue dereference and undefined behaviors. gcc/rust/ChangeLog: * resolve/rust-late-name-resolver-2.0.cc (Late::visit): Add optional check. Signed-off-by: Pierre-Emmanuel Patry --- gcc/rust/resol

[COMMITTED 089/144] rust: fix ICE when compiling impl block for !

2025-03-19 Thread arthur . cohen
From: Philip Herron We need to resolve the never type which is its own special AST node so it doesnt magically get handled like the regular builtin type paths such as i32. Fixes #3035 gcc/rust/ChangeLog: * resolve/rust-ast-resolve-type.cc (ResolveType::visit): handle never type

[COMMITTED 136/144] gccrs: Disambiguate generic args during name resolution 2.0

2025-03-19 Thread arthur . cohen
From: Owen Avery gcc/rust/ChangeLog: * resolve/rust-late-name-resolver-2.0.cc (Late::visit): Visit GenericArgs and GenericArg, the former because the latter involves a non-virtual member function call. * resolve/rust-late-name-resolver-2.0.h (Late::visit):

[COMMITTED 086/144] gccrs: adjust hir dump of BlockExpr

2025-03-19 Thread arthur . cohen
From: Marc Poulhiès Add tail_reachable and label fields to the dump. gcc/rust/ChangeLog: * hir/rust-hir-dump.cc (Dump::visit): Add missing fields. Signed-off-by: Marc Poulhiès --- gcc/rust/hir/rust-hir-dump.cc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/gcc/rust/hir/rust-hi

<    5   6   7   8   9   10   11   12   13   14   >