[COMMITTED 098/101] gccrs: Test: check implemented for lifetime handling

2024-01-30 Thread arthur . cohen
From: Jakub Dupak gcc/testsuite/ChangeLog: * rust/compile/for_lifetimes.rs: New test. Signed-off-by: Jakub Dupak --- gcc/testsuite/rust/compile/for_lifetimes.rs | 19 +++ 1 file changed, 19 insertions(+) create mode 100644 gcc/testsuite/rust/compile/for_lifetimes.rs

[COMMITTED 095/101] gccrs: Test: fix missing lifetime in a test

2024-01-30 Thread arthur . cohen
From: Jakub Dupak This test did not compile with rustc. gcc/testsuite/ChangeLog: * rust/compile/torture/utf8_identifiers.rs: add mising lifetime Signed-off-by: Jakub Dupak --- gcc/testsuite/rust/compile/torture/utf8_identifiers.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)

[COMMITTED 090/101] gccrs: Fix inconsistent formatting

2024-01-30 Thread arthur . cohen
From: Kushal Pal gcc/rust/ChangeLog: * checks/errors/rust-ast-validation.cc (ASTValidation::visit): Enclose const in single quotes. gcc/testsuite/ChangeLog: * rust/compile/const_trait_fn.rs: Enclose const in single quotes. Signed-off-by: Kushal Pal --- gcc/ru

[COMMITTED 088/101] gccrs: Handle newlines during string parsing while lexing

2024-01-30 Thread arthur . cohen
From: Nirmal Patel If newline strings are encountered while lexing, the lexer now handles newline characters by incrementing current line number. This provides correct line number when displaying errors. If the lexer encounters end of file before string end, then it will use the start of the stri

[COMMITTED 080/101] gccrs: Handle `async` qualifier inside trait

2024-01-30 Thread arthur . cohen
From: Kushal Pal Fixes #2778 gcc/rust/ChangeLog: * parse/rust-parse-impl.h (Parser::parse_trait_impl_item): Handled `async` items Signed-off-by: Kushal Pal --- gcc/rust/parse/rust-parse-impl.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/gcc/rust/parse/rust-parse-imp

[COMMITTED 077/101] gccrs: TyTy: SubstitutionRef cast specialization

2024-01-30 Thread arthur . cohen
From: Jakub Dupak Allows skipping parent check when casting. gcc/rust/ChangeLog: * typecheck/rust-tyty.h (BaseType::is): Cast API. (SubstitutionRef>): Cast API. (BaseType::as): Cast API. (BaseType::try_as): Cast API. Signed-off-by: Jakub Dupak --- gcc/rust/typ

[COMMITTED 070/101] gccrs: Change cfg stripper to use default visitor

2024-01-30 Thread arthur . cohen
From: Pierre-Emmanuel Patry Cfg visitor used it's own visit patterns, this made the code longer than required. gcc/rust/ChangeLog: * expand/rust-cfg-strip.cc (CfgStrip::visit): Change calls from visitor to default visitor. (CfgStrip::go): Add call to visit crate.

[COMMITTED 067/101] gccrs: Allow enabling lang_items and no_core features

2024-01-30 Thread arthur . cohen
From: Owen Avery gcc/rust/ChangeLog: * checks/errors/rust-feature.cc (Feature::name_hash_map): Add entries for Name::LANG_ITEMS and Name::NO_CORE. * checks/errors/rust-feature.h (Feature::Name::LANG_ITEMS): New. (Feature::Name::NO_CORE): New. gcc/

[COMMITTED 066/101] gccrs: Renamed `WIN64` to `WIN_64`

2024-01-30 Thread arthur . cohen
From: Kushal Pal Fixes issue #2768 gcc/rust/ChangeLog: * backend/rust-compile-base.cc (HIRCompileBase::setup_abi_options): Renamed `WIN64` to `WIN_64` * util/rust-abi.cc (get_abi_from_string): Likewise (get_string_from_abi): Likewise * util/rust-abi.h (en

[COMMITTED 065/101] gccrs: Generate error for const trait functions

2024-01-30 Thread arthur . cohen
From: Nobel Singh Fixes issue #2040 Add check to assure that a function cant be declared const inside trait impl blocks. gcc/rust/ChangeLog: * checks/errors/rust-ast-validation.cc (ASTValidation::visit): Add check for const funtion. gcc/testsuite/ChangeLog: * rust/com

[COMMITTED 064/101] gccrs: Add a regression test for function body check

2024-01-30 Thread arthur . cohen
From: Pierre-Emmanuel Patry Function body check emit an error message when a required function body is missing. gcc/testsuite/ChangeLog: * rust/compile/functions_without_body.rs: New test. Signed-off-by: Pierre-Emmanuel Patry --- .../rust/compile/functions_without_body.rs| 21 +++

[COMMITTED 099/101] gccrs: Add improved error when no fields in initializer

2024-01-30 Thread arthur . cohen
From: Robert Goss If a struct type with a variant that has fields is initialized with some fields the expression HIR StructExprStructFields is checked that all the fields are assigned. However, if no fields are initialized the HIR StructExprStruct is generated. This doesn't check if the struc

[COMMITTED 100/101] gccrs: Remove TraitImplItem

2024-01-30 Thread arthur . cohen
From: Owen Avery gcc/rust/ChangeLog: * ast/rust-ast-full-decls.h (class TraitImplItem): Remove forward declaration. (class AssociatedItem): Add forward declaration. * ast/rust-ast.h (class TraitImplItem): Remove. (class TraitItem): Inherit from Ass

