aboutsummaryrefslogtreecommitdiff
path: root/gcc
AgeCommit message (Collapse)AuthorFilesLines
2024-05-17Change return type for lookup_hir_impl_blockPierre-Emmanuel Patry3-8/+8
Change the return type to an optiona. This allows to differentiate between missing hir impl block and null pointers. gcc/rust/ChangeLog: * typecheck/rust-type-util.cc (query_type): Change call to the function in order to accomodate the new return type. * util/rust-hir-map.cc (Mappings::lookup_hir_impl_block): Change the function's return type to an optional. * util/rust-hir-map.h: Update the function's prototype. Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
2024-05-17Change return type of lookup_hir_extern_blockPierre-Emmanuel Patry4-9/+9
Change the return type to an optional in order to easily differentiate between a null pointer and an missing value. gcc/rust/ChangeLog: * checks/errors/rust-unsafe-checker.cc (UnsafeChecker::check_function_call): Adapt function call to new return type. * typecheck/rust-type-util.cc (query_type): Likewise. * util/rust-hir-map.cc (Mappings::insert_hir_extern_block): Likewise. (Mappings::lookup_hir_extern_block): Change return type to an optional. * util/rust-hir-map.h: Update the function's prototype. Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
2024-05-17Change return type of lookup_hir_trait_itemPierre-Emmanuel Patry4-20/+25
Change the return type to an optional instead of returning a null pointer. This allows easier tracking of rogue null pointers in the map. This commit also fixes a bug in trait associated function mangling, the function was using an already invalidated pointer. gcc/rust/ChangeLog: * backend/rust-compile-resolve-path.cc (HIRCompileBase::query_compile): Adapt return type to new optional. * backend/rust-mangle-v0.cc (v0_function_path): Change prototype to use the generic arguments vector instead of the whole HIR function. (v0_path): Fix a bug with a null pointer being used to create the trait function mangling. * util/rust-hir-map.cc (Mappings::insert_hir_trait_item): Adapt code to new return type. (Mappings::lookup_hir_trait_item): Change the return type of the function to an optional. * util/rust-hir-map.h: Update the function's prototype. Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
2024-05-17Change return type for lookup_hir_item to optionalPierre-Emmanuel Patry9-39/+36
gcc/rust/ChangeLog: * backend/rust-compile-resolve-path.cc (HIRCompileBase::query_compile): Adapt function call to new return type. * backend/rust-mangle-v0.cc (v0_path): Likewise. * checks/errors/rust-const-checker.cc (ConstChecker::check_function_call): Likewise. * checks/errors/rust-unsafe-checker.cc (UnsafeChecker::check_use_of_static): Likewise. (UnsafeChecker::check_function_call): Likewise. (UnsafeChecker::check_function_attr): Likewise. * checks/lints/rust-lint-marklive.cc (MarkLive::go): Likewise. (MarkLive::visit): Likewise. * typecheck/rust-hir-trait-resolve.cc (TraitResolver::resolve_path_to_trait): Likewise. * typecheck/rust-type-util.cc (query_type): Likewise. * util/rust-hir-map.cc (Mappings::insert_hir_item): Likewise. (Mappings::lookup_hir_item): Change function return type to use optional. * util/rust-hir-map.h: Update function prototype. Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
2024-05-17Change return type of resolve_nodeid_to_stmtPierre-Emmanuel Patry2-7/+5
Change the return type to an optional. gcc/rust/ChangeLog: * util/rust-hir-map.cc (Mappings::resolve_nodeid_to_stmt): Change the return type and remove pointer out argument. * util/rust-hir-map.h: Update function prototype. Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
2024-05-17Change lookup_hir_to_node return type to optionalPierre-Emmanuel Patry4-16/+14
Optional are more convenient to use and avoid uninitialized data. gcc/rust/ChangeLog: * backend/rust-compile-expr.cc (CompileExpr::generate_closure_function): Adapt code for new optional return type. * checks/errors/privacy/rust-privacy-reporter.cc (PrivacyReporter::check_base_type_privacy): Likewise. * util/rust-hir-map.cc (Mappings::lookup_hir_to_node): Change return type to an optional. * util/rust-hir-map.h: Adapt function prototype with the new return type. Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
2024-05-17Change lookup_node_to_hir return type to optionalPierre-Emmanuel Patry13-119/+142
Previous API was using a boolean and a pointer, this was not practical and could be replaced with an optional. gcc/rust/ChangeLog: * backend/rust-compile-expr.cc (CompileExpr::visit): Change call to use the returned optional. (CompileExpr::generate_closure_function): Likewise. * backend/rust-compile-resolve-path.cc (ResolvePathRef::resolve): Likewise. * backend/rust-compile-type.cc (TyTyResolveCompile::visit): Likewise. * backend/rust-mangle-v0.cc (v0_path): Likewise. * checks/errors/privacy/rust-visibility-resolver.cc: Likewise. * checks/errors/rust-const-checker.cc (ConstChecker::visit): Likewise. * checks/errors/rust-unsafe-checker.cc (UnsafeChecker::visit): Likewise. * checks/lints/rust-lint-marklive.cc (MarkLive::visit): Likewise. (MarkLive::visit_path_segment): Likewise. * typecheck/rust-hir-trait-resolve.cc (TraitResolver::resolve_path_to_trait): Likewise. * typecheck/rust-hir-type-check-path.cc (TypeCheckExpr::resolve_root_path): Likewise. * typecheck/rust-hir-type-check-type.cc (TypeCheckType::resolve_root_path): Likewise. (ResolveWhereClauseItem::visit): Likewise. * util/rust-hir-map.cc (Mappings::lookup_node_to_hir): Return an optional instead of a boolean. * util/rust-hir-map.h: Change function prototype to match the new return type. Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
2024-05-16Visit constant items without expressions properlyOwen Avery1-6/+9
gcc/rust/ChangeLog: * resolve/rust-default-resolver.cc (DefaultResolver::visit): Verify constant item has expression before attempting to visit the later. Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
2024-05-16Improve matching on non-enum ADTsOwen Avery3-3/+17
gcc/rust/ChangeLog: * backend/rust-compile-expr.cc (check_match_scrutinee): Add assertion. * backend/rust-compile-pattern.cc (CompilePatternCheckExpr::visit): Handle HIR::PathInExpression matching a non-enum. gcc/testsuite/ChangeLog: * rust/compile/match-struct-path.rs: New test. Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
2024-05-15Add testcases for handling struct as scrutinee for match exprNobel Singh2-0/+44
gcc/testsuite/ChangeLog: * rust/compile/issue-2906.rs: New test. * rust/execute/torture/issue-2906.rs: New test. Signed-off-by: Nobel Singh <nobel2073@gmail.com>
2024-05-15Handle structs as scrutinee for match expressionsNobel Singh1-2/+2
gcc/rust/ChangeLog: * backend/rust-compile-expr.cc (check_match_scrutinee): Handle structs Signed-off-by: Nobel Singh <nobel2073@gmail.com>
2024-05-15Remove unused Context parameter for some backend methodsOwen Avery8-18/+18
gcc/rust/ChangeLog: * backend/rust-compile-base.cc (HIRCompileBase::compile_function_body): Adjust unit_expression calls. (HIRCompileBase::unit_expression): Remove unused Context parameter. * backend/rust-compile-base.h (HIRCompileBase::unit_expression): Likewise. * backend/rust-compile-block.cc (CompileBlock::visit): Adjust unit_expression calls. * backend/rust-compile-expr.cc (CompileExpr::visit): Likewise. * backend/rust-compile-pattern.cc (CompilePatternLet::visit): Likewise. * backend/rust-compile-resolve-path.cc (ResolvePathRef::attempt_constructor_expression_lookup): Likewise. * backend/rust-compile-type.cc (TyTyResolveCompile::get_implicit_enumeral_node_type): Remove unused Context parameter. (TyTyResolveCompile::get_unit_type): Likewise. (TyTyResolveCompile::visit): Adjust get_implicit_enumeral_node_type and get_unit_type calls. * backend/rust-compile-type.h (TyTyResolveCompile::get_implicit_enumeral_node_type): Remove unused Context parameter. (TyTyResolveCompile::get_unit_type): Likewise. Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
2024-05-06Change singleton returned type to a referencePierre-Emmanuel Patry94-941/+923
We do not need a raw pointer for this singleton, nor we need having it on the heap through a smart pointer. gcc/rust/ChangeLog: * ast/rust-ast.h: Change dereference from a pointer to a reference accessor. * ast/rust-expr.h: Likewise. * ast/rust-item.h: Likewise. * ast/rust-macro.h: Likewise. * ast/rust-path.h: Likewise. * ast/rust-pattern.h: Likewise. * ast/rust-type.h: Likewise. * backend/rust-compile-base.cc (HIRCompileBase::resolve_method_address): Likewise. * backend/rust-compile-context.h: Likewise. * backend/rust-compile-expr.cc (CompileExpr::visit): Likewise. (CompileExpr::generate_closure_function): Likewise. * backend/rust-compile-extern.h: Likewise. * backend/rust-compile-implitem.cc (CompileTraitItem::visit): Likewise. * backend/rust-compile-intrinsic.cc (Intrinsics::compile): Likewise. * backend/rust-compile-item.cc (CompileItem::visit): Likewise. * backend/rust-compile-resolve-path.cc (ResolvePathRef::resolve): Likewise. (HIRCompileBase::query_compile): Likewise. * backend/rust-compile-type.cc (TyTyResolveCompile::visit): Likewise. (TyTyResolveCompile::create_dyn_obj_record): Likewise. * backend/rust-compile.cc (HIRCompileBase::coerce_to_dyn_object): Likewise. * backend/rust-mangle-v0.cc (v0_path): Likewise. (v0_mangle_item): Likewise. * checks/errors/borrowck/rust-borrow-checker.cc (BorrowChecker::go): Likewise. * checks/errors/privacy/rust-privacy-check.cc (Resolver::resolve): Likewise. * checks/errors/rust-const-checker.cc (ConstChecker::ConstChecker): Likewise. * checks/errors/rust-unsafe-checker.cc (UnsafeChecker::UnsafeChecker): Likewise. * checks/lints/rust-lint-marklive-base.h: Likewise. * checks/lints/rust-lint-marklive.cc (MarkLive::go): Likewise. (MarkLive::visit): Likewise. (MarkLive::visit_path_segment): Likewise. * checks/lints/rust-lint-marklive.h: Likewise. * checks/lints/rust-lint-scan-deadcode.h: Likewise. * expand/rust-macro-expand.cc (MacroExpander::expand_invoc): Likewise. * expand/rust-macro-expand.h (struct MacroExpander): Change mapping from pointer to a reference. * expand/rust-proc-macro.cc (BangProcMacro::BangProcMacro): Replace pointer accessor with reference accessor. (AttributeProcMacro::AttributeProcMacro): Likewise. (CustomDeriveProcMacro::CustomDeriveProcMacro): Likewise. * hir/rust-ast-lower-base.cc (ASTLoweringBase::lower_lifetime): Likewise. (ASTLoweringBase::lower_loop_label): Likewise. (ASTLoweringBase::lower_path_expr_seg): Likewise. (ASTLoweringBase::lower_self): Likewise. (ASTLoweringBase::handle_lang_item_attribute): Likewise. (ASTLoweringBase::lower_extern_block): Likewise. (ASTLoweringBase::lower_macro_definition): Likewise. * hir/rust-ast-lower-base.h: Likewise. * hir/rust-ast-lower-block.h: Likewise. * hir/rust-ast-lower-enumitem.h: Likewise. * hir/rust-ast-lower-expr.cc (ASTLoweringExpr::translate): Likewise. (ASTLoweringExpr::visit): Likewise. * hir/rust-ast-lower-extern.h: Likewise. * hir/rust-ast-lower-implitem.cc (ASTLowerImplItem::translate): Likewise. (ASTLowerImplItem::visit): Likewise. (ASTLowerTraitItem::translate): Likewise. (ASTLowerTraitItem::visit): Likewise. * hir/rust-ast-lower-item.cc (ASTLoweringItem::translate): Likewise. (ASTLoweringItem::visit): Likewise. (ASTLoweringSimplePath::lower): Likewise. * hir/rust-ast-lower-pattern.cc (ASTLoweringPattern::translate): Likewise. (ASTLoweringPattern::visit): Likewise. * hir/rust-ast-lower-stmt.cc (ASTLoweringStmt::translate): Likewise. (ASTLoweringStmt::visit): Likewise. * hir/rust-ast-lower-struct-field-expr.h: Likewise. * hir/rust-ast-lower-type.cc (ASTLowerTypePath::visit): Likewise. (ASTLowerQualifiedPathInType::visit): Likewise. (ASTLoweringType::translate): Likewise. (ASTLoweringType::visit): Likewise. (ASTLowerGenericParam::translate): Likewise. (ASTLowerGenericParam::visit): Likewise. (ASTLoweringTypeBounds::translate): Likewise. (ASTLoweringTypeBounds::visit): Likewise. (ASTLowerWhereClauseItem::translate): Likewise. (ASTLowerWhereClauseItem::visit): Likewise. * hir/rust-ast-lower.cc (ASTLowering::go): Likewise. (ASTLoweringBlock::visit): Likewise. (ASTLoweringIfBlock::visit): Likewise. (ASTLoweringIfLetBlock::visit): Likewise. (ASTLowerStructExprField::visit): Likewise. (ASTLoweringExprWithBlock::visit): Likewise. (ASTLowerPathInExpression::visit): Likewise. (ASTLoweringBase::lower_qual_path_type): Likewise. (ASTLowerQualPathInExpression::visit): Likewise. * metadata/rust-export-metadata.cc (ExportContext::emit_trait): Likewise. (ExportContext::emit_function): Likewise. (ExportContext::emit_macro): Likewise. (PublicInterface::PublicInterface): Likewise. (PublicInterface::expected_metadata_filename): Likewise. * metadata/rust-export-metadata.h: Likewise. * resolve/rust-ast-resolve-base.h: Likewise. * resolve/rust-ast-resolve-implitem.h: Likewise. * resolve/rust-ast-resolve-item.cc (ResolveTraitItems::visit): Likewise. (ResolveItem::visit): Likewise. (ResolveExternItem::visit): Likewise. * resolve/rust-ast-resolve-path.cc (ResolvePath::resolve_path): Likewise. * resolve/rust-ast-resolve-stmt.h: Likewise. * resolve/rust-ast-resolve-toplevel.h: Likewise. * resolve/rust-ast-resolve-type.cc (ResolveRelativeTypePath::go): Likewise. (ResolveTypeToCanonicalPath::visit): Likewise. * resolve/rust-ast-resolve-type.h: Likewise. * resolve/rust-ast-resolve.cc (NameResolution::NameResolution): Likewise. (NameResolution::go): Likewise. * resolve/rust-ast-resolve.h: Likewise. * resolve/rust-early-name-resolver-2.0.cc (Early::visit_attributes): Likewise. * resolve/rust-early-name-resolver.cc (EarlyNameResolver::EarlyNameResolver): Likewise. * resolve/rust-late-name-resolver-2.0.cc (next_node_id): Likewise. (next_hir_id): Likewise. * resolve/rust-name-resolution-context.cc (NameResolutionContext::NameResolutionContext): Likewise. * resolve/rust-name-resolver.cc (Resolver::Resolver): Likewise. (Resolver::generate_builtins): Likewise. (Resolver::setup_builtin): Likewise. * resolve/rust-name-resolver.h: Likewise. * resolve/rust-toplevel-name-resolver-2.0.cc (TopLevel::visit): Likewise. (TopLevel::handle_use_glob): Likewise. * rust-session-manager.cc (Session::get_instance): Likewise. (Session::handle_input_files): Likewise. (Session::handle_crate_name): Likewise. (Session::compile_crate): Likewise. (Session::load_extern_crate): Likewise. * rust-session-manager.h: Likewise. * typecheck/rust-autoderef.cc (Adjuster::try_unsize_type): Likewise. * typecheck/rust-coercion.cc (TypeCoercionRules::do_coercion): Likewise. (TypeCoercionRules::coerce_unsafe_ptr): Likewise. (TypeCoercionRules::coerce_borrowed_pointer): Likewise. (TypeCoercionRules::coerce_unsized): Likewise. * typecheck/rust-coercion.h: Likewise. * typecheck/rust-hir-dot-operator.cc (MethodResolver::select): Likewise. * typecheck/rust-hir-inherent-impl-overlap.h: Likewise. * typecheck/rust-hir-path-probe.cc (PathProbeType::process_enum_item_for_candiates): Likewise. (PathProbeType::process_impl_items_for_candidates): Likewise. (PathProbeImplTrait::process_trait_impl_items_for_candidates): Likewise. * typecheck/rust-hir-trait-resolve.cc (TraitResolver::resolve_path_to_trait): Likewise. (TraitItemReference::get_parent_trait_mappings): Likewise. * typecheck/rust-hir-type-check-base.cc (TypeCheckBase::resolve_literal): Likewise. (TypeCheckBase::get_marker_predicate): Likewise. * typecheck/rust-hir-type-check-base.h: Likewise. * typecheck/rust-hir-type-check-enumitem.cc (TypeCheckEnumItem::visit): Likewise. * typecheck/rust-hir-type-check-expr.cc (TypeCheckExpr::visit): Likewise. (TypeCheckExpr::resolve_operator_overload): Likewise. (TypeCheckExpr::resolve_fn_trait_call): Likewise. * typecheck/rust-hir-type-check-implitem.cc (TypeCheckTopLevelExternItem::visit): Likewise. (TypeCheckImplItem::visit): Likewise. * typecheck/rust-hir-type-check-item.cc (TypeCheckItem::visit): Likewise. * typecheck/rust-hir-type-check-path.cc (TypeCheckExpr::resolve_root_path): Likewise. (TypeCheckExpr::resolve_segments): Likewise. * typecheck/rust-hir-type-check-pattern.cc (TypeCheckPattern::emit_pattern_size_error): Likewise. (ClosureParamInfer::Resolve): Likewise. * typecheck/rust-hir-type-check-struct.cc (TypeCheckStructExpr::resolve): Likewise. * typecheck/rust-hir-type-check-type.cc (TypeCheckType::visit): Likewise. (TypeCheckType::resolve_root_path): Likewise. (TypeResolveGenericParam::visit): Likewise. (ResolveWhereClauseItem::visit): Likewise. * typecheck/rust-hir-type-check.cc (TraitItemReference::get_type_from_fn): Likewise. * typecheck/rust-type-util.cc (query_type): Likewise. * typecheck/rust-typecheck-context.cc (TypeCheckContext::compute_inference_variables): Likewise. * typecheck/rust-tyty-bounds.cc (TypeBoundsProbe::scan): Likewise. (TypeBoundsProbe::assemble_builtin_candidate): Likewise. (TypeCheckBase::get_predicate_from_bound): Likewise. * typecheck/rust-tyty-call.cc (TypeCheckCallExpr::visit): Likewise. (TypeCheckMethodCallExpr::check): Likewise. * typecheck/rust-tyty-call.h: Likewise. * typecheck/rust-tyty-cmp.h: Likewise. * typecheck/rust-tyty-subst.cc (SubstitutionParamMapping::override_context): Likewise. (SubstitutionRef::monomorphize): Likewise. * typecheck/rust-tyty-util.cc (TyVar::get_implicit_infer_var): Likewise. (TyVar::monomorphized_clone): Likewise. (TyWithLocation::TyWithLocation): Likewise. * typecheck/rust-tyty.cc (BaseType::satisfies_bound): Likewise. (InferType::clone): Likewise. (ADTType::handle_substitions): Likewise. (TupleType::handle_substitions): Likewise. (FnType::handle_substitions): Likewise. (ClosureType::setup_fn_once_output): Likewise. (ArrayType::handle_substitions): Likewise. (SliceType::handle_substitions): Likewise. (ReferenceType::handle_substitions): Likewise. (PointerType::handle_substitions): Likewise. (ParamType::handle_substitions): Likewise. * typecheck/rust-tyty.h: Likewise. * typecheck/rust-unify.cc (UnifyRules::UnifyRules): Likewise. (UnifyRules::commit): Likewise. * util/rust-hir-map.cc: Change getter return type to a reference. * util/rust-hir-map.h: Update function's prototype. Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
2024-05-06Remove unnecessary SIDE_EFFECTS/READONLY macrosMael Cravero1-17/+0
Closes #2357 gcc/rust/ChangeLog: * rust-gcc.cc: remove unnecessary TREE_SIDE_EFFECTS and TREE_READONLY macros used in arithmetic overflow checks. Signed-off-by: Mael Cravero <mael.cravero@embecosm.com>
2024-05-06borrowck: Use std::ignoreJakub Dupak1-7/+7
gcc/rust/ChangeLog: * checks/errors/borrowck/rust-bir-builder-expr-stmt.cc (ExprStmtBuilder::visit): Use std::ignore.
2024-05-06borrowck: TestsuiteJakub Dupak12-0/+359
gcc/testsuite/ChangeLog: * rust/borrowck/borrowck.exp: New test. * rust/borrowck/position_dependant_outlives.rs: New test. * rust/borrowck/reference.rs: New test. * rust/borrowck/return_ref_to_local.rs: New test. * rust/borrowck/subset.rs: New test. * rust/borrowck/test_move.rs: New test. * rust/borrowck/test_move_behind_reference.rs: New test. * rust/borrowck/test_move_conditional.rs: New test. * rust/borrowck/tmp.rs: New test. * rust/borrowck/use_while_mut.rs: New test. * rust/borrowck/use_while_mut_fr.rs: New test. * rust/borrowck/well_formed_function_inputs.rs: New test.
2024-05-06borrowck: Polonius error reportingJakub Dupak5-37/+117
gcc/rust/ChangeLog: * checks/errors/borrowck/ffi-polonius/src/gccrs_ffi_generated.rs: Error reporting. * checks/errors/borrowck/ffi-polonius/src/lib.rs: Error reporting. * checks/errors/borrowck/polonius/rust-polonius-ffi.h (struct FactsView): Error reporting. (struct Output): Error reporting. * checks/errors/borrowck/polonius/rust-polonius.h (struct Facts): Error reporting. * checks/errors/borrowck/rust-borrow-checker.cc: Error reporting. Signed-off-by: Jakub Dupak <dev@jakubdupak.com>
2024-05-06borrowck: Link Polonius and run itJakub Dupak2-2/+7
gcc/rust/ChangeLog: * Make-lang.in: Link Polonius. * checks/errors/borrowck/rust-borrow-checker.cc: Run Polonius. Signed-off-by: Jakub Dupak <dev@jakubdupak.com>
2024-05-06borrowck: Build Polonius automaticallyJakub Dupak1-0/+7
This is minimalistic version to build Polonius with Cargo. gcc/rust/ChangeLog: * Make-lang.in: Build Polonius. Signed-off-by: Jakub Dupak <dev@jakubdupak.com>
2024-05-06borrowck: Polonius dumpJakub Dupak3-8/+88
gcc/rust/ChangeLog: * checks/errors/borrowck/polonius/rust-polonius.h (struct FullPoint): Polonius facts dump. (struct Facts): Polonius facts dump. * checks/errors/borrowck/rust-bir-dump.cc (Dump::go): Polonius facts dump. (Dump::visit): Polonius facts dump. (Dump::visit_place): Polonius facts dump. (Dump::visit_move_place): Polonius facts dump. (Dump::visit_scope): Polonius facts dump. * checks/errors/borrowck/rust-borrow-checker.cc (BorrowChecker::go): Polonius facts dump. Signed-off-by: Jakub Dupak <dev@jakubdupak.com>
2024-05-06Removed obsolete objectsKushal Pal1-11/+2
gcc/rust/ChangeLog: * backend/rust-compile-expr.cc (CompileExpr::visit): Lines removed as the objects are unused. Signed-off-by: Kushal Pal <kushalpal109@gmail.com>
2024-04-23Remove redundant macro definitionzhanghe97021-12/+0
gcc/rust/ChangeLog: * backend/rust-tree.h: removing the CLASSTYPE_VBASECLASSES macro which is duplicated three times. Signed-off-by: Zhang He <zhanghe9702@163.com>
2024-04-22Add a test for inherent impl type name resolvePierre-Emmanuel Patry1-0/+5
A previous bug with name resolution 2.0 was caused by an incorrectly resolved inherent impl name. This test shall highlight the behavior and prevent regression. gcc/testsuite/ChangeLog: * rust/compile/name_resolution25.rs: New test. Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
2024-04-22Visit type during resolution of inherent implPierre-Emmanuel Patry1-0/+1
Inherent impl has a type it applies to. This type was not visited and thus not resolved. gcc/rust/ChangeLog: * resolve/rust-default-resolver.cc (DefaultResolver::visit): Visit inherent impl type. Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
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>