]> git.ipfire.org Git - thirdparty/gcc.git/log
thirdparty/gcc.git
2 months agogccrs: Add check for placeholder (infer) type in return position
Philip Herron [Wed, 16 Apr 2025 19:38:17 +0000 (20:38 +0100)] 
gccrs: Add check for placeholder (infer) type in return position

It is not allowed to have a declared inference variable in the return
position of a function as this may never get infered you need good points
of truth.

Ideally if we get a student for GSoC 25 we will get the Default Hir Visitor
so that we can grab the HIR::InferredType locus instead of using the ref
location lookups.

Fixes Rust-GCC#402

gcc/rust/ChangeLog:

* typecheck/rust-hir-type-check-item.cc (TypeCheckItem::visit): add diagnostic
* typecheck/rust-tyty.cc (BaseType::contains_infer): new helper to grab first infer var
* typecheck/rust-tyty.h: prototype

gcc/testsuite/ChangeLog:

* rust/compile/issue-402.rs: New test.

Signed-off-by: Philip Herron <herron.philip@googlemail.com>
2 months agogccrs: Fix ICE when checking shift's which are behind array refs
Philip Herron [Wed, 16 Apr 2025 16:13:04 +0000 (17:13 +0100)] 
gccrs: Fix ICE when checking shift's which are behind array refs

I copied a bad form of this check from the c front-end this updates it
to ensure the rhs is an INTEGER_CST and the lhs needs checked in the first
place.

Fixes Rust-GCC#3664

gcc/rust/ChangeLog:

* rust-gcc.cc (arithmetic_or_logical_expression): Ensure this is an integer

gcc/testsuite/ChangeLog:

* rust/compile/issue-3664.rs: New test.

Signed-off-by: Philip Herron <herron.philip@googlemail.com>
2 months agogccrs: Fix crash in hir dump as labels are optional
Philip Herron [Wed, 16 Apr 2025 16:00:28 +0000 (17:00 +0100)] 
gccrs: Fix crash in hir dump as labels are optional

gcc/rust/ChangeLog:

* hir/rust-hir-dump.cc (Dump::visit): add guard for optional label

Signed-off-by: Philip Herron <herron.philip@googlemail.com>
2 months agogccrs: Update comments in repr parsing code
Yap Zhi Heng [Fri, 4 Apr 2025 11:37:03 +0000 (19:37 +0800)] 
gccrs: Update comments in repr parsing code

gcc/rust/ChangeLog:

* typecheck/rust-tyty.h: Remove extra redundant comment.
* typecheck/rust-hir-type-check-base.cc: Update comment on repr
handling.

Signed-off-by: Yap Zhi Heng <yapzhhg@gmail.com>
2 months agogccrs: Implement integer representation for enums
Zhi Heng [Thu, 3 Apr 2025 15:02:59 +0000 (23:02 +0800)] 
gccrs: Implement integer representation for enums

gcc/rust/ChangeLog:

* typecheck/rust-hir-type-check-base.cc: Set enum representing
type properly if repr is an integer type.
* typecheck/rust-hir-type-check-item.cc: Update comments.

Signed-off-by: Yap Zhi Heng <yapzhhg@gmail.com>
2 months agogccrs: Implement typecheck for zero-variant enums
Zhi Heng [Thu, 3 Apr 2025 12:23:46 +0000 (20:23 +0800)] 
gccrs: Implement typecheck for zero-variant enums

gcc/rust/ChangeLog:

* typecheck/rust-tyty.h: Add new `ReprKind` enum to
`ReprOptions`.
* typecheck/rust-hir-type-check-base.cc: Handle setting of
`repr_kind`.
* typecheck/rust-hir-type-check-item.cc: New check for
zero-variant enums.

Signed-off-by: Yap Zhi Heng <yapzhhg@gmail.com>
2 months agogccrs: Fix segv in unsafe chcker
Philip Herron [Fri, 4 Apr 2025 15:35:13 +0000 (16:35 +0100)] 
gccrs: Fix segv in unsafe chcker

Trait constants were missing type resolution step, this adds that
as if it was a normal constant. The unsafe checker was missing a
null check.

Fixes Rust-GCC#3612

gcc/rust/ChangeLog:

* checks/errors/rust-unsafe-checker.cc (UnsafeChecker::visit): add null check
* hir/tree/rust-hir-item.h: add has_type helper
* typecheck/rust-hir-trait-resolve.cc (TraitItemReference::resolve_item):
add missing type checking

gcc/testsuite/ChangeLog:

* rust/compile/issue-3612.rs: New test.

Signed-off-by: Philip Herron <herron.philip@googlemail.com>
2 months agolang-items: Add ManuallyDrop<T>
Arthur Cohen [Tue, 8 Apr 2025 15:04:09 +0000 (17:04 +0200)] 
lang-items: Add ManuallyDrop<T>

gcc/rust/ChangeLog:

* util/rust-lang-item.h: Add new manually_drop lang item.
* util/rust-lang-item.cc: Likewise.

2 months agoattributes: Handle external tool annotations like rustfmt::
Arthur Cohen [Wed, 9 Apr 2025 13:17:38 +0000 (15:17 +0200)] 
attributes: Handle external tool annotations like rustfmt::

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.

2 months agonr2.0: Only insert derive macros if they exist
Arthur Cohen [Wed, 9 Apr 2025 12:48:55 +0000 (14:48 +0200)] 
nr2.0: Only insert derive macros if they exist

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 (Early::visit_attributes): Remove assertion.

2 months agoattributes: Add missing attributes used in `core`
Arthur Cohen [Fri, 4 Apr 2025 12:20:04 +0000 (14:20 +0200)] 
attributes: Add missing attributes used in `core`

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.

2 months agoAdd `#[track_caller]` as known attribute
beamandala [Thu, 20 Mar 2025 22:34:48 +0000 (17:34 -0500)] 
Add `#[track_caller]` as known attribute

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.

gcc/testsuite/ChangeLog:

* rust/compile/track_caller.rs: New test.

Signed-off-by: Bhavesh Mandalapu <mandalapubhavesh@gmail.com>
2 months agoci: Update warnings for new location in install.texi
Arthur Cohen [Mon, 14 Apr 2025 08:58:25 +0000 (10:58 +0200)] 
ci: Update warnings for new location in install.texi

ChangeLog:

* .github/glibcxx_ubuntu64b_log_expected_warnings: Change line number
for warning from 2230 to 2236.
* .github/log_expected_warnings: Likewise.

2 months agoinstall.texi: Mention Rust requirement for building gccrs
Arthur Cohen [Tue, 1 Apr 2025 11:00:56 +0000 (13:00 +0200)] 
install.texi: Mention Rust requirement for building gccrs

Addresses PR#117869

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=117869

gcc/ChangeLog:

* doc/install.texi: Add requirements for building gccrs.

2 months agoFix const checking of enum discriminants
Owen Avery [Sat, 5 Apr 2025 21:20:44 +0000 (17:20 -0400)] 
Fix const checking of enum discriminants

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:

* rust/compile/enum_discriminant2.rs: New test.

Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
2 months agoformat_args: Allow extraneous commas, improve safety
Arthur Cohen [Wed, 9 Apr 2025 12:42:08 +0000 (14:42 +0200)] 
format_args: Allow extraneous commas, improve safety

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.

2 months agoexpansion: Desugar doc comments into attributes before expansion
Arthur Cohen [Tue, 8 Apr 2025 14:20:18 +0000 (16:20 +0200)] 
expansion: Desugar doc comments into attributes before expansion

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.

gcc/testsuite/ChangeLog:

* rust/compile/macros/mbe/macro-issue3709-1.rs: New test.
* rust/compile/macros/mbe/macro-issue3709-2.rs: New test.

2 months agoexpansion: Only add fragments if the matcher succeeded
Arthur Cohen [Tue, 8 Apr 2025 12:41:16 +0000 (14:41 +0200)] 
expansion: Only add fragments if the matcher succeeded

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.

2 months agosession: Desugar question mark operator after expansion instead.
Arthur Cohen [Fri, 4 Apr 2025 12:21:00 +0000 (14:21 +0200)] 
session: Desugar question mark operator after expansion instead.

gcc/rust/ChangeLog:

