[COMMITTED 15/19] gccrs: Add `#[track_caller]` as known attribute

2025-04-15 Thread arthur . cohen
From: beamandala gcc/rust/ChangeLog: * expand/rust-macro-builtins.cc (MacroBuiltin::builtin_transcribers): Add entry for track_caller. * util/rust-attribute-values.h: add `TRACK_CALLER` attribute. * util/rust-attributes.cc: add `track_caller` attribute definition.

[COMMITTED 05/19] gccrs: typecheck: Properly select methods when dealing with specialization

2025-04-14 Thread arthur . cohen
From: Arthur Cohen gcc/rust/ChangeLog: * typecheck/rust-hir-type-check-expr.cc (is_default_fn): New. (emit_ambiguous_resolution_error): New. (handle_multiple_candidates): Properly handle multiple candidates in the case of specialization. (TypeCheckExpr

[COMMITTED 18/19] gccrs: attributes: Handle external tool annotations like rustfmt::

2025-04-14 Thread arthur . cohen
From: Arthur Cohen gcc/rust/ChangeLog: * util/rust-attribute-values.h: Add RUSTFMT value. * util/rust-attributes.cc: Define the attribute. * util/rust-attributes.h (enum CompilerPass): Add EXTERNAL variant. * expand/rust-macro-builtins.cc: Fix formatting

[COMMITTED 17/19] gccrs: nr2.0: Only insert derive macros if they exist

2025-04-14 Thread arthur . cohen
From: Arthur Cohen This causes an assertion failure when compiling core with nr2.0, but should probably be improved. I'm not sure how this code enables built-in derive macros to be resolved so this is a temporary fix. gcc/rust/ChangeLog: * resolve/rust-early-name-resolver-2.0.cc (

[COMMITTED 13/19] gccrs: Fix const checking of enum discriminants

2025-04-14 Thread arthur . cohen
From: Owen Avery gcc/rust/ChangeLog: * checks/errors/rust-const-checker.cc (ConstChecker::visit): Visit the enum items of enums. * resolve/rust-ast-resolve-item.cc (ResolveItem::visit): Resolve enum discriminants during nr1.0. gcc/testsuite/ChangeLog: *

[COMMITTED 08/19] gccrs: ast: Add get_locus() to DelimTokenTree

2025-04-14 Thread arthur . cohen
From: Arthur Cohen gcc/rust/ChangeLog: * ast/rust-ast.h (DelimTokenTree::get_locus): New function. --- gcc/rust/ast/rust-ast.h | 1 + 1 file changed, 1 insertion(+) diff --git a/gcc/rust/ast/rust-ast.h b/gcc/rust/ast/rust-ast.h index 09e0fce4f19..91611ec6a62 100644 --- a/gcc/rust/ast

[COMMITTED 04/19] rust: Add comment inside block [PR119342]

2025-04-14 Thread arthur . cohen
From: Andrew Pinski Inside a BLOCK node, all of the variables of the scope/block are chained together and that connects them to the block. This just adds a comment to that effect as reading the code it is not so obvious why they need to be chained together. gcc/rust/ChangeLog: PR rust/1

[COMMITTED 19/19] gccrs: lang-items: Add ManuallyDrop

2025-04-14 Thread arthur . cohen
From: Arthur Cohen gcc/rust/ChangeLog: * util/rust-lang-item.h: Add new manually_drop lang item. * util/rust-lang-item.cc: Likewise. --- gcc/rust/util/rust-lang-item.cc | 1 + gcc/rust/util/rust-lang-item.h | 2 ++ 2 files changed, 3 insertions(+) diff --git a/gcc/rust/util

[COMMITTED 16/19] gccrs: attributes: Add missing attributes used in `core`

2025-04-14 Thread arthur . cohen
From: Arthur Cohen gcc/rust/ChangeLog: * util/rust-attribute-values.h: Add missing attributes. * util/rust-attributes.cc: Likewise. * util/rust-attributes.h (enum CompilerPass): Mention adding something for const functions. --- gcc/rust/util/rust-attribute

[COMMITTED 12/19] gccrs: format_args: Allow extraneous commas, improve safety

2025-04-14 Thread arthur . cohen
From: Arthur Cohen gcc/rust/ChangeLog: * expand/rust-macro-builtins-format-args.cc (format_args_parse_arguments): Improve safety, allow extra commas after end of argument list. gcc/testsuite/ChangeLog: * rust/compile/format_args_extra_comma.rs: New test

[COMMITTED 14/19] gccrs: install.texi: Mention Rust requirement for building gccrs

2025-04-14 Thread arthur . cohen
From: Arthur Cohen Addresses PR#117869 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=117869 gcc/ChangeLog: * doc/install.texi: Add requirements for building gccrs. --- gcc/doc/install.texi | 6 ++ 1 file changed, 6 insertions(+) diff --git a/gcc/doc/install.texi b/gcc/doc

[COMMITTED 09/19] gccrs: session: Desugar question mark operator after expansion instead.

2025-04-14 Thread arthur . cohen
From: Arthur Cohen gcc/rust/ChangeLog: * rust-session-manager.cc (Session::compile_crate): Call the visitor later in the pipeline. --- gcc/rust/rust-session-manager.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gcc/rust/rust-session-manager.cc b/gcc/rust/rust

[COMMITTED 11/19] gccrs: expansion: Desugar doc comments into attributes before expansion

2025-04-14 Thread arthur . cohen
From: Arthur Cohen gcc/rust/ChangeLog: * expand/rust-macro-expand.cc (MacroExpander::expand_decl_macro): Call into TokenTreeDesugar. * expand/rust-token-tree-desugar.cc: New file. * expand/rust-token-tree-desugar.h: New file. * Make-lang.in: Compile them

[COMMITTED 01/19] rust: Use FLOAT_TYPE_P instead of manual checking

2025-04-14 Thread arthur . cohen
From: Andrew Pinski This moves is_floating_point over to using FLOAT_TYPE_P instead of manually checking. Note before it would return true for all COMPLEX_TYPE but complex types' inner type could be integral. Also fixes up the comment to be in more of the GNU style. Bootstrapped and tested on x

[COMMITTED 10/19] gccrs: expansion: Only add fragments if the matcher succeeded

2025-04-14 Thread arthur . cohen
From: Arthur Cohen gcc/rust/ChangeLog: * expand/rust-macro-expand.cc (MacroExpander::match_n_matches): Do not insert fragments and substack fragments if the matcher failed. gcc/testsuite/ChangeLog: * rust/compile/macros/mbe/macro-issue3708.rs: New test. --- gcc/rust

[COMMITTED 06/19] gccrs: nr2.0: Do not resolve modules this run if they are unloaded

2025-04-14 Thread arthur . cohen
From: Arthur Cohen Instead, mark the visitor as dirty and wait for the next round of the fixed point to take care of them. This avoids issues with module items being loaded while not being stripped yet. gcc/rust/ChangeLog: * resolve/rust-toplevel-name-resolver-2.0.cc (TopLevel::visit

[COMMITTED 02/19] rust: Use error_operand_p in rust-gcc.cc

2025-04-14 Thread arthur . cohen
From: Andrew Pinski Just a simple cleanupof the code to use error_operand_p instead of directly comparing against error_mark_node. This also moves some cdoe around when dealing with error_operand_p just to be faster and/or slightly tighten up the code slightly. gcc/rust/ChangeLog: * ru

[COMMITTED 03/19] rust: use range for inside rust-gcc.cc [PR119341]

2025-04-14 Thread arthur . cohen
From: Andrew Pinski There are some places inside rust-gcc.cc which are candidates to use range for instead of iterators directly. This changes the locations I saw and makes the code slightly more readable. gcc/rust/ChangeLog: PR rust/119341 * rust-gcc.cc (function_type): Use ran

[COMMITTED 07/19] gccrs: ast: Support outer attributes for AST::RangeExpr

2025-04-14 Thread arthur . cohen
From: Arthur Cohen gcc/rust/ChangeLog: * ast/rust-expr.h (class RangeExpr): Add empty outer attributes and allow getting them and setting them. --- gcc/rust/ast/rust-expr.h | 12 ++-- 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/gcc/rust/ast/rust

[COMMITTED 04/32] gccrs: Fix ICE when resolving lifetimes without name

2025-04-10 Thread arthur . cohen
From: Philip Herron We dont need to assert here the lifetime code already supports this case. Fixes Rust-GCC#3657 gcc/rust/ChangeLog: * typecheck/rust-hir-type-check-base.cc: remove assertion gcc/testsuite/ChangeLog: * rust/compile/issue-3657.rs: New test. Signed-off-by: Phi

[COMMITTED 07/32] gccrs: Fix ICE on invalid match arms

2025-04-10 Thread arthur . cohen
From: Philip Herron We hit assertions on empty enum or unknown variant, this catches the error and emits a new diagnostic. Fixes Rust-GCC#3656 gcc/rust/ChangeLog: * typecheck/rust-hir-type-check-pattern.cc (TypeCheckPattern::visit): emit error gcc/testsuite/ChangeLog: * rust

[COMMITTED 21/32] gccrs: Remove unused error constructor and getter

2025-04-10 Thread arthur . cohen
From: Pierre-Emmanuel Patry These constructor for eroneous state are not in use anymore since we replaced this error state with an optional in the parent nodes. gcc/rust/ChangeLog: * ast/rust-expr.h: Remove error getter and constructor. Signed-off-by: Pierre-Emmanuel Patry --- gcc/ru

[COMMITTED 24/32] gccrs: Fix unresolved label error message

2025-04-10 Thread arthur . cohen
From: Pierre-Emmanuel Patry gcc/rust/ChangeLog: * resolve/rust-ast-resolve-expr.cc (ResolveExpr::visit): Change error message to match rustc. gcc/testsuite/ChangeLog: * rust/compile/undeclared_label.rs: Change test expected string. Signed-off-by: Pierre-Emmanue

[COMMITTED 10/32] gccrs: feature: Add min_specialization feature

2025-04-10 Thread arthur . cohen
From: Arthur Cohen gcc/rust/ChangeLog: * checks/errors/rust-feature.cc (Feature::create): Handle `#![feature(min_specialization)]`. * checks/errors/rust-feature.h: Likewise. --- gcc/rust/checks/errors/rust-feature.cc | 4 gcc/rust/checks/errors/rust-feature.h | 1 + 2

[COMMITTED 26/32] gccrs: Adapt testcase to name resolution 2.0

2025-04-08 Thread arthur . cohen
From: Pierre-Emmanuel Patry Name resolution 2.0 behavior matches more closely rustc's behavior and trying to prevent undeclared label error emission would break some other test. gcc/testsuite/ChangeLog: * rust/compile/invalid_label_name.rs: Adapt test to nr2. Signed-off-by: Pierre-Emma

[COMMITTED 28/32] gccrs: Rename label getter in ContinueExpr

2025-04-08 Thread arthur . cohen
From: Pierre-Emmanuel Patry gcc/rust/ChangeLog: * ast/rust-ast-collector.cc (TokenCollector::visit): Call unchecked getter. * ast/rust-ast-visitor.cc (DefaultASTVisitor::visit): Likewise. * ast/rust-ast.cc (ContinueExpr::as_string): Likewise. * hir

[COMMITTED 31/32] gccrs: nr2.0: Adjust test issue-2812.rs

2025-04-08 Thread arthur . cohen
From: Owen Avery gcc/testsuite/ChangeLog: * rust/compile/issue-2812.rs: Avoid multiple definition error. * rust/compile/nr2/exclude: Remove issue-2812.rs. Signed-off-by: Owen Avery --- gcc/testsuite/rust/compile/issue-2812.rs | 4 ++-- gcc/testsuite/rust/compile/nr2/exclude

[COMMITTED 27/32] gccrs: Change optional to expected for parse_loop_label

2025-04-08 Thread arthur . cohen
From: Pierre-Emmanuel Patry gcc/rust/ChangeLog: * parse/rust-parse-impl.h (Parser::parse_loop_label): Change function return type to expected. (Parser::parse_labelled_loop_expr): Adapt call location to new return type. * parse/rust-parse.h (enum class): Up

[COMMITTED 23/32] gccrs: Migrate error state to optionals

2025-04-08 Thread arthur . cohen
From: Pierre-Emmanuel Patry gcc/rust/ChangeLog: * ast/rust-ast-builder.cc (Builder::self_ref_param): Remove error state and use optional. * ast/rust-ast-visitor.cc (DefaultASTVisitor::visit): Check label before visiting. * ast/rust-ast.cc (ContinueExpr::as

[COMMITTED 32/32] gccrs: nr2.0: Adjust test macro6.rs

2025-04-08 Thread arthur . cohen
From: Owen Avery gcc/testsuite/ChangeLog: * rust/compile/macros/mbe/macro6.rs: Remove call of undefined function. * rust/compile/nr2/exclude: Remove macros/mbe/macro6.rs. Signed-off-by: Owen Avery --- gcc/testsuite/rust/compile/macros/mbe/macro6.rs | 2 +- gcc/testsuit

[COMMITTED 22/32] gccrs: Update ast visitor with proper check for looplabel

2025-04-08 Thread arthur . cohen
From: Pierre-Emmanuel Patry The visitor was visiting loop label even when they did not exist. gcc/rust/ChangeLog: * ast/rust-ast-visitor.cc (DefaultASTVisitor::visit): Add check for loop label before visiting it. Signed-off-by: Pierre-Emmanuel Patry --- gcc/rust/ast/rust-ast-

[COMMITTED 30/32] gccrs: fix ICE segfault with empty feature gate

2025-04-08 Thread arthur . cohen
From: Matty Kuhn This patch fixes an issue where an empty feature gate would segfault, instead of reporting a syntax error to the user. gcc/rust/ChangeLog: * ast/rust-ast.h: (AST::Attribute): add empty_input function * checks/errors/rust-feature-gate.cc: (FeatureGate::visit): ch

[COMMITTED 25/32] gccrs: Resolve labels within break or continue expressions

2025-04-08 Thread arthur . cohen
From: Pierre-Emmanuel Patry gcc/rust/ChangeLog: * resolve/rust-late-name-resolver-2.0.cc (Late::visit): Add call to label resolution if there is one label. (Late::resolve_label): Look for labels and emit an error message on failure. * resolve/rust-late-nam

[COMMITTED 13/32] gccrs: nr2.0: Remove duplicate self visit

2025-04-08 Thread arthur . cohen
From: Owen Avery gcc/rust/ChangeLog: * ast/rust-ast-visitor.cc (DefaultASTVisitor::visit): Remove explicit visitation of a function's self parameter, as if it exists it'll be visited as one of the function parameters. gcc/testsuite/ChangeLog: * rust/comp

[COMMITTED 29/32] gccrs: Rename label getter to unchecked

2025-04-08 Thread arthur . cohen
From: Pierre-Emmanuel Patry gcc/rust/ChangeLog: * ast/rust-ast-collector.cc (TokenCollector::visit): Update label getter call. * ast/rust-ast-visitor.cc (DefaultASTVisitor::visit): Likewise. * ast/rust-ast.cc (BreakExpr::as_string): Likewise. * hir/rust-as

[COMMITTED 12/32] gccrs: Fix ICE for reserved lifetime name

2025-04-08 Thread arthur . cohen
From: Philip Herron This is a reserved name so this changes the assertion to a diagnostic. Fixes Rust-GCC#3647 gcc/rust/ChangeLog: * typecheck/rust-typecheck-context.cc (TypeCheckContext::lookup_lifetime): emit error gcc/testsuite/ChangeLog: * rust/compile/issue-3647.rs: New

[COMMITTED 18/32] gccrs: Add check for label

2025-04-08 Thread arthur . cohen
From: Pierre-Emmanuel Patry gcc/rust/ChangeLog: * ast/rust-ast-visitor.cc (DefaultASTVisitor::visit): Visit loop label only if it exists. gcc/testsuite/ChangeLog: * rust/compile/nr2/exclude: Remove passing test. Signed-off-by: Pierre-Emmanuel Patry --- gcc/rust/ast/r

[COMMITTED 20/32] gccrs: Make loop label truly optional

2025-04-08 Thread arthur . cohen
From: Pierre-Emmanuel Patry A loop label error state was in use to represent missing loop label but this may be easily forgotten and the optional nature of the label was misrepresented. gcc/rust/ChangeLog: * ast/rust-ast-builder.cc (Builder::block): Call with a nullopt instead o

[COMMITTED 14/32] gccrs: nr2.0: Improve test script

2025-04-08 Thread arthur . cohen
From: Owen Avery gcc/testsuite/ChangeLog: * rust/compile/nr2/compile.exp: Avoid absolute paths in output, adjust phrasing of output, and avoid false XPASS output when tests are run in parallel. Signed-off-by: Owen Avery --- gcc/testsuite/rust/compile/nr2/compile.exp |

[COMMITTED 19/32] gccrs: Visit loop label before predicate expression

2025-04-08 Thread arthur . cohen
From: Pierre-Emmanuel Patry If the label is referenced within the while predicate expression it has to be resolved before the latter. gcc/rust/ChangeLog: * ast/rust-ast-visitor.cc (DefaultASTVisitor::visit): Change default visit order. gcc/testsuite/ChangeLog: * rust/c

[COMMITTED 05/32] gccrs: Fix ICE when there are 2 functions named main

2025-04-08 Thread arthur . cohen
From: Philip Herron We need to setup the main_identifier_node for MAIN_DECL_P checks in the middle-end. But it is valid to have a main function/method on impl blocks. So we need to flag if this is a "root" item or not, which is one that is jsut an HIR::Function on part of the Crate::items as oppp

[COMMITTED 11/32] gccrs: hir: Add default qualifier to function, lower it properly

2025-04-08 Thread arthur . cohen
From: Arthur Cohen gcc/rust/ChangeLog: * ast/rust-ast.cc (Function::Function): Rename is_default -> has_default. (Function::operator=): Likewise. * ast/rust-item.h (class Function): Add `is_default` method. * hir/rust-ast-lower-implitem.cc (ASTLowerImplI

[COMMITTED 09/32] gccrs: Fix ICE when hitting invalid types for generics

2025-04-08 Thread arthur . cohen
From: Philip Herron We need to check upfront if the type is valid or not. Then error with a decent message. Fixes Rust-GCC#3643 Fixes Rust-GCC#3646 Fixes Rust-GCC#3654 Fixes Rust-GCC#3663 Fixes Rust-GCC#3671 gcc/rust/ChangeLog: * resolve/rust-ast-resolve-type.cc (ResolveRelativeTypePat

[COMMITTED 16/32] gccrs: Revert part of 44ffe1193269

2025-04-08 Thread arthur . cohen
From: Pierre-Emmanuel Patry This commit got rid of msvc specific code and remove the else clause, this triggered warning with tl::expected::value function. gcc/rust/ChangeLog: * util/expected.h: Use gcc_unreachable within gcc context. Signed-off-by: Pierre-Emmanuel Patry --- gcc/rust

[COMMITTED 08/32] gccrs: Fix ICE on raw reference

2025-04-08 Thread arthur . cohen
From: Philip Herron This patch adds support for raw references which enforce the pointer type away from a reference type. Fixes Rust-GCC#3667 gcc/rust/ChangeLog: * backend/rust-compile-base.cc (HIRCompileBase::address_expression): allow optional type * backend/rust-compile-bas

[COMMITTED 17/32] gccrs: Resolve labels

2025-04-08 Thread arthur . cohen
From: Pierre-Emmanuel Patry gcc/rust/ChangeLog: * hir/rust-ast-lower.cc (ASTLoweringBlock::visit): Lower label only if it exists. * hir/tree/rust-hir-expr.cc (BlockExpr::BlockExpr): Make loop label optional. (BaseLoopExpr::BaseLoopExpr): Likewise.

[COMMITTED 15/32] gccrs: refactoring rust_error_at "redefined multiple times"

2025-04-08 Thread arthur . cohen
From: Sri Ganesh Thota gcc/rust/ChangeLog: * resolve/rust-ast-resolve-base.h (redefined_error): created a function for rust_error_at for redefined at multiple times. * resolve/rust-ast-resolve-implitem.h: changed rust_error_at to redefined_error. * resolve/rust-

[COMMITTED 01/32] gccrs: Evaluate the enum's discriminant in a const context

2025-04-08 Thread arthur . cohen
From: Ryutaro Okada <1015ry...@gmail.com> gcc/rust/ChangeLog: * backend/rust-compile-resolve-path.cc: Evaluate the enum's discriminant in a const context gcc/testsuite/ChangeLog: * rust/compile/enum_discriminant1.rs: New test. Signed-off-by: Ryutaro Okada <1015ry...@gmail.com>

[COMMITTED 06/32] gccrs: Fix recusive type query and nullptr on type path

2025-04-08 Thread arthur . cohen
From: Philip Herron This was a small fix to sort out the segfault to check for nullptr on the TypePath cases for query type. But when this happened opened up a few bugs that were hidden under the carpet namely: compile/issue-2905-{1,2}.rs which has a recursive type query which needs to ne handled

[COMMITTED 02/32] gccrs: nr2.0: Handle global paths

2025-04-08 Thread arthur . cohen
From: Owen Avery gcc/rust/ChangeLog: * resolve/rust-forever-stack.h (ForeverStack::ForeverStack): Initialize extern_prelude. (ForeverStack::resolve_path): Add parameter has_opening_scope_resolution. (ForeverStack::extern_prelude): Add field. * reso

[COMMITTED 03/32] gccrs: Fix ICE when doing shift checks on const decl

2025-04-08 Thread arthur . cohen
From: Philip Herron Const decls are just delcarations wrapping the value into the DECL_INITIAL and the shift checks we have assume no decls are involved and its just flat values. This patch simply unwraps the constant values if they exist. Fixes Rust-GCC#3665 gcc/rust/ChangeLog: * rust

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

2025-04-05 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 106/141] gccrs: expansion: Expand generic args in generic type path segments

2025-04-05 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 010/146] rust: Desugar IfLet* into MatchExpr

2025-04-05 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 046/141] gccrs: ast-builder: Add new methods for functions, traits and tuples.

2025-04-05 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 104/144] gccrs: Mark virtual function override in default resolver

