[Bug rust/113472] rust/compile/issue-1446.rs FAILs

2024-08-01 Thread jakub at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113472 Jakub Jelinek changed: What|Removed |Added Target Milestone|14.2|14.3 --- Comment #3 from Jakub Jelinek

[Bug rust/113473] rust/compile/iterators1.rs etc. FAIL

2024-08-01 Thread jakub at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113473 Jakub Jelinek changed: What|Removed |Added Target Milestone|14.2|14.3 --- Comment #3 from Jakub Jelinek

[Bug rust/113477] rust/compile/torture/alt_patterns1.rs FAILs

2024-08-01 Thread jakub at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113477 Jakub Jelinek changed: What|Removed |Added Target Milestone|14.2|14.3 --- Comment #2 from Jakub Jelinek

☝ Buildbot (Sourceware): gccrust - worker not available (master)

2024-08-01 Thread builder
A retry build has been detected on builder gccrust-fedora-x86_64 while building gccrust. Full details are available at: https://builder.sourceware.org/buildbot/#/builders/16/builds/2953 Build state: worker not available Revision: (unknown) Worker: bb2-2 Build Reason: (unknown) Blamelist: 0xn

[PATCH 001/125] Rust: Make 'tree'-level 'MAIN_NAME_P' work

2024-08-01 Thread Arthur Cohen
From: Thomas Schwinge 'gcc/tree.h': #define main_identifier_nodeglobal_trees[TI_MAIN_IDENTIFIER] #define MAIN_NAME_P(NODE) \ (IDENTIFIER_NODE_CHECK (NODE) == main_identifier_node) ..., which is not initialized by default, but has to be set up by every front end ind

[PATCH 002/125] gccrs: Fix false positive for top-level AltPattern

2024-08-01 Thread Arthur Cohen
From: Owen Avery gcc/rust/ChangeLog: * hir/rust-ast-lower-pattern.cc (ASTLoweringPattern::visit): Reset is_let_top_level while visiting GroupedPattern. gcc/testsuite/ChangeLog: * rust/compile/let_alt.rs: Check for false positive. Signed-off-by: Owen Avery ---

[PATCH 003/125] gccrs: minor cleanup in langhook.type_for_mode