* rust-session-manager.cc (Session::compile_crate): Call the visitor later in the pipeline.

2 months agoast: Add get_locus() to DelimTokenTree
Arthur Cohen [Wed, 9 Apr 2025 12:44:11 +0000 (14:44 +0200)] 
ast: Add get_locus() to DelimTokenTree

gcc/rust/ChangeLog:

* ast/rust-ast.h (DelimTokenTree::get_locus): New function.

2 months agoast: Support outer attributes for AST::RangeExpr
Arthur Cohen [Wed, 9 Apr 2025 12:44:56 +0000 (14:44 +0200)] 
ast: Support outer attributes for AST::RangeExpr

gcc/rust/ChangeLog:

* ast/rust-expr.h (class RangeExpr): Add empty outer attributes and allow getting them
and setting them.

2 months agonr2.0: Do not resolve modules this run if they are unloaded
Arthur Cohen [Fri, 4 Apr 2025 12:18:33 +0000 (14:18 +0200)] 
nr2.0: Do not resolve modules this run if they are unloaded

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): Return if module
is unloaded.

2 months agotypecheck: Properly select methods when dealing with specialization
Arthur Cohen [Thu, 3 Apr 2025 14:22:10 +0000 (16:22 +0200)] 
typecheck: Properly select methods when dealing with specialization

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::visit): Call `handle_multiple_candidates`.

gcc/testsuite/ChangeLog:

* rust/execute/torture/min_specialization2.rs: New test.
* rust/execute/torture/min_specialization3.rs: New test.

3 months agorust: Add comment inside block [PR119342]
Andrew Pinski [Thu, 20 Mar 2025 00:30:02 +0000 (17:30 -0700)] 
rust: Add comment inside block [PR119342]

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/119342
* rust-gcc.cc (block): Add comment on why chaining
the variables of the scope toether.

Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com>
3 months agorust: use range for inside rust-gcc.cc [PR119341]
Andrew Pinski [Thu, 20 Mar 2025 00:30:01 +0000 (17:30 -0700)] 
rust: use range for inside rust-gcc.cc [PR119341]

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 range fors.
(function_type_variadic): Likewise.
(fill_in_fields): Likewise.
(statement_list): Likewise.
(block): Likewise.
(block_add_statements): Likewise.
(function_set_parameters): Likewise.
(write_global_definitions): Likewise.

Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com>
3 months agorust: Use error_operand_p in rust-gcc.cc
Andrew Pinski [Thu, 20 Mar 2025 00:30:00 +0000 (17:30 -0700)] 
rust: Use error_operand_p in rust-gcc.cc

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:

* rust-gcc.cc (Bvariable::get_tree): Use error_operand_p.
(pointer_type): Likewise.
(reference_type): Likewise.
(immutable_type): Likewise.
(function_type): Likewise.
(function_type_variadic): Likewise.
Cleanup the check for receiver.type first.
(function_ptr_type): Use error_operand_p.
(fill_in_fields): Likewise.
(fill_in_array): Likewise.
(named_type): Likewise.
(type_size): Likewise.
(type_alignment): Likewise.
(type_field_alignment): Likewise.
(type_field_offset): Likewise.
(zero_expression): Likewise.
(float_constant_expression): Likewise.
(convert_expression): Likewise.
(struct_field_expression): Likewise.
(compound_expression): Likewise.
(conditional_expression): Likewise.
(negation_expression): Likewise.
(arithmetic_or_logical_expression): Likewise.
(arithmetic_or_logical_expression_checked): Likewise.
(comparison_expression): Likewise.
(lazy_boolean_expression): Likewise.
(constructor_expression): Likewise.
(array_constructor_expression): Likewise.
(array_index_expression): Likewise.
(call_expression): Likewise.
(init_statement): Likewise.
(assignment_statement): Likewise.
(return_statement): Likewise.
(exception_handler_statement): Likewise.
(if_statement): Likewise.
(compound_statement): Likewise.
Tighten up the code, removing t variable.
(statement_list): Use error_operand_p.
(block): Likewise.
(block_add_statements): Likewise.
(convert_tree): Likewise.
(global_variable): Likewise.
(global_variable_set_init): Likewise.
(local_variable): Likewise.
(parameter_variable): Likewise.
(static_chain_variable): Likewise.
(temporary_variable): Likewise.
(function): Likewise. Tighten up the code.
(function_defer_statement): Use error_operand_p.
(function_set_parameters): Use error_operand_p.
(write_global_definitions): Use error_operand_p.
Tighten up the code around the loop.

Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com>
3 months agorust: Use FLOAT_TYPE_P instead of manual checking
Andrew Pinski [Thu, 20 Mar 2025 00:29:59 +0000 (17:29 -0700)] 
rust: Use FLOAT_TYPE_P instead of manual checking

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 x86_64-linux-gnu.

gcc/rust/ChangeLog:

* rust-gcc.cc (is_floating_point): Use FLOAT_TYPE_P
instead of manually checking the type.

Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com>
3 months agonr2.0: Adjust test macro6.rs
Owen Avery [Mon, 24 Mar 2025 01:40:47 +0000 (21:40 -0400)] 
nr2.0: Adjust test macro6.rs

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 <powerboat9.gamer@gmail.com>
3 months agonr2.0: Adjust test issue-2812.rs
Owen Avery [Mon, 24 Mar 2025 22:27:41 +0000 (18:27 -0400)] 
nr2.0: Adjust test issue-2812.rs

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 <powerboat9.gamer@gmail.com>
3 months agogccrs: fix ICE segfault with empty feature gate
Matty Kuhn [Sat, 5 Apr 2025 00:09:41 +0000 (18:09 -0600)] 
gccrs: fix ICE segfault with empty feature gate

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): check for empty feature gate

gcc/testsuite/ChangeLog:

* rust/compile/feature.rs: add an invalid empty feature to produce an error

Signed-off-by: Matty Kuhn <matty.kuhn.1@gmail.com>
3 months agoRename label getter to unchecked
Pierre-Emmanuel Patry [Thu, 3 Apr 2025 13:43:40 +0000 (15:43 +0200)] 
Rename label getter to unchecked

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-ast-lower-expr.cc (ASTLoweringExpr::visit): Likewise.
* resolve/rust-ast-resolve-expr.cc (ResolveExpr::visit): Likewise.
* resolve/rust-late-name-resolver-2.0.cc (Late::visit): Likewise.
* ast/rust-expr.h: Add optional getter and rename label getter to
get_label_unchecked.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
3 months agoRename label getter in ContinueExpr
Pierre-Emmanuel Patry [Thu, 3 Apr 2025 12:40:15 +0000 (14:40 +0200)] 
Rename label getter in ContinueExpr

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/rust-ast-lower-expr.cc (ASTLoweringExpr::visit): Likewise.
* resolve/rust-ast-resolve-expr.cc (ResolveExpr::visit): Likewise.
* resolve/rust-late-name-resolver-2.0.cc (Late::visit): Likewise.
* ast/rust-expr.h: Add new getter for the optional and rename getter
to get_label_unchecked.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
3 months agoChange optional to expected for parse_loop_label
Pierre-Emmanuel Patry [Thu, 3 Apr 2025 11:16:33 +0000 (13:16 +0200)] 
Change optional to expected for parse_loop_label

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): Update function prototype.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
3 months agoAdapt testcase to name resolution 2.0
Pierre-Emmanuel Patry [Wed, 2 Apr 2025 16:20:54 +0000 (18:20 +0200)] 
Adapt testcase to name resolution 2.0

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-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
3 months agoResolve labels within break or continue expressions
Pierre-Emmanuel Patry [Wed, 2 Apr 2025 15:41:54 +0000 (17:41 +0200)] 
Resolve labels within break or continue expressions

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-name-resolver-2.0.h: Add function prototypes.

gcc/testsuite/ChangeLog:

