aboutsummaryrefslogtreecommitdiff
AgeCommit message (Collapse)AuthorFilesLines
2024-04-10Merge commit 'ceed844b5284aeabbdfe25ccf099e7ebeeb14a9b^' into HEADThomas Schwinge3120-6312/+28693
2024-04-10Merge commit '2341df1cb9b3681bfefe29207887b2b3dc271a95' into HEAD [#2801]Thomas Schwinge0-0/+0
2024-04-10Merge commit '2341df1cb9b3681bfefe29207887b2b3dc271a95^' into HEADThomas Schwinge134-812/+15957
2024-04-10Merge commit 'e621b174d7c622aa4b677a4c812e5061e311cc5c' into HEADThomas Schwinge0-0/+0
2024-04-10Merge commit 'a5258f3a11ab577835ef5e93be5cb65ec9e44132^' into HEADThomas Schwinge2-0/+26
2024-04-10Merge commit '4bd09ce06f50d266c992c984cc993384d5e6655e' into HEADThomas Schwinge0-0/+0
2024-04-10Merge commit '7a6906c8d80e437a97c780370a8fec4e00561c7b' into HEAD [#2288]Thomas Schwinge0-0/+0
2024-04-10Merge commit 'fc59a3995cb46c190c0efb0431ad204e399975c4' into HEAD [#2183]Thomas Schwinge0-0/+0
2024-04-10Merge commit 'fc59a3995cb46c190c0efb0431ad204e399975c4^' into HEADThomas Schwinge828-3767/+25582
2024-04-09Fix grammar as pointed out by MarcJasmine Tang1-2/+2
ChangeLog: * README.md (gccrs-workspace]): like-wise.
2024-04-09Add an alternative solution on MacOSJasmine Tang1-0/+6
For #2937. ChangeLog: * README.md (gccrs-workspace]): like-wise.
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>
2024-03-26Remove unsafe block empty visit functionPierre-Emmanuel Patry2-5/+0
We need to visit subcomponents in unsafe elements, this means we can leverage the default ast visitor's code instead of duplicating it. gcc/rust/ChangeLog: * resolve/rust-default-resolver.cc (DefaultResolver::visit): Remove empty visit function. * resolve/rust-default-resolver.h: Remove function prototype. Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
2024-03-26Remove extern block scopingPierre-Emmanuel Patry2-13/+0
Remove extern block scoping visit function, use the default visitor visit function instead. We do not need scoping for extern block as their element shall be visible from the extern block scope. gcc/rust/ChangeLog: * resolve/rust-default-resolver.cc (DefaultResolver::visit): Remove visitor implementation and scoping. * resolve/rust-default-resolver.h: Remove function prototype. Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
2024-03-26Add constant identifiers to the value namespacePierre-Emmanuel Patry1-0/+3
Constants could not be resolved without their identifier in the right scope. gcc/rust/ChangeLog: * resolve/rust-toplevel-name-resolver-2.0.cc (TopLevel::visit): Add constant identifiers to the resolver. Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
2024-03-26Struct are types, not valuesPierre-Emmanuel Patry1-1/+3
We shall search in the right namespace. The correct namespace for struct is type namespace. gcc/rust/ChangeLog: * typecheck/rust-hir-type-check-item.cc (TypeCheckItem::visit): Change search location for struct types. Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
2024-03-26Change enum namespace from value to typePierre-Emmanuel Patry1-1/+1
The enum type shall be in type namespace, not value namespace. gcc/rust/ChangeLog: * resolve/rust-toplevel-name-resolver-2.0.cc (GlobbingVisitor::visit): Change enum type namespace. Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
2024-03-26Add tuple struct to the type namespacePierre-Emmanuel Patry1-2/+7
Only tuple struct constructor was added to the resolver. gcc/rust/ChangeLog: * resolve/rust-toplevel-name-resolver-2.0.cc (GlobbingVisitor::visit): Add tuple struct type to the resolver's context. Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
2024-03-26Unit struct constructor shall be resolvedPierre-Emmanuel Patry1-2/+7
Unit struct have a special constructor that should be added to the struct namespace in order to be resolved later when called. As it is a function it should be added in the value namespace. gcc/rust/ChangeLog: * resolve/rust-toplevel-name-resolver-2.0.cc (GlobbingVisitor::visit): Add the struct constructor when the struct is a unit. Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>