2024-08-01 Thread Arthur Cohen
From: Marc Poulhiès gcc/rust/ChangeLog: * rust-lang.cc (grs_langhook_type_for_mode): simplify code for xImode. Add missing long_double_type_node. Signed-off-by: Marc Poulhiès --- gcc/rust/rust-lang.cc | 39 +++ 1 file changed, 15 insertions(

[PATCH 008/125] Rust: Don't cache 'libformat_parser.a'

2024-08-01 Thread Arthur Cohen
From: Thomas Schwinge gcc/rust/ * Make-lang.in (LIBFORMAT_PARSER): Point to the actual build artifact. ($(LIBFORMAT_PARSER)): Don't cache it. --- gcc/rust/Make-lang.in | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/gcc/rust/Make-lang.in b/gcc/rust/M

[PATCH 009/125] Rust: Move 'libformat_parser' build into the GCC build directory

2024-08-01 Thread Arthur Cohen
From: Thomas Schwinge Fixes #2883. gcc/rust/ChangeLog: * Make-lang.in (LIBFORMAT_PARSER): Point to the GCC build directory. * ($(LIBFORMAT_PARSER)): Build in the GCC build directory. --- gcc/rust/Make-lang.in | 11 +-- 1 file changed, 9 insertions(+), 2 deletions

[PATCH 010/125] Rust: Move 'libformat_parser' build into libgrust

2024-08-01 Thread Arthur Cohen
From: Thomas Schwinge Addresses #2883. contrib/ * gcc_update (files_and_dependencies): Update for 'libformat_parser' in libgrust. gcc/rust/ * Make-lang.in (LIBFORMAT_PARSER): Point to 'libformat_parser' build in libgrust. (%.toml:, $(LIBFOR

[PATCH 020/125] gccrs: Adjust error checks to match name resolution 2.0

2024-08-01 Thread Arthur Cohen
From: Owen Avery gcc/testsuite/ChangeLog: * rust/compile/bad_stmt_enums.rs: Adjust redefinition error. * rust/compile/bad_toplevel_enums.rs: Likewise. * rust/compile/redef_error1.rs: Likewise. * rust/compile/redef_error3.rs: Likewise. * rust/compile/redef_

[PATCH 022/125] gccrs: lang-items: Cleanup parsing and lookups of lang items.

2024-08-01 Thread Arthur Cohen
gcc/rust/ChangeLog: * Make-lang.in: Compile new rust-lang-item.o. * util/rust-lang-item.h: Split into header and source. * util/rust-lang-item.cc: Cleanup parsing of lang items by using a hashmap and returning optional values, cleanup handling of exhaustive lang it

[PATCH 006/125] gccrs: Add 'gcc/rust/Make-lang.in:LIBFORMAT_PARSER'

2024-08-01 Thread Arthur Cohen
From: Thomas Schwinge ... to avoid verbatim repetition. gcc/rust/ * Make-lang.in (LIBPROC_MACRO_INTERNAL): New. (RUST_LIBDEPS, crab1$(exeext), rust/libformat_parser.a): Use it. --- gcc/rust/Make-lang.in | 12 1 file changed, 8 insertions(+), 4 deletions(-)

[PATCH 004/125] gccrs: fmt: Start working on format_args!() parser

2024-08-01 Thread Arthur Cohen
This commit adds a base class for parsing the various constructs of a Rust format string, according to the grammar in the reference: https://doc.rust-lang.org/std/fmt/index.html#syntax gcc/rust/ChangeLog: * Make-lang.in: Compile rust-fmt object * ast/rust-fmt.cc: New file.

[PATCH 017/125] gccrs: rust-fmt: Store parsed string in Pieces struct

2024-08-01 Thread Arthur Cohen
gcc/rust/ChangeLog: * ast/rust-fmt.cc (Pieces::collect): Fix signature to take ownership of the given string. * ast/rust-fmt.h (struct Pieces): Store parsed string in the struct. libgrust/ChangeLog: * libformat_parser/src/lib.rs: Add debug prompt. --- gcc/rust/as

[PATCH 025/125] gccrs: hir: Add ExternalTypeItem node

2024-08-01 Thread Arthur Cohen
gcc/rust/ChangeLog: * hir/tree/rust-hir-item.h (class ExternalTypeItem): New class. * hir/tree/rust-hir.cc (ExternalTypeItem::as_string): Likewise. * backend/rust-compile-extern.h: Add base for handling HIR::ExternalTypeItem node. * checks/errors/borrowck/r

[PATCH 011/125] gccrs: libformat_parser: Add FFI safe interface

2024-08-01 Thread Arthur Cohen
libgrust/ChangeLog: * libformat_parser/generic_format_parser/src/lib.rs: Add generic library. * libformat_parser/src/lib.rs: Add base for FFI interface. --- .../generic_format_parser/src/lib.rs | 2 +- libgrust/libformat_parser/src/lib.rs | 301

[PATCH 005/125] gccrs: libgrust: Add format_parser library

2024-08-01 Thread Arthur Cohen
Compile libformat_parser and link to it. gcc/rust/ChangeLog: * Make-lang.in: Compile libformat_parser. * ast/rust-fmt.cc: New FFI definitions. * ast/rust-fmt.h: Likewise. * expand/rust-macro-builtins.cc (MacroBuiltin::format_args_handler): Call into libfor

[PATCH 012/125] gccrs: libformat_parser: Start experimenting with cbindgen

2024-08-01 Thread Arthur Cohen
libgrust/ChangeLog: * libformat_parser/cbindgen.toml: New file. * libformat_parser/libformat-parser.h: New file. gcc/rust/ChangeLog: * ast/rust-fmt.h: Add remaining FFI types. --- gcc/rust/ast/rust-fmt.h | 4 +- libgrust/libformat_parser/cbindgen.t

[PATCH 024/125] gccrs: extern-types: Declare external types in name resolver.

2024-08-01 Thread Arthur Cohen
gcc/rust/ChangeLog: * resolve/rust-ast-resolve-implitem.h: Declare external types as new types. --- gcc/rust/resolve/rust-ast-resolve-implitem.h | 19 +++ 1 file changed, 19 insertions(+) diff --git a/gcc/rust/resolve/rust-ast-resolve-implitem.h b/gcc/rust/resolv

[PATCH 014/125] gccrs: libformat_parser: Send boxed values across FFI properly

2024-08-01 Thread Arthur Cohen
gcc/rust/ChangeLog: * ast/rust-fmt.cc (Pieces::~Pieces): Call libformat_parser's release function in destructor. * ast/rust-fmt.h (struct PieceSlice): Add capacity. (destroy_pieces): New. (struct Pieces): Add destructor. libgrust/ChangeLog: * libfo

[PATCH 027/125] gccrs: Make DefaultResolver visit more of the AST

2024-08-01 Thread Arthur Cohen
From: Owen Avery gcc/rust/ChangeLog: * resolve/rust-default-resolver.cc (DefaultResolver::visit): Visit inner AST nodes of ClosureExprInner, ClosureExprInnerTyped, IfExpr, IfExprConseqElse, MatchExpr, PathInExpression, EnumItemTuple, EnumItemStruct, and En

[PATCH 023/125] gccrs: lang-items: Make lang items enum stronger, rename class, cleanup ns.

2024-08-01 Thread Arthur Cohen
gcc/rust/ChangeLog: * util/rust-lang-item.h (class RustLangItem): Renamed to... (class LangItem): ...this. Rename ItemType enum to Kind * util/rust-lang-item.cc: Rename methods to use new class name. * backend/rust-compile-expr.cc (CompileExpr::visit): Use new lang-

[PATCH 034/125] gccrs: Add error emitting when we can't resolve id expr

2024-08-01 Thread Arthur Cohen
From: jjasmine gcc/rust/ChangeLog: * resolve/rust-late-name-resolver-2.0.cc (Late::visit): Add error emitting --- gcc/rust/resolve/rust-late-name-resolver-2.0.cc | 5 - 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/gcc/rust/resolve/rust-late-name-resolver-2.0.cc b/g

[PATCH 013/125] gccrs: libformat_parser: Update header and remove old interface

2024-08-01 Thread Arthur Cohen
gcc/rust/ChangeLog: * ast/rust-fmt.cc (Pieces::collect): Use new Pieces API. * ast/rust-fmt.h: Update interface with new FFI bindings. libgrust/ChangeLog: * libformat_parser/src/lib.rs: Add IntoFFI trait. * libformat_parser/libformat-parser.h: Removed. --- gcc/ru

[PATCH 016/125] gccrs: format_args: Parse entire token invocation

2024-08-01 Thread Arthur Cohen
gcc/rust/ChangeLog: * expand/rust-macro-builtins.cc (MacroBuiltin::format_args_handler): Transform entire invocation token stream into string for the parser. --- gcc/rust/expand/rust-macro-builtins.cc | 40 ++ 1 file changed, 22 insertions(+), 18 deletions(

[PATCH 015/125] gccrs: format_args: Parse format string properly

2024-08-01 Thread Arthur Cohen
gcc/rust/ChangeLog: * expand/rust-macro-builtins.cc (MacroBuiltin::format_args_handler): Construct string to parser properly. --- gcc/rust/expand/rust-macro-builtins.cc | 19 ++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/gcc/rust/expand/rust-mac

[PATCH 019/125] gccrs: format-parser: Add `is_some_and` method for Option

2024-08-01 Thread Arthur Cohen
Workaround for Ubuntu 18.04, since we still use it for the GCC 4.8 CI. The default Rust package is 1.65 (and unlikely to change I assume?), but the generic format parser library uses `is_some_and` which was introduced in 1.70. So this is a simple reimplementation, directly taken from the standard l

[PATCH 043/125] gccrs: Placate clang-format re 'gcc/rust/backend/rust-tree.cc'

2024-08-01 Thread Arthur Cohen
From: Thomas Schwinge Reformat the upstream GCC commit f4a2ae2338962208b8039f154f5912402e94c378 "Change MODE_BITSIZE to MODE_PRECISION for MODE_VECTOR_BOOL" change to 'gcc/rust/backend/rust-tree.cc' to clang-format's liking. gcc/rust/ * backend/rust-tree.cc (c_common_type_for_mod

[PATCH 040/125] gccrs: Unify ASTValidation::visit for ExternalFunctionItem and Function

2024-08-01 Thread Arthur Cohen
From: 0xn4utilus gcc/rust/ChangeLog: * checks/errors/rust-ast-validation.cc (ASTValidation::visit): Add external function validation support. Add ErrorCode::E0130. * parse/rust-parse-impl.h (Parser::parse_function): Parse external functions from `parse_function`.

[PATCH 018/125] gccrs: libformat_parser: Fix Rust warnings.

2024-08-01 Thread Arthur Cohen
libgrust/ChangeLog: * libformat_parser/generic_format_parser/src/lib.rs: Remove unused deprecated attribute and unused import. * libformat_parser/src/lib.rs: Remove unused import. --- libgrust/libformat_parser/generic_format_parser/src/lib.rs | 2 -- libgrust/libformat_par

[PATCH 021/125] gccrs: Fix small FixMe task in rust macro builtins

2024-08-01 Thread Arthur Cohen
From: jjasmine gcc/rust/ChangeLog: * expand/rust-macro-builtins.cc: Change BuiltinMacro in builtin_macro_from_string to tl::optional<> * expand/rust-macro-builtins.h (enum class): Change BuiltinMacro in builtin_macro_from_string to tl::optional<> * resolve

[PATCH 029/125] gccrs: macro-builtins: Add newline generic format_args!() handler

2024-08-01 Thread Arthur Cohen
gcc/rust/ChangeLog: * expand/rust-macro-builtins.cc (format_args_maker): New function. (try_expand_many_expr): Add comment about reworking function. (MacroBuiltin::format_args_handler): Add newline parameter. * expand/rust-macro-builtins.h: Likewise. --- gcc/rust/e

[PATCH 026/125] gccrs: extern-types: Lower to HIR::ExternalTypeItem properly

2024-08-01 Thread Arthur Cohen
gcc/rust/ChangeLog: * hir/rust-ast-lower-extern.h: Lower to HIR::ExternalTypeItem nodes. * hir/tree/rust-hir-item.h (class ExternalTypeItem): Create private visibility by default as extern types have no visibility - add a comment about the correctness of this. ---

[PATCH 033/125] gccrs: format-args: Add documentation for future expansion of function

2024-08-01 Thread Arthur Cohen
gcc/rust/ChangeLog: * expand/rust-macro-builtins.cc (MacroBuiltin::format_args_handler): Add documentation regarding future tasks. --- gcc/rust/expand/rust-macro-builtins.cc | 26 +- 1 file changed, 5 insertions(+), 21 deletions(-) diff --git a/gcc/rust/ex

[PATCH 032/125] gccrs: lower: Add base for lowering FormatArgs nodes

2024-08-01 Thread Arthur Cohen
gcc/rust/ChangeLog: * Make-lang.in: Compile the new source file. * ast/rust-ast-collector.cc (TokenCollector::visit): Error out when visiting FormatArgs nodes. * resolve/rust-ast-resolve-base.cc (ResolverBase::visit): Likewise. * hir/rust-ast-lower-expr.cc (

[PATCH 031/125] gccrs: format-args: Fix Rust interface and add input parsing.

2024-08-01 Thread Arthur Cohen
gcc/rust/ChangeLog: * ast/rust-ast.cc: Make FormatArgs inherit from AST::Expr * ast/rust-builtin-ast-nodes.h: Improve FormatArg* nodes and helpers. * ast/rust-fmt.cc (Pieces::collect): Fix interface to match FFI function. * ast/rust-fmt.h (collect_pieces): Likewise

[PATCH 035/125] gccrs: Add curly brackets, formatted clang

2024-08-01 Thread Arthur Cohen
From: jjasmine gcc/rust/ChangeLog: * resolve/rust-late-name-resolver-2.0.cc (Late::visit): Add error emitting --- gcc/rust/resolve/rust-late-name-resolver-2.0.cc | 17 - 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/gcc/rust/resolve/rust-late-name-resol

[PATCH 038/125] gccrs: Add support for external functions

2024-08-01 Thread Arthur Cohen
From: 0xn4utilus gcc/rust/ChangeLog: * ast/rust-ast.cc (Function::Function): Add `is_external_function` field. (Function::operator=): Likewise. * ast/rust-ast.h: New constructor for ExternalItem. * ast/rust-item.h (class Function): Add `is_external_function`

[PATCH 028/125] gccrs: ast: Add base nodes for FormatArgs

2024-08-01 Thread Arthur Cohen
This commit adds a base for creating AST FormatArgs nodes after expanding invocations of `format_args!()`. These nodes will then be expanded to the proper runtime function calls (to core::fmt::rt) during the AST lowering. gcc/rust/ChangeLog: * ast/rust-builtin-ast-nodes.h: New file.

[PATCH 047/125] gccrs: format-args: Add base for expanding FormatArgs nodes

2024-08-01 Thread Arthur Cohen
gcc/rust/ChangeLog: * Make-lang.in: Add new object. * hir/rust-ast-lower-expr.cc (ASTLoweringExpr::visit): Remove calls to FormatArgsLowering. * expand/rust-expand-format-args.cc: New file. * expand/rust-expand-format-args.h: New file. --- gcc/rust/Make-lan

[PATCH 036/125] gccrs: Ensure TupleStructPattern and TuplePattern have items

2024-08-01 Thread Arthur Cohen
From: Owen Avery Note that instances of both classes which have been moved from will have (items == nullptr). gcc/rust/ChangeLog: * ast/rust-pattern.h (class TupleStructPattern): Assert that items != nullptr. (class TuplePattern): Likewise. (TupleStructPattern::h

[PATCH 030/125] gccrs: parser: Add peek(n) method to parser

2024-08-01 Thread Arthur Cohen
gcc/rust/ChangeLog: * parse/rust-parse.h: New method. --- gcc/rust/parse/rust-parse.h | 1 + 1 file changed, 1 insertion(+) diff --git a/gcc/rust/parse/rust-parse.h b/gcc/rust/parse/rust-parse.h index 1614d19e4a5..8c8bf96eb8d 100644 --- a/gcc/rust/parse/rust-parse.h +++ b/gcc/rust/parse/

[PATCH 048/125] gccrs: format-args: Start storing string in Rust memory

2024-08-01 Thread Arthur Cohen
gcc/rust/ChangeLog: * ast/rust-fmt.cc (ffi::RustHamster::to_string): New. (Pieces::collect): Adapt to use new handle API. (Pieces::~Pieces): Likewise. (Pieces::Pieces): Likewise. (Pieces::operator=): Likewise. * ast/rust-fmt.h (struct RustString): Ad

[PATCH 039/125] gccrs: Add get_pattern_kind to Pattern

2024-08-01 Thread Arthur Cohen
From: 0xn4utilus gcc/rust/ChangeLog: * ast/rust-ast.h: Add Kind Enum to Pattern. * ast/rust-macro.h: Add get_pattern_kind(). * ast/rust-path.h: Likewise. * ast/rust-pattern.h: Likewise. Signed-off-by: 0xn4utilus --- gcc/rust/ast/rust-ast.h | 20

[PATCH 037/125] gccrs: Clean BiMap to use tl::optional for lookups

2024-08-01 Thread Arthur Cohen
From: Sourabh Jaiswal gcc/rust/Changelog: * expand/rust-expand-visitor.cc (ExpandVisitor::expand_inner_items): Adjust to use has_value () (ExpandVisitor::expand_inner_stmts): Likewise * expand/rust-macro-builtins.cc (builtin_macro_from_string): Likewise (m

[PATCH 062/125] gccrs: session manager: Init Immutable name resolver.

2024-08-01 Thread Arthur Cohen
gcc/rust/ChangeLog: * rust-session-manager.cc (Session::compile_crate): Create an immutable view of the name resolution context. --- gcc/rust/rust-session-manager.cc | 4 1 file changed, 4 insertions(+) diff --git a/gcc/rust/rust-session-manager.cc b/gcc/rust/rust-session-ma

[PATCH 044/125] gccrs: Replace reference to unique pointer with reference

2024-08-01 Thread Arthur Cohen
From: Pierre-Emmanuel Patry Reference to unique pointers are a known anti pattern, only the element shall be taken by reference instead of the whole wrapper. gcc/rust/ChangeLog: * ast/rust-item.h: Change getter function prototype to return a reference directly instead of a refer

[PATCH 049/125] gccrs: format-args: Add basic expansion of unnamed Display::fmt arguments.

2024-08-01 Thread Arthur Cohen
gcc/rust/ChangeLog: * ast/rust-ast-builder.h: Rename AST::AstBuilder -> AST::Builder * ast/rust-ast-builder.cc: Likewise. * expand/rust-derive.cc: Use new AST::Builder name. * expand/rust-derive.h: Likewise. * ast/rust-builtin-ast-nodes.h: Add required gette

[PATCH 053/125] gccrs: TyTy: Variance analysis module

2024-08-01 Thread Arthur Cohen
From: Jakub Dupak gcc/rust/ChangeLog: * Make-lang.in: Add new .cc file. * rust-session-manager.cc (Session::compile_crate): Run analysis. * typecheck/rust-tyty-variance-analysis-private.h: New file. * typecheck/rust-tyty-variance-analysis.cc: New file.

[PATCH 056/125] gccrs: Fix typo

2024-08-01 Thread Arthur Cohen
From: Guillaume Gomez gcc/rust/ChangeLog: * expand/rust-derive.cc (DeriveVisitor::derive): Fix typo --- gcc/rust/expand/rust-derive.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gcc/rust/expand/rust-derive.cc b/gcc/rust/expand/rust-derive.cc index 4177004eccf..e

[PATCH 042/125] gccrs: Remove dead code associated with `AST::ExternalFunctionItem`

2024-08-01 Thread Arthur Cohen
From: 0xn4utilus gcc/rust/ChangeLog: * ast/rust-ast-collector.cc (TokenCollector::visit): Remove dead code. * ast/rust-ast-collector.h: Likewise. * ast/rust-ast-full-decls.h (class ExternalFunctionItem): Likewise. * ast/rust-ast-visitor.cc (Default

[PATCH 052/125] gccrs: TyTy: add common SubstitutionRef API

2024-08-01 Thread Arthur Cohen
From: Jakub Dupak gcc/rust/ChangeLog: * typecheck/rust-tyty-subst.cc (SubstitutionRef::get_arg_at): Add unified API. Signed-off-by: Jakub Dupak --- gcc/rust/typecheck/rust-tyty-subst.cc | 11 +++ 1 file changed, 11 insertions(+) diff --git a/gcc/rust/typecheck/rust-ty

[PATCH 063/125] gccrs: nr2.0: Add lookup of resolved nodes.

2024-08-01 Thread Arthur Cohen
gcc/rust/ChangeLog: * resolve/rust-name-resolution-context.cc (NameResolutionContext::lookup): Add lookup function. * resolve/rust-name-resolution-context.h: Include mappings and optional. --- gcc/rust/resolve/rust-name-resolution-context.cc | 13 + gcc/rust/r

[PATCH 070/125] gccrs: Change error message on unresolved import

2024-08-01 Thread Arthur Cohen
From: Pierre-Emmanuel Patry The error message did not match rustc's. gcc/rust/ChangeLog: * resolve/rust-toplevel-name-resolver-2.0.cc (TopLevel::visit): Change error message. Signed-off-by: Pierre-Emmanuel Patry --- gcc/rust/resolve/rust-toplevel-name-resolver-2.0.cc | 3 +--

[PATCH 055/125] gccrs: Store visibility properly in ExternalTypeItem

2024-08-01 Thread Arthur Cohen
From: jjasmine Fix issue 2897 gcc/rust/ChangeLog: * hir/rust-ast-lower-extern.h: Add translate_visiblity * hir/tree/rust-hir-item.h: Fix constructor of ExternalTypeItem --- gcc/rust/hir/rust-ast-lower-extern.h | 4 +++- gcc/rust/hir/tree/rust-hir-item.h| 4 ++-- 2 files cha

[PATCH 078/125] gccrs: Add support for ambiguous use declarations

2024-08-01 Thread Arthur Cohen
From: Pierre-Emmanuel Patry Glob use declarations may lead to ambiguous situation where two definitions with the same name are imported in a given scope. The compiler now handles shadowable items inserted after non shadowable items. An error is now thrown when multiple shadowable items are import

[PATCH 051/125] gccrs: format-args: Only pass the format string to the parser.

2024-08-01 Thread Arthur Cohen
This fixes an issue we had where the generated code ended with more static pieces than its rustc counterpart. gcc/rust/ChangeLog: * expand/rust-macro-builtins.cc (struct FormatArgsInput): Store the format_str as a string instead of an AST::Expr. (format_args_parse_argumen

[PATCH 059/125] gccrs: nr2.0: Add new ImmutableNameResolutionCtx class.

2024-08-01 Thread Arthur Cohen
gcc/rust/ChangeLog: * Make-lang.in: Compile it. * resolve/rust-immutable-name-resolution-context.cc: New file. * resolve/rust-immutable-name-resolution-context.h: New file. --- gcc/rust/Make-lang.in | 1 + .../rust-immutable-name-resolution-context

[PATCH 079/125] gccrs: Add tuple struct constructor to value namespace

2024-08-01 Thread Arthur Cohen
From: Pierre-Emmanuel Patry A tuple struct constructor should be inserted in the value namespace during name resolution in order to reject multiple definitions of the function. gcc/rust/ChangeLog: * resolve/rust-toplevel-name-resolver-2.0.cc (TopLevel::visit): Add the struct con

[PATCH 087/125] gccrs: Change enum namespace from value to type

2024-08-01 Thread Arthur Cohen
From: Pierre-Emmanuel Patry The enum type shall be in type namespace, not value namespace. gcc/rust/ChangeLog: * resolve/rust-toplevel-name-resolver-2.0.cc (GlobbingVisitor::visit): Change enum type namespace. Signed-off-by: Pierre-Emmanuel Patry --- gcc/rust/resolve/rust-top

[PATCH 054/125] gccrs: TyTy: Collect variance info from types

2024-08-01 Thread Arthur Cohen
From: Jakub Dupak gcc/rust/ChangeLog: * typecheck/rust-hir-type-check-item.cc (TypeCheckItem::visit): Collect variance info from types. Signed-off-by: Jakub Dupak --- gcc/rust/typecheck/rust-hir-type-check-item.cc | 17 + 1 file changed, 13 insertions(+), 4 del

[PATCH 068/125] gccrs: Fix duplicate detection

2024-08-01 Thread Arthur Cohen
From: Pierre-Emmanuel Patry The resolver did report duplicate symbols when being run multiple times even if the node id was the same. This commit adds an additional condition, the error will only be reported if the existing node id is different from the current node id. gcc/rust/ChangeLog:

[PATCH 067/125] gccrs: late: Setup builtin types properly, change Rib API

2024-08-01 Thread Arthur Cohen
gcc/rust/ChangeLog: * resolve/rust-forever-stack.hxx: Start using Rib::Definition for shadowable information. * resolve/rust-late-name-resolver-2.0.cc (next_node_id): New. (next_hir_id): New. (Late::setup_builtin_types): Improve builtin type setup. *

[PATCH 090/125] gccrs: Remove extern block scoping

2024-08-01 Thread Arthur Cohen
From: Pierre-Emmanuel Patry Remove extern block scoping visit function, use the default visitor visit function instead. We do not need scoping for extern block as their element shall be visible from the extern block scope. gcc/rust/ChangeLog: * resolve/rust-default-resolver.cc (DefaultR

[PATCH 075/125] gccrs: Shape up name resolver for normal direct calls

2024-08-01 Thread Arthur Cohen
From: Pierre-Emmanuel Patry Direct function calls did not work anymore due to the transition to the new resolver. gcc/rust/ChangeLog: * checks/lints/rust-lint-marklive.cc (MarkLive::find_ref_node_id): Add code path for the resolver 2.0 * resolve/rust-late-name-resolver-2

[PATCH 084/125] gccrs: Values shall be inserted in the value namespace

2024-08-01 Thread Arthur Cohen
From: Pierre-Emmanuel Patry Values were inserted in the label namespace instead of the value namespace this lead to several bugs. gcc/rust/ChangeLog: * resolve/rust-late-name-resolver-2.0.cc (Late::visit): Change the namespace for values from "label" to "values". Signed-off-by:

[PATCH 097/125] gccrs: Add mappings for struct base and struct fields

2024-08-01 Thread Arthur Cohen
From: Pierre-Emmanuel Patry Definition/usage mapping during name resolution was missing. gcc/rust/ChangeLog: * resolve/rust-late-name-resolver-2.0.cc (Late::visit): Add mapping implementation. * resolve/rust-late-name-resolver-2.0.h: Add function visitor prototype

[PATCH 100/125] gccrs: nr2.0: Add new test cases.

2024-08-01 Thread Arthur Cohen
gcc/testsuite/ChangeLog: * rust/compile/name_resolution13.rs: Add new module and remove compile step. * rust/compile/name_resolution14.rs: New test. * rust/compile/name_resolution15.rs: New test. * rust/compile/name_resolution16.rs: New test. * rust/

[PATCH 103/125] gccrs: Improve parsing of raw byte string literals

2024-08-01 Thread Arthur Cohen
From: Owen Avery gcc/rust/ChangeLog: * lex/rust-lex.cc (Lexer::parse_raw_byte_string): Bring handling of edge cases to par with parse_byte_string. gcc/testsuite/ChangeLog: * rust/compile/raw-byte-string-loc.rs: New test. Signed-off-by: Owen Avery --- gcc/rust

[PATCH 107/125] gccrs: Improve parsing of raw string literals

2024-08-01 Thread Arthur Cohen
From: Owen Avery gcc/rust/ChangeLog: * lex/rust-lex.cc (Lexer::parse_raw_string): Bring handling of edge cases to par with parse_raw_byte_string. gcc/testsuite/ChangeLog: * rust/compile/raw-string-loc.rs: New test. Signed-off-by: Owen Avery --- gcc/rust/lex/r

[PATCH 115/125] gccrs: borrowck: BIR: emit moves

2024-08-01 Thread Arthur Cohen
From: Jakub Dupak gcc/rust/ChangeLog: * checks/errors/borrowck/rust-bir-builder-expr-stmt.cc (ExprStmtBuilder::visit): Emit moves. * checks/errors/borrowck/rust-bir-builder-internal.h: Emit moves. * checks/errors/borrowck/rust-bir-builder-lazyboolexpr.h: Emit moves.

[PATCH 069/125] gccrs: Emit error on identical use declarations

2024-08-01 Thread Arthur Cohen
From: Pierre-Emmanuel Patry The compiler did not emit any warning when a same target was declared from different sources. gcc/rust/ChangeLog: * resolve/rust-toplevel-name-resolver-2.0.cc (TopLevel::handle_use_dec): Use the new dict to track down already resolved use declarations

[PATCH 122/125] gccrs: borrowck: Remove block braces to satisfy GNU style

2024-08-01 Thread Arthur Cohen
From: Jakub Dupak gcc/rust/ChangeLog: * checks/errors/borrowck/rust-bir-dump.cc (renumber_places): Remove unecessary braces. (Dump::go): Remove unecessary braces. (Dump::visit): Remove unecessary braces. (Dump::visit_scope): Remove unecessary braces.

[PATCH 125/125] gccrs: Add a test for inherent impl type name resolve

2024-08-01 Thread Arthur Cohen
From: Pierre-Emmanuel Patry A previous bug with name resolution 2.0 was caused by an incorrectly resolved inherent impl name. This test shall highlight the behavior and prevent regression. gcc/testsuite/ChangeLog: * rust/compile/name_resolution25.rs: New test. Signed-off-by: Pierre-Emm

[PATCH 071/125] gccrs: Prevent error emission on resolver reentry

2024-08-01 Thread Arthur Cohen
From: Pierre-Emmanuel Patry The resolver was emitting an error when meeting the same symbol twice. What is important here is the origin of the resolved symbol, we should emit an error when the name is similar but the symbol isn't be not when the resolver is simply meeting the exact same symbol.

[PATCH 058/125] gccrs: Placate clang-format re 'gcc/rust/lex/rust-lex.cc'

2024-08-01 Thread Arthur Cohen
From: Thomas Schwinge Reformat the upstream GCC commit 61644aea34c4623d16273ff705f8b8b1ff2d87f0 "gccrs: tokenize Unicode identifiers" change to 'gcc/rust/lex/rust-lex.cc' to clang-format's liking. gcc/rust/ * lex/rust-lex.cc (is_identifier_start): Placate clang-format. --- gcc/r

[PATCH 099/125] gccrs: compile: resolve-path-ref: properly resolve nodeId with nr2.0

2024-08-01 Thread Arthur Cohen
gcc/rust/ChangeLog: * backend/rust-compile-resolve-path.cc: Attempt to resolve names also using new name resolution context. * backend/rust-compile-resolve-path.h: Add new declaration. --- gcc/rust/backend/rust-compile-resolve-path.cc | 112 +++--- gcc/rust/bac

[PATCH 076/125] gccrs: Add call to globbing visitor

2024-08-01 Thread Arthur Cohen
From: Pierre-Emmanuel Patry Globbing visitor did not visit subitems. gcc/rust/ChangeLog: * resolve/rust-late-name-resolver-2.0.cc (Late::visit): Add a check for missing item. * resolve/rust-toplevel-name-resolver-2.0.cc (GlobbingVisitor::go): Add a new function i

[PATCH 060/125] gccrs: sesh: Add late name resolution 2.0

2024-08-01 Thread Arthur Cohen
gcc/rust/ChangeLog: * rust-session-manager.cc (Session::compile_crate): Create name resolution context for Session::expansion and subsequent name resolution passes. (Session::expansion): Take name resolution context as a parameter instead. * rust-session-ma

[PATCH 041/125] gccrs: Update resolver to use `AST::Function` instead of `AST::ExternalFunctionItem`

2024-08-01 Thread Arthur Cohen
From: 0xn4utilus gcc/rust/ChangeLog: * checks/errors/rust-feature-gate.cc (FeatureGate::visit): Check if function is_external or not. * hir/rust-ast-lower-extern.h: Use AST::Function instead of AST::ExternalFunctionItem. * parse/rust-parse-impl.h (Parser::

[PATCH 080/125] gccrs: Change error message to match test

2024-08-01 Thread Arthur Cohen
From: Pierre-Emmanuel Patry Error message did not match the test from the previous name resolver when a given path cannot be resolved. gcc/rust/ChangeLog: * typecheck/rust-hir-type-check-path.cc (TypeCheckExpr::resolve_root_path): Change error message to match old resolver and

[PATCH 061/125] gccrs: session-manager: Dump name resolution pass.

2024-08-01 Thread Arthur Cohen
gcc/rust/ChangeLog: * rust-session-manager.cc: Add files for dumping name resolution, call name resolution dump function. (Session::dump_name_resolution): New. * rust-session-manager.h: New declaration. --- gcc/rust/rust-session-manager.cc | 30

[PATCH 081/125] gccrs: Visit function return type in default resolver

2024-08-01 Thread Arthur Cohen
From: Pierre-Emmanuel Patry Function return type was not properly visited in the default resolver visitor pattern. gcc/rust/ChangeLog: * resolve/rust-default-resolver.cc (DefaultResolver::visit): Visit function return type. Signed-off-by: Pierre-Emmanuel Patry --- gcc/rust/re

[PATCH 065/125] gccrs: backend: Use new name resolver where necessary

2024-08-01 Thread Arthur Cohen
gcc/rust/ChangeLog: * backend/rust-compile-base.cc: Use new ImmutableNrCtx. * backend/rust-compile-context.h: Likewise. * backend/rust-compile-expr.cc: Likewise. * backend/rust-compile-item.cc: Likewise. --- gcc/rust/backend/rust-compile-base.cc | 1 + gcc/rust/

[PATCH 066/125] gccrs: nr2.0: Start using newtype pattern for Usage and Declaration

2024-08-01 Thread Arthur Cohen
gcc/rust/ChangeLog: * resolve/rust-name-resolution-context.cc (NameResolutionContext::map_usage): Use newtype pattern. (NameResolutionContext::lookup): Likewise. * resolve/rust-name-resolution-context.h (class Usage): New class. (class Definition): Likewise

[PATCH 046/125] gccrs: macro: Use MacroInvocation's node_id in ExternalItem constructor.

2024-08-01 Thread Arthur Cohen
gcc/rust/ChangeLog: * ast/rust-macro.h: Use proper node id instead of the one in the base Expr class - which is uninitialized. --- gcc/rust/ast/rust-macro.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gcc/rust/ast/rust-macro.h b/gcc/rust/ast/rust-macro.h in

[PATCH 085/125] gccrs: Unit struct constructor shall be resolved

2024-08-01 Thread Arthur Cohen
From: Pierre-Emmanuel Patry Unit struct have a special constructor that should be added to the struct namespace in order to be resolved later when called. As it is a function it should be added in the value namespace. gcc/rust/ChangeLog: * resolve/rust-toplevel-name-resolver-2.0.cc (Glo

[PATCH 050/125] gccrs: format-args: Add basic test case

2024-08-01 Thread Arthur Cohen
gcc/testsuite/ChangeLog: * rust/compile/format_args_basic_expansion.rs: New test. --- .../compile/format_args_basic_expansion.rs| 47 +++ 1 file changed, 47 insertions(+) create mode 100644 gcc/testsuite/rust/compile/format_args_basic_expansion.rs diff --git a/gcc/te

[PATCH 094/125] gccrs: Update assignment operator with cratenum

2024-08-01 Thread Arthur Cohen
From: Pierre-Emmanuel Patry Crate number was not assigned with the other fields in the assignment operator overload of a CannonicalPath. gcc/rust/ChangeLog: * util/rust-canonical-path.h: Also assign crate number. Signed-off-by: Pierre-Emmanuel Patry --- gcc/rust/util/rust-canonical-p

[PATCH 077/125] gccrs: Make globbing definition shadowable by default

2024-08-01 Thread Arthur Cohen
From: Pierre-Emmanuel Patry Elements from glob use declaration shall be shadowable by default. gcc/rust/ChangeLog: * resolve/rust-forever-stack.h: Add a new function prototype to insert a shadowable definition. * resolve/rust-forever-stack.hxx: Add the new insert_shadowa

[PATCH 109/125] gccrs: unify: Always coerce `!` to the target type.

2024-08-01 Thread Arthur Cohen
Never can... never... exist, so it should always be coerced to the type it is being matched against. This is useful for breaking off of a loop from inside a match, or an if condition, for example. gcc/rust/ChangeLog: * typecheck/rust-unify.cc (UnifyRules::go): Always unify to `ltype` if

[PATCH 082/125] gccrs: Visit constant item type in default resolver

2024-08-01 Thread Arthur Cohen
From: Pierre-Emmanuel Patry The type of constant item expression was not properly visited in the default resolver. gcc/rust/ChangeLog: * resolve/rust-default-resolver.cc (DefaultResolver::visit): Visit constant item's types. Signed-off-by: Pierre-Emmanuel Patry --- gcc/rust/r

[PATCH 083/125] gccrs: Raw pointer type visitor didn't require overload

2024-08-01 Thread Arthur Cohen
From: Pierre-Emmanuel Patry This overload did not dispatch the visitor to sub members of a raw pointer like the default one. It is therefore useless as pointed type shall be visited to be resolved correctly. gcc/rust/ChangeLog: * resolve/rust-default-resolver.cc (DefaultResolver::visit)

[PATCH 086/125] gccrs: Add tuple struct to the type namespace

2024-08-01 Thread Arthur Cohen
From: Pierre-Emmanuel Patry Only tuple struct constructor was added to the resolver. gcc/rust/ChangeLog: * resolve/rust-toplevel-name-resolver-2.0.cc (GlobbingVisitor::visit): Add tuple struct type to the resolver's context. Signed-off-by: Pierre-Emmanuel Patry --- gcc/rust/r

[PATCH 091/125] gccrs: Remove unsafe block empty visit function

2024-08-01 Thread Arthur Cohen
From: Pierre-Emmanuel Patry We need to visit subcomponents in unsafe elements, this means we can leverage the default ast visitor's code instead of duplicating it. gcc/rust/ChangeLog: * resolve/rust-default-resolver.cc (DefaultResolver::visit): Remove empty visit function.

[PATCH 098/125] gccrs: Fix use rebind name resolution.

2024-08-01 Thread Arthur Cohen
From: Pierre-Emmanuel Patry Name resolution for rebind were missing. gcc/rust/ChangeLog: * resolve/rust-toplevel-name-resolver-2.0.cc (TopLevel::handle_use_glob): Change function prototype to use a reference instead. (TopLevel::handle_use_dec): Likewise. (TopLev

[PATCH 104/125] gccrs: Recognize rustc_deprecated as a builtin attribute

2024-08-01 Thread Arthur Cohen
From: Owen Avery gcc/rust/ChangeLog: * util/rust-attribute-values.h (Attributes::RUSTC_DEPRECATED): New. * util/rust-attributes.cc (__definitions): Add Attributes::RUSTC_DEPRECATED. gcc/testsuite/ChangeLog: * rust/compile/deprecated-fn.rs: New test. Sig

[PATCH 106/125] gccrs: Avoid parsing const unsafe/extern functions as async

2024-08-01 Thread Arthur Cohen
From: Owen Avery gcc/rust/ChangeLog: * parse/rust-parse-impl.h (Parser::parse_vis_item): Call parse_function instead of parse_async_item when finding UNSAFE or EXTERN_KW during lookahead. gcc/testsuite/ChangeLog: * rust/compile/func-const-unsafe.rs: New

[PATCH 108/125] gccrs: raw-strings: Remove dg-excess-error directive

2024-08-01 Thread Arthur Cohen
The error is actually expected and uses the correct location. gcc/testsuite/ChangeLog: * rust/compile/raw-byte-string-loc.rs: Use dg-error instead of dg-excess-error. * rust/compile/raw-string-loc.rs: Likewise. --- gcc/testsuite/rust/compile/raw-byte-string-loc.rs | 2 +-

  1   2   >