* rust/compile/nr2/exclude: Remove test.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
3 months agoFix unresolved label error message
Pierre-Emmanuel Patry [Wed, 2 Apr 2025 15:38:28 +0000 (17:38 +0200)] 
Fix unresolved label error message

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-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
3 months agoMigrate error state to optionals
Pierre-Emmanuel Patry [Tue, 1 Apr 2025 17:55:28 +0000 (19:55 +0200)] 
Migrate error state to optionals

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_string): Retrieve label value.
(Lifetime::as_string): Retrieve lifetime value.
(ReferenceType::as_string): Likewise.
(SelfParam::as_string): Likewise.
* ast/rust-ast.h: Remove lifetime and LifetimeParam error state.
* ast/rust-desugar-for-loops.cc (DesugarForLoops::DesugarCtx::make_break_arm):
Use optional instead of error state.
* ast/rust-expr.h (class ContinueExpr): Make label optional.
* ast/rust-item.h (class SelfParam): Make lifetime optional.
* ast/rust-type.h (class ReferenceType): Likewise.
* backend/rust-compile-base.cc: Use optional for self param instead
of error state.
* backend/rust-compile-base.h: Update function prototype.
* expand/rust-derive-clone.cc (DeriveClone::clone_fn): Use optional.
* hir/rust-ast-lower-base.cc (ASTLoweringBase::lower_self): Lower
lifetime only if it exists.
* hir/rust-ast-lower-block.h: Lower loop label only if it exists.
* hir/rust-ast-lower-expr.cc (ASTLoweringExpr::visit): Likewise.
* hir/rust-ast-lower-implitem.cc (ASTLowerImplItem::visit): Remove
references to error state.
(ASTLowerTraitItem::visit): Lower self param only if it exists.
* hir/rust-ast-lower-item.cc (ASTLoweringItem::visit): Use nullopt
for default value instead of SelfParam error state.
* hir/rust-ast-lower.cc (ASTLoweringExprWithBlock::visit): Lower label
only if it exists.
* hir/rust-hir-dump.cc (Dump::do_traitfunctiondecl): Print self only if
it exists.
(Dump::visit): Liewise.
* hir/tree/rust-hir-bound.h: Remove error state.
* hir/tree/rust-hir-expr.cc (ContinueExpr::ContinueExpr): Use optional
in constructor for loop label.
(BreakExpr::BreakExpr): Likewise.
* hir/tree/rust-hir-expr.h (class ContinueExpr): Remove error state
implementation.
(class BreakExpr): Likewise.
* hir/tree/rust-hir-generic-param.h: Likewise.
* hir/tree/rust-hir-item.cc (SelfParam::SelfParam): Make lifetime
optional.
(Function::Function): Make self param optional.
* hir/tree/rust-hir-item.h (class Function): Likewise.
* hir/tree/rust-hir-type.cc (ReferenceType::ReferenceType): Make
lifetime optional.
* hir/tree/rust-hir-type.h (class ReferenceType): Likewise.
* hir/tree/rust-hir.cc (ContinueExpr::as_string): Use new getter.
(BreakExpr::as_string): Likewise.
(Lifetime::as_string): Likewise.
(ReferenceType::as_string): Likewise.
(TraitFunctionDecl::as_string): Likewise.
(SelfParam::as_string): Remove error state checking.
* parse/rust-parse-impl.h (Parser::parse_generic_param): Adapt to
optional.
(Parser::parse_lifetime_params): Likewise.
(Parser::parse_lifetime_params_objs): Likewise.
(Parser::parse_lifetime_param): Likewise.
(Parser::parse_lifetime_where_clause_item): Likewise.
(Parser::parse_type_param_bound): Likewise.
(Parser::parse_lifetime_bounds): Likewise.
(Parser::parse_path_generic_args): Likewise.
(Parser::parse_self_param): Likewise.
(Parser::parse_break_expr): Likewise.
(Parser::parse_continue_expr): Likewise.
(Parser::parse_reference_type_inner): Likewise.
* parse/rust-parse.h (class ParseLifetimeParamError): Add new class for
lifetime param parsing errors.
(class ParseLifetimeError): Add new class for lifetime parsing errors.
(enum ParseSelfError): Add new class for self param parsing errors.
* typecheck/rust-hir-type-check-implitem.cc (TypeCheckImplItem::visit):
Use unchecked getter in checked context. And make anonymous region.
* typecheck/rust-hir-type-check.cc (TraitItemReference::get_type_from_fn):
Likewise.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
3 months agoUpdate ast visitor with proper check for looplabel
Pierre-Emmanuel Patry [Tue, 1 Apr 2025 14:10:38 +0000 (16:10 +0200)] 
Update ast visitor with proper check for looplabel

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 <pierre-emmanuel.patry@embecosm.com>
3 months agoRemove unused error constructor and getter
Pierre-Emmanuel Patry [Tue, 1 Apr 2025 14:08:37 +0000 (16:08 +0200)] 
Remove unused error constructor and getter

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 <pierre-emmanuel.patry@embecosm.com>
3 months agoMake loop label truly optional
Pierre-Emmanuel Patry [Tue, 1 Apr 2025 13:57:47 +0000 (15:57 +0200)] 
Make loop label truly optional

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
of an error loop label.
(WhileLetLoopExpr::as_string): Use getter function and adapt to
newtype.
* ast/rust-ast.cc (WhileLoopExpr::as_string): Likewise.
(LoopExpr::as_string): Likewise.
(BreakExpr::as_string): Likewise.
(ForLoopExpr::as_string): Likewise.
* ast/rust-expr.h (class BlockExpr): Make loop label optional.
(class BreakExpr): Likewise.
* expand/rust-derive-clone.cc (DeriveClone::clone_fn): Use nullopt.
* expand/rust-derive-debug.cc (DeriveDebug::stub_debug_fn): Likewise.
* expand/rust-derive-default.cc (DeriveDefault::default_fn): Likewise.
* expand/rust-derive-eq.cc: Likewise.
* parse/rust-parse-impl.h (Parser::parse_block_expr): Use optional
for arguments.
(Parser::parse_loop_expr): Likewise.
(Parser::parse_while_loop_expr): Likewise.
(Parser::parse_while_let_loop_expr): Likewise.
(Parser::parse_for_loop_expr): Likewise.
(Parser::parse_labelled_loop_expr): Likewise.
(Parser::parse_loop_label): Return an optional.
* parse/rust-parse.h: Update function prototype and use nullopt for
default values.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
3 months agoVisit loop label before predicate expression
Pierre-Emmanuel Patry [Tue, 1 Apr 2025 10:02:31 +0000 (12:02 +0200)] 
Visit loop label before predicate expression

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/compile/nr2/exclude: Remove test from exclusion list.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
3 months agoAdd check for label
Pierre-Emmanuel Patry [Mon, 31 Mar 2025 15:01:18 +0000 (17:01 +0200)] 
Add check for label

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 <pierre-emmanuel.patry@embecosm.com>
3 months agoResolve labels
Pierre-Emmanuel Patry [Mon, 31 Mar 2025 15:00:11 +0000 (17:00 +0200)] 
Resolve labels

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.
(LoopExpr::LoopExpr): Likewise.
(WhileLoopExpr::WhileLoopExpr): Likewise.
* hir/tree/rust-hir-expr.h: Use optional for lifetime and labels.
* hir/tree/rust-hir.cc (WhileLoopExpr::as_string): Use getter.
(WhileLetLoopExpr::as_string): Likewise.
(LoopExpr::as_string): Likewise.
* resolve/rust-late-name-resolver-2.0.cc (Late::visit): Resolve labels.
* resolve/rust-late-name-resolver-2.0.h: Add visit function prototype
for loop labels.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
3 months agoRevert part of 44ffe1193269
Pierre-Emmanuel Patry [Thu, 3 Apr 2025 15:27:46 +0000 (17:27 +0200)] 
Revert part of 44ffe1193269

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 <pierre-emmanuel.patry@embecosm.com>
3 months agogccrs: refactoring rust_error_at "redefined multiple times"
Sri Ganesh Thota [Tue, 25 Mar 2025 13:00:58 +0000 (18:30 +0530)] 
gccrs: refactoring rust_error_at "redefined multiple times"

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-ast-resolve-stmt.cc (ResolveStmt::visit): changed rust_error_at to
redefined_error.
* resolve/rust-ast-resolve-stmt.h: changed rust_error_at to redefined_error.
* resolve/rust-ast-resolve-toplevel.h: changed rust_error_at to redefined_error.

