summaryrefslogtreecommitdiff
Commit message (Collapse)AuthorAgeFilesLines
* cli: Add frust-extern optiondevel/rust/masterPierre-Emmanuel Patry2023-04-283-0/+26
| | | | | | | | | | | | | | Add a new option to gather extern crates location. gcc/rust/ChangeLog: * lang.opt: Add frust-extern option. * rust-session-manager.cc (Session::handle_extern_option): Add frust-extern option handler. * rust-session-manager.h (struct Session): Add an unordered map to store library name and locations. Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
* Fix infinite loop with parsing invalid generic parametersOwen Avery2023-04-282-0/+4
| | | | | | | | | | | | | | gcc/rust/ChangeLog: * parse/rust-parse-impl.h (Parser::parse_generic_params): Handle parameter parsing error. gcc/testsuite/ChangeLog: * rust/compile/issue-2125.rs: New test. Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
* gccrs: Improve operator overload check for recursive overloadPhilip Herron2023-04-281-31/+59
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is a case in #2019 where you have the default Add impl for i32 for example which has: impl Add for i32 { fn add(self, other:i32) { self + other } } This function will do a check for operator overload which then is able to find multiple candidates such as: impl<'a> Add<i32> for &'a i32 { type Output = <i32 as Add<i32>>::Output; fn add(self, other: i32) -> <i32 as Add<i32>>::Output { Add::add(*self, other) } } This initial operator overload will resolve to this as it looks like a valid candidate. This patch adds another level of checks to ensure the candidate does not equal the current context DefId. Addresses #2019 gcc/rust/ChangeLog: * typecheck/rust-hir-type-check-expr.cc: update for op overload Signed-off-by: Philip Herron <herron.philip@googlemail.com>
* gccrs: qualified path syntax is used to disambiguate predicatesPhilip Herron2023-04-282-35/+66
| | | | | | | | | | | | | | | | | | | | | When resolving a qualified path we need to use the predicate to lookup the relevant assoicated impl block where possible. The issue here is that it might not have one due to a valid error in the impl block or it might be used within a trait this is a valid case. Generally we will be able to resolve to an impl block then it can grab that type and move on. Fixes #2135 gcc/rust/ChangeLog: * typecheck/rust-hir-type-check-path.cc (TypeCheckExpr::visit): use the predicate (TypeCheckExpr::resolve_segments): cleanup gcc/testsuite/ChangeLog: * rust/compile/issue-2135.rs: New test. Signed-off-by: Philip Herron <herron.philip@googlemail.com>
* gccrs: Extract helper lookup_associated_impl_blockPhilip Herron2023-04-289-149/+183
| | | | | | | | | | | | | | | | | | | | | | | | | | | | This will look for a specified predicate that is associated with it so we might have the predicate Foo<u16, i32> which would refer to: impl Foo<i32> for u16 {} This is a general helper which can be used in several places. gcc/rust/ChangeLog: * typecheck/rust-hir-trait-reference.cc (AssociatedImplTrait::AssociatedImplTrait): bind the predicate (AssociatedImplTrait::get_trait): remove (AssociatedImplTrait::get_predicate): new getter * typecheck/rust-hir-trait-reference.h: bind predicate * typecheck/rust-hir-type-check-item.cc: update ctor * typecheck/rust-type-util.cc (lookup_associated_impl_block): new function * typecheck/rust-type-util.h (class BaseType): remove unused forward decl (lookup_associated_impl_block): new helper * typecheck/rust-tyty-bounds.cc (TypeBoundPredicate::is_equal): new * typecheck/rust-tyty-subst.cc (SubstitutionRef::lookup_associated_impl): use new helper (SubstitutionRef::monomorphize): update usage/error handling * typecheck/rust-tyty-subst.h: remove old prototype * typecheck/rust-tyty.h: add is_equal decl Signed-off-by: Philip Herron <herron.philip@googlemail.com>
* Type check StructPatternFieldIdentPatOwen Avery2023-04-281-2/+17
| | | | | | | | | gcc/rust/ChangeLog: * typecheck/rust-hir-type-check-pattern.cc (TypeCheckPattern::visit): Type check StructPatternFieldIdentPat. Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
* Lower StructPatternFieldIdentPatOwen Avery2023-04-281-2/+17
| | | | | | | | | gcc/rust/ChangeLog: * hir/rust-ast-lower-pattern.cc (ASTLoweringPattern::visit): Lower StructPatternFieldIdentPat. Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
* gccrs: resolve the associated_predicate when mapping Fn traitsPhilip Herron2023-04-272-6/+12
| | | | | | | | | | | | This is required to solve #2105 gcc/rust/ChangeLog: * typecheck/rust-hir-type-check-expr.cc (TypeCheckExpr::resolve_fn_trait_call): return the assoicated predicate * typecheck/rust-hir-type-check-expr.h: update prototype Signed-off-by: Philip Herron <herron.philip@googlemail.com>
* gccrs: Add missing where clause lowering for Impl functionsPhilip Herron2023-04-273-1/+32
| | | | | | | | | | | | | | | Fixes #2106 gcc/rust/ChangeLog: * hir/rust-ast-lower-implitem.h: add missing where clause lowering gcc/testsuite/ChangeLog: * rust/compile/issue-2106.rs: New test. * rust/compile/issue-1524.rs: regression (placeholder generic) Signed-off-by: Philip Herron <herron.philip@googlemail.com>
* gccrs: Add missing TypeBoundWhereClauseItem::get_locusPhilip Herron2023-04-271-0/+2
| | | | | | | | gcc/rust/ChangeLog: * hir/tree/rust-hir-item.h: add get_locus() const Signed-off-by: Philip Herron <herron.philip@googlemail.com>
* Add accessors to HIR::StructPatternFieldIdentPatOwen Avery2023-04-271-0/+4
| | | | | | | | | | gcc/rust/ChangeLog: * hir/tree/rust-hir-pattern.h (StructPatternFieldIdentPat::get_identifier): New. (StructPatternFieldIdentPat::get_pattern): New. Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
* gccrs: Minor tuning in AST dumpMarc Poulhiès2023-04-261-2/+3
| | | | | | | | | | | Use parentheses to remove any ambiguities when dumping expressions with unary ! and -. gcc/rust/ChangeLog: * ast/rust-ast-dump.cc (Dump::visit): print parentheses around unique expression operand. Signed-off-by: Marc Poulhiès <dkm@kataplop.net>
* Fix -frust-dump-* error messagesOwen Avery2023-04-261-6/+8
| | | | | | | | | gcc/rust/ChangeLog: * rust-session-manager.cc (Session::enable_dump): Fix error messages. Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
* gccrs: Add missing ABI checking on function typesPhilip Herron2023-04-262-0/+27
| | | | | | | | | | | | Addresses #2304 gcc/rust/ChangeLog: * typecheck/rust-unify.cc (UnifyRules::emit_abi_mismatch): new error method (UnifyRules::expect_fndef): add ABI check * typecheck/rust-unify.h: prototype for new error method Signed-off-by: Philip Herron <herron.philip@googlemail.com>
* gccrs: Add missing ABI mappingPhilip Herron2023-04-261-0/+2
| | | | | | | | gcc/rust/ChangeLog: * util/rust-abi.cc (get_abi_from_string): add ABI mapping Signed-off-by: Philip Herron <herron.philip@googlemail.com>
* gccrs: Add mechanism use pattern information to improve type infoPhilip Herron2023-04-265-13/+159
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When we have an untyped closure we assumed all parameters were inference variables but we can use the pattern type to try and improve the type info so if we have a reference pattern it must be a reference to an inference variables '&_'. This patch adds a new visitor to figure this out for untyped closure parameters. Note this test case does fully type resolve into the gimple: bool test::main::{{closure}} (struct test::main::{{closure}} $closure, struct (& u8) args) { ... } Though the Rustc version does fail type-resolution but we make some assumptions during comparison expressions here that they resolve to a bool this will change when we implement the comparison lang items. Fixes #2142 gcc/rust/ChangeLog: * hir/tree/rust-hir-pattern.h: add missing get_mutability * typecheck/rust-hir-type-check-expr.cc (TypeCheckExpr::visit): use new ClosureParamInfer on untyped parameters * typecheck/rust-hir-type-check-pattern.cc (ClosureParamInfer::Resolve): interface (ClosureParamInfer::ClosureParamInfer): constructor (ClosureParamInfer::visit): visitors for each pattern * typecheck/rust-hir-type-check-pattern.h (class ClosureParamInfer): new visitor gcc/testsuite/ChangeLog: * rust/compile/issue-2142.rs: New test. Signed-off-by: Philip Herron <herron.philip@googlemail.com>
* gccrs: remove unused headerPhilip Herron2023-04-261-1/+0
| | | | | | | | gcc/rust/ChangeLog: * typecheck/rust-hir-type-check-pattern.h: cleanup Signed-off-by: Philip Herron <herron.philip@googlemail.com>
* gccrs: Fix ICE when we dont get a reference typePhilip Herron2023-04-261-2/+5
| | | | | | | | | gcc/rust/ChangeLog: * typecheck/rust-hir-type-check-pattern.cc (TypeCheckPattern::visit): return so we dont hit undefined behaviour Signed-off-by: Philip Herron <herron.philip@googlemail.com>
* gccrs: remove unused includesPhilip Herron2023-04-261-2/+0
| | | | | | | | gcc/rust/ChangeLog: * backend/rust-compile-implitem.h: remove includes Signed-off-by: Philip Herron <herron.philip@googlemail.com>
* gccrs: fix ICE with recursive function callsPhilip Herron2023-04-263-12/+29
| | | | | | | | | | | | | | | Fixes #2136 gcc/rust/ChangeLog: * backend/rust-compile-item.cc (CompileItem::visit): remove bad checks gcc/testsuite/ChangeLog: * rust/compile/issue-2136-1.rs: New test. * rust/compile/issue-2136-2.rs: New test. Signed-off-by: Philip Herron <herron.philip@googlemail.com>
* gccrs: enable -Winfinite-recursion warnings by defaultPhilip Herron2023-04-262-0/+6
| | | | | | | | | gcc/rust/ChangeLog: * lang.opt: add lang option flag * rust-lang.cc (grs_langhook_init_options_struct): enable by default Signed-off-by: Philip Herron <herron.philip@googlemail.com>
* gccrs: Fix ICE in assignment of error type bound predicatesPhilip Herron2023-04-261-0/+3
| | | | | | | | | gcc/rust/ChangeLog: * typecheck/rust-tyty-bounds.cc (TypeBoundPredicate::operator=): we are done if other is in an error state Signed-off-by: Philip Herron <herron.philip@googlemail.com>
* gccrs: Fix ICE during method resolutionPhilip Herron2023-04-262-1/+21
| | | | | | | | | | | | | | | | | | We were missing a check for trait item selection to ensure they are actually methods and remove assertion to check if the trait item is a function this is a valid error check not an assertion. Fixes #2139 gcc/rust/ChangeLog: * typecheck/rust-hir-dot-operator.cc (MethodResolver::select): verify it is a method gcc/testsuite/ChangeLog: * rust/compile/issue-2139.rs: New test. Signed-off-by: Philip Herron <herron.philip@googlemail.com>
* gccrs: Track Self properly with TypePredicateBoundsPhilip Herron2023-04-2612-49/+148
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When we handle generic trait bounds we never tracked its associated Self type. Its important to remember a Trait Predicate is associated with a type this means we end up missing a lot of helpful type information down the line relating to higher ranked trait bounds and associated types compuations. Remember traits have an implict Generic Type Parameter of Self we use this in computing trait defintions so in that case no associated type is specified which is to be expected but in all other cases we do even if it is generic its still useful type information to keep track of. There is one regression here with compile/issue-1893.rs this testcase mostly worked out as a fluke rather than a proper fix so its no suprise here it has regressed the other two test cases one where the number generic arguments has changed, Rustc gets around this and has a seperate error message for this case. We need to solve this patch in order to solve #2019 gcc/rust/ChangeLog: * typecheck/rust-hir-trait-resolve.cc (TraitResolver::resolve_trait): use new interface * typecheck/rust-hir-type-check-base.h: update prototype to include Self * typecheck/rust-hir-type-check-expr.cc (TypeCheckExpr::visit): lifewise * typecheck/rust-hir-type-check-item.cc (TypeCheckItem::resolve_impl_block_substitutions): likewise * typecheck/rust-hir-type-check-path.cc (TypeCheckExpr::visit): likewise (TypeCheckExpr::resolve_segments): likewise * typecheck/rust-hir-type-check-type.cc (TypeCheckType::visit): likewise (TypeResolveGenericParam::visit): likewise (ResolveWhereClauseItem::visit): likewise * typecheck/rust-tyty-bounds.cc (TypeCheckBase::get_predicate_from_bound): likewise (TypeBoundPredicate::apply_generic_arguments): likewise (TypeBoundsMappings::lookup_predicate): likewise * typecheck/rust-tyty-bounds.h: likewise * typecheck/rust-tyty.h:likewise gcc/testsuite/ChangeLog: * rust/compile/issue-1893.rs: regression * rust/compile/traits12.rs: rustc uses a custom error message here * rust/compile/unconstrained_type_param.rs: extra error message Signed-off-by: Philip Herron <herron.philip@googlemail.com>
* gccrs: add error state to TypeCheckContextItem and missing copy ctor'sPhilip Herron2023-04-262-0/+82
| | | | | | | | | | | | | | | | | | | When checking current context we might be in the const or static context which does not have a current function or impl or trait context associated with it. So this allows us to represent the an error state for that case. gcc/rust/ChangeLog: * typecheck/rust-hir-type-check.h: New error state and missing copy implementations * typecheck/rust-typecheck-context.cc (TypeCheckContextItem::TypeCheckContextItem): missing copy ctor (TypeCheckContextItem::operator=): missing copy implementation (TypeCheckContextItem::get_error): new static function (TypeCheckContextItem::is_error): new method (TypeCheckContextItem::get_context_type): handle error state (TypeCheckContextItem::get_defid): handle error state Signed-off-by: Philip Herron <herron.philip@googlemail.com>
* gccrs: add helper to check for a const or static contextPhilip Herron2023-04-262-0/+7
| | | | | | | | | | gcc/rust/ChangeLog: * typecheck/rust-hir-type-check.h: new helper * typecheck/rust-typecheck-context.cc (TypeCheckContext::have_function_context): implementation Signed-off-by: Philip Herron <herron.philip@googlemail.com>
* gccrs: Add get_defid helper to TypeCheckContextItemPhilip Herron2023-04-262-0/+20
| | | | | | | | | gcc/rust/ChangeLog: * typecheck/rust-hir-type-check.h: Add prototype * typecheck/rust-typecheck-context.cc (TypeCheckContextItem::get_defid): implementation Signed-off-by: Philip Herron <herron.philip@googlemail.com>
* gccrs: minor refactor to reuse a variable instead of recreating it laterPhilip Herron2023-04-261-2/+1
| | | | | | | | gcc/rust/ChangeLog: * typecheck/rust-hir-type-check-expr.cc: refactor Signed-off-by: Philip Herron <herron.philip@googlemail.com>
* gccrs: Fix memory corruption at peek_contextPhilip Herron2023-04-264-5/+5
| | | | | | | | | | | | | | | | | | When working in the resolve_operator_overload it was found that we got memory corruption as method resolution will use the query system and therefore resolve new methods and the current function context info will change and due to the fact the peek_context interface returns a reference to the element which was now safe from a vector which can change and all you need is the current function context at that moment in time. gcc/rust/ChangeLog: * typecheck/rust-autoderef.cc: don't take a reference * typecheck/rust-hir-type-check-expr.cc (TypeCheckExpr::visit): likewise * typecheck/rust-hir-type-check.h: remove reference * typecheck/rust-typecheck-context.cc (TypeCheckContext::pop_return_type): likewise Signed-off-by: Philip Herron <herron.philip@googlemail.com>
* patterns: Add execution testcases to verify proper pattern matchingArthur Cohen2023-04-252-0/+30
| | | | | | | | | | These testcases are similar to the ones added in #2072 but regarding execution. One more issue was opened from them - #2144 gcc/testsuite/ChangeLog: * rust/execute/torture/issue-1852-1.rs: New test. * rust/execute/torture/issue-1852.rs: New test.
* ci: Add libgrust to clang-format checkerPierre-Emmanuel Patry2023-04-251-1/+1
| | | | | | | | | | Add the libgrust directory to the clang-format github action. ChangeLog: * .github/workflows/clang-format.yml: Add libgrust directory. Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
* Resolve identifier-pattern struct pattern fieldsOwen Avery2023-04-251-2/+4
| | | | | | | | | gcc/rust/ChangeLog: * resolve/rust-ast-resolve-pattern.cc (PatternDeclaration::visit): Handle StructPatternFieldIdentPat. Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
* libproc_macro: Fix literal drop functionPierre-Emmanuel Patry2023-04-211-2/+2
| | | | | | | | | | | | Fix drop function by changing the delete operator to delete[] in order to avoid undefined behaviors. ChangeLog: * libgrust/libproc_macro/literal.cc (Literal::drop): Change delete operator to delete[]. Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
* libproc_macro: Implement Drop for TokenStreamPierre-Emmanuel Patry2023-04-211-0/+7
| | | | | | | | | | | | TokenStream did not have any drop implementation, the memory could not have been freed correctly. ChangeLog: * libgrust/libproc_macro/rust/bridge/token_stream.rs: Implement drop. Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
* libproc_macro: Add remaining drop functionsPierre-Emmanuel Patry2023-04-216-4/+44
| | | | | | | | | | | | | | | | | | | | Remaining structures from the rust bridge that missed a drop function now have one. ChangeLog: * libgrust/libproc_macro/group.cc (Group::drop): Add drop implementation. * libgrust/libproc_macro/group.h: Add drop prototype. * libgrust/libproc_macro/tokenstream.cc (TokenStream::drop): Add drop implementation. (TokenStream__drop): Change to a call to TokenStream::drop. * libgrust/libproc_macro/tokenstream.h: Add drop prototype. * libgrust/libproc_macro/tokentree.cc (TokenTree::drop): Add drop implementation. * libgrust/libproc_macro/tokentree.h: Add drop prototype. Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
* libproc_macro: Add drop function to Literal structPierre-Emmanuel Patry2023-04-212-2/+11
| | | | | | | | | | | | | Add a drop function to clean internal fields of a Literal struct. ChangeLog: * libgrust/libproc_macro/literal.cc (Literal__drop): Replace implementation by a call to Literal::drop. (Literal::drop): Add drop implementation. * libgrust/libproc_macro/literal.h: Add function prototype. Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
* libproc_macro: Add drop function on Ident structPierre-Emmanuel Patry2023-04-212-1/+10
| | | | | | | | | | | | | Add a drop function that cleans internal fields of a given Ident struct. ChangeLog: * libgrust/libproc_macro/ident.cc (Ident__drop): Replace by call to Ident::drop. (Ident::drop): Add drop function. * libgrust/libproc_macro/ident.h: Add drop prototype. Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
* libproc_macro: Add remaining tokenstream structs.Pierre-Emmanuel Patry2023-04-218-2/+400
| | | | | | | | | | | | | | | | | | Add remaining missing tokenstream structures. Most are interdependent. ChangeLog: * libgrust/libproc_macro/Makefile.am: Add tokenstream, group and tokentree source files. * libgrust/libproc_macro/Makefile.in: Regenerate. * libgrust/libproc_macro/group.cc: New file. * libgrust/libproc_macro/group.h: New file. * libgrust/libproc_macro/tokenstream.cc: New file. * libgrust/libproc_macro/tokenstream.h: New file. * libgrust/libproc_macro/tokentree.cc: New file. * libgrust/libproc_macro/tokentree.h: New file. Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
* Fix translation mistakes 2023 in GCC/Rust [PR108890]TieWay592023-04-211-6/+6
| | | | | | | | | | | | | | | | | | | | | | | | | In https://gcc.gnu.org/PR108890 "Translation mistakes 2023" @rillig lists several issues with GCC/Rust diagnostics and option help texts (but also a few non-GCC/Rust). This commit fix mistakes only related to GCC/Rust, specifically to the file `gcc/rust/lang.opt`. closes https://github.com/Rust-GCC/gccrs/issues/1916 PR translation/108890 gcc/rust/ * lang.opt: Fix translation mistakes 2023 in GCC/Rust [PR108890] (line 67): change the inconsistent tab to spaces (line 75): wrap bare placeholder `integer` (line 79): remove redundant text of `Choose which` (line 96): remove redundant text of `Choose which` (line 112): remove redundant `Flag to` (line 124): correct the exclusive term `When to stop` (line 124): correct typo of `copimlation` Signed-off-by: Tieway59 <tieway59@foxmail.com>
* libproc_macro: Add Punct structPierre-Emmanuel Patry2023-04-214-1/+86
| | | | | | | | | | | | | | Add Punct struct for rust interface as well as a basic named constructor. ChangeLog: * libgrust/libproc_macro/Makefile.am: Add punct.cc. * libgrust/libproc_macro/Makefile.in: Regenerate. * libgrust/libproc_macro/punct.cc: New file. * libgrust/libproc_macro/punct.h: New file. Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
* libproc_macro: Add namespace to IdentPierre-Emmanuel Patry2023-04-212-0/+9
| | | | | | | | | | | | | Add a new Ident namespace to group Ident related enumeration and structures. ChangeLog: * libgrust/libproc_macro/ident.cc (Ident::make_ident): Add Ident namespace. * libgrust/libproc_macro/ident.h (Ident__clone): Likewise. Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
* libproc_macro: Add named constructorPierre-Emmanuel Patry2023-04-212-9/+33
| | | | | | | | | | | | | | | | | Add named constructor directly in Ident struct. ChangeLog: * libgrust/libproc_macro/ident.cc (Ident__new): Use named constructor. (Ident__new_raw): Use named constructor. (Ident__clone): Use clone member function. (Ident::clone): Make clone const. (Ident::make_ident): Add named construcot. * libgrust/libproc_macro/ident.h (struct Ident): Add named constructor prototypes. Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
* libproc_macro: Change drop rust interfacePierre-Emmanuel Patry2023-04-211-2/+2
| | | | | | | | | | | | Change rust interface on drop function to take a mut pointer instead. This will match the drop trait interface more closely. ChangeLog: * libgrust/libproc_macro/rust/bridge/ident.rs: Change drop function interface. Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
* libproc_macro: Add ident implementationPierre-Emmanuel Patry2023-04-214-1/+113
| | | | | | | | | | | | | | Add implementation and representation for ident cpp structure as well as a high level wrapper interface. ChangeLog: * libgrust/libproc_macro/Makefile.am: Add ident to source list. * libgrust/libproc_macro/Makefile.in: Regenerate. * libgrust/libproc_macro/ident.cc: New file. * libgrust/libproc_macro/ident.h: New file. Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
* Deleted the as_string ASR and HIR dumpsM V V S Manoj Kumar2023-04-213-55/+1
| | | | | | | | | | | | | | | | | | | | | Fixes #2021, #2022 Deleted Parser::debug_dump_ast_output, removed any functions that called it i.e Session::dump_ast and Session::dump_ast_expanded, and any associated items. Made it so that when you use the dump option "expanded" it dumps the pretty ast only. gcc/rust/ChangeLog: * parse/rust-parse-impl.h (Parser::debug_dump_ast_output): Removed this funtion. * rust-session-manager.cc (Session::enable_dump): Removed else if (arg == "parse"). (Session::compile_crate): Removed calls of dump_ast and dump_ast_expanded. (Session::dump_ast): Removed this function. (Session::dump_ast_expanded): Removed this function. * rust-session-manager.h (struct CompileOptions): Removed the PARSER_AST_DUMP option. Signed-off-by: M V V S Manoj Kumar <mvvsmanojkumar@gmail.com>
* parser: Parse reference patterns correctlyArthur Cohen2023-04-212-1/+7
| | | | | | | | | | | | | | | Reference patterns cannot contain AltPatterns per the Rust reference, so we should not call into `parse_pattern` to parse the referenced pattern, but rather the more restrictive `parse_pattern_no_alt`. gcc/rust/ChangeLog: * parse/rust-parse-impl.h (Parser::parse_reference_pattern): Do not call into `parse_pattern` anymore. gcc/testsuite/ChangeLog: * rust/compile/issue-1807.rs: New test.
* Add error message for AltPattern in let statementsOwen Avery2023-04-214-3/+15
| | | | | | | | | | | | | | | | | | gcc/rust/ChangeLog: * hir/rust-ast-lower-pattern.cc (ASTLoweringPattern::translate): Add is_let_top_level parameter. (ASTLoweringPattern::visit): Handle is_let_top_level. * hir/rust-ast-lower-pattern.h (class ASTLoweringPattern): Add is_let_top_level. * hir/rust-ast-lower-stmt.cc (ASTLoweringStmt::visit): Set is_let_top_level. gcc/testsuite/ChangeLog: * rust/compile/let_alt.rs: New test. Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
* Implement Dump:visit() function for QualifiedPathInType argument.Zheyuan Chen2023-04-201-3/+15
| | | | | | | | gcc/rust/ChangeLog: * ast/rust-ast-dump.cc: fix bad formatting for associated type. Signed-off-by: Zheyuan Chen <sephirotheca17@gmail.com>
* gccrs: Add testcase to show matching of enum variantsPhilip Herron2023-04-191-0/+30
| | | | | | | | | | Fixes #852 gcc/testsuite/ChangeLog: * rust/compile/issue-852.rs: New test. Signed-off-by: Philip Herron <herron.philip@googlemail.com>
* gccrs: Lower ErrorPropagationExpr from AST to HIRSergey Bugaev2023-04-192-0/+16
| | | | | | | | gcc/rust/ChangeLog: * hir/rust-ast-lower-expr.h, hir/rust-ast-lower-expr.cc: Lower AST::ErrorPropagationExpr to HIR::ErrorPropagationExpr Signed-off-by: Sergey Bugaev <bugaevc@gmail.com>