[COMMITTED 096/101] gccrs: AST: Fix for lifetime parsing

2024-01-30 Thread arthur . cohen
From: Jakub Dupak gcc/rust/ChangeLog: * parse/rust-parse-impl.h (Parser::parse_where_clause): fix parsing (Parser::parse_where_clause_item): fix parsing (Parser::parse_type_bound_where_clause_item): fix parsing (Parser::parse_trait_bound): fix parsing * pa

[COMMITTED 092/101] gccrs: Add improved error when a field is redefined in a struct constructor

2024-01-30 Thread arthur . cohen
From: Robert Goss Fixes #2381 If a struct type is initialized with one of it's fields repeated it will currently issue an error at the use site. However we would like to give the rust error code and (like rustc) show both the specifications for the field to help the user diagnose the issue.

[COMMITTED 087/101] gccrs: TyTy: Refactor FnType deprecated API

2024-01-30 Thread arthur . cohen
From: Jakub Dupak gcc/rust/ChangeLog: * backend/rust-compile-expr.cc (CompileExpr::visit): Use new API. * typecheck/rust-tyty-call.cc (TypeCheckCallExpr::visit): Use new API. * typecheck/rust-tyty-cmp.h: Remove old API. * typecheck/rust-tyty.cc (FnPtr::is_equal):

[COMMITTED 084/101] gccrs: ast: Full lifetime elision handling