Signed-off-by: Sri Ganesh Thota <sriganeshthota12345@gmail.com>
3 months agonr2.0: Improve test script
Owen Avery [Sun, 30 Mar 2025 23:08:45 +0000 (19:08 -0400)] 
nr2.0: Improve test script

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 <powerboat9.gamer@gmail.com>
3 months agonr2.0: Remove duplicate self visit
Owen Avery [Tue, 1 Apr 2025 21:50:32 +0000 (17:50 -0400)] 
nr2.0: Remove duplicate self visit

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/compile/nr2/exclude: Remove entry.

Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
3 months agogccrs: Fix ICE for reserved lifetime name
Philip Herron [Thu, 3 Apr 2025 15:32:36 +0000 (16:32 +0100)] 
gccrs: Fix ICE for reserved lifetime name

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 test.

Signed-off-by: Philip Herron <herron.philip@googlemail.com>
3 months agohir: Add default qualifier to function, lower it properly
Arthur Cohen [Tue, 1 Apr 2025 15:45:28 +0000 (17:45 +0200)] 
hir: Add default qualifier to function, lower it properly

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 (ASTLowerImplItem::visit): Lower default qualifier.
* hir/rust-ast-lower-item.cc (ASTLoweringItem::visit): Likewise.
* hir/tree/rust-hir-item.cc (Function::Function): Add `is_default` member.
(Function::operator=): Likewise.
* hir/tree/rust-hir-item.h (enum class Defaultness): New enum.
(class Function): Use it.

gcc/testsuite/ChangeLog:

* rust/compile/min_specialization1.rs: New test.

3 months agofeature: Add min_specialization feature
Arthur Cohen [Tue, 1 Apr 2025 15:45:00 +0000 (17:45 +0200)] 
feature: Add min_specialization feature

gcc/rust/ChangeLog:

* checks/errors/rust-feature.cc (Feature::create): Handle `#![feature(min_specialization)]`.
* checks/errors/rust-feature.h: Likewise.

3 months agogccrs: Fix ICE when hitting invalid types for generics
Philip Herron [Wed, 2 Apr 2025 20:02:44 +0000 (21:02 +0100)] 
gccrs: Fix ICE when hitting invalid types for generics

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 (ResolveRelativeTypePath::go): fix error msg
* typecheck/rust-substitution-mapper.cc (SubstMapper::Resolve): add validation
(SubstMapper::valid_type): new check
(SubstMapper::visit): check if can resolve
* typecheck/rust-substitution-mapper.h: new prototype

gcc/testsuite/ChangeLog:

* rust/compile/nr2/exclude: nr2 is missing type path error
* rust/compile/issue-3643.rs: New test.
* rust/compile/issue-3646.rs: New test.
* rust/compile/issue-3654.rs: New test.
* rust/compile/issue-3663.rs: New test.
* rust/compile/issue-3671.rs: New test.

Signed-off-by: Philip Herron <herron.philip@googlemail.com>
3 months agogccrs: Fix ICE on raw reference
Philip Herron [Thu, 3 Apr 2025 14:39:58 +0000 (15:39 +0100)] 
gccrs: Fix ICE on raw reference

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-base.h: update prototype
* backend/rust-compile-expr.cc (CompileExpr::visit): update borrow expr
* backend/rust-compile-extern.h: remove unused debug
* backend/rust-compile-resolve-path.cc (HIRCompileBase::query_compile): update usage
* hir/rust-ast-lower-expr.cc (ASTLoweringExpr::visit): lower raw ref
* hir/tree/rust-hir-expr.cc (BorrowExpr::BorrowExpr): add flag for raw ref
* hir/tree/rust-hir-expr.h (class BorrowExpr): add new raw ref field
* typecheck/rust-hir-type-check-expr.cc (TypeCheckExpr::visit): add handle for raw ref

gcc/testsuite/ChangeLog:

* rust/compile/issue-3667.rs: New test.

Signed-off-by: Philip Herron <herron.philip@googlemail.com>
3 months agogccrs: Fix ICE on invalid match arms
Philip Herron [Thu, 3 Apr 2025 14:37:40 +0000 (15:37 +0100)] 
gccrs: Fix ICE on invalid match arms

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/compile/issue-3656.rs: New test.

Signed-off-by: Philip Herron <herron.philip@googlemail.com>
3 months agogccrs: Fix recusive type query and nullptr on type path
Philip Herron [Wed, 2 Apr 2025 17:21:46 +0000 (18:21 +0100)] 
gccrs: Fix recusive type query and nullptr on type path

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 but now and error
message is being output for the type path. This happens because we start
resolving a generic struct:

  struct Wierd<T>(A<(T,)>);

So the child field A is also generic and the generic argument of the tuple
of T needs to be applied to this generic field. This causes a chunk of
code to do bounds checking to ensure the bounds are ok, this is also
something that probably might change as generic types will have the bounds
secified anyway but thats besides the case right now. So once this bounds
checking occurs we endup looking at the impl block for Wierd<i32> which is
also grand but we still havent finished resolving the parent type of Wierd
which is recusive. But the query type system needs to check for that.

The other issue was: compile/issue-3022.rs which is a resolution issue:

  impl<T: Foo<U>, U> Foo<U> for Bar<T, U>

The bound of Foo<T> is added to T before U is resolved but this was hidden
before the new error message was added. So now we have a generic
arguements handler being used correctly all over the code base apart from
1 last case for Traits but we will deal with that later. This handles the
case by setting up the type parameters upfront then sorting out their
bounds.

Fixes Rust-GCC#3625

gcc/rust/ChangeLog:

* typecheck/rust-hir-trait-resolve.cc (TraitResolver::resolve_trait): new argument
* typecheck/rust-hir-type-check-base.cc (TypeCheckBase::TypeCheckBase): new helper
* typecheck/rust-hir-type-check-base.h: new helper prototype
* typecheck/rust-hir-type-check-implitem.cc (TypeCheckTopLevelExternItem::visit):
remove comment out code
* typecheck/rust-hir-type-check-path.cc (TypeCheckExpr::resolve_root_path): check for null
* typecheck/rust-hir-type-check-type.cc (TypeCheckType::resolve_root_path): likewise
(TypeResolveGenericParam::Resolve): new args
(TypeResolveGenericParam::ApplyAnyTraitBounds): new helper
(TypeResolveGenericParam::apply_trait_bounds): new field
(TypeResolveGenericParam::visit): update
* typecheck/rust-hir-type-check-type.h: new args
* typecheck/rust-hir-type-check.cc (TraitItemReference::get_type_from_fn): reuse helper
* typecheck/rust-type-util.cc (query_type): check for recursive query
* typecheck/rust-tyty-subst.cc (SubstitutionParamMapping::SubstitutionParamMapping):
remove const
(SubstitutionParamMapping::get_generic_param): likewise
* typecheck/rust-tyty-subst.h: likewise
* typecheck/rust-tyty-variance-analysis.cc (GenericTyVisitorCtx::process_type): likewise

gcc/testsuite/ChangeLog:

* rust/compile/issue-3625.rs: New test.

Signed-off-by: Philip Herron <herron.philip@googlemail.com>
3 months agogccrs: Fix ICE when there are 2 functions named main
Philip Herron [Wed, 2 Apr 2025 15:16:47 +0000 (16:16 +0100)] 
gccrs: Fix ICE when there are 2 functions named main

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 oppposed to a
HIR::Function which is part of an HIR::ImplBlock as part of the HIR::Crate.
Some small cleanups have been added here too.

Fixes Rust-GCC#3648

gcc/rust/ChangeLog:

* backend/rust-compile-base.cc: new flag is_root_item
* backend/rust-compile-base.h: update prototype
* backend/rust-compile-implitem.cc (CompileTraitItem::visit): update call
* backend/rust-compile-implitem.h: remove old debug internal error
* backend/rust-compile-item.cc (CompileItem::visit): update call
* backend/rust-compile-item.h: remove old debug
* backend/rust-compile-resolve-path.cc (HIRCompileBase::query_compile): update calls
* backend/rust-compile.cc: likewise
* typecheck/rust-hir-trait-resolve.cc (TraitResolver::resolve_path_to_trait):
remove assertion and error

gcc/testsuite/ChangeLog:

* rust/compile/issue-3648.rs: New test.