2025-04-05 Thread arthur . cohen
From: Pierre-Emmanuel Patry Those function prototype were not marked as override and throwing warning. gcc/rust/ChangeLog: * resolve/rust-default-resolver.h: Make most visit function override. Signed-off-by: Pierre-Emmanuel Patry --- gcc/rust/resolve/rust-default-resolver.h | 178 +++

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

2025-04-05 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 055/146] gccrs: lang-items: Move comment about arithmetic lang items

2025-04-05 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 107/146] gccrs: match arms are a LUB

2025-04-05 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 013/146] gccrs: add test case to show method resolution is working

2025-04-05 Thread arthur . cohen
From: Philip Herron The issue here was that the impl block for Cell defines that T must have the bound of Copy implemented. But simultaneously if you do an deref you get direct access to the unsafe cell which also defines a get method so these are two valid ways of accessing the method in questio

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

2025-04-05 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 132/144] gccrs: Allow identifiers and paths to reference types during nr2.0

2025-04-05 Thread arthur . cohen
From: Owen Avery gcc/rust/ChangeLog: * resolve/rust-late-name-resolver-2.0.cc (Late::visit): Allow IdentifierExpr and PathInExpression to reference types as well as values, remove ability for IdentifierExpr to reference labels. gcc/testsuite/ChangeLog: *

