aboutsummaryrefslogtreecommitdiff
path: root/gcc
AgeCommit message (Collapse)AuthorFilesLines
2024-04-16Rust: Move 'libformat_parser' build into libgrustThomas Schwinge1-15/+1
Addresses #2883. contrib/ * gcc_update (files_and_dependencies): Update for 'libformat_parser' in libgrust. gcc/rust/ * Make-lang.in (LIBFORMAT_PARSER): Point to 'libformat_parser' build in libgrust. (%.toml:, $(LIBFORMAT_PARSER):): Remove. libgrust/ * libformat_parser/Makefile.am: New. * Makefile.am [!TARGET_LIBRARY] (SUBDIRS): Add 'libformat_parser'. * configure.ac: Handle it. (TARGET_LIBRARY): New 'AM_CONDITIONAL'. * libformat_parser/Makefile.in: Generate. * Makefile.in: Regenerate. * configure: Likewise.
2024-04-16Rust: Move 'libformat_parser' build into the GCC build directoryThomas Schwinge1-2/+9
Fixes #2883. * .gitignore: Remove 'libgrust/*/target/'. gcc/rust/ * Make-lang.in (LIBFORMAT_PARSER): Point to the GCC build directory. * ($(LIBFORMAT_PARSER)): Build in the GCC build directory.
2024-04-16Rust: Don't cache 'libformat_parser.a'Thomas Schwinge1-2/+1
gcc/rust/ * Make-lang.in (LIBFORMAT_PARSER): Point to the actual build artifact. ($(LIBFORMAT_PARSER)): Don't cache it.
2024-04-16Inline 'gcc/rust/Make-lang.in:RUST_LIBDEPS'Thomas Schwinge1-3/+1
gcc/rust/ * Make-lang.in (RUST_LIBDEPS): Inline into all users.
2024-04-16Add 'gcc/rust/Make-lang.in:LIBFORMAT_PARSER'Thomas Schwinge1-3/+4
... to avoid verbatim repetition. gcc/rust/ * Make-lang.in (LIBPROC_MACRO_INTERNAL): New. (RUST_LIBDEPS, crab1$(exeext), rust/libformat_parser.a): Use it.
2024-04-16Add 'gcc/rust/Make-lang.in:LIBPROC_MACRO_INTERNAL'Thomas Schwinge1-2/+4
... to avoid verbatim repetition. gcc/rust/ * Make-lang.in (LIBPROC_MACRO_INTERNAL): New. (RUST_LIBDEPS, crab1$(exeext)): Use it.
2024-04-16Inline 'gcc/rust/Make-lang.in:RUST_LDFLAGS'Thomas Schwinge1-2/+1
Unused. gcc/rust/ * Make-lang.in (RUST_LDFLAGS): Inline into all users.
2024-04-16Remove 'libgrust/libproc_macro_internal' from ↵Thomas Schwinge1-1/+1
'gcc/rust/Make-lang.in:RUST_LDFLAGS' This isn't necessary, as the full path to 'libproc_macro_internal.a' is specified. gcc/rust/ * Make-lang.in (RUST_LDFLAGS): Remove 'libgrust/libproc_macro_internal'.
2024-04-16Remove 'libgrust/librustc_format_parser' from ↵Thomas Schwinge1-1/+1
'gcc/rust/Make-lang.in:RUST_LDFLAGS' That directory doesn't even exist. gcc/rust/ * Make-lang.in (RUST_LDFLAGS): Remove 'libgrust/librustc_format_parser'.
2024-04-10rust: Add --offline flag to cargo when building Rust components.Arthur Cohen1-1/+2
gcc/rust/ChangeLog: * Make-lang.in: Add --offline flag to cargo invocation.
2024-04-10Merge commit 'f5a805d82902fe2d6e0a7af8c0e6519f9d25a8f3' into HEADThomas Schwinge3032-10313/+27870
2024-04-10Merge commit '8534cc772def8142379c0e72ab6392d40f3f60f6^' into HEADThomas Schwinge279-285333/+357894
2024-04-10Merge commit 'f0b1cf01782ba975cfda32800c91076df78058d6^' into HEADThomas Schwinge316-1411/+6163
2024-04-10Merge commit 'f89186f962421f6d972035fc4b4c20490e7b1c5b^' into HEADThomas Schwinge658-14868/+27079
2024-04-10Merge commit 'ceed844b5284aeabbdfe25ccf099e7ebeeb14a9b^' into HEADThomas Schwinge3042-6013/+27153
2024-04-10Merge commit '2341df1cb9b3681bfefe29207887b2b3dc271a95^' into HEADThomas Schwinge98-791/+11950
2024-04-10Merge commit 'a5258f3a11ab577835ef5e93be5cb65ec9e44132^' into HEADThomas Schwinge2-0/+26
2024-04-10Merge commit 'fc59a3995cb46c190c0efb0431ad204e399975c4^' into HEADThomas Schwinge749-2842/+22828
2024-04-04borrowck: Bump copyright noticeJakub Dupak7-5/+41
gcc/rust/ChangeLog: * checks/errors/borrowck/ffi-polonius/src/gccrs_ffi.rs: Bump copyright. * checks/errors/borrowck/ffi-polonius/src/lib.rs: Bump copyright. * checks/errors/borrowck/polonius/rust-polonius-ffi.h: Bump copyright. * checks/errors/borrowck/polonius/rust-polonius.h: Bump copyright. * checks/errors/borrowck/rust-bir-dump.cc: Bump copyright. * checks/errors/borrowck/rust-bir-fact-collector.h: Bump copyright. * checks/errors/borrowck/rust-bir-free-region.h: Bump copyright. Signed-off-by: Jakub Dupak <dev@jakubdupak.com>
2024-04-04borrowck: Remove block braces to satisfy GNU styleJakub Dupak6-121/+56
gcc/rust/ChangeLog: * checks/errors/borrowck/rust-bir-dump.cc (renumber_places): Remove unecessary braces. (Dump::go): Remove unecessary braces. (Dump::visit): Remove unecessary braces. (Dump::visit_scope): Remove unecessary braces. * checks/errors/borrowck/rust-bir-fact-collector.h (class FactCollector): Remove unecessary braces. (points): Remove unecessary braces. * checks/errors/borrowck/rust-bir-free-region.h: Remove unecessary braces. * checks/errors/borrowck/rust-bir-place.h: Remove unecessary braces. * checks/errors/borrowck/rust-borrow-checker.cc (BorrowChecker::go): Remove unecessary braces. * checks/errors/borrowck/rust-function-collector.h: Remove unecessary braces. Signed-off-by: Jakub Dupak <dev@jakubdupak.com>
2024-04-04borrowck: Fact collectorJakub Dupak2-0/+898
This is the main Polonius based logic which creates the information Polonius needs from BIR. It is largly guessed and rever engineered, so some aspects are probably wrong. gcc/rust/ChangeLog: * checks/errors/borrowck/rust-bir-fact-collector.h: New file. * checks/errors/borrowck/rust-borrow-checker.cc (BorrowChecker::go): Enable fact collection. Signed-off-by: Jakub Dupak <dev@jakubdupak.com>
2024-04-04borrowck: Regions in BIRJakub Dupak8-275/+610
gcc/rust/ChangeLog: * checks/errors/borrowck/rust-bir-place.h (struct Lifetime): Extended regions and loans. (struct Loan): Representation of loan (result of borrowing) * checks/errors/borrowck/rust-bir-builder-expr-stmt.cc (ExprStmtBuilder::visit): Fix let stmt handling. * checks/errors/borrowck/rust-bir-builder-pattern.h: improved pattern translation * checks/errors/borrowck/rust-bir-builder-internal.h: region binding * checks/errors/borrowck/rust-bir-builder-expr-stmt.h (class ExprStmtBuilder): Region support. (class RenumberCtx): Region support. * checks/errors/borrowck/rust-bir-builder.h (class Builder): Region support. * checks/errors/borrowck/rust-bir-dump.cc (get_lifetime_name): Region support. (renumber_places): Region support. (Dump::go): Region support. (Dump::visit): Region support. (Dump::visit_lifetime): Region support. (Dump::visit_scope): Region support. * checks/errors/borrowck/rust-bir.h (class AbstractExpr): Region support. (struct Function): Region support. (class BorrowExpr): Region support. (class CallExpr): Region support. Signed-off-by: Jakub Dupak <dev@jakubdupak.com>
2024-04-04borrowck: extract regions from types using VAJakub Dupak3-19/+140
Biggybag on variance analysis to extract regions of fields from ADT regions. gcc/rust/ChangeLog: * typecheck/rust-tyty-variance-analysis-private.h (class FieldVisitorCtx): Region extraction. * typecheck/rust-tyty-variance-analysis.cc (query_field_regions): Region extraction. (FieldVisitorCtx::collect_regions): Region extraction. (FieldVisitorCtx::add_constraints_from_ty): Region extraction. (FieldVisitorCtx::add_constraints_from_region): Region extraction. (FieldVisitorCtx::add_constrints_from_param): Region extraction. * typecheck/rust-tyty-variance-analysis.h (query_field_regions): Region extraction. Signed-off-by: Jakub Dupak <dev@jakubdupak.com>
2024-04-04borrowck: Free region representationJakub Dupak1-0/+107
gcc/rust/ChangeLog: * checks/errors/borrowck/rust-bir-free-region.h: New file. Signed-off-by: Jakub Dupak <dev@jakubdupak.com>
2024-04-04borrowck: Polonius FFIJakub Dupak6-0/+596
Rust part is not build and not invoked at this point. gcc/rust/ChangeLog: * checks/errors/borrowck/ffi-polonius/Cargo.toml: New file. * checks/errors/borrowck/ffi-polonius/src/gccrs_ffi.rs: New file. * checks/errors/borrowck/ffi-polonius/src/gccrs_ffi_generated.rs: New file. * checks/errors/borrowck/ffi-polonius/src/lib.rs: New file. * checks/errors/borrowck/polonius/rust-polonius-ffi.h: New file. * checks/errors/borrowck/polonius/rust-polonius.h: New file. Signed-off-by: Jakub Dupak <dev@jakubdupak.com>
2024-04-04borrowck: BIR: make BIR visitor constJakub Dupak4-22/+26
gcc/rust/ChangeLog: * checks/errors/borrowck/rust-bir-dump.cc (Dump::visit): const visitor * checks/errors/borrowck/rust-bir-dump.h: const visitor * checks/errors/borrowck/rust-bir-visitor.h: const visitor * checks/errors/borrowck/rust-bir.h: const getter Signed-off-by: Jakub Dupak <dev@jakubdupak.com>
2024-04-04borrowck: BIR: emit movesJakub Dupak7-80/+103
gcc/rust/ChangeLog: * checks/errors/borrowck/rust-bir-builder-expr-stmt.cc (ExprStmtBuilder::visit): Emit moves. * checks/errors/borrowck/rust-bir-builder-internal.h: Emit moves. * checks/errors/borrowck/rust-bir-builder-lazyboolexpr.h: Emit moves. * checks/errors/borrowck/rust-bir-dump.cc (Dump::visit_move_place): Emit moves. (Dump::visit): Emit moves. * checks/errors/borrowck/rust-bir-place.h (struct Place): Emit moves. * checks/errors/borrowck/rust-bir-visitor.h: Emit moves. * checks/errors/borrowck/rust-bir.h (enum class): Emit moves. (class AbstractExpr): Emit moves. (BasicBlock::is_terminated): Emit moves. Signed-off-by: Jakub Dupak <dev@jakubdupak.com>
2024-04-04borrowck: BIR: scope handlingJakub Dupak5-37/+188
gcc/rust/ChangeLog: * checks/errors/borrowck/rust-bir-builder-expr-stmt.cc (ExprStmtBuilder::setup_loop): Loop handling. (ExprStmtBuilder::visit): Handle scopes. * checks/errors/borrowck/rust-bir-builder-internal.h (struct BuilderContext): Handle scopes. * checks/errors/borrowck/rust-bir-dump.cc (Dump::go): Dump scopes. (Dump::visit): Add scopes dump. (Dump::indent): Add indentation logic. (Dump::visit_scope): Dump scope. * checks/errors/borrowck/rust-bir-dump.h: Dump methods. * checks/errors/borrowck/rust-bir-place.h (std::numeric_limits::max): Scope constants. (struct Scope): Scope representation. (class PlaceDB): Scope tracking. Signed-off-by: Jakub Dupak <dev@jakubdupak.com>
2024-04-04borrowck: BIR: Place tree traverse APIJakub Dupak1-0/+23
gcc/rust/ChangeLog: * checks/errors/borrowck/rust-bir-place.h: Create place tree traverse API. Signed-off-by: Jakub Dupak <dev@jakubdupak.com>
2024-04-04borrowck: BIR: use callable APIJakub Dupak1-18/+5
gcc/rust/ChangeLog: * checks/errors/borrowck/rust-bir-builder-expr-stmt.cc (ExprStmtBuilder::visit): Use callable API Signed-off-by: Jakub Dupak <dev@jakubdupak.com>
2024-04-04borrowck: Unify BIR terminilogy (node->statement)Jakub Dupak8-59/+62
gcc/rust/ChangeLog: * checks/errors/borrowck/bir-design-notes.md (nodes): Rename node to statement. (Nodes): Rename node to statement. * checks/errors/borrowck/rust-bir-builder-expr-stmt.cc (ExprStmtBuilder::visit): Rename node to statement. * checks/errors/borrowck/rust-bir-builder-internal.h: Rename node to statement. * checks/errors/borrowck/rust-bir-builder.h: Rename node to statement. * checks/errors/borrowck/rust-bir-dump.cc (Dump::go): Rename node to statement. (Dump::visit): Rename node to statement. * checks/errors/borrowck/rust-bir-dump.h (class Dump): Rename node to statement. * checks/errors/borrowck/rust-bir-visitor.h (class Node): Rename node to statement. (class Statement): Rename node to statement. * checks/errors/borrowck/rust-bir.h (class Node): Rename node to statement. (class Statement): Rename node to statement. (class AbstractExpr): Rename node to statement. (struct Function): Rename node to statement. (struct BasicBlock): Rename node to statement. Signed-off-by: Jakub Dupak <dev@jakubdupak.com>
2024-04-04borrowck: Use rust-system.hJakub Dupak9-13/+10
Replace direct usage of system headers. gcc/rust/ChangeLog: * checks/errors/borrowck/rust-bir-dump.cc: Use rust-system.h * checks/errors/borrowck/rust-bir-dump.h (RUST_BIR_DUMP_H): Use rust-system.h * checks/errors/borrowck/rust-bir-place.h (RUST_BIR_PLACE_H): Use rust-system.h * checks/errors/borrowck/rust-function-collector.h: Use rust-system.h * rust-system.h: Use rust-system.h * typecheck/rust-hir-type-check.h: Use rust-system.h * typecheck/rust-tyty-subst.cc: Use rust-system.h * typecheck/rust-tyty-subst.h: Use rust-system.h * typecheck/rust-tyty.h: Use rust-system.h Signed-off-by: Jakub Dupak <dev@jakubdupak.com>
2024-04-03unify: Always coerce `!` to the target type.Arthur Cohen3-25/+45
Never can... never... exist, so it should always be coerced to the type it is being matched against. This is useful for breaking off of a loop from inside a match, or an if condition, for example. gcc/rust/ChangeLog: * typecheck/rust-unify.cc (UnifyRules::go): Always unify to `ltype` if we are matching against a `Never` in `rtype`. (UnifyRules::expect_never): Always unify to the expected type. gcc/testsuite/ChangeLog: * rust/compile/match-never-ltype.rs: New test. * rust/compile/match-never-rtype.rs: New test.
2024-04-03raw-strings: Remove dg-excess-error directiveArthur Cohen2-2/+2
The error is actually expected and uses the correct location. gcc/testsuite/ChangeLog: * rust/compile/raw-byte-string-loc.rs: Use dg-error instead of dg-excess-error. * rust/compile/raw-string-loc.rs: Likewise.
2024-03-28Improve parsing of raw string literalsOwen Avery2-3/+24
gcc/rust/ChangeLog: * lex/rust-lex.cc (Lexer::parse_raw_string): Bring handling of edge cases to par with parse_raw_byte_string. gcc/testsuite/ChangeLog: * rust/compile/raw-string-loc.rs: New test. Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
2024-03-27Avoid parsing const unsafe/extern functions as asyncOwen Avery2-2/+3
gcc/rust/ChangeLog: * parse/rust-parse-impl.h (Parser::parse_vis_item): Call parse_function instead of parse_async_item when finding UNSAFE or EXTERN_KW during lookahead. gcc/testsuite/ChangeLog: * rust/compile/func-const-unsafe.rs: New test. Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
2024-03-27Recognize unstable as a builtin attributeOwen Avery3-1/+5
gcc/rust/ChangeLog: * util/rust-attribute-values.h (Attributes::UNSTABLE): New. * util/rust-attributes.cc (__definitions): Add Attributes::UNSTABLE. gcc/testsuite/ChangeLog: * rust/compile/unstable-fn.rs: New test. Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
2024-03-27Recognize rustc_deprecated as a builtin attributeOwen Avery3-0/+6
gcc/rust/ChangeLog: * util/rust-attribute-values.h (Attributes::RUSTC_DEPRECATED): New. * util/rust-attributes.cc (__definitions): Add Attributes::RUSTC_DEPRECATED. gcc/testsuite/ChangeLog: * rust/compile/deprecated-fn.rs: New test. Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
2024-03-27Improve parsing of raw byte string literalsOwen Avery2-4/+25
gcc/rust/ChangeLog: * lex/rust-lex.cc (Lexer::parse_raw_byte_string): Bring handling of edge cases to par with parse_byte_string. gcc/testsuite/ChangeLog: * rust/compile/raw-byte-string-loc.rs: New test. Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
2024-03-26Change dfs function return type to support gcc 4.8Pierre-Emmanuel Patry2-4/+8
GCC 4.8 does not handle pair with references correctly. We need to use a properly typed struct instead. gcc/rust/ChangeLog: * resolve/rust-forever-stack.h: Change dfs function prototype and declare dfs return type structure. * resolve/rust-forever-stack.hxx: Adapt dfs function to the new return type. Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
2024-03-26Add globbing name resolution 2.0 testPierre-Emmanuel Patry2-0/+34
Add a few test for globbing to highlight function call ambiguities. gcc/testsuite/ChangeLog: * rust/compile/name_resolution23.rs: New test. * rust/compile/name_resolution24.rs: New test. Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
2024-03-26nr2.0: Add new test cases.Arthur Cohen9-1/+126
gcc/testsuite/ChangeLog: * rust/compile/name_resolution13.rs: Add new module and remove compile step. * rust/compile/name_resolution14.rs: New test. * rust/compile/name_resolution15.rs: New test. * rust/compile/name_resolution16.rs: New test. * rust/compile/name_resolution17.rs: New test. * rust/compile/name_resolution18.rs: New test. * rust/compile/name_resolution19.rs: New test. * rust/compile/name_resolution20.rs: New test. * rust/compile/name_resolution21.rs: New test.
2024-03-26compile: resolve-path-ref: properly resolve nodeId with nr2.0Arthur Cohen2-44/+74
gcc/rust/ChangeLog: * backend/rust-compile-resolve-path.cc: Attempt to resolve names also using new name resolution context. * backend/rust-compile-resolve-path.h: Add new declaration.
2024-03-26Fix use rebind name resolution.Pierre-Emmanuel Patry2-48/+151
Name resolution for rebind were missing. gcc/rust/ChangeLog: * resolve/rust-toplevel-name-resolver-2.0.cc (TopLevel::handle_use_glob): Change function prototype to use a reference instead. (TopLevel::handle_use_dec): Likewise. (TopLevel::handle_rebind): Add name resolution on rebind use declarations. (flatten_rebind): Change prototype to accept a pair of path/alias. (flatten_list): Adapt call to flatten_rebind. (flatten): Adapt call to flatten_rebind. (flatten_glob): Remove unused part. (TopLevel::visit): Add rebind resolution. * resolve/rust-toplevel-name-resolver-2.0.h: Adapt function prototypes. Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
2024-03-26Add mappings for struct base and struct fieldsPierre-Emmanuel Patry2-0/+23
Definition/usage mapping during name resolution was missing. gcc/rust/ChangeLog: * resolve/rust-late-name-resolver-2.0.cc (Late::visit): Add mapping implementation. * resolve/rust-late-name-resolver-2.0.h: Add function visitor prototype override. Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
2024-03-26Fix quoted string formatPierre-Emmanuel Patry1-1/+1
This format dialog triggered a warning. gcc/rust/ChangeLog: * resolve/rust-toplevel-name-resolver-2.0.cc (TopLevel::handle_use_dec): Replace the string format %<%s%> with the proper %qs format. Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
2024-03-26Prevent getting immutable context with classic nrPierre-Emmanuel Patry2-14/+17
Immutable name resolution context is not initialized when the classic name resolution is in use. It can therefore not be used, the getter would error out. gcc/rust/ChangeLog: * typecheck/rust-hir-type-check-path.cc (TypeCheckExpr::resolve_root_path): Only get immutable name resolution context when name resolution 2.0 is used. * typecheck/rust-hir-type-check-type.cc (TypeCheckType::resolve_root_path): Likewise. Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
2024-03-26Update assignment operator with cratenumPierre-Emmanuel Patry1-0/+1
Crate number was not assigned with the other fields in the assignment operator overload of a CannonicalPath. gcc/rust/ChangeLog: * util/rust-canonical-path.h: Also assign crate number. Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
2024-03-26Reinject Self parameter in new resolverPierre-Emmanuel Patry2-0/+24
The old resolver injected a Self generic parameter in order to help the trait solver. This is clearly sketchy at best and should be fixed in the future. gcc/rust/ChangeLog: * resolve/rust-toplevel-name-resolver-2.0.cc (TopLevel::visit): Add Self generic parameter injection and a warning. * resolve/rust-toplevel-name-resolver-2.0.h: Add function prototype. Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
2024-03-26Use new name resolver to compile constant itemsPierre-Emmanuel Patry1-10/+26
Constant items were handled only by the old resolver, this lead to an ICE when using the new resolver on some rust code containing a constant item as the new and the old resolver cannot be used at the same time. gcc/rust/ChangeLog: * backend/rust-compile-item.cc (CompileItem::visit): Check the resolver flag and use the new one when required. Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>