Signed-off-by: Philip Herron <herron.philip@googlemail.com>
3 months agogccrs: Fix ICE when resolving lifetimes without name
Philip Herron [Mon, 31 Mar 2025 16:33:59 +0000 (17:33 +0100)] 
gccrs: Fix ICE when resolving lifetimes without name

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: Philip Herron <herron.philip@googlemail.com>
3 months agogccrs: Fix ICE when doing shift checks on const decl
Philip Herron [Mon, 31 Mar 2025 16:58:24 +0000 (17:58 +0100)] 
gccrs: Fix ICE when doing shift checks on const decl

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-gcc.cc (arithmetic_or_logical_expression): unwrap const decls

gcc/testsuite/ChangeLog:

* rust/compile/issue-3665.rs: New test.

Signed-off-by: Philip Herron <herron.philip@googlemail.com>
3 months agonr2.0: Handle global paths
Owen Avery [Tue, 25 Mar 2025 02:49:12 +0000 (22:49 -0400)] 
nr2.0: Handle global paths

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.
* resolve/rust-forever-stack.hxx: Include rust-edition.h.
(ForeverStacl::resolve_path): Handle global paths (paths with an
opening scope resolution operator).
* resolve/rust-late-name-resolver-2.0.cc
(Late::visit): Handle global paths.
* resolve/rust-name-resolution-context.h
(NameResolutionContext::resolve_path): Handle global paths.

gcc/testsuite/ChangeLog:

* rust/compile/nr2/exclude: Remove entries.

Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
3 months agoEvaluate the enum's discriminant in a const context
Ryutaro Okada [Sun, 30 Mar 2025 16:28:41 +0000 (09:28 -0700)] 
Evaluate the enum's discriminant in a const context

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 <1015ryu88@gmail.com>
3 months agogccrs: Fix SEGV when type path resolver fails outright
Philip Herron [Fri, 28 Mar 2025 18:59:33 +0000 (18:59 +0000)] 
gccrs: Fix SEGV when type path resolver fails outright

When we resolve paths we resolve to Types first we walk each segment to
the last module which has no type but then in the event that the child
of a module is not found we have a null root_tyty which needs to be caught
and turned into an ErrorType node.

Fixes Rust-GCC#3613

gcc/rust/ChangeLog:

* typecheck/rust-hir-type-check-type.cc (TypeCheckType::resolve_root_path):
catch nullptr root_tyty

gcc/testsuite/ChangeLog:

* rust/compile/issue-3613.rs: New test.

Signed-off-by: Philip Herron <herron.philip@googlemail.com>
3 months agogccrs: fix crash in parse repr options and missing delete call
Philip Herron [Fri, 28 Mar 2025 18:06:14 +0000 (18:06 +0000)] 
gccrs: fix crash in parse repr options and missing delete call

Fixes Rust-GCC#3606

gcc/rust/ChangeLog:

* typecheck/rust-hir-type-check-base.cc (TypeCheckBase::parse_repr_options):
check for null and empty and add missing delete call

gcc/testsuite/ChangeLog:

* rust/compile/issue-3606.rs: New test.

Signed-off-by: Philip Herron <herron.philip@googlemail.com>
3 months agogccrs: fix ice when setting up regions
Philip Herron [Fri, 28 Mar 2025 18:24:57 +0000 (18:24 +0000)] 
gccrs: fix ice when setting up regions

num regions is based on the used arguments of regions which can be
less than the substutions requirements. So lets check for that and allow
anon regions to be created for them.

Fixes Rust-GCC#3605

gcc/rust/ChangeLog:

* typecheck/rust-tyty-subst.h: check for min range

gcc/testsuite/ChangeLog:

* rust/compile/issue-3605.rs: New test.

Signed-off-by: Philip Herron <herron.philip@googlemail.com>
3 months agogccrs: FIX ICE for malformed repr attribute
Philip Herron [Fri, 28 Mar 2025 17:52:51 +0000 (17:52 +0000)] 
gccrs: FIX ICE for malformed repr attribute

Fixes Rust-GCC#3614

gcc/rust/ChangeLog:

* typecheck/rust-hir-type-check-base.cc (TypeCheckBase::parse_repr_options): check for input

gcc/testsuite/ChangeLog:

* rust/compile/issue-3614.rs: New test.

Signed-off-by: Philip Herron <herron.philip@googlemail.com>
3 months agogccrs: FIX ICE when working with HIR::BareFunctionType
Philip Herron [Fri, 28 Mar 2025 17:42:07 +0000 (17:42 +0000)] 
gccrs: FIX ICE when working with HIR::BareFunctionType

Fixes Rust-GCC#3615

gcc/rust/ChangeLog:

* hir/rust-hir-dump.cc (Dump::visit): check has type
* hir/tree/rust-hir-type.cc (BareFunctionType::BareFunctionType): likewise

gcc/testsuite/ChangeLog:

* rust/compile/issue-3615.rs: New test.

Signed-off-by: Philip Herron <herron.philip@googlemail.com>
3 months agogccrs: Fix ICE in array ref constexpr
Philip Herron [Fri, 28 Mar 2025 16:59:33 +0000 (16:59 +0000)] 
gccrs: Fix ICE in array ref constexpr

Since 898d55ad7e2 was fixed to remove the VIEW_CONVERT_EXPR from
array expressions we can now turn on the array element access
const expr.

Fixes Rust-GCC#3563

gcc/rust/ChangeLog:

* backend/rust-constexpr.cc (eval_store_expression): turn this back on

gcc/testsuite/ChangeLog:

* rust/compile/issue-3563.rs: New test.

Signed-off-by: Philip Herron <herron.philip@googlemail.com>
3 months agoAdd ending newline to rust-macro-builtins-log-debug.cc
Owen Avery [Fri, 28 Mar 2025 00:39:00 +0000 (20:39 -0400)] 
Add ending newline to rust-macro-builtins-log-debug.cc

gcc/rust/ChangeLog:

* expand/rust-macro-builtins-log-debug.cc:
Add newline to end of file.

Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
3 months agonr2.0: Rename prelude to lang_prelude
Owen Avery [Thu, 27 Mar 2025 19:30:23 +0000 (15:30 -0400)] 
nr2.0: Rename prelude to lang_prelude

gcc/rust/ChangeLog:

* resolve/rust-forever-stack.h
(ForeverStack::get_prelude): Rename to...
(ForeverStack::get_lang_prelude): ...here.
(ForeverStack::prelude): Rename to...
(ForeverStack::lang_prelude): ...here.
(ForeverStack::ForeverStack): Handle renames.
* resolve/rust-forever-stack.hxx
(ForeverStack::push_inner): Likewise.
(ForeverStack::resolve_segments): Likewise.
(ForeverStack::resolve_path): Likewise.
(ForeverStack::get_prelude): Rename to...
(ForeverStack::get_lang_prelude): ...here and handle renames.
* resolve/rust-late-name-resolver-2.0.cc
(Late::visit): Handle renames.

Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
3 months agonr2.0: Fix test macros/mbe/macro43.rs
Owen Avery [Mon, 24 Mar 2025 01:04:32 +0000 (21:04 -0400)] 
nr2.0: Fix test macros/mbe/macro43.rs

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 <powerboat9.gamer@gmail.com>
3 months agogccrs: Fix ICE during const expr eval on array expressions
Philip Herron [Thu, 27 Mar 2025 17:27:56 +0000 (17:27 +0000)] 
gccrs: Fix ICE during const expr eval on array expressions

Array expressions are still getting turned into VIEW_CONVERT_EXPR's becuase
TYPE_MAIN_VARIANT is not set so then we might as well reuse the type-hasher
to sort this out.

Fixes Rust-GCC#3588

gcc/rust/ChangeLog:

* backend/rust-compile-context.h: only push named types
* backend/rust-compile-type.cc (TyTyResolveCompile::visit): run the type hasher

gcc/testsuite/ChangeLog:

* rust/compile/issue-3588.rs: New test.

Signed-off-by: Philip Herron <herron.philip@googlemail.com>
3 months agogccrs: Fix ICE when compiling path which resolves to trait constant
Philip Herron [Thu, 27 Mar 2025 16:32:21 +0000 (16:32 +0000)] 
gccrs: Fix ICE when compiling path which resolves to trait constant

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 test.