[COMMITTED 067/146] gccrs: attributes: Add class for sharing methods on attributes.

2025-04-05 Thread arthur . cohen
From: Arthur Cohen gcc/rust/ChangeLog: * util/rust-attributes.h (class Attributes): New. * util/rust-attributes.cc: Implement Attributes::is_known(). * ast/rust-collect-lang-items.cc (is_known_attribute): Remove. (get_lang_item_attr): Call Attributes::is_known

[COMMITTED 113/146] gccrs: gcc/rust/ChangeLog:

2025-04-05 Thread arthur . cohen
From: Om Swaroop Nayak <96killera...@gmail.com> * ast/rust-collect-lang-items.cc (get_lang_item_attr): "removed checker fn" * util/rust-attributes.cc (Attributes::is_lang_item): "added fn" * util/rust-attributes.h: "added fn" Signed-off-by: Om Swaroop Nayak <96killera...@

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

2025-04-05 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 081/146] gccrs: typecheck-path: Fix typo (reciever -> receiver)

2025-04-05 Thread arthur . cohen
From: Arthur Cohen gcc/rust/ChangeLog: * typecheck/rust-hir-path-probe.cc: Fix typos. * typecheck/rust-hir-path-probe.h: Likewise. * typecheck/rust-hir-type-check-path.cc: Likewise. --- gcc/rust/typecheck/rust-hir-path-probe.cc | 4 ++-- gcc/rust/typecheck/rust

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

