aboutsummaryrefslogtreecommitdiff
path: root/gcc/rust
AgeCommit message (Collapse)AuthorFilesLines
11 daysDaily bump.GCC Administrator1-0/+5
13 daysrust: Silence a clang warning in borrow-checker-diagnosticsMartin Jambor1-1/+1
When compiling gcc/rust/checks/errors/borrowck/rust-borrow-checker-diagnostics.cc with clang, it emits the following warning: gcc/rust/checks/errors/borrowck/rust-borrow-checker-diagnostics.cc:145:46: warning: non-constant-expression cannot be narrowed from type 'Polonius::Loan' (aka 'unsigned long') to 'uint32_t' (aka 'unsigned int') in initializer list [-Wc++11-narrowing] I'd hope that for indexing that is never really a problem, nevertheless if narrowing is taking place, I guess it can be argued it should be made explicit. gcc/rust/ChangeLog: 2025-06-23 Martin Jambor <mjambor@suse.cz> * checks/errors/borrowck/rust-borrow-checker-diagnostics.cc (BorrowCheckerDiagnostics::get_loan): Type cast loan to uint32_t.
2025-04-29Daily bump.GCC Administrator1-0/+353
2025-04-28gccrs: Fix narrowing conversion warningsOwen Avery2-23/+29
Fixes PR#119641 gcc/rust/ChangeLog: * checks/errors/borrowck/rust-bir-place.h (IndexVec::size_type): Add. (IndexVec::MAX_INDEX): Add. (IndexVec::size): Change the return type to the type of the internal value used by the index type. (PlaceDB::lookup_or_add_variable): Use the return value from the PlaceDB::add_place call. * checks/errors/borrowck/rust-bir.h (struct BasicBlockId): Move this definition before the definition of the struct Function. Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
2025-04-28gccrs: Visit visibility in UseDeclarationPierre-Emmanuel Patry1-0/+1
Default visitor should visit all it's children. gcc/rust/ChangeLog: * ast/rust-ast-visitor.cc (DefaultASTVisitor::visit): Visit visibility. Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
2025-04-28gccrs: Some assorted tweaks and bug fixesOwen Avery3-5/+5
gcc/rust/ChangeLog: * ast/rust-ast-visitor.cc (DefaultASTVisitor::visit): Visit the loop labels of WhileLetLoopExpr instances before visiting their scrutinee expressions. * resolve/rust-early-name-resolver-2.0.cc (Early::resolve_glob_import): Pass the glob import's path directly to NameResolutionContext::resolve_path. * resolve/rust-toplevel-name-resolver-2.0.cc (TopLevel::visit): Remove unnecessary call to Identifier::as_string. (flatten_glob): Improve handling of cases where a glob use tree has no path. Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
2025-04-28gccrs: Completely duplicate path nodePierre-Emmanuel Patry1-1/+7
Both nodes had the same id, this led to a resolution conflict. gcc/rust/ChangeLog: * expand/rust-derive-clone.cc (DeriveClone::clone_enum_struct): Clone path to avoid using the same nodeid. gcc/testsuite/ChangeLog: * rust/compile/nr2/exclude: Remove now passing test from exclusion list. Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
2025-04-28gccrs: Use specialized param visit function for paramsPierre-Emmanuel Patry4-28/+20
This commit introduce a new public function to visit function parameters in the default visitor. It allows visitors derived from DefaultVisitor to override only a small part of the default visitor. gcc/rust/ChangeLog: * ast/rust-ast-visitor.cc (DefaultASTVisitor::visit_function_params): Add specialized function to visit function parameters. (DefaultASTVisitor::visit): Remove parameter visit and call specialized function instead. * ast/rust-ast-visitor.h: Add function prototye. * resolve/rust-late-name-resolver-2.0.cc (Late::visit): Remove function. (Late::visit_function_params): Override specialized visit function. * resolve/rust-late-name-resolver-2.0.h: Add overriden function prototype. Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
2025-04-28gccrs: Use stacked context for nested bindings.Pierre-Emmanuel Patry4-71/+113
Binding context may be stacked when a new binding group is introduced within a const expression. gcc/rust/ChangeLog: * resolve/rust-name-resolution-context.h: Use BindingLayer instead. * resolve/rust-name-resolution-context.cc (BindingLayer::BindingLayer): Add new constructor for binding layer. (BindingLayer::bind_test): Add a function to test a binding constraint. (BindingLayer::push): Push a new binding group. (BindingLayer::and_binded): Add function to test and-binding constraint. (BindingLayer::or_binded): Add function to test or-binding constraints. (BindingLayer::insert_ident): Insert a new identifier in the current binding group. (BindingLayer::merge): Merge current binding group with it's parent. (BindingLayer::get_source): Get the source of the current binding group. * resolve/rust-late-name-resolver-2.0.cc: Use stacked context for binding group. * util/rust-stacked-contexts.h: Add mutable peek function. Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
2025-04-28gccrs: Add pattern bindingsPierre-Emmanuel Patry3-5/+156
gcc/rust/ChangeLog: * resolve/rust-late-name-resolver-2.0.cc (Late::visit): Add binding creation in visitor. * resolve/rust-late-name-resolver-2.0.h: Add function prototypes. * resolve/rust-name-resolution-context.h: Add binding context. Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
2025-04-28gccrs: Add binding context classPierre-Emmanuel Patry1-0/+81
We need to differentiate bindings types, so the same binding cannot be reused multiple time in a product binding. gcc/rust/ChangeLog: * resolve/rust-name-resolution-context.h (struct Binding): Add Binding struct to differentiate Or and Product bindings in patterns. (enum class): Add Binding kind. (class BindingContext): Add binding context with Binding stack. Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
2025-04-28gccrs: Add hash function for IdentifiersPierre-Emmanuel Patry1-0/+13
gcc/rust/ChangeLog: * ast/rust-ast.h: Add hash function. Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
2025-04-28gccrs: Add equality operator for identifiersPierre-Emmanuel Patry1-0/+5
gcc/rust/ChangeLog: * ast/rust-ast.h: Add equality operator. Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
2025-04-28gccrs: Prevent forward declaration in type parametersPierre-Emmanuel Patry4-0/+33
gcc/rust/ChangeLog: * resolve/rust-default-resolver.cc (DefaultResolver::visit): Add visit function for TypeParam. * resolve/rust-default-resolver.h: Add function prototype. * resolve/rust-forever-stack.h: Add function to check for forward declaration ban. * resolve/rust-late-name-resolver-2.0.cc (Late::visit): Check forward declarations. Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
2025-04-28gccrs: Remove error state for GenericArgPierre-Emmanuel Patry8-45/+35
gcc/rust/ChangeLog: * ast/rust-ast-collector.cc (TokenCollector::visit): Remove error kind and change function call. * ast/rust-ast-visitor.cc (DefaultASTVisitor::visit): Change call name. * ast/rust-path.cc (ConstGenericParam::as_string): Likewise. * ast/rust-path.h: Remove error kind. * hir/rust-ast-lower-type.cc (ASTLowerGenericParam::visit): Change call name. * parse/rust-parse-impl.h (Parser::parse_generic_param): Use optional on parsing failure. (Parser::parse_generic_arg): Likewise. (Parser::parse_path_generic_args): Likewise. * parse/rust-parse.h: Likewise. * resolve/rust-ast-resolve-type.h: Change call name. Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
2025-04-28gccrs: Change error message to match expected test outputPierre-Emmanuel Patry1-2/+2
gcc/rust/ChangeLog: * resolve/rust-late-name-resolver-2.0.cc (Late::visit): Change error message. gcc/testsuite/ChangeLog: * rust/compile/nr2/exclude: Remove passing test from exclusion list. Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
2025-04-28gccrs: nr2.0: Improve error handlingOwen Avery5-48/+115
gcc/rust/ChangeLog: * resolve/rust-early-name-resolver-2.0.cc (Early::build_import_mapping): Avoid outputting an "unresolved import" error if other errors are outputted during resolution. * resolve/rust-early-name-resolver-2.0.h (Early::resolve_path_in_all_ns): Collect path resolution errors while avoiding duplicate errors for resolutions in each namespace. * resolve/rust-forever-stack.h (ForeverStack::resolve_path): Add parameter for collecting errors. (ForeverStack::find_starting_point): Likewise. (ForeverStack::resolve_segments): Likewise. * resolve/rust-forever-stack.hxx (check_leading_kw_at_start): Likewise. (ForeverStack::find_starting_point): Likewise. (ForeverStack::resolve_segments): Likewise. (ForeverStack::resolve_path): Likewise. * resolve/rust-name-resolution-context.h (NameResolutionContext::resolve_path): Add optional parameter for collecting errors. gcc/testsuite/ChangeLog: * rust/compile/nr2/exclude: Remove entry. Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
2025-04-28gccrs: prealloc the initilizer vectorPhilip Herron1-0/+4
There are two cases when initilizing an array, this is the const context which means we need to build the array ctor, which means using lots of memory, its super inefficient because we are using a big wrapper over the GCC internals here but preallocating the vectors here causes a: terminate called after throwing an instance of 'std::bad_alloc' So this is a handy error condition to rely on for this senario. Fixes Rust-GCC#3713 Fixes Rust-GCC#3727 gcc/rust/ChangeLog: * backend/rust-compile-expr.cc (CompileExpr::array_copied_expr): prealloc the vector Signed-off-by: Philip Herron <herron.philip@googlemail.com>
2025-04-28gccrs: Fix ICE with empty generic argumentsPhilip Herron2-2/+4
We have an assertion when accessing generic args if there are any which is really useful so this adds the missing guards for the case where they are specified but empty. Fixes Rust-GCC#3649 gcc/rust/ChangeLog: * ast/rust-ast-visitor.cc (DefaultASTVisitor::visit): add guard * expand/rust-expand-visitor.cc (ExpandVisitor::visit): add guard gcc/testsuite/ChangeLog: * rust/compile/nr2/exclude: nr2 is missing error for this * rust/compile/issue-3649.rs: New test. Signed-off-by: Philip Herron <herron.philip@googlemail.com>
2025-04-28gccrs: Adjust segment start position errorsOwen Avery3-10/+8
gcc/rust/ChangeLog: * resolve/rust-ast-resolve-path.cc (ResolvePath::resolve_path): Adjust error messages. * resolve/rust-ast-resolve-type.cc (ResolveRelativeTypePath::go): Likewise. * resolve/rust-forever-stack.hxx (check_leading_kw_at_start): Likewise. gcc/testsuite/ChangeLog: * rust/compile/issue-3568.rs: Adjust expected errors. * rust/compile/name_resolution9.rs: Likewise. * rust/compile/self-path2.rs: Likewise. Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
2025-04-28gccrs: Fix ICE when handling case of unknown field in HIR::FieldAccessPhilip Herron1-10/+8
We were wrongly adding the assertion that this must not be an enum but this is a pointless assertion we only care that there are variant in the ADT and if the field exists in the first variant. Fixes Rust-GCC#3581 gcc/rust/ChangeLog: * typecheck/rust-hir-type-check-expr.cc (TypeCheckExpr::visit): fix bad assertion gcc/testsuite/ChangeLog: * rust/compile/nonexistent-field.rs: fix bad error message * rust/compile/issue-3581-1.rs: New test. * rust/compile/issue-3581-2.rs: New test. Signed-off-by: Philip Herron <herron.philip@googlemail.com>
2025-04-28gccrs: nr2.0: Remove unnecessary copy of NodeOwen Avery1-1/+1
gcc/rust/ChangeLog: * resolve/rust-forever-stack.hxx (ForeverStack::resolve_path): Pass instance of Node to lambda by reference instead of by value. Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
2025-04-28gccrs: Fix ICE in struct expressionsPhilip Herron2-27/+30
The error handling here was done long ago when we didnt know how to do any error handling very well. This removed bad fatal_errors and adds in some nice rich_location error diagnostics instead. Fixes Rust-GCC#3628 gcc/rust/ChangeLog: * typecheck/rust-hir-type-check-struct-field.h: keep reference to parent expression * typecheck/rust-hir-type-check-struct.cc (TypeCheckStructExpr::TypeCheckStructExpr): update ctor (TypeCheckStructExpr::resolve): remove bad rust_fatal_errors (TypeCheckStructExpr::visit): cleanup errors gcc/testsuite/ChangeLog: * rust/compile/macros/mbe/macro-issue2983_2984.rs: cleanup error diagnotics * rust/compile/struct_init1.rs: likewise * rust/compile/issue-3628.rs: New test. Signed-off-by: Philip Herron <herron.philip@googlemail.com>
2025-04-28gccrs: nr2.0: Handle StructPatternFieldIdentOwen Avery2-0/+9
gcc/rust/ChangeLog: * resolve/rust-late-name-resolver-2.0.cc (Late::visit): Handle StructPatternFieldIdent. * resolve/rust-late-name-resolver-2.0.h (Late::visit): Likewise. gcc/testsuite/ChangeLog: * rust/compile/nr2/exclude: Remove entry. Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
2025-04-28gccrs: Add LlvmInlineAsm node dumpPierre-Emmanuel Patry1-1/+38
gcc/rust/ChangeLog: * ast/rust-ast-collector.cc (TokenCollector::visit): Dump llvm inline asm tokens. Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
2025-04-28gccrs: Parse and lower llvm asm nodePierre-Emmanuel Patry36-17/+576
Add a new HIR LlvmInlineAsm HIR node as well as some structures to represent it's options and operands. Lower AST::LlvmInlineAsm node to it and then create a tree from that node. gcc/rust/ChangeLog: * ast/rust-ast-collector.cc (TokenCollector::visit): Remove unreachable code. * ast/rust-expr.h (struct LlvmOperand): Add LlvmOperand struct to represent input and outputs. (class LlvmInlineAsm): Add input, output and clobber operands. (struct TupleTemplateStr): Add locus getter. * backend/rust-compile-block.h: Add visit for LlvmInlineAsm. * backend/rust-compile-expr.cc (CompileExpr::visit): Add llvm inline asm stmt compilation. * backend/rust-compile-expr.h: Add function prototype. * backend/rust-compile-asm.h (class CompileLlvmAsm): Add llvm asm hir not to gimple. * backend/rust-compile-asm.cc (CompileLlvmAsm::CompileLlvmAsm): Add constructor. (CompileLlvmAsm::construct_operands): Add function to construct operand tree. (CompileLlvmAsm::construct_clobbers): Add function to construct clobber tree. (CompileLlvmAsm::tree_codegen_asm): Generate the whole tree for a given llvm inline assembly node. * checks/errors/borrowck/rust-bir-builder-expr-stmt.cc (ExprStmtBuilder::visit): Add visit function. * checks/errors/borrowck/rust-bir-builder-expr-stmt.h: Add function prototype. * checks/errors/borrowck/rust-bir-builder-lazyboolexpr.h: Add visit function. * checks/errors/borrowck/rust-bir-builder-struct.h: Likewise. * checks/errors/borrowck/rust-function-collector.h: Likewise. * checks/errors/privacy/rust-privacy-reporter.cc (PrivacyReporter::visit): Likewise. * checks/errors/privacy/rust-privacy-reporter.h: Add visit function prototype. * checks/errors/rust-const-checker.cc (ConstChecker::visit): Add visit function. * checks/errors/rust-const-checker.h: Add visit function prototype. * checks/errors/rust-hir-pattern-analysis.cc (PatternChecker::visit): Add visit function. * checks/errors/rust-hir-pattern-analysis.h: Add visit function prototype. * checks/errors/rust-unsafe-checker.cc (UnsafeChecker::visit): Add visit function. * checks/errors/rust-unsafe-checker.h: Add function prototype. * expand/rust-macro-builtins-asm.cc (parse_llvm_templates): Parse templates. (parse_llvm_arguments): Add function to parse non template tokens. (parse_llvm_operands): Add function to parse operands, either input or output. (parse_llvm_outputs): Add function to parse and collect llvm asm outputs. (parse_llvm_inputs): Likewise with inputs. (parse_llvm_clobbers): Add function to parse llvm asm clobbers. (parse_llvm_options): Add function to parse llvm asm options. (parse_llvm_asm): Add function to parse llvm asm. * expand/rust-macro-builtins-asm.h (class LlvmAsmContext): Add context for llvm asm parser. (parse_llvm_outputs): Add function prototype. (parse_llvm_inputs): Likewise. (parse_llvm_clobbers): Likewise. (parse_llvm_options): Likewise. * hir/rust-ast-lower-expr.cc (ASTLoweringExpr::visit): Lower AST llvm asm node to HIR. * hir/rust-ast-lower-expr.h: Add function prototype. * hir/rust-hir-dump.cc (Dump::visit): Add visit function. * hir/rust-hir-dump.h: Add function prototype. * hir/tree/rust-hir-expr-abstract.h: Add HIR llvm asm node kind. * hir/tree/rust-hir-expr.h (struct LlvmOperand): Add LlvmOperand type to represent input and outputs. (class LlvmInlineAsm): Add LlvmInlineAsm hir node. * hir/tree/rust-hir-full-decls.h (class LlvmInlineAsm): Add LlvmInlineAsm hir node forward declaration. * hir/tree/rust-hir-visitor.h: Add visit functions for LlvmInlineAsm hir node. * hir/tree/rust-hir.cc (LlvmInlineAsm::accept_vis): Add hir node visitor related functions. * typecheck/rust-hir-type-check-expr.cc (TypeCheckExpr::visit): Type check input and output operands. * typecheck/rust-hir-type-check-expr.h: Add function prototype. * ast/rust-ast-visitor.cc (DefaultASTVisitor::visit): Visit input and output operand expressions. * resolve/rust-ast-resolve-expr.cc (ResolveExpr::visit): Resolve input and output expressions. * resolve/rust-ast-resolve-expr.h: Add function prototypes. Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
2025-04-28gccrs: Add llvmInlineAsm nodePierre-Emmanuel Patry16-2/+124
InlineAsm node does not support memory clobbers. gcc/rust/ChangeLog: * ast/rust-ast-collector.cc (TokenCollector::visit): Make visitor unreachable. * ast/rust-ast-collector.h: Add visit for LlvmInlineAsmNode. * ast/rust-ast-visitor.cc (DefaultASTVisitor::visit): Add visit function for the default ast visitor. * ast/rust-ast-visitor.h: Add function prototype. * ast/rust-ast.cc (LlvmInlineAsm::accept_vis): Add accept_vis to LlvmInlineAsm node. * ast/rust-ast.h: Add LlvmInlineAsm node kind. * ast/rust-expr.h (class LlvmInlineAsm): Add LlvmInlineAsm node. * expand/rust-derive.h: Add visit function for LlvmInlineAsm node. * expand/rust-macro-builtins-asm.cc (MacroBuiltin::llvm_asm_handler): Add handler for llvm inline assembly nodes. (parse_llvm_asm): Add function to parse llvm assembly nodes. * expand/rust-macro-builtins-asm.h (parse_llvm_asm): Add function prototypes. * expand/rust-macro-builtins.cc (inline_llvm_asm_maker): Add macro transcriber. * expand/rust-macro-builtins.h: Add transcriber function prototype. * hir/rust-ast-lower-base.cc (ASTLoweringBase::visit): Add visit function for LlvmInlineAsm node. * hir/rust-ast-lower-base.h: Add visit function prototype. * resolve/rust-ast-resolve-base.cc (ResolverBase::visit): Add visit function for LlvmInlineAsm node. * resolve/rust-ast-resolve-base.h: Add visit function prototype. Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
2025-04-28gccrs: Emit error with old asm syntax in new asm blocksPierre-Emmanuel Patry1-0/+8
gcc/rust/ChangeLog: * expand/rust-macro-builtins-asm.cc (parse_asm_arg): Emit error message. Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
2025-04-28gccrs: Add check for placeholder (infer) type in return positionPhilip Herron3-0/+120
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>
2025-04-28gccrs: Fix ICE when checking shift's which are behind array refsPhilip Herron1-0/+1
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>
2025-04-28gccrs: Fix crash in hir dump as labels are optionalPhilip Herron1-1/+3
gcc/rust/ChangeLog: * hir/rust-hir-dump.cc (Dump::visit): add guard for optional label Signed-off-by: Philip Herron <herron.philip@googlemail.com>
2025-04-28gccrs: Update comments in repr parsing codeYap Zhi Heng2-2/+2
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>
2025-04-28gccrs: Implement integer representation for enumsZhi Heng2-4/+11
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>
2025-04-28gccrs: Implement typecheck for zero-variant enumsZhi Heng3-6/+57
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>
2025-04-28gccrs: Fix segv in unsafe chckerPhilip Herron3-1/+27
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>
2025-04-15Daily bump.GCC Administrator1-0/+159
2025-04-14gccrs: lang-items: Add ManuallyDrop<T>Arthur Cohen2-0/+3
gcc/rust/ChangeLog: * util/rust-lang-item.h: Add new manually_drop lang item. * util/rust-lang-item.cc: Likewise.
2025-04-14gccrs: attributes: Handle external tool annotations like rustfmt::Arthur Cohen4-3/+8
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.
2025-04-14gccrs: nr2.0: Only insert derive macros if they existArthur Cohen1-4/+3
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.
2025-04-14gccrs: attributes: Add missing attributes used in `core`Arthur Cohen3-1/+45
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.
2025-04-14gccrs: Add `#[track_caller]` as known attributebeamandala3-1/+4
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>
2025-04-14gccrs: Fix const checking of enum discriminantsOwen Avery2-0/+5
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>
2025-04-14gccrs: format_args: Allow extraneous commas, improve safetyArthur Cohen1-0/+7
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.
2025-04-14gccrs: expansion: Desugar doc comments into attributes before expansionArthur Cohen4-1/+133
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.
2025-04-14gccrs: expansion: Only add fragments if the matcher succeededArthur Cohen1-7/+8
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.
2025-04-14gccrs: session: Desugar question mark operator after expansion instead.Arthur Cohen1-1/+1
gcc/rust/ChangeLog: * rust-session-manager.cc (Session::compile_crate): Call the visitor later in the pipeline.
2025-04-14gccrs: ast: Add get_locus() to DelimTokenTreeArthur Cohen1-0/+1
gcc/rust/ChangeLog: * ast/rust-ast.h (DelimTokenTree::get_locus): New function.
2025-04-14gccrs: ast: Support outer attributes for AST::RangeExprArthur Cohen1-6/+6
gcc/rust/ChangeLog: * ast/rust-expr.h (class RangeExpr): Add empty outer attributes and allow getting them and setting them.
2025-04-14gccrs: nr2.0: Do not resolve modules this run if they are unloadedArthur Cohen1-1/+11
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.
2025-04-14gccrs: typecheck: Properly select methods when dealing with specializationArthur Cohen1-24/+105
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.