aboutsummaryrefslogtreecommitdiff
path: root/gcc
AgeCommit message (Collapse)AuthorFilesLines
2024-05-21Remove useless cstddef header from rust-fmtjjasmine1-1/+0
gcc/rust/ChangeLog: * ast/rust-fmt.h: Remove useless cstddef header from rust-fmt
2024-05-17Change lookup_ast_item's return typePierre-Emmanuel Patry3-16/+10
Wrap the function's return type within an optional. gcc/rust/ChangeLog: * metadata/rust-export-metadata.cc (ExportContext::emit_trait): Adapt call site to the new return type. (ExportContext::emit_function): Likewise. (ExportContext::emit_macro): Likewise. * util/rust-hir-map.cc (Mappings::lookup_ast_item): Change the function's return type. * util/rust-hir-map.h: Update the function's prototype. Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
2024-05-17Change lookup_visibility's return typePierre-Emmanuel Patry4-13/+12
Wrap the return type within an optional. gcc/rust/ChangeLog: * checks/errors/privacy/rust-privacy-reporter.cc: Change call site to accomodate new return type. * checks/errors/privacy/rust-pub-restricted-visitor.cc: Likewise. * util/rust-hir-map.cc (Mappings::lookup_visibility): Change the function's return type. * util/rust-hir-map.h: Update the function's prototype. Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
2024-05-17Change lookup_macro_invocation's return typePierre-Emmanuel Patry5-25/+18
Wrap the function's return type within an optional and remove the out reference argument. gcc/rust/ChangeLog: * expand/rust-macro-expand.cc (MacroExpander::expand_invoc): Adapt the function call to match its new prototype. * resolve/rust-early-name-resolver-2.0.cc (Early::insert_once): Likewise. (Early::visit): Likewise. * resolve/rust-early-name-resolver.cc (EarlyNameResolver::visit): Likewise. * util/rust-hir-map.cc (Mappings::lookup_macro_invocation): Change the function's return type. * util/rust-hir-map.h: Update the function's prototype. Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
2024-05-17Change lookup_macro_def return typePierre-Emmanuel Patry5-34/+22
Wrap the function's return type within an optional. gcc/rust/ChangeLog: * resolve/rust-early-name-resolver-2.0.cc (Early::insert_once): Change call site to accomodate the new return type. (Early::visit): Likewise. * resolve/rust-early-name-resolver.cc (EarlyNameResolver::visit): Likewise. * resolve/rust-toplevel-name-resolver-2.0.cc (TopLevel::visit): Likewise. * util/rust-hir-map.cc (Mappings::lookup_macro_def): Change the function's return type. * util/rust-hir-map.h: Update the function's prototype. Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
2024-05-17Change lookup_canonical_path's return pathPierre-Emmanuel Patry11-101/+61
Change the function's return type to wrap it within an optional. gcc/rust/ChangeLog: * backend/rust-compile-base.cc: Change call site to accomodate new return type. * backend/rust-compile-base.h: Change parameter to use a reference. * backend/rust-compile-extern.h: Likewise. * backend/rust-compile-implitem.cc (CompileTraitItem::visit): Change call site for new return type. * backend/rust-compile-item.cc (CompileItem::visit): Likewise. * resolve/rust-ast-resolve-type.cc (ResolveTypeToCanonicalPath::visit): Likewise. * typecheck/rust-hir-type-check-enumitem.cc (TypeCheckEnumItem::visit): Likewise. * typecheck/rust-hir-type-check-implitem.cc (TypeCheckImplItem::visit): Likewise. * typecheck/rust-hir-type-check-item.cc (TypeCheckItem::visit): Likewise. * typecheck/rust-hir-type-check.cc (TraitItemReference::get_type_from_fn): Likewise. * util/rust-hir-map.h: Update the function's prototype and change the function's return type. Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
2024-05-17Change lookup_hir_pattern return typePierre-Emmanuel Patry2-4/+4
Wrap the function's return type within an optional in order to differentiate between a null pointer and a missing value. gcc/rust/ChangeLog: * util/rust-hir-map.cc (Mappings::insert_hir_pattern): Change call site in order to accomodate new return type. (Mappings::lookup_hir_pattern): Change the function's return type. * util/rust-hir-map.h: Update the function's prototype. Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
2024-05-17Change lookup_hir_struct_field return typePierre-Emmanuel Patry2-4/+4
Wrap the function's return type within an optional to differentiate between a null pointer and a missing value. gcc/rust/ChangeLog: * util/rust-hir-map.cc (Mappings::insert_hir_struct_field): Change call site to accomodate new return type. (Mappings::lookup_hir_struct_field): Change the function's return type. * util/rust-hir-map.h: Update the function's prototype. Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
2024-05-17Change lookup_hir_self_param return typePierre-Emmanuel Patry2-4/+4
Wrap the function's return type within an optional in order to differentiate null pointers from missing value. gcc/rust/ChangeLog: * util/rust-hir-map.cc (Mappings::insert_hir_self_param): Adapt call site to new return type. (Mappings::lookup_hir_self_param): Change the function's return type. * util/rust-hir-map.h: Update the function's prototype. Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
2024-05-17Change lookup_hir_param return type with optionalPierre-Emmanuel Patry2-4/+4
Wrap the function's return type within an optional to differentiate between a null ppointer and a missing value. gcc/rust/ChangeLog: * util/rust-hir-map.cc (Mappings::insert_hir_param): Change call site to accomodate new return type. (Mappings::lookup_hir_param): Change the function's return type. * util/rust-hir-map.h: Updat ethe function's prototype. Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
2024-05-17Change lookup_hir_smt's return type with optionalPierre-Emmanuel Patry2-5/+5
Wrap the function's return type within an optional in order to differentiate missing values from null pointers. gcc/rust/ChangeLog: * util/rust-hir-map.cc (Mappings::insert_hir_stmt): Change call site to accomodate new return type. (Mappings::lookup_hir_stmt): Change the function's return type. (Mappings::resolve_nodeid_to_stmt): Adapt call site to new return type. * util/rust-hir-map.h: Update the function's prototype. Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
2024-05-17Change lookup_hir_type return type with an optionalPierre-Emmanuel Patry2-4/+4
Wrap the function's return type with an optional in order to tell appart a null pointer from a missing value. gcc/rust/ChangeLog: * util/rust-hir-map.cc (Mappings::insert_hir_type): Change call site to accomodate the new return type. (Mappings::lookup_hir_type): Change the function's return type. * util/rust-hir-map.h: Update the function's prototype. Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
2024-05-17Change lookup_hir_generic_param return typePierre-Emmanuel Patry2-4/+4
Wrap the function's return type with an optional. gcc/rust/ChangeLog: * util/rust-hir-map.cc (Mappings::insert_hir_generic_param): Change call site to accomodate the new return type. (Mappings::lookup_hir_generic_param): Wrap the function's return type with 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 lookup_hir_path_expr_seg return typePierre-Emmanuel Patry2-4/+4
Make the function's return type optional in order to differentiate between null pointers and missing value. gcc/rust/ChangeLog: * util/rust-hir-map.cc (Mappings::insert_hir_path_expr_seg): Change call site to accomodate the new return type. (Mappings::lookup_hir_path_expr_seg): Wrap the function's return type with 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 lookup_hir_expr return type to optionalPierre-Emmanuel Patry3-7/+5
Wrap the function's return type with an optional in order to differentiate missing values from null pointers. gcc/rust/ChangeLog: * backend/rust-mangle-v0.cc (v0_path): Adapt call site to new returned type. * util/rust-hir-map.cc (Mappings::lookup_hir_expr): Change the function's return type. * util/rust-hir-map.h: Update the function's prototype. Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
2024-05-17Change lookup_hir_implitem return typePierre-Emmanuel Patry8-73/+35
Wrap the return type within an optional. Now return the parent id within a pair instead of taking an out reference. gcc/rust/ChangeLog: * backend/rust-compile-item.cc (CompileItem::visit): Change call site to accept new return type. * backend/rust-compile-resolve-path.cc (HIRCompileBase::query_compile): Likewise. * backend/rust-mangle-v0.cc (v0_path): Likewise. * checks/errors/rust-unsafe-checker.cc (UnsafeChecker::visit): Likewise. * checks/lints/rust-lint-marklive.cc (MarkLive::go): Likewise. (MarkLive::visit): Likewise. * typecheck/rust-type-util.cc (query_type): Likewise. * util/rust-hir-map.cc (Mappings::insert_hir_implitem): Likewise. (Mappings::lookup_hir_implitem): Change return type. * 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 to optional in get_lang_itemPierre-Emmanuel Patry6-52/+30
Wrap the function's return type with an optional. gcc/rust/ChangeLog: * typecheck/rust-autoderef.cc: Adapt calling code to new return type. * typecheck/rust-hir-type-check-expr.cc (TypeCheckExpr::visit): Likewise. (TypeCheckExpr::resolve_operator_overload): Likewise. * typecheck/rust-tyty-bounds.cc (TypeBoundsProbe::assemble_builtin_candidate): Likewise. * typecheck/rust-tyty.cc (ClosureType::setup_fn_once_output): Likewise. * util/rust-hir-map.cc (Mappings::get_lang_item): Change return type. * util/rust-hir-map.h: Update the function's prototype. Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
2024-05-17Change lookup_module function return typePierre-Emmanuel Patry5-15/+13
Wrap the return type into an optional. gcc/rust/ChangeLog: * checks/errors/privacy/rust-visibility-resolver.cc: Update function call to match the new return type. * typecheck/rust-hir-type-check-path.cc (TypeCheckExpr::resolve_root_path): Likewise. * typecheck/rust-hir-type-check-type.cc (TypeCheckType::resolve_root_path): Likewise. * util/rust-hir-map.cc (Mappings::insert_module): Likewise. (Mappings::lookup_module): Change the function's return type. * util/rust-hir-map.h: Update the function's prototype. Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
2024-05-17Change lookup_hir_extern_item return typePierre-Emmanuel Patry6-37/+26
Wrap the return type with an optional and make the return type a pair with the parent hid. gcc/rust/ChangeLog: * backend/rust-compile-resolve-path.cc (HIRCompileBase::query_compile): Adapt code around new return type. * 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. * typecheck/rust-type-util.cc (query_type): Likewise. * util/rust-hir-map.cc (Mappings::insert_hir_extern_item): Likewise. (Mappings::lookup_hir_extern_item): Change return type. * 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 trait defid functions.Pierre-Emmanuel Patry5-13/+16
Wrap the return type with an optional. gcc/rust/ChangeLog: * backend/rust-compile-base.cc (HIRCompileBase::resolve_method_address): Update code around lookup return type. * typecheck/rust-tyty-bounds.cc (TypeCheckBase::get_predicate_from_bound): Likewise. * typecheck/rust-tyty.cc (ClosureType::setup_fn_once_output): Likewise. * util/rust-hir-map.cc (Mappings::insert_defid_mapping): Likewise. (Mappings::lookup_trait_item_defid): Update return type with an optional. (Mappings::get_lang_item): Likewise. * util/rust-hir-map.h: Update the functions prototype. Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
2024-05-17Change lookup_local_defid return type to optionalPierre-Emmanuel Patry2-7/+8
Make the API more convenient by changing the function's return type. We can now differentiate between a stored null pointer and a missing value. gcc/rust/ChangeLog: * util/rust-hir-map.cc (Mappings::insert_defid_mapping): Adapt call to new return type. (Mappings::insert_local_defid_mapping): Likewise. (Mappings::lookup_local_defid): Change return type to wrap it with 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_defidPierre-Emmanuel Patry8-27/+20
Change the return type to an optional. gcc/rust/ChangeLog: * backend/rust-compile-base.cc (HIRCompileBase::resolve_method_address): Change calling code to accomodate new return type. * checks/errors/privacy/rust-privacy-reporter.cc: Likewise. * typecheck/rust-hir-type-check-base.cc (TypeCheckBase::get_marker_predicate): Likewise. * typecheck/rust-hir-type-check-expr.cc (TypeCheckExpr::visit): Likewise. * typecheck/rust-tyty-bounds.cc (TypeBoundsProbe::assemble_builtin_candidate): Likewise. * typecheck/rust-tyty.cc (ClosureType::setup_fn_once_output): Likewise. * util/rust-hir-map.cc (Mappings::lookup_defid): Change function's return type. * util/rust-hir-map.h: Update function's prototype. Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
2024-05-17Change crate name retrieval function return typesPierre-Emmanuel Patry4-19/+11
Change their return type to a const reference in order to avoid copies when possible. Also wrap this new return type into an optional. gcc/rust/ChangeLog: * checks/errors/borrowck/rust-borrow-checker.cc (BorrowChecker::go): Adapt the code to the new return types. * resolve/rust-ast-resolve.cc (NameResolution::go): Likewise. * util/rust-hir-map.cc (Mappings::get_crate_name): Change return type to const string reference optional. (Mappings::get_current_crate_name): Likewise. * util/rust-hir-map.h: Update function prototypes. Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
2024-05-17Change crate_num_to_nodeid return typePierre-Emmanuel Patry4-18/+12
Change the function's return type to an optional. gcc/rust/ChangeLog: * resolve/rust-ast-resolve-toplevel.h: Adapt the code to the new return type. * rust-session-manager.cc (Session::load_extern_crate): Likewise. * util/rust-hir-map.cc (Mappings::crate_num_to_nodeid): Change the return type. * 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_crate_namePierre-Emmanuel Patry5-21/+13
Change the function's return type to use an optional. gcc/rust/ChangeLog: * resolve/rust-ast-resolve-toplevel.h: Adapt the code to the new return type. * resolve/rust-toplevel-name-resolver-2.0.cc (TopLevel::visit): Likewise. * rust-session-manager.cc (Session::load_extern_crate): Likewise. * util/rust-hir-map.cc (Mappings::lookup_crate_name): Change the 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_impl_block_typePierre-Emmanuel Patry3-11/+8
Change the return type to an optional. gcc/rust/ChangeLog: * typecheck/rust-type-util.cc (query_type): Adapt code to accomodate the new return type. * util/rust-hir-map.cc (Mappings::lookup_impl_block_type): Change the function's return type and remove the out pointer argument. * 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_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>