Signed-off-by: Philip Herron <herron.philip@googlemail.com>
3 months agoAdd new test to highlight namespace for self import
Pierre-Emmanuel Patry [Tue, 25 Mar 2025 18:03:00 +0000 (19:03 +0100)] 
Add new test to highlight namespace for self import

gcc/testsuite/ChangeLog:

* rust/compile/self_import_namespace.rs: New test.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
3 months agoUpdate exclusion list
Pierre-Emmanuel Patry [Tue, 25 Mar 2025 17:47:04 +0000 (18:47 +0100)] 
Update exclusion list

gcc/testsuite/ChangeLog:

* rust/compile/nr2/exclude: Remove now passing tests from exclusion
list.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
3 months agoResolve module final self segment in use decls
Pierre-Emmanuel Patry [Mon, 24 Mar 2025 17:31:12 +0000 (18:31 +0100)] 
Resolve module final self segment in use decls

Lowercase self suffix with path was not resolved properly, this should
point to the module right before.

gcc/rust/ChangeLog:

* resolve/rust-forever-stack.hxx: Add a new specialized function
to retrieve the last "real" segment depending on the namespace.
* resolve/rust-forever-stack.h: Add new function prototype.
* resolve/rust-early-name-resolver-2.0.cc (Early::finalize_rebind_import):
Set declared name according to the selected segment, if there is a self
suffix in the use declaration then select the previous segment.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
3 months agogccrs: Give the builtin unit struct an actual locus
Philip Herron [Thu, 27 Mar 2025 15:15:08 +0000 (15:15 +0000)] 
gccrs: Give the builtin unit struct an actual locus

This has been a pet peeve of mine for a while because the gimple never
emitted the struct () name properly it was always empty which for record
types they always require a real locus or they dont get a proper name.

gcc/rust/ChangeLog:

* backend/rust-compile-base.cc (HIRCompileBase::unit_expression): pass ctx
* backend/rust-compile-base.h: cant be static
* backend/rust-compile-intrinsic.cc (try_handler_inner): pass ctx
* backend/rust-compile-type.cc
(TyTyResolveCompile::get_unit_type): update to grab the first locus
(TyTyResolveCompile::visit): pass ctx
* backend/rust-compile-type.h: likewise

Signed-off-by: Philip Herron <herron.philip@googlemail.com>
3 months agogccrs: Fix ICE when doing method resolution on trait predicates
Philip Herron [Thu, 27 Mar 2025 14:22:48 +0000 (14:22 +0000)] 
gccrs: Fix ICE when doing method resolution on trait predicates

We need to ensure we are adding methods to the possible candidates.

Fixes Rust-GCC#3554

gcc/rust/ChangeLog:

* typecheck/rust-hir-dot-operator.cc:

gcc/testsuite/ChangeLog:

* rust/compile/issue-3554-1.rs: New test.
* rust/compile/issue-3554-2.rs: New test.

Signed-off-by: Philip Herron <herron.philip@googlemail.com>
3 months agogccrs: Fix ICE when using super mid way though path
Philip Herron [Wed, 26 Mar 2025 17:26:12 +0000 (17:26 +0000)] 
gccrs: Fix ICE when using super mid way though path

Fixes Rust-GCC#3568

gcc/rust/ChangeLog:

* resolve/rust-ast-resolve-path.cc (ResolvePath::resolve_path): check for super mid path

gcc/testsuite/ChangeLog:

* rust/compile/nr2/exclude: nr2 puts out a different error multiple times
* rust/compile/issue-3568.rs: New test.

Signed-off-by: Philip Herron <herron.philip@googlemail.com>
3 months agogccrs: Fix ICE when compiling block expressions in array capacity
Philip Herron [Thu, 27 Mar 2025 12:04:41 +0000 (12:04 +0000)] 
gccrs: Fix ICE when compiling block expressions in array capacity

We need to reuse the existing compile_constant_item helper which handles
the case if this is a simple expression, fn-call or a block expression.
The patch extracts out this helper as a static method so this can be used
in more places.

Fixes Rust-GCC#3566

gcc/rust/ChangeLog:

* backend/rust-compile-base.cc (HIRCompileBase::address_expression): new helper constexpr
* backend/rust-compile-base.h: prototype
* backend/rust-compile-type.cc (TyTyResolveCompile::visit): call constexpr helper

gcc/testsuite/ChangeLog:

* rust/compile/issue-3566-1.rs: New test.
* rust/compile/issue-3566-2.rs: New test.

Signed-off-by: Philip Herron <herron.philip@googlemail.com>
3 months agogccrs: Add check for super traits being implemented by Self
Philip Herron [Wed, 26 Mar 2025 19:00:41 +0000 (19:00 +0000)] 
gccrs: Add check for super traits being implemented by Self

We need to recursively check the super traits of the predicate the Self
type is trying to implement. Otherwise its cannot implement it.

Fixes Rust-GCC#3553

gcc/rust/ChangeLog:

* typecheck/rust-hir-type-check-item.cc (TypeCheckItem::resolve_impl_block_substitutions):
Track the polarity
* typecheck/rust-tyty-bounds.cc (TypeBoundPredicate::validate_type_implements_this):
new validator
* typecheck/rust-tyty.h: new prototypes

gcc/testsuite/ChangeLog:

* rust/compile/issue-3553.rs: New test.

Signed-off-by: Philip Herron <herron.philip@googlemail.com>
3 months agogccrs: Fix ICE when array elements are not a value
Philip Herron [Wed, 26 Mar 2025 17:11:36 +0000 (17:11 +0000)] 
gccrs: Fix ICE when array elements are not a value

We need to check for error_mark_node when doing adjustments from coercion
sites otherwise we hit assetions as part of the coercion. That fixes the
ICE but the reason for the error_mark_node is because the array element
value.

Fixes Rust-GCC#3567

gcc/rust/ChangeLog:

* backend/rust-compile-expr.cc (CompileExpr::array_value_expr): add value chk for array expr

gcc/testsuite/ChangeLog:

* rust/compile/issue-3567.rs: New test.

Signed-off-by: Philip Herron <herron.philip@googlemail.com>
3 months agoFix core library test with proper canonical path
Pierre-Emmanuel Patry [Wed, 26 Mar 2025 14:22:28 +0000 (15:22 +0100)] 
Fix core library test with proper canonical path

Import from core library was wrong, it misses several crate directives
since we're no longer dealing with multiple files.

gcc/testsuite/ChangeLog:

* rust/compile/issue-2905-2.rs: Import from core library into a single
file misses the crate directives.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
3 months agogccrs: fix unconstrained infer vars on generic associated type
Philip Herron [Wed, 26 Mar 2025 14:05:03 +0000 (14:05 +0000)] 
gccrs: fix unconstrained infer vars on generic associated type

The trick here is that when Bar::test is resolved it resolves to the
trait method:

  fn <Bar<i32>, T> (placeholder) -> placeholder

Which is fine so we need to setup the associated types for Bar<i32> which
means looking up the associated impl block then setting up the projection
of A = T so it becomes:

  fn <Bar<i32>, T> (placeholder: projection<T>:T)
    -> placeholder: projection<T>:T

But previously it was auto injecting inference variables so it became:

  fn <Bar<i32>, T> (placeholder: projection<T>:?T)
    -> placeholder: projection<T>:?T

The issue is that the binding of the generics was still T so this caused
inference variables to be injected again but unlinked. A possible tweak
would be that we are substituting again with new infer vars to actually
just unify them enplace so they are all part of the chain. This still
might be needed but lets hold off for now.

So basically when we are Path probing we dont allow GAT's to generate new
inference vars because they wont be bound to this current segment which
just causes confusion.

Fixes Rust-GCC#3242

gcc/rust/ChangeLog:

* typecheck/rust-hir-trait-reference.h: add default infer arg
* typecheck/rust-hir-trait-resolve.cc: dont add new infer vars
* typecheck/rust-hir-type-check-path.cc (TypeCheckExpr::resolve_segments): dont infer

gcc/testsuite/ChangeLog:

* rust/compile/issue-3242.rs: no longer skip the test