2025-04-05 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 045/146] gccrs: Use nr2.0 in typechecker

2025-04-05 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 022/146] gccrs: fix ICE for placeholder which is not setup

2025-04-05 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 102/146] gccrs: add support for lang_item eq and PartialEq trait

2025-04-05 Thread arthur . cohen
From: Philip Herron The Eq and Partial Ord are very similar to the operator overloads we support for add/sub/etc... but they differ in that usually the function call name matches the name of the lang item. This time we need to have support to send in a new path for the method call on the lang ite

[COMMITTED 24/35] gccrs: Add new test to highlight namespace for self import

2025-04-05 Thread arthur . cohen
From: Pierre-Emmanuel Patry gcc/testsuite/ChangeLog: * rust/compile/self_import_namespace.rs: New test. Signed-off-by: Pierre-Emmanuel Patry --- .../rust/compile/self_import_namespace.rs | 14 ++ 1 file changed, 14 insertions(+) create mode 100644 gcc/testsuite/r

[COMMITTED 121/144] rust: Add support for Clone and Copy derive on generic types

2025-04-05 Thread arthur . cohen
From: Philip Herron When we generate derivations for Copy and Clone we need to make sure the associated impl block sets up the generic parameters and arguments correctly. This patch introduces the framework to copy chunks of the AST because we need to make sure these new AST nodes have their own

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