2024-01-30 Thread arthur . cohen
From: Jakub Dupak gcc/rust/ChangeLog: * parse/rust-parse-impl.h (Parser::parse_generic_param): Lifetime elision control. (Parser::parse_lifetime_where_clause_item): Lifetime elision control. (Parser::parse_type_param_bound): Lifetime elision control. (Parser::par

[COMMITTED 068/101] gccrs: Make default resolver inherit from default visitor

2024-01-30 Thread arthur . cohen
From: Pierre-Emmanuel Patry The default resolver put some scope in place but mostly has traversal functions similar to the default ast visitor, making it inherit from the default visitor allows us to avoid code duplication. gcc/rust/ChangeLog: * resolve/rust-default-resolver.cc (Default

[COMMITTED 062/101] gccrs: Make function bodies truly optional

2024-01-30 Thread arthur . cohen
From: Pierre-Emmanuel Patry Missing body on a function should be rejected at a later stage in the compiler, not during parsing. gcc/rust/ChangeLog: * ast/rust-ast-collector.cc (TokenCollector::visit): Adapt defintion getter. * ast/rust-ast-visitor.cc (DefaultASTVisitor::

[COMMITTED 057/101] gccrs: Make feature gate visitor inherit from default one

2024-01-30 Thread arthur . cohen
From: Pierre-Emmanuel Patry The feature gating behavior may be shortened and kept cleaner using the default visitor. This means less maintenance on visit functions as the traversal is shared by multiple visitors. gcc/rust/ChangeLog: * checks/errors/rust-feature-gate.cc (FeatureGate::vis

[COMMITTED 063/101] gccrs: Add validation for functions without body

2024-01-30 Thread arthur . cohen
From: Pierre-Emmanuel Patry Add checks in the ast validation pass to error out with functions (either free or associated) without a definition. gcc/rust/ChangeLog: * checks/errors/rust-ast-validation.cc (ASTValidation::visit): Add a validation check and emit an error depending o

[COMMITTED 060/101] gccrs: Add multiple regression test in name resolution

2024-01-30 Thread arthur . cohen
From: Pierre-Emmanuel Patry Local variables and functions or global variables have different resolution when binded to a variable. This was not covered before, even though it was handled by the new name resolution. This commit highlight this behavior from the new name resolution mechanism. gcc/t

[COMMITTED 058/101] gccrs: Change the attribute checker visitor to default one

2024-01-30 Thread arthur . cohen
From: Pierre-Emmanuel Patry Make the attribute checker visitor inherit from the default visitor in order to keep visit behavior shared. gcc/rust/ChangeLog: * util/rust-attributes.cc (AttributeChecker::visit): Add visit function for crates. * util/rust-attributes.h (class

[COMMITTED 091/101] gccrs: Handle `async` keyword for regular implementations

2024-01-30 Thread arthur . cohen
From: Kushal Pal Fixes #2788 gcc/rust/ChangeLog: * parse/rust-parse-impl.h (Parser::parse_inherent_impl_item): Added switch-case for ASYNC token. gcc/testsuite/ChangeLog: * rust/compile/issue-2788.rs: New test. Signed-off-by: Kushal Pal --- gcc/rust/parse/rust-parse

[COMMITTED 093/101] gccrs: Unify storage of associated items in SingleASTNode

2024-01-30 Thread arthur . cohen
From: Owen Avery gcc/rust/ChangeLog: * ast/rust-ast-fragment.cc (Fragment::assert_single_fragment): Update. * ast/rust-ast.h (class TraitImplItem): Move definition before that of TraitItem. (class TraitItem): Inherit from TraitImplItem instead of

[COMMITTED 083/101] gccrs: ast: Unify explicitly and implicitly elided lifettimes

2024-01-30 Thread arthur . cohen
From: Jakub Dupak gcc/rust/ChangeLog: * ast/rust-ast.h: Elided lifetime static constructor * ast/rust-type.h: Default lifetime to elided. * parse/rust-parse-impl.h (Parser::parse_lifetime_param): Use elided lifetime. (Parser::parse_lifetime): Use elided lifetime/

[COMMITTED 079/101] gccrs: split rust-mangle.cc into two files

2024-01-30 Thread arthur . cohen
From: Raiki Tamura gcc/rust/ChangeLog: * Make-lang.in: Add .o files * backend/rust-mangle.cc (struct V0Path): moved to splitted files (v0_path): Likewise. (legacy_mangle_name): Likewise. (legacy_mangle_canonical_path): Likewise. (legacy_hash): Like

[COMMITTED 054/101] gccrs: Add a regression test for async const functions

2024-01-30 Thread arthur . cohen
From: Pierre-Emmanuel Patry Functions that are both async and const shall be rejected during the AST validation pass. This new test highlight this behavior. gcc/testsuite/ChangeLog: * rust/compile/const_async_function.rs: New test. Signed-off-by: Pierre-Emmanuel Patry --- gcc/testsui

[COMMITTED 055/101] gccrs: Add AST validation check for const in trait

2024-01-30 Thread arthur . cohen
From: Pierre-Emmanuel Patry Add a new check in AST validation pass that checks that no function declaration in traits are declared const. gcc/rust/ChangeLog: * checks/errors/rust-ast-validation.cc (ASTValidation::visit): Add const check. * checks/errors/rust-ast-validati

[COMMITTED 050/101] gccrs: Remove class AST::InherentImplItem

2024-01-30 Thread arthur . cohen
From: Owen Avery gcc/rust/ChangeLog: * ast/rust-ast-full-decls.h (class InherentImplItem): Remove. * ast/rust-ast.h (class InherentImplItem): Remove. (class SingleASTNode): Store pointer to AssociatedItem instead of InherentImplItem. * ast

[COMMITTED 049/101] gccrs: Remove backend dependancy on resolution rib information

2024-01-30 Thread arthur . cohen
From: Philip Herron When making more desugaring for the HIR we can need to add new Let bindings which will require namesolution information but also rib information for which block the let binding is associated which was very unnessecary. This patch simply updates the BLOCK_CONTEXT of the current

[COMMITTED 053/101] gccrs: Add async const function ast validation pass

2024-01-30 Thread arthur . cohen
From: Pierre-Emmanuel Patry Add a check during AST validation pass to ensure functions are either const or async but not both. gcc/rust/ChangeLog: * checks/errors/rust-ast-validation.cc (ASTValidation::visit): Add async const check. Signed-off-by: Pierre-Emmanuel Patry --- gc

[COMMITTED 040/101] gccrs: toplevel: Add comment about running the collector twice

2024-01-30 Thread arthur . cohen
From: Arthur Cohen gcc/rust/ChangeLog: * resolve/rust-toplevel-name-resolver-2.0.cc (TopLevel::insert_or_error_out): Add documentation comment. (TopLevel::go): Likewise. --- gcc/rust/resolve/rust-toplevel-name-resolver-2.0.cc | 8 1 file changed, 8 insertions(+)

[COMMITTED 051/101] gccrs: Split async and const function qualifiers

2024-01-30 Thread arthur . cohen
From: Pierre-Emmanuel Patry A function cannot be both async and const, however this should not be handled in the parser but rather at a later stage in the compiler. This commit change the AsyncConstStatus in the AST and the HIR to allows a function to be both async and const. gcc/rust/ChangeLog:

[COMMITTED 039/101] gccrs: early: Resolve paths properly

2024-01-30 Thread arthur . cohen
From: Arthur Cohen gcc/rust/ChangeLog: * resolve/rust-early-name-resolver-2.0.cc (Early::insert_once): New function. (Early::visit): Likewise. * resolve/rust-early-name-resolver-2.0.h: Likewise. --- .../resolve/rust-early-name-resolver-2.0.cc | 30 +

[COMMITTED 043/101] gccrs: toplevel: Resolve `use` declarations

2024-01-30 Thread arthur . cohen
From: Arthur Cohen gcc/rust/ChangeLog: * resolve/rust-toplevel-name-resolver-2.0.cc (TopLevel::insert_or_error_out): New functions. (TopLevel::handle_use_dec): New function. (flatten_rebind): Likewise. (flatten_list): Likewise. (flatten_glob): Like

[COMMITTED 035/101] gccrs: toplevel: Use DefaultResolver for Function

2024-01-30 Thread arthur . cohen
From: Arthur Cohen gcc/rust/ChangeLog: * resolve/rust-toplevel-name-resolver-2.0.cc (TopLevel::visit): Use the DefaultResolver in the toplevel visitor. --- gcc/rust/resolve/rust-toplevel-name-resolver-2.0.cc | 5 + 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a

[COMMITTED 019/101] gccrs: Add a regression test for super trait on auto trait

2024-01-30 Thread arthur . cohen
From: Pierre-Emmanuel Patry Add a new regression test to highlight the error behavior with a super trait on an auto trait. gcc/testsuite/ChangeLog: * rust/compile/auto_trait_super_trait.rs: New test. Signed-off-by: Pierre-Emmanuel Patry --- gcc/testsuite/rust/compile/auto_trait_super

[COMMITTED 011/101] gccrs: forever stack: Improve resolve_path implementation

2024-01-30 Thread arthur . cohen
From: Arthur Cohen gcc/rust/ChangeLog: * resolve/rust-forever-stack.hxx: Do not copy segment when dereferencing iterator in `find_starting_point`. --- gcc/rust/resolve/rust-forever-stack.hxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gcc/rust/resolve/rus

[COMMITTED 097/101] gccrs: AST: Fix for lifetime lowering

2024-01-30 Thread arthur . cohen
From: Jakub Dupak gcc/rust/ChangeLog: * hir/rust-ast-lower-type.cc (ASTLoweringTypeBounds::visit): fix for lifetimes (ASTLowerWhereClauseItem::visit): fix for lifetimes Signed-off-by: Jakub Dupak --- gcc/rust/hir/rust-ast-lower-type.cc | 21 + 1 file chang

[COMMITTED 101/101] gccrs: Fix output line ending patterns.

2024-01-30 Thread arthur . cohen
From: Arthur Cohen gcc/testsuite/ChangeLog: * rust/execute/torture/builtin_macros1.rs: Fix output pattern. * rust/execute/torture/coercion3.rs: Likewise. * rust/execute/torture/issue-2080.rs: Likewise. * rust/execute/torture/issue-2179.rs: Likewise. * rust

[COMMITTED 086/101] gccrs: ast: Lower 'for' lifetimes

2024-01-30 Thread arthur . cohen
From: Jakub Dupak gcc/rust/ChangeLog: * hir/rust-ast-lower-type.cc (ASTLoweringType::visit): For lifetimes. Signed-off-by: Jakub Dupak --- gcc/rust/hir/rust-ast-lower-type.cc | 7 +++ 1 file changed, 7 insertions(+) diff --git a/gcc/rust/hir/rust-ast-lower-type.cc b/gcc/rust/hir

[COMMITTED 094/101] gccrs: Added newline to get more readable lexdump

2024-01-30 Thread arthur . cohen
From: Kushal Pal Fixes #2783 gcc/rust/ChangeLog: * lex/rust-lex.cc (Lexer::dump_and_skip): Changed " " to '\n' Signed-off-by: Kushal Pal --- gcc/rust/lex/rust-lex.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gcc/rust/lex/rust-lex.cc b/gcc/rust/lex/ru

[COMMITTED 082/101] gccrs: ast: Fix lifetime type parsing

2024-01-30 Thread arthur . cohen
From: Jakub Dupak There was a mismatch whether lifetime 'static is parsed as "static" or "'static". gcc/rust/ChangeLog: * parse/rust-parse-impl.h (Parser::lifetime_from_token): Fix matched pattern. Signed-off-by: Jakub Dupak --- gcc/rust/parse/rust-parse-impl.h | 4 ++-- 1 file chan

[COMMITTED 076/101] gccrs: TyTy: Common interface for fucntion-like types

2024-01-30 Thread arthur . cohen
From: Jakub Dupak gcc/rust/ChangeLog: * typecheck/rust-tyty.h (class ClosureType): Inherit interface. (class FnPtr): Inherit interface. (class FnType): Inherit interface. (class CallableTypeInterface): New interface. (BaseType::is): Detect interface member

[COMMITTED 089/101] gccrs: Handle `async` functions in traits

2024-01-30 Thread arthur . cohen
From: Kushal Pal Fixes #2785 gcc/rust/ChangeLog: * checks/errors/rust-ast-validation.cc (ASTValidation::visit): Added check for `async` functions inside trait. * parse/rust-parse-impl.h (Parser::parse_trait_item): Added switch-case for ASYNC token. gcc/testsuite

[COMMITTED 075/101] gccrs: TyTy: refactor to new API

2024-01-30 Thread arthur . cohen
From: Jakub Dupak gcc/rust/ChangeLog: * typecheck/rust-hir-type-check-type.cc (TypeCheckType::resolve_root_path): Refactor. Signed-off-by: Jakub Dupak --- gcc/rust/typecheck/rust-hir-type-check-type.cc | 11 +++ 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/gc

[COMMITTED 073/101] gccrs: TyTy: Fix missed nodiscard

2024-01-30 Thread arthur . cohen
From: Jakub Dupak gcc/rust/ChangeLog: * typecheck/rust-tyty.h: Fix nodiscard to warn unused. Signed-off-by: Jakub Dupak --- gcc/rust/typecheck/rust-tyty.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gcc/rust/typecheck/rust-tyty.h b/gcc/rust/typecheck/rust-tyty.

[COMMITTED 071/101] gccrs: refactor builtins initialization and attributes

2024-01-30 Thread arthur . cohen
From: Arthur Cohen This commit performs builtin initialization in a more "GCC-y" way, similarly to what the D frontend is doing. This way, we no longer have to worry about invalid attributes or types when initializing them by hand. Also add attributes support through LANG_HOOKS_COMMON_ATTRIBUTE_

[COMMITTED 056/101] gccrs: Add regression test for const fn in trait

2024-01-30 Thread arthur . cohen
From: Pierre-Emmanuel Patry Const fn declaration in trait declarations shall emit an error. This new test highlight this behavior. gcc/testsuite/ChangeLog: * rust/compile/const_trait_fn.rs: New test. Signed-off-by: Pierre-Emmanuel Patry --- gcc/testsuite/rust/compile/const_trait_fn.r

[COMMITTED 045/101] gccrs: Add unsafety member to modules

2024-01-30 Thread arthur . cohen
From: Pierre-Emmanuel Patry The rust syntax allows unsafe module even if those are rejected at a later stage. gcc/rust/ChangeLog: * ast/rust-item.h: Add safety status to Modules in the AST. * parse/rust-parse-impl.h (Parser::parse_module): Adapt constructors. Signed-off-by: Pie

[COMMITTED 038/101] gccrs: late: Start storing mappings properly in the resolver

2024-01-30 Thread arthur . cohen
From: Arthur Cohen gcc/rust/ChangeLog: * resolve/rust-late-name-resolver-2.0.cc (Late::visit): Store mappings after having resolved them. * resolve/rust-late-name-resolver-2.0.h: Add `TypePath` visitor. --- .../resolve/rust-late-name-resolver-2.0.cc| 33 +

[COMMITTED 044/101] gccrs: Create base class for TupleStructItems and TuplePatternItems

2024-01-30 Thread arthur . cohen
From: Owen Avery gcc/rust/ChangeLog: * hir/tree/rust-hir-pattern.h (class TupleItems): New. (class TupleStructItems): Inherit from TupleItems. (class TuplePatternItems): Likewise. Signed-off-by: Owen Avery --- gcc/rust/hir/tree/rust-hir-pattern.h | 47 +

[COMMITTED 028/101] gccrs: Replace some keyword raw values

2024-01-30 Thread arthur . cohen
From: Pierre-Emmanuel Patry Raw values cannot be understood easily by most tools. This commit replace some raw values with their variable counterpart. gcc/rust/ChangeLog: * ast/rust-ast-collector.cc (TokenCollector::visit): Replace raw value with keyword call. * ast/rust

[COMMITTED 029/101] gccrs: Add a list of weak keyword

2024-01-30 Thread arthur . cohen
From: Pierre-Emmanuel Patry Retrieving a weak keyword value is done using raw values. Introducing a list of weak keywords means this could change. gcc/rust/ChangeLog: * util/rust-keyword-values.h (class WeakKeywords): Add new class with weak keyword constexpr. Signed-off-by: Pi

[COMMITTED 026/101] gccrs: Treat underscore as a keyword

2024-01-30 Thread arthur . cohen
From: Pierre-Emmanuel Patry Make the underscore token a 2015 keyword. gcc/rust/ChangeLog: * lex/rust-token.h (enum PrimitiveCoreType): Change macro for underscore in token list. Signed-off-by: Pierre-Emmanuel Patry --- gcc/rust/lex/rust-token.h | 3 +-- 1 file changed, 1 inse

[COMMITTED 025/101] gccrs: Add edition separation for keywords

2024-01-30 Thread arthur . cohen
From: Pierre-Emmanuel Patry It might be required in the future to get only the keywords from a specific edition. To do so we need a mean to differentiate keywords based on their edition. This commit changes the existing keyword macro to allow such behavior. gcc/rust/ChangeLog: * lex/rus

[COMMITTED 022/101] gccrs: Add a test regular variadic functions errors

2024-01-30 Thread arthur . cohen
From: Pierre-Emmanuel Patry Add a new regression test for the error message in regular function variadic errors during ast validation pass. gcc/testsuite/ChangeLog: * rust/compile/non_foreign_variadic_function.rs: New test. Signed-off-by: Pierre-Emmanuel Patry --- gcc/testsuite/rust/

[COMMITTED 021/101] gccrs: Emit an error on variadic non extern functions

2024-01-30 Thread arthur . cohen
From: Pierre-Emmanuel Patry Variadic regular functions were recently added in the parser as they should be rejected in the ast validation pass. This commit add the ast validation pass rejecting this kind of variadic arguments. gcc/rust/ChangeLog: * checks/errors/rust-ast-validation.cc (

[COMMITTED 085/101] gccrs: ast: Infer static lifetime for const and static items

2024-01-30 Thread arthur . cohen
From: Jakub Dupak (probably incomplete propagation) gcc/rust/ChangeLog: * hir/rust-ast-lower-base.cc (ASTLoweringBase::lower_lifetime): Propagate static requirement. * hir/rust-ast-lower-base.h: Propagate static requirement. * hir/rust-ast-lower-implitem.h: Prop

[COMMITTED 018/101] gccrs: Reject auto traits with super trait

2024-01-30 Thread arthur . cohen
From: Pierre-Emmanuel Patry Reject auto traits containing a super trait bound during AST validation pass. gcc/rust/ChangeLog: * checks/errors/rust-ast-validation.cc (ASTValidation::visit): Reject auto traits with super traits. Signed-off-by: Pierre-Emmanuel Patry --- gcc/rust

[COMMITTED 014/101] gccrs: resolve: Format if properly

2024-01-30 Thread arthur . cohen
From: Arthur Cohen gcc/rust/ChangeLog: * resolve/rust-ast-resolve-path.cc (ResolvePath::resolve_path): Format. --- gcc/rust/resolve/rust-ast-resolve-path.cc | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/gcc/rust/resolve/rust-ast-resolve-path.cc b/gcc/rust/resol

[COMMITTED 072/101] gccrs: HIR: add missing getters

2024-01-30 Thread arthur . cohen
From: Jakub Dupak gcc/rust/ChangeLog: * hir/tree/rust-hir-item.h: Ad lifetime getter. * hir/tree/rust-hir-path.h: Make getter const ref. * hir/tree/rust-hir.h: Const ref and new getter. Signed-off-by: Jakub Dupak --- gcc/rust/hir/tree/rust-hir-item.h | 2 ++ gcc/rust/h

[COMMITTED 069/101] gccrs: Make expand visitor inherit from default visitor

2024-01-30 Thread arthur . cohen
From: Pierre-Emmanuel Patry Many visit functions in the expand visitor simply visit their components like the default visitor. Making the expand visitor inherit from the default visitor allows us to keep all visitor in sync without having to change every visitor. gcc/rust/ChangeLog: * e

[COMMITTED 009/101] gccrs: foreverstack: Specialize `get` for Namespace::Labels

2024-01-30 Thread arthur . cohen
From: Arthur Cohen gcc/rust/ChangeLog: * resolve/rust-forever-stack.hxx: Add specific behavior for `ForeverStack::get` when dealing with labels. --- gcc/rust/resolve/rust-forever-stack.hxx | 29 - 1 file changed, 28 insertions(+), 1 deletion(-) diff --gi

[COMMITTED 034/101] gccrs: nr2.0: Add base for late name resolution

2024-01-30 Thread arthur . cohen
From: Arthur Cohen gcc/rust/ChangeLog: * Make-lang.in: Compile late name resolver. * resolve/rust-late-name-resolver-2.0.cc: New file. * resolve/rust-late-name-resolver-2.0.h: New file. --- gcc/rust/Make-lang.in | 1 + .../resolve/rust-late-name

[COMMITTED 081/101] gccrs: Generate error for `async` trait fucntions

2024-01-30 Thread arthur . cohen
From: Kushal Pal Fixes #2767 gcc/rust/ChangeLog: * checks/errors/rust-ast-validation.cc (ASTValidation::visit): Added check for `async` function inside trait. gcc/testsuite/ChangeLog: * rust/compile/issue-2767.rs: New test. Signed-off-by: Kushal Pal --- gcc/rust/che

[COMMITTED 006/101] gccrs: ast: Change *Path nodes API

2024-01-30 Thread arthur . cohen
From: Arthur Cohen gcc/rust/ChangeLog: * ast/rust-ast.h: Change Path API to be more consistent. * ast/rust-path.h: Likewise. * ast/rust-ast-collector.cc (TokenCollector::visit): Use new API. * resolve/rust-ast-resolve-item.cc (ResolveItem::visit): Likewise.

[COMMITTED 061/101] gccrs: Add execution test for name resolution 2.0

2024-01-30 Thread arthur . cohen
From: Pierre-Emmanuel Patry We already have some compile tests but it lacked an execution test to ensure everything compiles correctly to the correct value. gcc/testsuite/ChangeLog: * rust/execute/torture/name_resolution.rs: New test. Signed-off-by: Pierre-Emmanuel Patry --- .../rust

[COMMITTED 078/101] gccrs: BIR: Cleanup

2024-01-30 Thread arthur . cohen
From: Jakub Dupak gcc/rust/ChangeLog: * checks/errors/borrowck/rust-bir-place.h: Cleanup. * checks/errors/borrowck/rust-borrow-checker.h: Cleanup. Signed-off-by: Jakub Dupak --- gcc/rust/checks/errors/borrowck/rust-bir-place.h | 2 +- gcc/rust/checks/errors/borrowck/rust-

[COMMITTED 013/101] gccrs: foreverstack: Add `to_rib` method

2024-01-30 Thread arthur . cohen
From: Arthur Cohen gcc/rust/ChangeLog: * resolve/rust-forever-stack.h: New method. * resolve/rust-forever-stack.hxx: Likewise. --- gcc/rust/resolve/rust-forever-stack.h | 2 ++ gcc/rust/resolve/rust-forever-stack.hxx | 20 +++- 2 files changed, 21 insertions(+

[COMMITTED 074/101] gccrs: BIR: Fix missed nodiscard

2024-01-30 Thread arthur . cohen
From: Jakub Dupak gcc/rust/ChangeLog: * checks/errors/borrowck/rust-bir-builder-internal.h: Replace nodiscard. * checks/errors/borrowck/rust-bir-place.h: Replace nodiscard. Signed-off-by: Jakub Dupak --- gcc/rust/checks/errors/borrowck/rust-bir-builder-internal.h | 4 ++-- gcc

[COMMITTED 007/101] gccrs: rib: Add Namespace enum

2024-01-30 Thread arthur . cohen
From: Arthur Cohen gcc/rust/ChangeLog: * resolve/rust-rib.h: Add Namespace enum. --- gcc/rust/resolve/rust-rib.h | 25 + 1 file changed, 25 insertions(+) diff --git a/gcc/rust/resolve/rust-rib.h b/gcc/rust/resolve/rust-rib.h index 37bd90f1f75..4ffd00a5d6c 100644

[COMMITTED 047/101] gccrs: Emit an error on unsafe modules

2024-01-30 Thread arthur . cohen
From: Pierre-Emmanuel Patry An error should be emitted on unsafe modules during the AST validation pass as the syntax allows those even though they're not alowed later down the line. gcc/rust/ChangeLog: * ast/rust-item.h: Add safety getter to modules. * checks/errors/rust-ast-va

[COMMITTED 059/101] gccrs: Make early name resolver inherit from default one

2024-01-30 Thread arthur . cohen
From: Pierre-Emmanuel Patry Many visit functions in the early name resolver are just plain old traversal visit functions like the ones from the default visitor. gcc/rust/ChangeLog: * resolve/rust-early-name-resolver.cc (EarlyNameResolver::resolve_generic_args): Move function.

[COMMITTED 041/101] gccrs: ast: Add NodeId to UseTree base class

2024-01-30 Thread arthur . cohen
From: Arthur Cohen gcc/rust/ChangeLog: * ast/rust-item.h (class UseTree): Add `node_id` member. --- gcc/rust/ast/rust-item.h | 8 ++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/gcc/rust/ast/rust-item.h b/gcc/rust/ast/rust-item.h index 2c0e45962ce..3480d126bc0 100

[COMMITTED 046/101] gccrs: Parse module safety

2024-01-30 Thread arthur . cohen
From: Pierre-Emmanuel Patry Unsafe module are rejected at a later stage but could not be parsed properly. This commit changes the parser in order to allow unsafe module in the AST. gcc/rust/ChangeLog: * parse/rust-parse-impl.h (Parser::parse_vis_item): Dispatch to parse module w

[COMMITTED 030/101] gccrs: Replace some weak keyword raw value with constexpr

2024-01-30 Thread arthur . cohen
From: Pierre-Emmanuel Patry Raw values may have typos or contain error, replacing those will improve the codebase. gcc/rust/ChangeLog: * ast/rust-ast-collector.cc (TokenCollector::visit): Replace raw value. * parse/rust-parse-impl.h (Parser::is_macro_rules_def): Likewise.

[COMMITTED 004/101] gccrs: Report self parameter parsing error kind

2024-01-30 Thread arthur . cohen
From: Pierre-Emmanuel Patry Self parameter parsing errors may come from different situations, which should not be handled in the same way. It is now possible to differentiate a missing self parameter from a self pointer or a parsing error. gcc/rust/ChangeLog: * parse/rust-parse-impl.h (

[COMMITTED 033/101] gccrs: ctx: Add Labels ForeverStack to the resolver.

2024-01-30 Thread arthur . cohen
From: Arthur Cohen Not sure if dealing with "labels" is the proper way of doing so, so we might eventually change this to use `resolver.values` later on. gcc/rust/ChangeLog: * resolve/rust-name-resolution-context.h: Add a Labels stack. --- gcc/rust/resolve/rust-name-resolution-context.

[COMMITTED 052/101] gccrs: Allow const and async specifiers in functions

2024-01-30 Thread arthur . cohen
From: Pierre-Emmanuel Patry We need to account for const specifiers in async parsing as const can be used in the syntax before the async keyword. gcc/rust/ChangeLog: * parse/rust-parse-impl.h (Parser::parse_vis_item): Allow parsing async items in const. (Parser::parse_as

[COMMITTED 032/101] gccrs: Added support to Parse ASYNC function

2024-01-30 Thread arthur . cohen
From: M V V S Manoj Kumar Fixes issue #2650 The parser now parses ASYNC functions. Added ASYNC case to parse_item Added a new function parse_async_item which is called in parse_vis_item to handle the ASYNC case. Parse_async_item also checks the current Rust edition and generates an error if the e

[COMMITTED 048/101] gccrs: Add a regression test for unsafe module validation

2024-01-30 Thread arthur . cohen
From: Pierre-Emmanuel Patry Add a new test to check for unsafe modules during AST validation pass. gcc/testsuite/ChangeLog: * rust/compile/unsafe_module.rs: New test. Signed-off-by: Pierre-Emmanuel Patry --- gcc/testsuite/rust/compile/unsafe_module.rs | 2 ++ 1 file changed, 2 insert

[COMMITTED 031/101] gccrs: Introduce a proper keyword list

2024-01-30 Thread arthur . cohen
From: Pierre-Emmanuel Patry The old "keyword" list was used for the lexer, and could therefore not be used with keyword spanning over multiple tokens as those tokens should remain lexed as is. Hence the introduction of a new list macro for keyword exclusive tasks. This also means we can no longer

[COMMITTED 042/101] gccrs: early: Move `use` declaration resolving to TopLevel

2024-01-30 Thread arthur . cohen
From: Arthur Cohen gcc/rust/ChangeLog: * resolve/rust-early-name-resolver-2.0.cc (Early::visit): Remove visitors. * resolve/rust-early-name-resolver-2.0.h: Likewise. --- gcc/rust/resolve/rust-early-name-resolver-2.0.cc | 16 gcc/rust/resolve/rust-early-n

[COMMITTED 027/101] gccrs: Add await keyword

2024-01-30 Thread arthur . cohen
From: Pierre-Emmanuel Patry The 2018 edition await keyword was missing from the keyword list. gcc/rust/ChangeLog: * lex/rust-token.h (enum PrimitiveCoreType): Add await keyword definition. Signed-off-by: Pierre-Emmanuel Patry --- gcc/rust/lex/rust-token.h | 1 + 1 file change

[COMMITTED 037/101] gccrs: late: Start setting up builtin types

2024-01-30 Thread arthur . cohen
From: Arthur Cohen gcc/rust/ChangeLog: * resolve/rust-late-name-resolver-2.0.cc (Late::setup_builtin_types): New function. (Late::go): Setup builtin types. * resolve/rust-late-name-resolver-2.0.h: * resolve/rust-name-resolution-context.cc (NameReso

[COMMITTED 023/101] gccrs: Add ast validation check on union variant number

2024-01-30 Thread arthur . cohen
From: Pierre-Emmanuel Patry Unions with zero fields are forbidden. Add regression test for empty unions. gcc/rust/ChangeLog: * checks/errors/rust-ast-validation.cc (ASTValidation::visit): Add zero field check during ast validation pass. * checks/errors/rust-ast-validatio

[COMMITTED 036/101] gccrs: nr2.0: Store mappings in NameResolutionContext

2024-01-30 Thread arthur . cohen
From: Arthur Cohen gcc/rust/ChangeLog: * resolve/rust-name-resolution-context.h: Store a reference to the mappings. * resolve/rust-name-resolution-context.cc (NameResolutionContext::NameResolutionContext): Likewise. --- gcc/rust/resolve/rust-name-resolution-conte

[COMMITTED 020/101] gccrs: Add check for associated items on auto traits

2024-01-30 Thread arthur . cohen
From: Pierre-Emmanuel Patry Reject rust code with associated items on auto traits. gcc/rust/ChangeLog: * checks/errors/rust-ast-validation.cc (ASTValidation::visit): Add auto trait associated item check in AST validation pass. * parse/rust-parse-impl.h: Remove old error

[COMMITTED 024/101] gccrs: Replace TOK suffix with KW

2024-01-30 Thread arthur . cohen
From: Pierre-Emmanuel Patry TOK suffix was chosen to disambiguate some identifiers with c++ reserved keyword. Even though this list lies within the rust-token header, this macro is used in many context sometimes unrelated with the lexer and tokens. This TOK suffix may appear surprising in such co

[COMMITTED 015/101] gccrs: forever stack: Remove development debug info

2024-01-30 Thread arthur . cohen
From: Arthur Cohen gcc/rust/ChangeLog: * resolve/rust-forever-stack.hxx: Remove debug log. --- gcc/rust/resolve/rust-forever-stack.hxx | 2 -- 1 file changed, 2 deletions(-) diff --git a/gcc/rust/resolve/rust-forever-stack.hxx b/gcc/rust/resolve/rust-forever-stack.hxx index 65796172b0

[COMMITTED 017/101] gccrs: Add regression test for generic auto traits

2024-01-30 Thread arthur . cohen
From: Pierre-Emmanuel Patry Generics are forbidden on auto traits and an error should be emitted. This commit highlight this behavior. gcc/testsuite/ChangeLog: * rust/compile/generic_auto_trait.rs: New test. Signed-off-by: Pierre-Emmanuel Patry --- gcc/testsuite/rust/compile/generic_

[COMMITTED 012/101] gccrs: foreverstack: Add `to_canonical_path` method

2024-01-30 Thread arthur . cohen
From: Arthur Cohen gcc/rust/ChangeLog: * resolve/rust-forever-stack.h: New method. * resolve/rust-forever-stack.hxx: Likewise. --- gcc/rust/resolve/rust-forever-stack.h | 25 ++- gcc/rust/resolve/rust-forever-stack.hxx | 90 - 2 files changed, 110 i

[COMMITTED 016/101] gccrs: Reject auto traits with generic parameters

2024-01-30 Thread arthur . cohen
From: Pierre-Emmanuel Patry Generic parameters are not allowed on auto traits, the compiler should emit an error. gcc/rust/ChangeLog: * checks/errors/rust-ast-validation.cc (ASTValidation::visit): Add check for generics on auto traits. * checks/errors/rust-ast-validation

[COMMITTED 010/101] gccrs: forever stack: Fix resolve_path signature

2024-01-30 Thread arthur . cohen
From: Arthur Cohen gcc/rust/ChangeLog: * resolve/rust-forever-stack.h: Fix `ForeverStack::resolve_path` signature. * resolve/rust-forever-stack.hxx: Likewise. * resolve/rust-early-name-resolver-2.0.cc (Early::visit): Use new API. (Early::visit_attributes):

[COMMITTED 008/101] gccrs: forever-stack: Fix basic get logic

2024-01-30 Thread arthur . cohen
From: Arthur Cohen gcc/rust/ChangeLog: * resolve/rust-forever-stack.h: Improve resolve_path API. * resolve/rust-forever-stack.hxx: Likewise and fix implementation. --- gcc/rust/resolve/rust-forever-stack.h | 19 +++-- gcc/rust/resolve/rust-forever-stack.hxx | 38 ++

[COMMITTED 005/101] gccrs: Add new test for parsing errors on self pointers

2024-01-30 Thread arthur . cohen
From: Pierre-Emmanuel Patry Add new tests to highlight the behavior of errors thrown when meeting a self pointer. gcc/testsuite/ChangeLog: * rust/compile/self_const_ptr.rs: New test. * rust/compile/self_mut_ptr.rs: New test. * rust/compile/self_ptr.rs: New test. Signed-

[COMMITTED 003/101] gccrs: Fix error emission for self pointers

2024-01-30 Thread arthur . cohen
From: Pierre-Emmanuel Patry Self pointer checking loop condition was inverted, the latter was therefore never executed. gcc/rust/ChangeLog: * parse/rust-parse-impl.h (Parser::parse_self_param): Fix the loop exit condition. Signed-off-by: Pierre-Emmanuel Patry --- gcc/rust/par

[COMMITTED 001/101] gccrs: Add visibility to trait item

2024-01-30 Thread arthur . cohen
From: Pierre-Emmanuel Patry The compiler shall parse visibility modifiers on trait items and reject those at a later stage (ast validation). gcc/rust/ChangeLog: * ast/rust-item.h (struct Visibility): Move Visibility from here... * ast/rust-ast.h (struct Visibility): ...to here.

  1   2   >