aboutsummaryrefslogtreecommitdiff
AgeCommit message (Collapse)AuthorFilesLines
2024-08-16Subset errors with locationsKushal Pal3-9/+64
gcc/rust/ChangeLog: * checks/errors/borrowck/rust-borrow-checker-diagnostics.cc (BorrowCheckerDiagnostics::report_subset_errors): Highlight lifetime locations while reporting subset errors. (BorrowCheckerDiagnostics::get_lifetime_param): Helper function to fetch HIR::Lifetime node from Polonius::Origin. * checks/errors/borrowck/rust-borrow-checker-diagnostics.h: Definition of helper function. gcc/testsuite/ChangeLog: * rust/borrowck/subset.rs: Better subset errors. Signed-off-by: Kushal Pal <kushalpal109@gmail.com>
2024-08-16Map locations to placeholder regionsKushal Pal2-0/+24
Mapped placeholder regions to their respective HIR nodes so we can fetch locations during error reporting. gcc/rust/ChangeLog: * checks/errors/borrowck/rust-bir-builder.h: Map regions to their respective HIR nodes. * checks/errors/borrowck/rust-bir.h (struct Function): Add unordered_map to maintain the mapping. Signed-off-by: Kushal Pal <kushalpal109@gmail.com>
2024-08-14Fixed testcaseKushal Pal1-2/+2
gcc/testsuite/ChangeLog: * rust/borrowck/test_move.rs: Assigning `a` to `c` is the correct way to test the behaviour. Signed-off-by: Kushal Pal <kushalpal109@gmail.com>
2024-08-06[#2324] Add error message for E0532Liam Naddell3-0/+63
gcc/rust/ChangeLog: * typecheck/rust-hir-type-check-pattern.cc: Emit E0532 when trying to reference a Tuple or Struct variant using a non Tuple or Struct pattern. gcc/testsuite/ChangeLog: * rust/compile/issue-2324-1.rs: add test for E0532 with tuple enum variant * rust/compile/issue-2324-2.rs: add test for E0532 with struct enum variant Signed-off-by: Liam Naddell <liam.naddell@mail.utoronto.ca>
2024-08-06borrowck: Avoid overloading issues on 32bit architecturesArthur Cohen1-2/+2
On architectures where `size_t` is `unsigned int`, such as 32bit x86, we encounter an issue with `PlaceId` and `FreeRegion` being aliases to the same types. This poses an issue for overloading functions for these two types, such as `push_subset` in that case. This commit renames one of these `push_subset` functions to avoid the issue, but this should be fixed with a newtype pattern for these two types. gcc/rust/ChangeLog: * checks/errors/borrowck/rust-bir-fact-collector.h (points): Rename `push_subset(PlaceId, PlaceId)` to `push_subset_place(PlaceId, PlaceId)`
2024-08-06borrowck: Fix debug prints on 32-bits architecturesArthur Cohen2-3/+6
gcc/rust/ChangeLog: * checks/errors/borrowck/rust-bir-builder.h: Cast size_t values to unsigned long before printing. * checks/errors/borrowck/rust-bir-fact-collector.h: Likewise.
2024-08-06Eager expansion for include* #1805 #1865Liam Naddell15-40/+170
gcc/rust/ChangeLog: * expand/rust-expand-visitor.h: remove auto keyword * expand/rust-macro-builtins-helpers.cc: allow for changing macro invoc types on eager expansions to semicoloned macros * expand/rust-macro-builtins-helpers.h: add default semicoloned argument * expand/rust-macro-builtins-include.cc: allow for eager expansion for include and include_bytes allow for parsing include invocations as items instead of expressions, which allows invocations at global scope * expand/rust-macro-expand.cc: push Expr type for eager invocations gcc/testsuite/ChangeLog: * rust/compile/macros/builtin/include1.rs: add basic include test at global scope * rust/compile/macros/builtin/include2.rs: add basic include test at local scope with expression * rust/compile/macros/builtin/include3.rs: add eager expansion test at global scope * rust/compile/macros/builtin/include4.rs: add eager expansion test at local scope with expression * rust/compile/macros/builtin/include_bytes.rs: add eager expansion test at global scope * rust/compile/macros/builtin/include_rs: supporting test file with dummy function * rust/compile/macros/builtin/include_rs2: supporting test file with dummy string * rust/compile/macros/builtin/include_str.rs: add eager expansion test at global scope * rust/execute/torture/builtin_macro_include_bytes.rs: clean up old test logic, add permutations for eager expansion * rust/execute/torture/builtin_macro_include_str.rs: add eager expansion permutations
2024-08-06rust: avoid clobbering LIBSMarc Poulhiès2-14/+16
Save LIBS around calls to AC_SEARCH_LIBS to avoid clobbering $LIBS. ChangeLog: * configure: Regenerate. * configure.ac: Save LIBS around calls to AC_SEARCH_LIBS. Signed-off-by: Marc Poulhiès <dkm@kataplop.net> Reviewed-by: Thomas Schwinge <tschwinge@baylibre.com> Tested-by: Thomas Schwinge <tschwinge@baylibre.com>
2024-08-02Simplify construction of BIR::StatementKushal Pal2-25/+51
gcc/rust/ChangeLog: * checks/errors/borrowck/rust-bir-builder-internal.h: Use `make_*` functions to create BIR::Statements. * checks/errors/borrowck/rust-bir.h: Make a complete constructor and introduce `make_*` functions to create various BIR::Statements. Signed-off-by: Kushal Pal <kushalpal109@gmail.com>
2024-08-02Loan errors with locationsKushal Pal8-32/+295
gcc/rust/ChangeLog: * checks/errors/borrowck/rust-borrow-checker-diagnostics.cc (BorrowCheckerDiagnostics::report_loan_errors): Add label to where the borrow occurs and where the invalid access occurs. (BorrowCheckerDiagnostics::get_statement): Fetch BIR::Statement from Polonius::Point (BorrowCheckerDiagnostics::get_loan): Fetch BIR::Loan from Polonius::Loan * checks/errors/borrowck/rust-borrow-checker-diagnostics.h: Function definition of helpers. gcc/testsuite/ChangeLog: * rust/borrowck/reference.rs: Test rich errors for borrow-checker. * rust/borrowck/return_ref_to_local.rs: Likewise. * rust/borrowck/tmp.rs: Likewise. * rust/borrowck/use_while_mut.rs: Likewise. * rust/borrowck/use_while_mut_fr.rs: Likewise. * rust/borrowck/well_formed_function_inputs.rs: Likewise. Signed-off-by: Kushal Pal <kushalpal109@gmail.com>
2024-08-02Add location to BIR::Statement of kind RETURNKushal Pal4-7/+15
This commit adds location_t to BIR::Statement where type is RETURN. gcc/rust/ChangeLog: * checks/errors/borrowck/rust-bir-builder-expr-stmt.cc (ExprStmtBuilder::visit): Add location parameter. * checks/errors/borrowck/rust-bir-builder.h: Likewise. * checks/errors/borrowck/rust-bir-builder-internal.h: Add helper function for pushing return statements. * checks/errors/borrowck/rust-bir.h: Remove `expr` parameter as it is only needed for ASSIGNMENT statements, for which we already have a constructor. Signed-off-by: Kushal Pal <kushalpal109@gmail.com>
2024-08-02Implement resolve expr for inline asm astbadumbatish2-6/+63
gcc/rust/ChangeLog: * resolve/rust-ast-resolve-expr.cc (ResolveExpr::visit): Implement resolve expr for inline asm ast (translate_operand): Likewise. * resolve/rust-ast-resolve-expr.h: Likewise.
2024-08-01Add location to BIR::LoanKushal Pal2-2/+4
This commit adds location_t to BIR::Loan, this location will point to location is source code where the borrow occured, this information will be useful for reporting borrow-checking errors. gcc/rust/ChangeLog: * checks/errors/borrowck/rust-bir-builder-internal.h: Fill location for loan. * checks/errors/borrowck/rust-bir-place.h (struct Loan): Add location field. Signed-off-by: Kushal Pal <kushalpal109@gmail.com>
2024-08-01Add location support to BIR::StatementKushal Pal6-121/+194
This commit adds location_t to BIR::Statement where type is ASSIGNMENT this information will be later used for reporting borrow-checking errors. gcc/rust/ChangeLog: * checks/errors/borrowck/rust-bir-builder-expr-stmt.cc (ExprStmtBuilder::visit): Added location parameter. * checks/errors/borrowck/rust-bir-builder-internal.h: Likewise. * checks/errors/borrowck/rust-bir-builder-lazyboolexpr.h: Likewise. * checks/errors/borrowck/rust-bir-builder-pattern.h: Likewise. * checks/errors/borrowck/rust-bir-builder.h: Likewise. * checks/errors/borrowck/rust-bir.h: Likewise. Signed-off-by: Kushal Pal <kushalpal109@gmail.com>
2024-08-01Turn to switch case, use new helper functionsbadumbatish1-70/+94
gcc/rust/ChangeLog: * hir/rust-ast-lower-expr.cc (translate_operand_in): Turn to switch case, use new helper functions (translate_operand_out): Likewise. (translate_operand_inout): Likewise. (translate_operand_split_in_out): Likewise. (translate_operand_const): Likewise. (translate_operand_sym): Likewise. (translate_operand_label): Likewise. (from_operand): Likewise. (ASTLoweringExpr::visit): Likewise.
2024-08-01Set up the hir lowering for operandbadumbatish2-14/+343
gcc/rust/ChangeLog: * hir/rust-ast-lower-expr.cc (from_operand): Set up the lowering for operand (ASTLoweringExpr::visit): Likewise * hir/tree/rust-hir-expr.h (struct InlineAsmRegOrRegClass): Not necessary, kept from ast (struct AnonConst): Set up lowering for operand (class InlineAsmOperand): Likewise, add getters
2024-07-31Improve compressed point bit manipulationKushal Pal2-3/+35
gcc/rust/ChangeLog: * checks/errors/borrowck/polonius/rust-polonius.h (struct FullPoint): Added comments and made extraction of statement more verbose for better understanding. * checks/errors/borrowck/ffi-polonius/src/lib.rs: Likewise. Signed-off-by: Kushal Pal <kushalpal109@gmail.com>
2024-07-31Use new constructors and control flow for operandbadumbatish2-84/+53
gcc/rust/ChangeLog: * ast/rust-expr.h (struct InlineAsmOperand): changed to class (class InlineAsmOperand): Have appropriate constructor, and getter * expand/rust-macro-builtins-asm.cc (parse_reg_operand): Use the new implement constructors and new control flow. (parse_reg_operand_in): Likewise (parse_reg_operand_out): Likewise (parse_reg_operand_inout): Likewise (parse_reg_operand_const): Likewise
2024-07-31Fix the parser's operand and flags storagebadumbatish5-28/+60
gcc/rust/ChangeLog: * ast/rust-expr.h (struct InlineAsmOperand): Add construction for register_type * expand/rust-macro-builtins-asm.cc (parse_reg_operand): Fix parsing logic & reassignment logic (parse_reg_operand_in): Fix parsing (parse_reg_operand_out): Fix parsing (parse_reg_operand_inout): Fix parsing (parse_reg_operand_unexpected): Remove rust_unreachable() (parse_asm_arg): Fix parsing logic * expand/rust-macro-builtins-asm.h: Add = operator overloading gcc/testsuite/ChangeLog: * rust/compile/inline_asm_illegal_operands.rs: Test now passing * rust/compile/inline_asm_parse_operand.rs: Remove _, not supported right now
2024-07-31Fixed bitwise operation in `extract_stmt`Kushal Pal1-1/+1
gcc/rust/ChangeLog: * checks/errors/borrowck/polonius/rust-polonius.h (struct FullPoint): This is the correct way of extracting the required bits. Signed-off-by: Kushal Pal <kushalpal109@gmail.com>
2024-07-30Move mbe macro tests to their own directoryPierre-Emmanuel Patry80-0/+35
gcc/testsuite/ChangeLog: * rust/compile/macro-delim.rs: Move to... * rust/compile/macros/mbe/macro-delim.rs: ...here. * rust/compile/macro-issue1053-2.rs: Move to... * rust/compile/macros/mbe/macro-issue1053-2.rs: ...here. * rust/compile/macro-issue1053.rs: Move to... * rust/compile/macros/mbe/macro-issue1053.rs: ...here. * rust/compile/macro-issue1224.rs: Move to... * rust/compile/macros/mbe/macro-issue1224.rs: ...here. * rust/compile/macro-issue1233.rs: Move to... * rust/compile/macros/mbe/macro-issue1233.rs: ...here. * rust/compile/macro-issue1395-2.rs: Move to... * rust/compile/macros/mbe/macro-issue1395-2.rs: ...here. * rust/compile/macro-issue1395.rs: Move to... * rust/compile/macros/mbe/macro-issue1395.rs: ...here. * rust/compile/macro-issue1400-2.rs: Move to... * rust/compile/macros/mbe/macro-issue1400-2.rs: ...here. * rust/compile/macro-issue1400.rs: Move to... * rust/compile/macros/mbe/macro-issue1400.rs: ...here. * rust/compile/macro-issue2092.rs: Move to... * rust/compile/macros/mbe/macro-issue2092.rs: ...here. * rust/compile/macro-issue2192.rs: Move to... * rust/compile/macros/mbe/macro-issue2192.rs: ...here. * rust/compile/macro-issue2194.rs: Move to... * rust/compile/macros/mbe/macro-issue2194.rs: ...here. * rust/compile/macro-issue2229.rs: Move to... * rust/compile/macros/mbe/macro-issue2229.rs: ...here. * rust/compile/macro-issue2264.rs: Move to... * rust/compile/macros/mbe/macro-issue2264.rs: ...here. * rust/compile/macro-issue2268.rs: Move to... * rust/compile/macros/mbe/macro-issue2268.rs: ...here. * rust/compile/macro-issue2273.rs: Move to... * rust/compile/macros/mbe/macro-issue2273.rs: ...here. * rust/compile/macro-issue2653.rs: Move to... * rust/compile/macros/mbe/macro-issue2653.rs: ...here. * rust/compile/macro-issue2983_2984.rs: Move to... * rust/compile/macros/mbe/macro-issue2983_2984.rs: ...here. * rust/compile/macro1.rs: Move to... * rust/compile/macros/mbe/macro1.rs: ...here. * rust/compile/macro10.rs: Move to... * rust/compile/macros/mbe/macro10.rs: ...here. * rust/compile/macro11.rs: Move to... * rust/compile/macros/mbe/macro11.rs: ...here. * rust/compile/macro12.rs: Move to... * rust/compile/macros/mbe/macro12.rs: ...here. * rust/compile/macro13.rs: Move to... * rust/compile/macros/mbe/macro13.rs: ...here. * rust/compile/macro14.rs: Move to... * rust/compile/macros/mbe/macro14.rs: ...here. * rust/compile/macro15.rs: Move to... * rust/compile/macros/mbe/macro15.rs: ...here. * rust/compile/macro16.rs: Move to... * rust/compile/macros/mbe/macro16.rs: ...here. * rust/compile/macro17.rs: Move to... * rust/compile/macros/mbe/macro17.rs: ...here. * rust/compile/macro18.rs: Move to... * rust/compile/macros/mbe/macro18.rs: ...here. * rust/compile/macro19.rs: Move to... * rust/compile/macros/mbe/macro19.rs: ...here. * rust/compile/macro2.rs: Move to... * rust/compile/macros/mbe/macro2.rs: ...here. * rust/compile/macro20.rs: Move to... * rust/compile/macros/mbe/macro20.rs: ...here. * rust/compile/macro21.rs: Move to... * rust/compile/macros/mbe/macro21.rs: ...here. * rust/compile/macro22.rs: Move to... * rust/compile/macros/mbe/macro22.rs: ...here. * rust/compile/macro23.rs: Move to... * rust/compile/macros/mbe/macro23.rs: ...here. * rust/compile/macro25.rs: Move to... * rust/compile/macros/mbe/macro25.rs: ...here. * rust/compile/macro26.rs: Move to... * rust/compile/macros/mbe/macro26.rs: ...here. * rust/compile/macro27.rs: Move to... * rust/compile/macros/mbe/macro27.rs: ...here. * rust/compile/macro28.rs: Move to... * rust/compile/macros/mbe/macro28.rs: ...here. * rust/compile/macro29.rs: Move to... * rust/compile/macros/mbe/macro29.rs: ...here. * rust/compile/macro3.rs: Move to... * rust/compile/macros/mbe/macro3.rs: ...here. * rust/compile/macro30.rs: Move to... * rust/compile/macros/mbe/macro30.rs: ...here. * rust/compile/macro31.rs: Move to... * rust/compile/macros/mbe/macro31.rs: ...here. * rust/compile/macro32.rs: Move to... * rust/compile/macros/mbe/macro32.rs: ...here. * rust/compile/macro33.rs: Move to... * rust/compile/macros/mbe/macro33.rs: ...here. * rust/compile/macro34.rs: Move to... * rust/compile/macros/mbe/macro34.rs: ...here. * rust/compile/macro35.rs: Move to... * rust/compile/macros/mbe/macro35.rs: ...here. * rust/compile/macro36.rs: Move to... * rust/compile/macros/mbe/macro36.rs: ...here. * rust/compile/macro37.rs: Move to... * rust/compile/macros/mbe/macro37.rs: ...here. * rust/compile/macro38.rs: Move to... * rust/compile/macros/mbe/macro38.rs: ...here. * rust/compile/macro39.rs: Move to... * rust/compile/macros/mbe/macro39.rs: ...here. * rust/compile/macro4.rs: Move to... * rust/compile/macros/mbe/macro4.rs: ...here. * rust/compile/macro40.rs: Move to... * rust/compile/macros/mbe/macro40.rs: ...here. * rust/compile/macro41.rs: Move to... * rust/compile/macros/mbe/macro41.rs: ...here. * rust/compile/macro42.rs: Move to... * rust/compile/macros/mbe/macro42.rs: ...here. * rust/compile/macro43.rs: Move to... * rust/compile/macros/mbe/macro43.rs: ...here. * rust/compile/macro44.rs: Move to... * rust/compile/macros/mbe/macro44.rs: ...here. * rust/compile/macro45.rs: Move to... * rust/compile/macros/mbe/macro45.rs: ...here. * rust/compile/macro46.rs: Move to... * rust/compile/macros/mbe/macro46.rs: ...here. * rust/compile/macro47.rs: Move to... * rust/compile/macros/mbe/macro47.rs: ...here. * rust/compile/macro48.rs: Move to... * rust/compile/macros/mbe/macro48.rs: ...here. * rust/compile/macro49.rs: Move to... * rust/compile/macros/mbe/macro49.rs: ...here. * rust/compile/macro5.rs: Move to... * rust/compile/macros/mbe/macro5.rs: ...here. * rust/compile/macro50.rs: Move to... * rust/compile/macros/mbe/macro50.rs: ...here. * rust/compile/macro51.rs: Move to... * rust/compile/macros/mbe/macro51.rs: ...here. * rust/compile/macro52.rs: Move to... * rust/compile/macros/mbe/macro52.rs: ...here. * rust/compile/macro53.rs: Move to... * rust/compile/macros/mbe/macro53.rs: ...here. * rust/compile/macro54.rs: Move to... * rust/compile/macros/mbe/macro54.rs: ...here. * rust/compile/macro55.rs: Move to... * rust/compile/macros/mbe/macro55.rs: ...here. * rust/compile/macro56.rs: Move to... * rust/compile/macros/mbe/macro56.rs: ...here. * rust/compile/macro57.rs: Move to... * rust/compile/macros/mbe/macro57.rs: ...here. * rust/compile/macro6.rs: Move to... * rust/compile/macros/mbe/macro6.rs: ...here. * rust/compile/macro7.rs: Move to... * rust/compile/macros/mbe/macro7.rs: ...here. * rust/compile/macro8.rs: Move to... * rust/compile/macros/mbe/macro8.rs: ...here. * rust/compile/macro9.rs: Move to... * rust/compile/macros/mbe/macro9.rs: ...here. * rust/compile/macro_call_statement.rs: Move to... * rust/compile/macros/mbe/macro_call_statement.rs: ...here. * rust/compile/macro_export_1.rs: Move to... * rust/compile/macros/mbe/macro_export_1.rs: ...here. * rust/compile/macro_return.rs: Move to... * rust/compile/macros/mbe/macro_return.rs: ...here. * rust/compile/macro_rules_macro_rules.rs: Move to... * rust/compile/macros/mbe/macro_rules_macro_rules.rs: ...here. * rust/compile/macro_use1.rs: Move to... * rust/compile/macros/mbe/macro_use1.rs: ...here. * rust/compile/macros/mbe/mbe_macro.exp: New test. Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
2024-07-30Move builtin macro tests to their own directoryPierre-Emmanuel Patry16-31/+66
We need a finer grain to filter tests and organise them. gcc/testsuite/ChangeLog: * rust/compile/builtin_macro_compile_error.rs: Move to... * rust/compile/macros/builtin/compile_error.rs: ...here. * rust/compile/builtin_macro_concat.rs: Move to... * rust/compile/macros/builtin/concat.rs: ...here. * rust/compile/builtin_macro_eager1.rs: Move to... * rust/compile/macros/builtin/eager1.rs: ...here. * rust/compile/builtin_macro_eager2.rs: Move to... * rust/compile/macros/builtin/eager2.rs: ...here. * rust/compile/builtin_macro_eager3.rs: Move to... * rust/compile/macros/builtin/eager3.rs: ...here. * rust/compile/builtin_macro_env.rs: Move to... * rust/compile/macros/builtin/env.rs: ...here. * rust/compile/builtin_macro_include_bytes.rs: Move to... * rust/compile/macros/builtin/include_bytes.rs: ...here. * rust/compile/builtin_macro_include_bytes_location_info.rs: Move to... * rust/compile/macros/builtin/include_bytes_location_info.rs: ...here. * rust/compile/builtin_macro_include_str.rs: Move to... * rust/compile/macros/builtin/include_str.rs: ...here. * rust/compile/builtin_macro_include_str_location_info.rs: Move to... * rust/compile/macros/builtin/include_str_location_info.rs: ...here. * rust/compile/builtin_macro_not_found.rs: Move to... * rust/compile/macros/builtin/not_found.rs: ...here. * rust/compile/builtin_macro_recurse2.rs: Move to... * rust/compile/macros/builtin/recurse2.rs: ...here. * rust/compile/macros/builtin/builtin_macro.exp: New test. * rust/compile/invalid_utf8: Move invalid-utf8 data to... * rust/compile/macros/builtin/invalid_utf8: ...here. Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
2024-07-29github: Remove nightly Rust installationArthur Cohen2-5/+5
ChangeLog: * .github/workflows/ccpp.yml: Install Rust 1.72 instead of nightly. * .github/workflows/bootstrap.yml: Likewise.
2024-07-29ffi-polonius: Remove usage of extern types.Arthur Cohen2-5/+8
This will allow us to revert our dependency on extern types, which would help our godbolt build as well as our various builders. gcc/rust/ChangeLog: * checks/errors/borrowck/ffi-polonius/src/gccrs_ffi.rs: Remove extern type feature. * checks/errors/borrowck/ffi-polonius/src/lib.rs: Define FFIVector per the nomicon's recommendation https://doc.rust-lang.org/nomicon/ffi.html#representing-opaque-structs
2024-07-26Move procedural macro test to their own directoryPierre-Emmanuel Patry22-0/+35
gcc/testsuite/ChangeLog: * rust/compile/macros/proc/proc_macro.exp: New deja gnu file to execute proc-macro tests. * rust/compile/proc_macro_attribute_crate_type.rs: Move to... * rust/compile/macros/proc/attribute_crate_type.rs: ...here. * rust/compile/proc_macro_attribute_non_function.rs: Move to... * rust/compile/macros/proc/attribute_non_function.rs: ...here. * rust/compile/proc_macro_attribute_non_root_function.rs: Move to... * rust/compile/macros/proc/attribute_non_root_function.rs: ...here. * rust/compile/proc_macro_attribute_non_root_method.rs: Move to... * rust/compile/macros/proc/attribute_non_root_method.rs: ...here. * rust/compile/proc_macro_attribute_non_root_module.rs: Move to... * rust/compile/macros/proc/attribute_non_root_module.rs: ...here. * rust/compile/proc_macro_attribute_private.rs: Move to... * rust/compile/macros/proc/attribute_private.rs: ...here. * rust/compile/proc_macro_crate_type.rs: Move to... * rust/compile/macros/proc/crate_type.rs: ...here. * rust/compile/proc_macro_derive_crate_type.rs: Move to... * rust/compile/macros/proc/derive_crate_type.rs: ...here. * rust/compile/proc_macro_derive_malformed.rs: Move to... * rust/compile/macros/proc/derive_malformed.rs: ...here. * rust/compile/proc_macro_derive_non_function.rs: Move to... * rust/compile/macros/proc/derive_non_function.rs: ...here. * rust/compile/proc_macro_derive_non_root_function.rs: Move to... * rust/compile/macros/proc/derive_non_root_function.rs: ...here. * rust/compile/proc_macro_derive_non_root_module.rs: Move to... * rust/compile/macros/proc/derive_non_root_module.rs: ...here. * rust/compile/proc_macro_derive_private.rs: Move to... * rust/compile/macros/proc/derive_private.rs: ...here. * rust/compile/proc_macro_non_function.rs: Move to... * rust/compile/macros/proc/non_function.rs: ...here. * rust/compile/proc_macro_non_root_function.rs: Move to... * rust/compile/macros/proc/non_root_function.rs: ...here. * rust/compile/proc_macro_non_root_method.rs: Move to... * rust/compile/macros/proc/non_root_method.rs: ...here. * rust/compile/proc_macro_non_root_module.rs: Move to... * rust/compile/macros/proc/non_root_module.rs: ...here. * rust/compile/proc_macro_derive_non_root_method.rs: Move to... * rust/compile/macros/proc/non_root_trait_method.rs: ...here. * rust/compile/proc_macro_private.rs: Move to... * rust/compile/macros/proc/private.rs: ...here. * rust/compile/proc_macro_pub_function.rs: Move to... * rust/compile/macros/proc/pub_function.rs: ...here. * rust/compile/proc_macro_pub_module.rs: Move to... * rust/compile/macros/proc/pub_module.rs: ...here. Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
2024-07-25[#3045] #[may_dangle] in safe implLiam Naddell10-37/+122
gcc/rust/ChangeLog: * ast/rust-ast.cc: Fix Attribute constructors to copy inner_attribute * checks/errors/rust-unsafe-checker.cc: Add pass for #[may_dangle] in safe impl's * hir/rust-ast-lower-item.cc: Add support for unsafe impl's * hir/rust-ast-lower-type.cc: Lower attributes in impl's from AST to HIR * hir/rust-hir-dump.cc: Change single attribute to AttrVec * hir/tree/rust-hir-item.h: Add unsafe support to Impl blocks in HIR * hir/tree/rust-hir.cc: Change single attribute to AttrVec * hir/tree/rust-hir.h: Add has/get_outer_attribute to GenericParam gcc/testsuite/ChangeLog: * rust/compile/issue-3045-1.rs: Add test for #[may_dangle] Generic Type triggering error * rust/compile/issue-3045-2.rs: Add test for #[may_dangle] Lifetime triggering error Signed-off-by: Liam Naddell <liam.naddell@mail.utoronto.ca>
2024-07-25gccrs: Add rustc test directory for testsuite adaptorMuhammad Mahad2-0/+39
gcc/testsuite/ChangeLog: * rust/rustc/README.md: information about rustc external directory. * rust/rustc/rustc.exp: New test. Signed-off-by: Muhammad Mahad <mahadtxt@gmail.com>
2024-07-25Properly striping struct fields when using attrsAntonio Gomes3-0/+55
gcc/rust/ChangeLog: * expand/rust-cfg-strip.cc: Strip struct expr fields and strip fields in struct definition * expand/rust-cfg-strip.h: Signatures for new function maybe_strip_struct_expr_fields gcc/testsuite/ChangeLog: * rust/compile/macro-issue2983_2984.rs: Add test to check for correct stripped fields Signed-off-by: Antonio Gomes <antoniospg100@gmail.com>
2024-07-24gccrs: [E0576] Associated `item` not found in given `type`Muhammad Mahad2-1/+21
gcc/rust/ChangeLog: * typecheck/rust-hir-type-check-type.cc (TypeCheckType::visit): Add rich error message and error code similiar to rustc with associaed type and trait name gcc/testsuite/ChangeLog: * rust/compile/unknown-associated-item.rs: New test. Signed-off-by: Muhammad Mahad <mahadtxt@gmail.com>
2024-07-24Change bug report issue templatePierre-Emmanuel Patry2-25/+64
ChangeLog: * .github/ISSUE_TEMPLATE/bug_report.yml: New file. * .github/ISSUE_TEMPLATE/bug_report.md: Deleted old template. Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
2024-07-24[#2987] Patch ICE when deriving Clone and CopyLiam Naddell2-8/+26
gcc/rust/ChangeLog: * expand/rust-expand-visitor.cc: Fix ICE caused by unique_ptr UB and buggy iterator use gcc/testsuite/ChangeLog: * rust/compile/issue-2987.rs: Add test for deriving Clone and Copy at the same time Signed-off-by: Liam Naddell <liam.naddell@mail.utoronto.ca>
2024-07-24Fix ffi and enum conventionsbadumbatish4-25/+27
gcc/rust/ChangeLog: * ast/rust-fmt.h (enum ParseMode): Drop typedef in Cpp libgrust/ChangeLog: * libformat_parser/generic_format_parser/src/lib.rs: Remove repr(C) * libformat_parser/src/bin.rs: Use ffi * libformat_parser/src/lib.rs: pub ffi, create ParseMode and match rustc's parse mode
2024-07-24Added options for ParseModebadumbatish6-9/+25
gcc/rust/ChangeLog: * ast/rust-fmt.cc (Pieces::collect): Added options for ParseMode * ast/rust-fmt.h (collect_pieces): Likewise. (struct Pieces): Likewise. * expand/rust-macro-builtins-format-args.cc (MacroBuiltin::format_args_handler): Likewise. libgrust/ChangeLog: * libformat_parser/generic_format_parser/src/lib.rs: Likewise. * libformat_parser/src/bin.rs: Likewise. * libformat_parser/src/lib.rs: Likewise.
2024-07-24Change assertion of constructorbadumbatish1-11/+14
Change the assert of (expr != nullptr) to (this->expr != nullptr) because we assigned (std::move(expr)) to this->expr, no need to assert expr gcc/rust/ChangeLog: * ast/rust-expr.h (struct AnonConst): Change assertion of constructor (struct InlineAsmOperand): Change assertion of constructor
2024-07-18[#3046] ICE on failing to find enum variantLiam Naddell2-1/+31
gcc/rust/ChangeLog: * typecheck/rust-hir-type-check-expr.cc: Fix ICE caused by not finding enum variant by adding new error message gcc/testsuite/ChangeLog: * rust/compile/issue-3046.rs: Add test for new error message Signed-off-by: Liam Naddell <liam.naddell@mail.utoronto.ca>
2024-07-18Fix CI bootstrap build with a nightly rust compilerPierre-Emmanuel Patry1-0/+1
The CI failed to compile some recent code that requires a nightly feature. This change allows the CI to use a nightly compiler instead. ChangeLog: * .github/workflows/bootstrap.yml: Install nightly rustc. Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
2024-07-18Update pattern with \r* for dg-output testsbadumbatish2-3/+2
First scan with "rg -v '\\r' gcc/testsuite/rust | rg 'dg-output'" gcc/testsuite/ChangeLog: * rust/execute/torture/issue-2187.rs: Update pattern with \r* for dg-output tests * rust/execute/xfail/macro1.rs: Likewise
2024-07-17Improve error messages for operator expressionsAntonio Gomes4-6/+25
gcc/rust/ChangeLog: * hir/tree/rust-hir-expr.h: Add new get_operator_str method in ArithmeticOrLogicalExpr and CompoundAssignmentExpr * hir/tree/rust-hir.cc: Likewise * typecheck/rust-hir-type-check-expr.cc: Improve error message for operator expressions to display the correct operator symbol gcc/testsuite/ChangeLog: * rust/compile/shadow1.rs: Fix test for new error message Signed-off-by: Antonio Gomes <antoniospg100@gmail.com>
2024-07-16Introduce new class to handle borrow errorsKushal Pal4-17/+142
gcc/rust/ChangeLog: * Make-lang.in: Compile new file. * checks/errors/borrowck/rust-borrow-checker.cc (BorrowChecker::go): Use new class to report errors. * checks/errors/borrowck/rust-borrow-checker-diagnostics.cc: New file. * checks/errors/borrowck/rust-borrow-checker-diagnostics.h: New file, adds new class. Signed-off-by: Kushal Pal <kushalpal109@gmail.com>
2024-07-16Fix nightly rustc warningsKushal Pal3-31/+1
libgrust/ChangeLog: * libformat_parser/Cargo.toml: Used crate-type instead of depricated crate_type. * libformat_parser/generic_format_parser/src/lib.rs: Remove dead code. * libformat_parser/src/lib.rs: Likewise. Signed-off-by: Kushal Pal <kushalpal109@gmail.com>
2024-07-16Added FFIVector to get Polonius output on C++ sideKushal Pal9-17/+262
ChangeLog: * .github/workflows/ccpp.yml: Switch to nightly version of rustc to use unstable features, namely extern types for FFI. gcc/rust/ChangeLog: * Make-lang.in: Compile new file, rust-polonius.cc * checks/errors/borrowck/ffi-polonius/src/gccrs_ffi.rs: Opaque type to represent FFIVector from C++. * checks/errors/borrowck/ffi-polonius/src/gccrs_ffi_generated.rs: Change types of fields in Output. * checks/errors/borrowck/ffi-polonius/src/lib.rs: Added helper functions to contruct Polonius output on C++ side, used helpers to contruct Polonius output on C++ side. * checks/errors/borrowck/polonius/rust-polonius-ffi.h (make_vector): FFIVector is a wrapper around std::vector for transfering data from Rust to C++. (struct Output): Use pointers to FFIVector instead of bool to store Polonius output data. * checks/errors/borrowck/polonius/rust-polonius.h (FFIVector__new): Helper function. (FFIVector__new_vec_pair): Likewise. (FFIVector__new_vec_triple): Likewise. (FFIVector__push): Likewise. (FFIVector__push_vec_pair): Likewise. (FFIVector__push_vec_triple): Likewise. * checks/errors/borrowck/rust-borrow-checker.cc (BorrowChecker::go): Convert FFIVector to std::vector representation for easier navigation. * checks/errors/borrowck/polonius/rust-polonius.cc: New file, implementation of helper functions. Signed-off-by: Kushal Pal <kushalpal109@gmail.com>
2024-07-15rust: fix HIR dump for MatchExprMarc Poulhiès2-7/+38
The visitor was still using the as_string() method. gcc/rust/ChangeLog: * hir/rust-hir-dump.cc (Dump::do_matcharm): New. (Dump::do_matchcase): New. (Dump::visit(MatchExpr)): Adjust, don't use as_string. * hir/rust-hir-dump.h (Dump::do_matcharm, Dump::do_matchcase): New. Signed-off-by: Marc Poulhiès <dkm@kataplop.net>
2024-07-11[#3051] Remove unnecessary #include from rust-expr.hLiam Naddell1-2/+0
gcc/rust/ChangeLog: * ast/rust-expr.h: Remove unnecessary include. Signed-off-by: Liam Naddell <liam.naddell@mail.utoronto.ca>
2024-07-10Pin node16 by allowing old versionbadumbatish1-0/+3
ChangeLog: * .github/workflows/ccpp.yml: Pin node16 by allowing old version
2024-07-03Safe-guard InlineAsm structsbadumbatish2-66/+53
gcc/rust/ChangeLog: * ast/rust-expr.h (struct AnonConst): Safe-guard InlineAsm structs (struct InlineAsmOperand): Likewise. * expand/rust-macro-builtins-asm.cc (parse_reg_operand_in): Likewise. (parse_reg_operand_out): Likewise. (parse_reg_operand_inout): Likewise. Signed-off-by: badumbatish <tanghocle456@gmail.com>
2024-07-01Store parse result of parse_format_string(s)badumbatish2-3/+21
gcc/rust/ChangeLog: * ast/rust-expr.h (struct TupleTemplateStr): Store parse result of parse_format_string(s) * expand/rust-macro-builtins-asm.cc (parse_format_strings): Likewise Signed-off-by: badumbatish <tanghocle456@gmail.com>
2024-06-28Clean up monadic operations on expected<>jjasmine1-5/+3
gcc/rust/ChangeLog: * expand/rust-macro-builtins-asm.cc (parse_asm): Clean up monadic operations on expected<> Signed-off-by: badumbatish <tanghocle456@gmail.com>
2024-06-28Addresses warning, put warn unused in right placejjasmine2-11/+34
gcc/rust/ChangeLog: * expand/rust-macro-builtins-asm.cc (parse_reg_operand): Addresses warning, put warn unused in right place (parse_reg_operand_inout): Likewise. (parse_asm_arg): Likewise. * expand/rust-macro-builtins-asm.h (enum WARN_UNUSED_RESULT): Likewise. (enum InlineAsmParseError): Likewise. (validate): Likewise. (parse_asm_arg): Likewise. (parse_format_strings): Likewise. (parse_clobber_abi): Likewise. (parse_reg_operand): Likewise. (parse_reg_operand_in): Likewise. (parse_reg_operand_out): Likewise. (parse_reg_operand_lateout): Likewise. (parse_reg_operand_inout): Likewise. (parse_reg_operand_inlateout): Likewise. (parse_reg_operand_const): Likewise. (parse_reg_operand_sym): Likewise. (parse_reg_operand_unexpected): Likewise. (parse_asm): Likewise. (check_and_set): Likewise. (parse_options): Likewise. (parse_reg): Likewise. (parse_format_string): Likewise. Signed-off-by: badumbatish <tanghocle456@gmail.com>
2024-06-28Add WARN_UNUSED_RESULT parse errorjjasmine1-1/+2
gcc/rust/ChangeLog: * expand/rust-macro-builtins-asm.h (enum InlineAsmParseError): Add WARN_UNUSED_RESULT parse error (enum WARN_UNUSED_RESULT): Likewise. Signed-off-by: badumbatish <tanghocle456@gmail.com>
2024-06-28Added a test that is expected to failjjasmine4-31/+60
gcc/rust/ChangeLog: * expand/rust-macro-builtins-asm.cc (parse_clobber_abi): added comments (parse_options): Likewise (parse_asm_arg): Likewise (parse_asm): Likewise * expand/rust-macro-builtins-asm.h: Likewise gcc/testsuite/ChangeLog: * rust/compile/inline_asm_illegal_options.rs: new test * rust/compile/inline_asm_illegal_operands.rs: New test. This is expected to fail but we couldn't resolve parse_expr()'s general functionality yet Signed-off-by: badumbatish <tanghocle456@gmail.com>