2025-04-05 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 007/146] gccrs: Use name resolver 2.0 in CompileTraitItem

2025-04-05 Thread arthur . cohen
From: Owen Avery gcc/rust/ChangeLog: * backend/rust-compile-implitem.cc (CompileTraitItem::visit): Use name resolver 2.0 (when enabled) to obtain canonical paths for instances of TraitItemConst and TraitItemFunc. Signed-off-by: Owen Avery --- gcc/rust/backend/r

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

2025-04-05 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 053/146] gccrs: allow casts from numeric types to floats

2025-04-05 Thread arthur . cohen
From: Philip Herron Fixes Rust-GCC#3261 gcc/rust/ChangeLog: * typecheck/rust-casts.cc (TypeCastRules::cast_rules): allow casts to float gcc/testsuite/ChangeLog: * rust/compile/issue-3261.rs: New test. Signed-off-by: Philip Herron --- gcc/rust/typecheck/rust-casts.cc

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

2025-04-05 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 086/146] gccrs: lang-item: Add Option::{None, Some}, Iterator::next, IntoIter::into_iter

2025-04-05 Thread arthur . cohen
From: Arthur Cohen gcc/rust/ChangeLog: * util/rust-lang-item.h: Add new lang items. * util/rust-lang-item.cc: Likewise. --- gcc/rust/util/rust-lang-item.cc | 6 ++ gcc/rust/util/rust-lang-item.h | 9 + 2 files changed, 15 insertions(+) diff --git a/gcc/rust/util