Signed-off-by: Philip Herron <herron.philip@googlemail.com>
3 months agoFix validation of constant items
Owen Avery [Tue, 25 Mar 2025 22:18:21 +0000 (18:18 -0400)] 
Fix validation of constant items

gcc/rust/ChangeLog:

* checks/errors/rust-ast-validation.cc
(ASTValidation::visit): Allow constant items lacking expressions
if and only if they're associated with a trait definition, not a
trait implementation.

gcc/testsuite/ChangeLog:

* rust/compile/issue-3541-1.rs: New test.
* rust/compile/issue-3541-2.rs: Likewise.

Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
3 months agotestsuite: Add more testcases for cfg() in core
Arthur Cohen [Fri, 7 Mar 2025 13:26:59 +0000 (13:26 +0000)] 
testsuite: Add more testcases for cfg() in core

gcc/testsuite/ChangeLog:

* rust/compile/cfg-core1.rs: New test.
* rust/compile/cfg-core2.rs: New test.

3 months agoLower raw string literals
Owen Avery [Tue, 25 Mar 2025 22:50:56 +0000 (18:50 -0400)] 
Lower raw string literals

gcc/rust/ChangeLog:

* hir/rust-ast-lower-base.cc
(ASTLoweringBase::lower_literal): Lower raw string literals into
normal string literals.

gcc/testsuite/ChangeLog:

* rust/compile/issue-3549.rs: New test.

Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
3 months agorust: Lower minimum supported Rust version to 1.49
Arthur Cohen [Mon, 24 Mar 2025 14:32:51 +0000 (15:32 +0100)] 
rust: Lower minimum supported Rust version to 1.49

gcc/rust/ChangeLog:

* checks/errors/borrowck/ffi-polonius/Cargo.lock: Regenerate.
* checks/errors/borrowck/ffi-polonius/Cargo.toml: Update to use source patching instead of
vendoring, lower edition to 2018.
* checks/errors/borrowck/ffi-polonius/vendor/log/Cargo.toml: Change edition to 2018.
* checks/errors/borrowck/ffi-polonius/vendor/log/src/lib.rs: Remove uses of unstable
feature.
* checks/errors/borrowck/ffi-polonius/.cargo/config.toml: Removed.

libgrust/ChangeLog:

* libformat_parser/Makefile.am: Avoid using --config as it is unsupported by cargo 1.49.
* libformat_parser/Makefile.in: Regenerate.
* libformat_parser/generic_format_parser/src/lib.rs: Use extension trait for missing
features.
* libformat_parser/src/lib.rs: Likewise.
* libformat_parser/.cargo/config: Moved to...
* libformat_parser/.cargo/config.toml: ...here.

3 months agonr2.0: Fix test const_generics_3.rs
Owen Avery [Thu, 20 Mar 2025 16:17:20 +0000 (12:17 -0400)] 
nr2.0: Fix test const_generics_3.rs

gcc/testsuite/ChangeLog:

* rust/compile/const_generics_3.rs: Modify test to run with name
resolution 2.0 only and to handle the absence of a bogus
resolution error.
* rust/compile/nr2/exclude: Remove const_generics_3.rs.

Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
3 months agolower: Handle let-else properly
Arthur Cohen [Wed, 5 Mar 2025 15:36:19 +0000 (15:36 +0000)] 
lower: Handle let-else properly

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.

3 months agoname-resolution: Handle let-else properly
Arthur Cohen [Wed, 5 Mar 2025 15:34:25 +0000 (15:34 +0000)] 
name-resolution: Handle let-else properly

gcc/rust/ChangeLog:

* resolve/rust-ast-resolve-stmt.h: Add handling for diverging else.
* resolve/rust-late-name-resolver-2.0.cc (Late::visit): Likewise.

3 months agodump: Handle let-else properly
Arthur Cohen [Wed, 5 Mar 2025 15:33:31 +0000 (15:33 +0000)] 
dump: Handle let-else properly

gcc/rust/ChangeLog:

* ast/rust-ast-collector.cc (TokenCollector::visit): Add handling for diverging else
expression.

3 months agoparser: Parse let-else statements
Arthur Cohen [Wed, 5 Mar 2025 15:30:04 +0000 (15:30 +0000)] 
parser: Parse let-else statements

gcc/rust/ChangeLog:

* parse/rust-parse-impl.h (Parser::parse_let_stmt): Add new parsing in case of `else` token.

3 months agoast: Add optional diverging else to AST::LetStmt
Arthur Cohen [Wed, 5 Mar 2025 15:31:56 +0000 (15:31 +0000)] 
ast: Add optional diverging else to AST::LetStmt

gcc/rust/ChangeLog:

* ast/rust-stmt.h (class LetStmt): Add optional expression for diverging else.
* ast/rust-ast-builder.cc (Builder::let): Use new API.

3 months agoRemove now passing test from exclusion list
Pierre-Emmanuel Patry [Thu, 20 Mar 2025 16:13:36 +0000 (17:13 +0100)] 
Remove now passing test from exclusion list

Those tests were malformed and failed with the new name resolution
because of it.

gcc/testsuite/ChangeLog:

* rust/compile/nr2/exclude: Remove test from exclusion list.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
3 months agoFix testcase module path
Pierre-Emmanuel Patry [Thu, 20 Mar 2025 14:10:07 +0000 (15:10 +0100)] 
Fix testcase module path

Those tests are coming from libcore and module inlining was wrong, in
libcore there was a use declaration to import those modules which was
missing here.

gcc/testsuite/ChangeLog:

* rust/compile/issue-2330.rs: Use complete path from crate root.
* rust/compile/issue-1901.rs: Likewise.
* rust/compile/issue-1981.rs: Likewise.
* rust/compile/iterators1.rs: Likewise.
* rust/compile/sizeof-stray-infer-var-bug.rs: Likewise.
* rust/compile/for-loop1.rs: Likewise.
* rust/compile/for-loop2.rs: Likewise.
* rust/compile/torture/builtin_abort.rs: Likewise.
* rust/compile/torture/uninit-intrinsic-1.rs: Likewise.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
3 months agoFix function name to printf
Pierre-Emmanuel Patry [Thu, 20 Mar 2025 16:26:55 +0000 (17:26 +0100)] 
Fix function name to printf

Function could not be found and triggered an error message.

gcc/testsuite/ChangeLog:

* rust/compile/feature_rust_attri0.rs: Add extern
function declaration and change name to printf.
* rust/compile/nr2/exclude: Remove now passing test from exclusion
list.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
3 months agoci: disable network
Sam James [Mon, 17 Mar 2025 17:17:43 +0000 (17:17 +0000)] 
ci: disable network

Disable network access via 'unshare' in two CI workflows to catch issues
like PR119333 where importing polonius meant bootstrap tried to pull crates
from the internet.

ChangeLog:
PR rust/119333

* .github/workflows/bootstrap.yml: Disable network via 'unshare'.
* .github/workflows/ccpp.yml: Ditto.

3 months agogccrs: support generic super traits recursively
Philip Herron [Sat, 22 Mar 2025 17:40:48 +0000 (17:40 +0000)] 
gccrs: support generic super traits recursively

In order to handle generic super traits on any trait bound we need to ensure
we track the TypeBoundPredicate as part of the TraitReference instead of just
the raw TraitReferences because these will have any applied generics enplace.

Then for any TypeBoundPredicate it takes a copy of the super traits because
this is the usage of a TraitBound and we can apply generics which then need
to be recursively applied up the chain of super predicates.

The main tweak is around TypeBoundPredicate::lookup_associated_item because
we need to associate the predicate with the item we are looking up so the caller
can respect the generics correctly as well.

Fixes Rust-GCC#3502

gcc/rust/ChangeLog:

