aboutsummaryrefslogtreecommitdiff
path: root/gcc/rust
AgeCommit message (Collapse)AuthorFilesLines
2024-03-22Merge commit '725fb3595622a4ad8cd078a42fab1c395cbf90cb' into HEAD [#1913, #2288]Thomas Schwinge1-0/+1
2024-03-21Split up rust-macro-builtins.ccjjasmine14-1020/+1316
Fixes issue #2855 gcc/rust/ChangeLog: * Make-lang.in: add new .o builds for new .cc files * expand/rust-cfg-strip.h (RUST_CFG_STRIP_H): Add include guards for rust-cfg-strip * expand/rust-macro-builtins.cc (make_macro_path_str): moved to new respective files (make_token): moved to new respective files (make_string): moved to new respective files (macro_end_token): moved to new respective files (try_extract_string_literal_from_fragment): moved to new respective files (try_expand_many_expr): moved to new respective files (parse_single_string_literal): moved to new respective files (source_relative_path): moved to new respective files (load_file_bytes): moved to new respective files (MacroBuiltin::assert_handler): moved to new respective files (MacroBuiltin::file_handler): moved to new respective files (MacroBuiltin::column_handler): moved to new respective files (MacroBuiltin::include_bytes_handler): moved to new respective files (MacroBuiltin::include_str_handler): moved to new respective files (MacroBuiltin::compile_error_handler): moved to new respective files (MacroBuiltin::concat_handler): moved to new respective files (MacroBuiltin::env_handler): moved to new respective files (MacroBuiltin::cfg_handler): moved to new respective files (MacroBuiltin::include_handler): moved to new respective files (MacroBuiltin::line_handler): moved to new respective files (MacroBuiltin::stringify_handler): moved to new respective files (struct FormatArgsInput): moved to new respective files (struct FormatArgsParseError): moved to new respective files (format_args_parse_arguments): moved to new respective files (MacroBuiltin::format_args_handler): moved to new respective files * expand/rust-macro-builtins.h (builtin_macro_from_string): merge tl::optional from master * expand/rust-macro-builtins-asm.cc: New file. * expand/rust-macro-builtins-format-args.cc: New file. * expand/rust-macro-builtins-helpers.cc: New file. * expand/rust-macro-builtins-helpers.h: New file. * expand/rust-macro-builtins-include.cc: New file. * expand/rust-macro-builtins-location.cc: New file. * expand/rust-macro-builtins-log-debug.cc: New file. * expand/rust-macro-builtins-test-bench.cc: New file. * expand/rust-macro-builtins-trait.cc: New file. * expand/rust-macro-builtins-utility.cc: New file.
2024-03-21Fix typoGuillaume Gomez1-1/+1
gcc/rust/ChangeLog: * expand/rust-derive.cc (DeriveVisitor::derive): Fix typo
2024-03-21Store visibility properly in ExternalTypeItemjjasmine2-3/+5
Fix issue 2897 gcc/rust/ChangeLog: * hir/rust-ast-lower-extern.h: Add translate_visiblity * hir/tree/rust-hir-item.h: Fix constructor of ExternalTypeItem
2024-03-21TyTy: Collect variance info from typesJakub Dupak1-4/+13
gcc/rust/ChangeLog: * typecheck/rust-hir-type-check-item.cc (TypeCheckItem::visit): Collect variance info from types. Signed-off-by: Jakub Dupak <dev@jakubdupak.com>
2024-03-21TyTy: Variance analysis moduleJakub Dupak7-0/+975
gcc/rust/ChangeLog: * Make-lang.in: Add new .cc file. * rust-session-manager.cc (Session::compile_crate): Run analysis. * typecheck/rust-tyty-variance-analysis-private.h: New file. * typecheck/rust-tyty-variance-analysis.cc: New file. * typecheck/rust-tyty-variance-analysis.h: New file. * typecheck/rust-typecheck-context.cc (TypeCheckContext::get_variance_analysis_ctx): Variance analysis context. * typecheck/rust-hir-type-check.h (TypeCheckItem::visit): Variance analysis context. Signed-off-by: Jakub Dupak <dev@jakubdupak.com>
2024-03-21TyTy: add common SubstitutionRef APIJakub Dupak1-0/+11
gcc/rust/ChangeLog: * typecheck/rust-tyty-subst.cc (SubstitutionRef::get_arg_at): Add unified API. Signed-off-by: Jakub Dupak <dev@jakubdupak.com>
2024-03-19format-args: Only pass the format string to the parser.Arthur Cohen1-15/+22
This fixes an issue we had where the generated code ended with more static pieces than its rustc counterpart. gcc/rust/ChangeLog: * expand/rust-macro-builtins.cc (struct FormatArgsInput): Store the format_str as a string instead of an AST::Expr. (format_args_parse_arguments): Transform format_expr into a format string properly - add note for handling eager macro invocations later on. (MacroBuiltin::format_args_handler): Parse the correct input, append newline to format_str if necessary.
2024-03-19format-args: Add basic expansion of unnamed Display::fmt arguments.Arthur Cohen8-56/+205
gcc/rust/ChangeLog: * ast/rust-ast-builder.h: Rename AST::AstBuilder -> AST::Builder * ast/rust-ast-builder.cc: Likewise. * expand/rust-derive.cc: Use new AST::Builder name. * expand/rust-derive.h: Likewise. * ast/rust-builtin-ast-nodes.h: Add required getters. * expand/rust-expand-format-args.cc (format_arg): New. (get_trait_name): New. (expand_format_args): Properly expand basic format_args!() invocations. * expand/rust-expand-format-args.h (expand_format_args): Fix signature. * expand/rust-macro-builtins.cc (MacroBuiltin::format_args_handler): Call into expand_format_args().
2024-03-19format-args: Start storing string in Rust memoryArthur Cohen4-34/+53
gcc/rust/ChangeLog: * ast/rust-fmt.cc (ffi::RustHamster::to_string): New. (Pieces::collect): Adapt to use new handle API. (Pieces::~Pieces): Likewise. (Pieces::Pieces): Likewise. (Pieces::operator=): Likewise. * ast/rust-fmt.h (struct RustString): Add members. (struct FormatArgsHandle): New. (clone_pieces): Adapt for new FFI API. (destroy_pieces): Likewise. (struct Pieces): Store new FormatArgsHandle type. * expand/rust-expand-format-args.cc (expand_format_args): Use proper namespace. * resolve/rust-ast-resolve-base.cc (ResolverBase::visit): FormatArgs nodes are already resolved, so do nothing. libgrust/ChangeLog: * libformat_parser/src/lib.rs: Use new Handle struct and expose it.
2024-03-19format-args: Add base for expanding FormatArgs nodesArthur Cohen4-4/+76
gcc/rust/ChangeLog: * Make-lang.in: Add new object. * hir/rust-ast-lower-expr.cc (ASTLoweringExpr::visit): Remove calls to FormatArgsLowering. * expand/rust-expand-format-args.cc: New file. * expand/rust-expand-format-args.h: New file.
2024-03-19Merge commit '8fc4e6c397e1ce64bec6f9fed148950821cc79e7' into HEADThomas Schwinge1-2/+2
Accordingly also adjust #2086 "break rust đŸ’¥" code, to avoid: [...]/source-gcc/gcc/rust/resolve/rust-ast-resolve-expr.cc: In member function ‘virtual void Rust::Resolver::ResolveExpr::visit(Rust::AST::IdentifierExpr&)’: [...]/source-gcc/gcc/rust/resolve/rust-ast-resolve-expr.cc:164:42: error: invalid conversion from ‘void (*)(diagnostic_context*, diagnostic_info*, diagnostic_t)’ to ‘diagnostic_finalizer_fn’ {aka ‘void (*)(diagnostic_context*, con iagnostic_info*, diagnostic_t)’} [-fpermissive] 164 | diagnostic_finalizer (global_dc) = funny_ice_finalizer; | ^~~~~~~~~~~~~~~~~~~ | | | void (*)(diagnostic_context*, diagnostic_info*, diagnostic_t)
2024-03-19Merge commit 'f7884f7673444b8a2c10ea0981d480f2e82dd16a'; commit ↵Thomas Schwinge1-1/+1
'adb56ef014effb17af27ab7baf0d87bc8bc48a0c' into HEAD [#2916] Merge "macro: Use MacroInvocation's node_id in ExternalItem constructor", to avoid bootstrap failure: [...] In file included from [...]/source-gcc/gcc/rust/ast/rust-expr.h:6, from [...]/source-gcc/gcc/rust/ast/rust-ast-full.h:24, from [...]/source-gcc/gcc/rust/ast/rust-ast.cc:24: In copy constructor ‘Rust::AST::MacroInvocation::MacroInvocation(const Rust::AST::MacroInvocation&)’, inlined from ‘Rust::AST::MacroInvocation* Rust::AST::MacroInvocation::clone_macro_invocation_impl() const’ at [...]/source-gcc/gcc/rust/ast/rust-\ macro.h:798:38: [...]/source-gcc/gcc/rust/ast/rust-macro.h:734:39: error: ‘*(Rust::AST::MacroInvocation*)<unknown>.Rust::AST::MacroInvocation::Rust::AST::ExprWithout\ Block.Rust::AST::ExprWithoutBlock::Rust::AST::Expr.Rust::AST::Expr::node_id’ is used uninitialized [-Werror=uninitialized] 734 | builtin_kind (other.builtin_kind) | ^ cc1plus: all warnings being treated as errors make[3]: *** [[...]/source-gcc/gcc/rust/Make-lang.in:423: rust/rust-ast.o] Error 1 [...] In file included from [...]/source-gcc/gcc/rust/ast/rust-expr.h:6, from [...]/source-gcc/gcc/rust/ast/rust-item.h:27, from [...]/source-gcc/gcc/rust/parse/rust-parse.h:20, from [...]/source-gcc/gcc/rust/expand/rust-macro-expand.h:24, from [...]/source-gcc/gcc/rust/expand/rust-macro-expand.cc:19: In copy constructor ‘Rust::AST::MacroInvocation::MacroInvocation(const Rust::AST::MacroInvocation&)’, inlined from ‘Rust::AST::MacroInvocation* Rust::AST::MacroInvocation::clone_macro_invocation_impl() const’ at [...]/source-gcc/gcc/rust/ast/rust-\ macro.h:798:38: [...]/source-gcc/gcc/rust/ast/rust-macro.h:734:39: error: ‘*(Rust::AST::MacroInvocation*)<unknown>.Rust::AST::MacroInvocation::Rust::AST::ExprWithout\ Block.Rust::AST::ExprWithoutBlock::Rust::AST::Expr.Rust::AST::Expr::node_id’ is used uninitialized [-Werror=uninitialized] 734 | builtin_kind (other.builtin_kind) | ^ cc1plus: all warnings being treated as errors make[3]: *** [[...]/source-gcc/gcc/rust/Make-lang.in:433: rust/rust-macro-expand.o] Error 1 [...]
2024-03-19Merge commit 'f7884f7673444b8a2c10ea0981d480f2e82dd16a^' into HEADThomas Schwinge1-0/+4
2024-03-19macro: Use MacroInvocation's node_id in ExternalItem constructor.Arthur Cohen1-1/+1
gcc/rust/ChangeLog: * ast/rust-macro.h: Use proper node id instead of the one in the base Expr class - which is uninitialized.
2024-03-19macro: Use MacroInvocation's node_id in ExternalItem constructor.Arthur Cohen1-1/+1
gcc/rust/ChangeLog: * ast/rust-macro.h: Use proper node id instead of the one in the base Expr class - which is uninitialized.
2024-03-17Merge commit '56ca59a03150cf44cea340f58967c990ed6bf43c^' into HEADThomas Schwinge1-0/+1
2024-03-16Merge commit '6a6d3817afa02bbcd2388c8e005da6faf88932f1^' into HEADThomas Schwinge3-4/+9
2024-03-13Replace unique_ptr references with referencesPierre-Emmanuel Patry51-1207/+1418
This kind of double indirection is pointless and prone to error. This commit change the api of all getters from the AST to use references directly instead of references to unique pointers. gcc/rust/ChangeLog: * ast/rust-ast-collector.cc (TokenCollector::visit): Remove reference to unique pointer and replace it with a direct reference to the wrapped data. * ast/rust-ast.cc (VariadicParam::as_string): Likewise. (BlockExpr::normalize_tail_expr): Likewise. * ast/rust-expr.h: Likewise and add pointer getter in order to allow pointer reseat. * ast/rust-item.h: Likewise and add pointer getter for reseat. * ast/rust-path.h: Likewise. * ast/rust-pattern.h: Likewise. * ast/rust-stmt.h: Likewise. * ast/rust-type.h: Likewise. * expand/rust-cfg-strip.cc (CfgStrip::maybe_strip_struct_fields): Remove references to unique pointers and replace it with direct references to the wrapped object. (CfgStrip::maybe_strip_tuple_fields): Likewise. (CfgStrip::maybe_strip_generic_args): Likewise. (CfgStrip::maybe_strip_qualified_path_type): Likewise. (CfgStrip::visit): Likewise. * expand/rust-expand-visitor.cc (ExpandVisitor::maybe_expand_expr): Likewise. (ExpandVisitor::maybe_expand_type): Likewise. (ExpandVisitor::visit): Likewise. * expand/rust-expand-visitor.h: Likewise. * hir/rust-ast-lower-base.cc (ASTLoweringBase::lower_binding): Likewise. (ASTLoweringBase::lower_generic_args): Likewise. (ASTLoweringBase::lower_self): Likewise. (ASTLoweringBase::lower_type_no_bounds): Likewise. (ASTLoweringBase::lower_bound): Likewise. (ASTLoweringBase::lower_range_pattern_bound): Likewise. * hir/rust-ast-lower-base.h: Likewise. * hir/rust-ast-lower-block.h: Likewise. * hir/rust-ast-lower-enumitem.h: Likewise. * hir/rust-ast-lower-expr.cc (ASTLoweringExpr::translate): Likewise. (ASTLoweringExpr::visit): Likewise. * hir/rust-ast-lower-expr.h: Likewise. * hir/rust-ast-lower-extern.h: Likewise. * hir/rust-ast-lower-implitem.cc (ASTLowerImplItem::translate): Likewise. (ASTLowerImplItem::visit): Likewise. (ASTLowerTraitItem::translate): Likewise. (ASTLowerTraitItem::visit): Likewise. * hir/rust-ast-lower-implitem.h: Likewise. * hir/rust-ast-lower-item.cc (ASTLoweringItem::translate): Likewise. (ASTLoweringItem::visit): Likewise. * hir/rust-ast-lower-item.h: Likewise. * hir/rust-ast-lower-pattern.cc (ASTLoweringPattern::translate): Likewise. (ASTLoweringPattern::visit): Likewise. * hir/rust-ast-lower-pattern.h: Likewise. * hir/rust-ast-lower-stmt.cc (ASTLoweringStmt::visit): Likewise. * hir/rust-ast-lower-struct-field-expr.h: Likewise. * hir/rust-ast-lower-type.cc (ASTLowerTypePath::visit): Likewise. (ASTLowerQualifiedPathInType::visit): Likewise. (ASTLoweringType::translate): Likewise. (ASTLoweringType::visit): Likewise. (ASTLowerGenericParam::translate): Likewise. (ASTLowerGenericParam::visit): Likewise. (ASTLoweringTypeBounds::translate): Likewise. (ASTLoweringTypeBounds::visit): Likewise. (ASTLowerWhereClauseItem::visit): Likewise. * hir/rust-ast-lower-type.h: Likewise. * hir/rust-ast-lower.cc (ASTLowering::go): Likewise. (ASTLoweringBlock::visit): Likewise. (ASTLoweringIfBlock::visit): Likewise. (ASTLoweringIfLetBlock::visit): Likewise. (ASTLowerStructExprField::visit): Likewise. (ASTLoweringExprWithBlock::visit): Likewise. (ASTLoweringBase::lower_qual_path_type): Likewise. (ASTLoweringBase::lower_closure_param): Likewise. * resolve/rust-ast-resolve-base.cc (ResolverBase::resolve_visibility): Likewise. * resolve/rust-ast-resolve-expr.cc (ResolveExpr::go): Likewise. (ResolveExpr::visit): Likewise. (ResolveExpr::resolve_closure_param): Likewise. * resolve/rust-ast-resolve-expr.h: Likewise. * resolve/rust-ast-resolve-implitem.h: Likewise. * resolve/rust-ast-resolve-item.cc (ResolveTraitItems::visit): Likewise. (ResolveItem::go): Likewise. (ResolveItem::visit): Likewise. (ResolveItem::resolve_impl_item): Likewise. (ResolveItem::resolve_extern_item): Likewise. (ResolveImplItems::go): Likewise. (ResolveExternItem::go): Likewise. (ResolveExternItem::visit): Likewise. * resolve/rust-ast-resolve-item.h: Likewise. * resolve/rust-ast-resolve-path.cc (ResolvePath::go): Likewise. (ResolvePath::resolve_path): Likewise. * resolve/rust-ast-resolve-path.h: Likewise. * resolve/rust-ast-resolve-pattern.cc (PatternDeclaration::go): Likewise. (PatternDeclaration::visit): Likewise. (resolve_range_pattern_bound): Likewise. * resolve/rust-ast-resolve-pattern.h: Likewise. * resolve/rust-ast-resolve-stmt.cc (ResolveStmt::visit): Likewise. * resolve/rust-ast-resolve-stmt.h: Likewise. * resolve/rust-ast-resolve-struct-expr-field.cc (ResolveStructExprField::go): Likewise. (ResolveStructExprField::visit): Likewise. * resolve/rust-ast-resolve-struct-expr-field.h: Likewise. * resolve/rust-ast-resolve-toplevel.h: Likewise. * resolve/rust-ast-resolve-type.cc (ResolveType::visit): Likewise. (ResolveRelativeTypePath::go): Likewise. (ResolveRelativeQualTypePath::resolve_qual_seg): Likewise. (ResolveTypeToCanonicalPath::go): Likewise. (ResolveTypeToCanonicalPath::visit): Likewise. (ResolveGenericArgs::resolve_disambiguated_generic): Likewise. (ResolveGenericArgs::go): Likewise. * resolve/rust-ast-resolve-type.h: Likewise. * resolve/rust-ast-resolve.cc (NameResolution::go): Likewise. * resolve/rust-default-resolver.cc (DefaultResolver::visit): Likewise. * resolve/rust-early-name-resolver.cc (EarlyNameResolver::resolve_qualified_path_type): Likewise. (EarlyNameResolver::visit): Likewise. * resolve/rust-toplevel-name-resolver-2.0.cc (TopLevel::visit): Likewise. * checks/errors/rust-ast-validation.cc: Likewise. Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
2024-03-13Replace reference to unique pointer with referencePierre-Emmanuel Patry5-28/+27
Reference to unique pointers are a known anti pattern, only the element shall be taken by reference instead of the whole wrapper. gcc/rust/ChangeLog: * ast/rust-item.h: Change getter function prototype to return a reference directly instead of a reference to the wrapper type. * checks/errors/rust-ast-validation.cc (ASTValidation::visit): Fix the code to accept references instead. * hir/rust-ast-lower-base.cc (ASTLoweringBase::lower_self): Change function implementation to return a reference. * hir/rust-ast-lower-base.h: Accept a reference instead of a unique pointer reference. * resolve/rust-ast-resolve-item.cc (ResolveItem::visit): Adapt the code to a reference instead of a unique pointer. Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
2024-03-12Placate clang-format re 'gcc/rust/backend/rust-tree.cc'Thomas Schwinge1-2/+2
Reformat the upstream GCC commit f4a2ae2338962208b8039f154f5912402e94c378 "Change MODE_BITSIZE to MODE_PRECISION for MODE_VECTOR_BOOL" change to 'gcc/rust/backend/rust-tree.cc' to clang-format's liking. gcc/rust/ * backend/rust-tree.cc (c_common_type_for_mode): Placate clang-format.
2024-03-11Merge commit 'af4bb221153359f5948da917d5ef2df738bb1e61' into HEADThomas Schwinge1-0/+5
2024-03-11Merge commit '46595ce72e5855189e3c60a140c3ca5aaddfb58c' into HEADThomas Schwinge1-1/+0
2024-03-11Merge commit '46595ce72e5855189e3c60a140c3ca5aaddfb58c^' into HEADThomas Schwinge1-0/+21
2024-03-11Merge commit 'ce7a757fd9ecb99c4f54cfde5cf5ef9a9e7819fc^' into HEADThomas Schwinge1-0/+13
2024-03-11Merge commit 'af91934c2f6b8efc67d625c99068b4761ae5edd0^' into HEADThomas Schwinge1-0/+11
2024-03-10Merge commit '126f707efbb5184178701cbdc753a10fd831374e^' into HEADThomas Schwinge1-0/+5
2024-03-10Merge commit 'f4a2ae2338962208b8039f154f5912402e94c378' into HEADThomas Schwinge1-1/+1
2024-03-10Merge commit 'f4a2ae2338962208b8039f154f5912402e94c378^' into HEADThomas Schwinge1-0/+5
2024-03-10Merge commit '8a30775b0d3037123ee540f7b65a736ad49e05ce' into HEADThomas Schwinge1-3/+3
2024-03-05Remove dead code associated with `AST::ExternalFunctionItem`0xn4utilus25-335/+2
gcc/rust/ChangeLog: * ast/rust-ast-collector.cc (TokenCollector::visit): Remove dead code. * ast/rust-ast-collector.h: Likewise. * ast/rust-ast-full-decls.h (class ExternalFunctionItem): Likewise. * ast/rust-ast-visitor.cc (DefaultASTVisitor::visit): Likewise. * ast/rust-ast-visitor.h: Likewise. * ast/rust-ast.cc (ExternalFunctionItem::as_string): Likewise. (ExternalFunctionItem::accept_vis): Likewise. * checks/errors/rust-ast-validation.cc (ASTValidation::visit): Likewise. * checks/errors/rust-ast-validation.h: Likewise. * checks/errors/rust-feature-gate.h: Likewise. * expand/rust-cfg-strip.cc (CfgStrip::visit): Likewise. * expand/rust-cfg-strip.h: Likewise. * expand/rust-derive.h: Likewise. * expand/rust-expand-visitor.cc (ExpandVisitor::visit): Likewise. * expand/rust-expand-visitor.h: Likewise. * hir/rust-ast-lower-base.cc (ASTLoweringBase::visit): Likewise. * hir/rust-ast-lower-base.h: Likewise. * metadata/rust-export-metadata.cc (ExportContext::emit_function): Likewise. * parse/rust-parse-impl.h: Likewise. * parse/rust-parse.h: Likewise. * resolve/rust-ast-resolve-base.cc (ResolverBase::visit): Likewise. * resolve/rust-ast-resolve-base.h: Likewise. * resolve/rust-default-resolver.cc (DefaultResolver::visit): Likewise. * resolve/rust-default-resolver.h: Likewise. * util/rust-attributes.cc (AttributeChecker::visit): Likewise. * util/rust-attributes.h: Likewise. gcc/testsuite/ChangeLog: * rust/compile/extern_func_with_body.rs: New test. Signed-off-by: 0xn4utilus <gyanendrabanjare8@gmail.com>
2024-03-05Update resolver to use `AST::Function` instead of `AST::ExternalFunctionItem`0xn4utilus7-19/+39
gcc/rust/ChangeLog: * checks/errors/rust-feature-gate.cc (FeatureGate::visit): Check if function is_external or not. * hir/rust-ast-lower-extern.h: Use AST::Function instead of AST::ExternalFunctionItem. * parse/rust-parse-impl.h (Parser::parse_external_item): Likewise. (Parser::parse_pattern): Fix clang format. * resolve/rust-ast-resolve-implitem.h: Likewise. * resolve/rust-ast-resolve-item.cc (ResolveExternItem::visit): Likewise. * resolve/rust-ast-resolve-item.h: Likewise. * resolve/rust-default-resolver.cc (DefaultResolver::visit): Check if param has_pattern before using get_pattern. Signed-off-by: 0xn4utilus <gyanendrabanjare8@gmail.com>
2024-03-05Unify ASTValidation::visit for ExternalFunctionItem and Function0xn4utilus3-17/+57
gcc/rust/ChangeLog: * checks/errors/rust-ast-validation.cc (ASTValidation::visit): Add external function validation support. Add ErrorCode::E0130. * parse/rust-parse-impl.h (Parser::parse_function): Parse external functions from `parse_function`. (Parser::parse_external_item): Clang format. (Parser::parse_pattern): Clang format. * parse/rust-parse.h: Add default parameter `is_external` in `parse_function`. Signed-off-by: 0xn4utilus <gyanendrabanjare8@gmail.com>
2024-03-05Add get_pattern_kind to Pattern0xn4utilus4-0/+60
gcc/rust/ChangeLog: * ast/rust-ast.h: Add Kind Enum to Pattern. * ast/rust-macro.h: Add get_pattern_kind(). * ast/rust-path.h: Likewise. * ast/rust-pattern.h: Likewise. Signed-off-by: 0xn4utilus <gyanendrabanjare8@gmail.com>
2024-03-05Add support for external functions0xn4utilus4-20/+43
gcc/rust/ChangeLog: * ast/rust-ast.cc (Function::Function): Add `is_external_function` field. (Function::operator=): Likewise. * ast/rust-ast.h: New constructor for ExternalItem. * ast/rust-item.h (class Function): Add `is_external_function` field. Update `get_node_id`. * ast/rust-macro.h: Update copy constructor. Signed-off-by: 0xn4utilus <gyanendrabanjare8@gmail.com>
2024-03-05Clean BiMap to use tl::optional for lookupsSourabh Jaiswal6-23/+28
gcc/rust/Changelog: * expand/rust-expand-visitor.cc (ExpandVisitor::expand_inner_items): Adjust to use has_value () (ExpandVisitor::expand_inner_stmts): Likewise * expand/rust-macro-builtins.cc (builtin_macro_from_string): Likewise (make_macro_path_str): Likewise * util/rust-hir-map.cc (Mappings::insert_macro_def): Likewise * util/rust-lang-item.cc (LangItem::Parse): Adjust to return tl::optional (LangItem::toString) Likewise * util/rust-token-converter.cc (handle_suffix): Adjust to use value.or () (from_literal) Likewise * util/bi-map.h (BiMap::lookup): Adjust to use tl::optional for lookups Signed-off-by: Sourabh Jaiswal <sourabhrj31@gmail.com>
2024-03-05Daily bump.GCC Administrator1-0/+4
2024-03-04Regenerate opt.urlsMark Wielaard1-0/+3
There were several commits that didn't regenerate the opt.urls files. Fixes: 438ef143679e ("rs6000: Neuter option -mpower{8,9}-vector") Fixes: 50c549ef3db6 ("gccrs: enable -Winfinite-recursion warnings by default") Fixes: 25bb8a40abd9 ("Move docs for -Wuse-after-free and -Wuseless-cast") Fixes: 48448055fb70 ("AVR: Support .rodata in Flash for AVR64* and AVR128*") Fixes: 42503cc257fb ("AVR: Document option -mskip-bug") Fixes: 7de5bb642c12 ("i386: [APX] Document inline asm behavior and new switch") Fixes: 49a14ee488b8 ("Add -mevex512 into invoke.texi") Fixes: 4666cbde5e6d ("Sort warning options in c-family/c.opt.") Fixes: cda383616183 ("AVR: target/114100 - Better indirect accesses for reduced Tiny") gcc/c-family/ChangeLog: * c.opt.urls: Regenerate. gcc/ChangeLog: * common.opt.urls: Regenerate. * config/avr/avr.opt.urls: Likewise. * config/i386/i386.opt.urls: Likewise. * config/pru/pru.opt.urls: Likewise. * config/riscv/riscv.opt.urls: Likewise. * config/rs6000/rs6000.opt.urls: Likewise. gcc/rust/ChangeLog: * lang.opt.urls: Regenerate.
2024-03-04Ensure TupleStructPattern and TuplePattern have itemsOwen Avery5-53/+25
Note that instances of both classes which have been moved from will have (items == nullptr). gcc/rust/ChangeLog: * ast/rust-pattern.h (class TupleStructPattern): Assert that items != nullptr. (class TuplePattern): Likewise. (TupleStructPattern::has_items): Remove. (TuplePattern::has_tuple_pattern_items): Likewise. * parse/rust-parse-impl.h (Parser::parse_ident_leading_pattern): Prevent construction of TupleStructPattern with (items == nullptr). (Parser::parse_pattern_no_alt): Likewise. * ast/rust-ast-collector.cc (TokenCollector::visit): Remove usage of TupleStructPattern::has_items. * ast/rust-ast-visitor.cc (DefaultASTVisitor::visit): Likewise. * resolve/rust-early-name-resolver.cc (EarlyNameResolver::visit): Likewise. gcc/testsuite/ChangeLog: * rust/compile/pattern-struct.rs: Fix test. Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
2024-03-04Add curly brackets, formatted clangjjasmine1-5/+12
gcc/rust/ChangeLog: * resolve/rust-late-name-resolver-2.0.cc (Late::visit): Add error emitting
2024-03-04Add error emitting when we can't resolve id exprjjasmine1-1/+4
gcc/rust/ChangeLog: * resolve/rust-late-name-resolver-2.0.cc (Late::visit): Add error emitting
2024-03-01format-args: Add documentation for future expansion of functionArthur Cohen1-21/+5
gcc/rust/ChangeLog: * expand/rust-macro-builtins.cc (MacroBuiltin::format_args_handler): Add documentation regarding future tasks.
2024-03-01lower: Add base for lowering FormatArgs nodesArthur Cohen10-54/+127
gcc/rust/ChangeLog: * Make-lang.in: Compile the new source file. * ast/rust-ast-collector.cc (TokenCollector::visit): Error out when visiting FormatArgs nodes. * resolve/rust-ast-resolve-base.cc (ResolverBase::visit): Likewise. * hir/rust-ast-lower-expr.cc (ASTLoweringExpr::visit): Likewise. * ast/rust-ast.cc (FormatArgs::get_locus): New. * ast/rust-builtin-ast-nodes.h: Improve FormatArgs API. * ast/rust-fmt.cc (Pieces::~Pieces): Cleanup. (Pieces::Pieces): Likewise. * ast/rust-fmt.h (struct Pieces): Add pieces_vector member. * hir/rust-ast-lower-format-args.cc: New file. * hir/rust-ast-lower-format-args.h: New file.
2024-03-01format-args: Fix Rust interface and add input parsing.Arthur Cohen7-60/+370
gcc/rust/ChangeLog: * Make-lang.in: Do not build Rust library in release mode. * ast/rust-ast.cc: Make FormatArgs inherit from AST::Expr * ast/rust-builtin-ast-nodes.h: Improve FormatArg* nodes and helpers. * ast/rust-fmt.cc (Pieces::collect): Fix interface to match FFI function. * ast/rust-fmt.h (collect_pieces): Likewise. (struct Pieces): Add append_newline parameter. * expand/rust-macro-builtins.cc: Add proper parsing of format_args input. * hir/rust-ast-lower-base.cc: Include diagnostics header. libgrust/ChangeLog: * libformat_parser/src/lib.rs: Switch interface to use more parser parameters. * libformat_parser/src/bin.rs: Use new interface.
2024-03-01parser: Add peek(n) method to parserArthur Cohen1-0/+1
gcc/rust/ChangeLog: * parse/rust-parse.h: New method.
2024-03-01macro-builtins: Add newline generic format_args!() handlerArthur Cohen2-8/+65
gcc/rust/ChangeLog: * expand/rust-macro-builtins.cc (format_args_maker): New function. (try_expand_many_expr): Add comment about reworking function. (MacroBuiltin::format_args_handler): Add newline parameter. * expand/rust-macro-builtins.h: Likewise.
2024-03-01ast: Add base nodes for FormatArgsArthur Cohen16-0/+191
This commit adds a base for creating AST FormatArgs nodes after expanding invocations of `format_args!()`. These nodes will then be expanded to the proper runtime function calls (to core::fmt::rt) during the AST lowering. gcc/rust/ChangeLog: * ast/rust-builtin-ast-nodes.h: New file. * ast/rust-ast-full-decls.h (class FormatArgs): Declare new class. * ast/rust-ast-collector.cc: Handle FormatArgs nodes properly. * ast/rust-ast-collector.h: Likewise. * ast/rust-ast-full.h: Likewise. * ast/rust-ast-visitor.cc: Likewise. * ast/rust-ast-visitor.h: Likewise. * ast/rust-ast.cc: Likewise. * ast/rust-ast.h: Likewise. * expand/rust-derive.h: Likewise. * hir/rust-ast-lower-base.cc: Likewise. * hir/rust-ast-lower-base.h: Likewise. * hir/rust-ast-lower-expr.cc: Likewise. * hir/rust-ast-lower-expr.h: Likewise. * resolve/rust-ast-resolve-base.cc: Likewise. * resolve/rust-ast-resolve-base.h: Likewise.
2024-03-01Make DefaultResolver visit more of the ASTOwen Avery2-16/+91
gcc/rust/ChangeLog: * resolve/rust-default-resolver.cc (DefaultResolver::visit): Visit inner AST nodes of ClosureExprInner, ClosureExprInnerTyped, IfExpr, IfExprConseqElse, MatchExpr, PathInExpression, EnumItemTuple, EnumItemStruct, and EnumItemDiscriminant. * ast/rust-item.h (EnumItemDiscriminant::has_expr): New function. Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
2024-02-29extern-types: Lower to HIR::ExternalTypeItem properlyArthur Cohen2-3/+16
gcc/rust/ChangeLog: * hir/rust-ast-lower-extern.h: Lower to HIR::ExternalTypeItem nodes. * hir/tree/rust-hir-item.h (class ExternalTypeItem): Create private visibility by default as extern types have no visibility - add a comment about the correctness of this.
2024-02-29hir: Add ExternalTypeItem nodeArthur Cohen16-3/+230
gcc/rust/ChangeLog: * hir/tree/rust-hir-item.h (class ExternalTypeItem): New class. * hir/tree/rust-hir.cc (ExternalTypeItem::as_string): Likewise. * backend/rust-compile-extern.h: Add base for handling HIR::ExternalTypeItem node. * checks/errors/borrowck/rust-bir-builder-struct.h: Likewise. * checks/errors/borrowck/rust-function-collector.h: Likewise. * checks/errors/rust-const-checker.cc (ConstChecker::visit): Likewise. * checks/errors/rust-const-checker.h: Likewise. * checks/errors/rust-unsafe-checker.cc (UnsafeChecker::visit): Likewise. * checks/errors/rust-unsafe-checker.h: Likewise. * hir/rust-ast-lower-extern.h: Likewise. * hir/rust-hir-dump.cc (Dump::visit): Likewise. * hir/rust-hir-dump.h: Likewise. * hir/tree/rust-hir-full-decls.h (class ExternalTypeItem): Likewise. * hir/tree/rust-hir-visitor.h: Likewise. (ExternalTypeItem::accept_vis): Likewise. * typecheck/rust-hir-type-check-implitem.cc (TypeCheckTopLevelExternItem::visit): Likewise. * typecheck/rust-hir-type-check-implitem.h: Likewise.