[COMMITTED 112/146] gccrs: improve mutability checks

2025-04-05 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 048/144] gccrs: Added new test for prep of output {}

2025-04-05 Thread arthur . cohen
From: badumbatish gcc/testsuite/ChangeLog: * rust/compile/inline_asm_parse_output_operand.rs: New test. --- .../compile/inline_asm_parse_output_operand.rs | 18 ++ 1 file changed, 18 insertions(+) create mode 100644 gcc/testsuite/rust/compile/inline_asm_parse_output_op

[COMMITTED 130/141] gccrs: Fix canonical path parent resolution

2025-04-05 Thread arthur . cohen
From: Pierre-Emmanuel Patry The algorithm was comparing using the wrong id, this lead to some mangling errors as an erroneous parent was selected. gcc/rust/ChangeLog: * resolve/rust-forever-stack.hxx: Fix the id comparison. Signed-off-by: Pierre-Emmanuel Patry --- gcc/rust/resolve/ru

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

2025-04-05 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 004/146] gccrs: Add a newline to the end of nr2/exclude

2025-04-05 Thread arthur . cohen
From: Owen Avery gcc/testsuite/ChangeLog: * rust/compile/nr2/exclude: Add trailing newline along with comment. Signed-off-by: Owen Avery --- gcc/testsuite/rust/compile/nr2/exclude | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/gcc/testsuite/rust/compile/

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