* typecheck/rust-hir-path-probe.cc: update call
* typecheck/rust-hir-trait-reference.cc (TraitReference::lookup_trait_item): track predicate
(TraitReference::is_equal): likewise
(TraitReference::is_object_safe): likewise
(TraitReference::satisfies_bound): likewise
* typecheck/rust-hir-trait-reference.h: likewise
* typecheck/rust-hir-trait-resolve.cc (TraitResolver::resolve_trait): likewise
* typecheck/rust-tyty-bounds.cc (TypeBoundPredicate::TypeBoundPredicate): track super traits
(TypeBoundPredicate::operator=): likewise
(TypeBoundPredicate::apply_generic_arguments): ensure we apply to super predicates
(TypeBoundPredicateItem::operator=): take copy of parent predicate
(TypeBoundPredicateItem::error): pass error instead of nullptr
(TypeBoundPredicateItem::is_error): update to no longer check for nullptr
(TypeBoundPredicateItem::get_parent): updated
(TypeBoundPredicateItem::get_tyty_for_receiver): likewise
(TypeBoundPredicate::get_associated_type_items): likewise
* typecheck/rust-tyty-bounds.h (class TypeBoundPredicateItem): move
* typecheck/rust-tyty-subst.cc: flag to handle placeholder Self on traits
* typecheck/rust-tyty-subst.h (class TypeBoundPredicateItem): likewise
* typecheck/rust-tyty.h (class TypeBoundPredicateItem): refactored

gcc/testsuite/ChangeLog:

* rust/execute/torture/issue-3502.rs: New test.

Signed-off-by: Philip Herron <herron.philip@googlemail.com>
3 months agonr2.0: Fix StructExprFieldIdentifier handling
Owen Avery [Mon, 3 Mar 2025 01:03:12 +0000 (20:03 -0500)] 
nr2.0: Fix StructExprFieldIdentifier handling

gcc/rust/ChangeLog:

* resolve/rust-late-name-resolver-2.0.cc
(Late::visit): Add visitor for StructExprFieldIdentifier.
* resolve/rust-late-name-resolver-2.0.h
(Late::visit): Likewise.

gcc/testsuite/ChangeLog:

* rust/compile/nr2/exclude: Remove entries.

Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
3 months agorust: force cargo to build offline
Marc Poulhiès [Mon, 17 Mar 2025 18:23:50 +0000 (19:23 +0100)] 
rust: force cargo to build offline

gcc/rust/Changelog:
PR rust/119333

* Make-lang.in: Force offline mode for cargo

Signed-off-by: Marc Poulhiès <dkm@kataplop.net>
3 months agopolonius: Vendor Rust dependencies
Arthur Cohen [Tue, 18 Mar 2025 10:39:54 +0000 (11:39 +0100)] 
polonius: Vendor Rust dependencies

This fixes PR #119333 by allowing our borrow-checker interface to be built
offline. This was already done for our components in libgrust/, but had never been
done for the borrow-checker.

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=119333

gcc/rust/ChangeLog:

* checks/errors/borrowck/ffi-polonius/.cargo/config.toml: New file, force vendored deps.
* checks/errors/borrowck/ffi-polonius/vendor/datafrog/.cargo-checksum.json: New file.
* checks/errors/borrowck/ffi-polonius/vendor/datafrog/CODE_OF_CONDUCT.md: New file.
* checks/errors/borrowck/ffi-polonius/vendor/datafrog/Cargo.toml: New file.
* checks/errors/borrowck/ffi-polonius/vendor/datafrog/LICENSE-APACHE: New file.
* checks/errors/borrowck/ffi-polonius/vendor/datafrog/LICENSE-MIT: New file.
* checks/errors/borrowck/ffi-polonius/vendor/datafrog/README.md: New file.
* checks/errors/borrowck/ffi-polonius/vendor/datafrog/RELEASES.md: New file.
* checks/errors/borrowck/ffi-polonius/vendor/datafrog/examples/borrow_check.rs: New file.
* checks/errors/borrowck/ffi-polonius/vendor/datafrog/examples/graspan1.rs: New file.
* checks/errors/borrowck/ffi-polonius/vendor/datafrog/src/join.rs: New file.
* checks/errors/borrowck/ffi-polonius/vendor/datafrog/src/lib.rs: New file.
* checks/errors/borrowck/ffi-polonius/vendor/datafrog/src/map.rs: New file.
* checks/errors/borrowck/ffi-polonius/vendor/datafrog/src/test.rs: New file.
* checks/errors/borrowck/ffi-polonius/vendor/datafrog/src/treefrog.rs: New file.
* checks/errors/borrowck/ffi-polonius/vendor/log/.cargo-checksum.json: New file.
* checks/errors/borrowck/ffi-polonius/vendor/log/CHANGELOG.md: New file.
* checks/errors/borrowck/ffi-polonius/vendor/log/Cargo.toml: New file.
* checks/errors/borrowck/ffi-polonius/vendor/log/LICENSE-APACHE: New file.
* checks/errors/borrowck/ffi-polonius/vendor/log/LICENSE-MIT: New file.
* checks/errors/borrowck/ffi-polonius/vendor/log/README.md: New file.
* checks/errors/borrowck/ffi-polonius/vendor/log/benches/value.rs: New file.
* checks/errors/borrowck/ffi-polonius/vendor/log/src/__private_api.rs: New file.
* checks/errors/borrowck/ffi-polonius/vendor/log/src/kv/error.rs: New file.
* checks/errors/borrowck/ffi-polonius/vendor/log/src/kv/key.rs: New file.
* checks/errors/borrowck/ffi-polonius/vendor/log/src/kv/mod.rs: New file.
* checks/errors/borrowck/ffi-polonius/vendor/log/src/kv/source.rs: New file.
* checks/errors/borrowck/ffi-polonius/vendor/log/src/kv/value.rs: New file.
* checks/errors/borrowck/ffi-polonius/vendor/log/src/lib.rs: New file.
* checks/errors/borrowck/ffi-polonius/vendor/log/src/macros.rs: New file.
* checks/errors/borrowck/ffi-polonius/vendor/log/src/serde.rs: New file.
* checks/errors/borrowck/ffi-polonius/vendor/log/triagebot.toml: New file.
* checks/errors/borrowck/ffi-polonius/vendor/polonius-engine/.cargo-checksum.json: New file.
* checks/errors/borrowck/ffi-polonius/vendor/polonius-engine/Cargo.toml: New file.
* checks/errors/borrowck/ffi-polonius/vendor/polonius-engine/README.md: New file.
* checks/errors/borrowck/ffi-polonius/vendor/polonius-engine/src/facts.rs: New file.
* checks/errors/borrowck/ffi-polonius/vendor/polonius-engine/src/lib.rs: New file.
* checks/errors/borrowck/ffi-polonius/vendor/polonius-engine/src/output/datafrog_opt.rs:
New file.
* checks/errors/borrowck/ffi-polonius/vendor/polonius-engine/src/output/initialization.rs:
New file.
* checks/errors/borrowck/ffi-polonius/vendor/polonius-engine/src/output/liveness.rs:
New file.
* checks/errors/borrowck/ffi-polonius/vendor/polonius-engine/src/output/location_insensitive.rs:
New file.
* checks/errors/borrowck/ffi-polonius/vendor/polonius-engine/src/output/mod.rs: New file.
* checks/errors/borrowck/ffi-polonius/vendor/polonius-engine/src/output/naive.rs: New file.
* checks/errors/borrowck/ffi-polonius/vendor/rustc-hash/.cargo-checksum.json: New file.
* checks/errors/borrowck/ffi-polonius/vendor/rustc-hash/CODE_OF_CONDUCT.md: New file.
* checks/errors/borrowck/ffi-polonius/vendor/rustc-hash/Cargo.toml: New file.
* checks/errors/borrowck/ffi-polonius/vendor/rustc-hash/LICENSE-APACHE: New file.
* checks/errors/borrowck/ffi-polonius/vendor/rustc-hash/LICENSE-MIT: New file.
* checks/errors/borrowck/ffi-polonius/vendor/rustc-hash/README.md: New file.
* checks/errors/borrowck/ffi-polonius/vendor/rustc-hash/src/lib.rs: New file.

3 months agonr2.0: Adjust indentifier expression handling
Owen Avery [Wed, 19 Mar 2025 00:28:25 +0000 (20:28 -0400)] 
nr2.0: Adjust indentifier expression handling

gcc/rust/ChangeLog:

* resolve/rust-late-name-resolver-2.0.cc
(Late::visit): Make sure to return early after a resolution
error, improve the resolution error message, fix a typo, handle
ambiguous resolutions, and remove an old comment.

gcc/testsuite/ChangeLog:

* rust/compile/nr2/exclude: Remove entries.

Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>