2025-04-05 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

[COMMITTED 085/146] gccrs: lang-item: Add Sync trait

2025-04-05 Thread arthur . cohen
From: Arthur Cohen gcc/rust/ChangeLog: * util/rust-lang-item.h: Add Sync marker trait. * util/rust-lang-item.cc: Likewise. --- gcc/rust/util/rust-lang-item.cc | 1 + gcc/rust/util/rust-lang-item.h | 1 + 2 files changed, 2 insertions(+) diff --git a/gcc/rust/util/rust-lang

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

2025-04-05 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 044/146] gccrs: Handle type path segments during late resolution 2.0

2025-04-05 Thread arthur . cohen
From: Owen Avery gcc/rust/ChangeLog: * resolve/rust-late-name-resolver-2.0.cc (Late::visit): Call DefaultResolver::visit when visiting TypePath. gcc/testsuite/ChangeLog: * rust/compile/nr2/exclude: Remove entries. Signed-off-by: Owen Avery --- gcc/rust/resolv

[COMMITTED 125/144] gccrs: Fix ICE when typechecking non-trait item when we expect one

2025-04-05 Thread arthur . cohen
From: Philip Herron We just had an assertion here for this case where we expect a trait. This changes the assertion into error handling producing the correct error code with fixit suggestion like rustc. Fixes #2499 gcc/rust/ChangeLog: * typecheck/rust-hir-trait-resolve.cc (TraitResolv

[COMMITTED 040/146] gccrs: Add optional template arguments to please GCC4.8

2025-04-05 Thread arthur . cohen
From: Pierre-Emmanuel Patry Clang on macos as well as GCC 4.8 complains when those templates are missing. gcc/rust/ChangeLog: * hir/rust-ast-lower-expr.cc (ASTLoweringExpr::visit): Add template to tl::optional. * hir/rust-ast-lower-type.cc (ASTLowerGenericParam::visit):

[COMMITTED 27/35] gccrs: nr2.0: Fix test macros/mbe/macro43.rs

2025-04-05 Thread arthur . cohen
From: Owen Avery gcc/testsuite/ChangeLog: * rust/compile/macros/mbe/macro43.rs: Adjust test to pass with name resolution 2.0. * rust/compile/nr2/exclude: Remove macros/mbe/macro43.rs. Signed-off-by: Owen Avery --- gcc/testsuite/rust/compile/macros/mbe/macro43.rs | 15 +

[COMMITTED 075/141] gccrs: fix unconstrained generics check to handle recursive generics

2025-04-05 Thread arthur . cohen
From: Philip Herron Generics can be constrained within other generic types so this check needs to be recursive. Fixes Rust-GCC#3031 gcc/rust/ChangeLog: * typecheck/rust-hir-type-check-base.cc (walk_types_to_constrain): recursive walker * typecheck/rust-tyty.cc (BaseType::get_s

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

2025-04-05 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 060/146] gccrs: Remove bad assertion in name resolution

2025-04-05 Thread arthur . cohen
From: Philip Herron This was a handy debug assertion but only works for valid rust code. This needs to handle the case where the type is not resolved which is a valid case. Fixes Rust-GCC#2423 gcc/rust/ChangeLog: * resolve/rust-ast-resolve-item.cc (ResolveItem::visit): remove assertio

[COMMITTED 041/146] gccrs: Use default constructor for default arguments

2025-04-05 Thread arthur . cohen
From: Pierre-Emmanuel Patry GCC 4.8 complains about the initializer list. gcc/rust/ChangeLog: * typecheck/rust-tyty.h: Change initializer list to default constructor call. Signed-off-by: Pierre-Emmanuel Patry --- gcc/rust/typecheck/rust-tyty.h | 6 +++--- 1 file changed, 3 in

[COMMITTED 111/144] gccrs: Move bir builder function implementation

2025-04-05 Thread arthur . cohen
From: Pierre-Emmanuel Patry Move function implementation to their own file. gcc/rust/ChangeLog: * Make-lang.in: Add new rust-bir-builder-pattern file. * checks/errors/borrowck/rust-bir-builder-pattern.h: Remove implementation. * checks/errors/borrowck/rust-bir-bu

[COMMITTED 08/35] gccrs: lower: Handle let-else properly

2025-04-05 Thread arthur . cohen
From: Arthur Cohen gcc/rust/ChangeLog: * hir/tree/rust-hir-stmt.h (class LetStmt): Add optional diverging else expression. * hir/tree/rust-hir-stmt.cc: Likewise. * hir/rust-ast-lower-stmt.cc (ASTLoweringStmt::visit): Add handling for lowering diverging else

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

2025-04-05 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 25/35] gccrs: Fix ICE when compiling path which resolves to trait constant

2025-04-05 Thread arthur . cohen
From: Philip Herron Fixes Rust-GCC#3552 gcc/rust/ChangeLog: * backend/rust-compile-resolve-path.cc (HIRCompileBase::query_compile): check for Expr trait * hir/rust-hir-dump.cc (Dump::visit): expr is optional gcc/testsuite/ChangeLog: * rust/compile/issue-3552.rs: New t

[COMMITTED 119/144] gccrs: Postpone break on error after name resolution

2025-04-05 Thread arthur . cohen
From: Pierre-Emmanuel Patry We need the top level to run at least once before breaking because it will be required by the other name resolution steps. gcc/rust/ChangeLog: * rust-session-manager.cc (Session::expansion): Break on error after top level name resolution. Signed-off-

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

2025-04-05 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

  1   2   3   4   5   6   7   8   9   10   >