diff options
author | Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com> | 2024-04-24 10:51:13 +0200 |
---|---|---|
committer | Arthur Cohen <arthur.cohen@embecosm.com> | 2025-03-17 16:35:22 +0100 |
commit | fd788dd543017cd801657b82bf80bb78e03479ed (patch) | |
tree | 7d8007823936b858a4beed0eee0a3030096a39cf /gcc/rust/resolve/rust-ast-resolve-toplevel.h | |
parent | 4d851ca89569b71ee87f22644d2e70938bb84992 (diff) | |
download | gcc-fd788dd543017cd801657b82bf80bb78e03479ed.zip gcc-fd788dd543017cd801657b82bf80bb78e03479ed.tar.gz gcc-fd788dd543017cd801657b82bf80bb78e03479ed.tar.bz2 |
gccrs: Change singleton returned type to a reference
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>
Diffstat (limited to 'gcc/rust/resolve/rust-ast-resolve-toplevel.h')
-rw-r--r-- | gcc/rust/resolve/rust-ast-resolve-toplevel.h | 78 |
1 files changed, 39 insertions, 39 deletions
diff --git a/gcc/rust/resolve/rust-ast-resolve-toplevel.h b/gcc/rust/resolve/rust-ast-resolve-toplevel.h index 1ba33c7..1cadf98 100644 --- a/gcc/rust/resolve/rust-ast-resolve-toplevel.h +++ b/gcc/rust/resolve/rust-ast-resolve-toplevel.h @@ -41,7 +41,7 @@ public: item.accept_vis (resolver); NodeId current_module = resolver.resolver->peek_current_module_scope (); - resolver.mappings->insert_child_item_to_parent_module_mapping ( + resolver.mappings.insert_child_item_to_parent_module_mapping ( item.get_node_id (), current_module); } @@ -62,8 +62,8 @@ public: }); NodeId current_module = resolver->peek_current_module_scope (); - mappings->insert_module_child_item (current_module, mod); - mappings->insert_module_child (current_module, module.get_node_id ()); + mappings.insert_module_child_item (current_module, mod); + mappings.insert_module_child (current_module, module.get_node_id ()); resolver->push_new_module_scope (module.get_node_id ()); for (auto &item : module.get_items ()) @@ -71,7 +71,7 @@ public: resolver->pop_module_scope (); - mappings->insert_canonical_path (module.get_node_id (), cpath); + mappings.insert_canonical_path (module.get_node_id (), cpath); } void visit (AST::TypeAlias &alias) override @@ -92,8 +92,8 @@ public: }); NodeId current_module = resolver->peek_current_module_scope (); - mappings->insert_module_child_item (current_module, talias); - mappings->insert_canonical_path (alias.get_node_id (), cpath); + mappings.insert_module_child_item (current_module, talias); + mappings.insert_canonical_path (alias.get_node_id (), cpath); } void visit (AST::TupleStruct &struct_decl) override @@ -114,8 +114,8 @@ public: }); NodeId current_module = resolver->peek_current_module_scope (); - mappings->insert_module_child_item (current_module, decl); - mappings->insert_canonical_path (struct_decl.get_node_id (), cpath); + mappings.insert_module_child_item (current_module, decl); + mappings.insert_canonical_path (struct_decl.get_node_id (), cpath); } void visit (AST::Enum &enum_decl) override @@ -142,8 +142,8 @@ public: resolver->pop_module_scope (); NodeId current_module = resolver->peek_current_module_scope (); - mappings->insert_module_child_item (current_module, decl); - mappings->insert_canonical_path (enum_decl.get_node_id (), cpath); + mappings.insert_module_child_item (current_module, decl); + mappings.insert_canonical_path (enum_decl.get_node_id (), cpath); } void visit (AST::EnumItem &item) override @@ -161,11 +161,11 @@ public: rust_error_at (r, "redefined multiple times"); }); - mappings->insert_canonical_path (item.get_node_id (), cpath); + mappings.insert_canonical_path (item.get_node_id (), cpath); NodeId current_module = resolver->peek_current_module_scope (); - mappings->insert_module_child_item (current_module, decl); - mappings->insert_module_child (current_module, item.get_node_id ()); + mappings.insert_module_child_item (current_module, decl); + mappings.insert_module_child (current_module, item.get_node_id ()); } void visit (AST::EnumItemTuple &item) override @@ -183,11 +183,11 @@ public: rust_error_at (r, "redefined multiple times"); }); - mappings->insert_canonical_path (item.get_node_id (), cpath); + mappings.insert_canonical_path (item.get_node_id (), cpath); NodeId current_module = resolver->peek_current_module_scope (); - mappings->insert_module_child_item (current_module, decl); - mappings->insert_module_child (current_module, item.get_node_id ()); + mappings.insert_module_child_item (current_module, decl); + mappings.insert_module_child (current_module, item.get_node_id ()); } void visit (AST::EnumItemStruct &item) override @@ -205,11 +205,11 @@ public: rust_error_at (r, "redefined multiple times"); }); - mappings->insert_canonical_path (item.get_node_id (), cpath); + mappings.insert_canonical_path (item.get_node_id (), cpath); NodeId current_module = resolver->peek_current_module_scope (); - mappings->insert_module_child_item (current_module, decl); - mappings->insert_module_child (current_module, item.get_node_id ()); + mappings.insert_module_child_item (current_module, decl); + mappings.insert_module_child (current_module, item.get_node_id ()); } void visit (AST::EnumItemDiscriminant &item) override @@ -227,11 +227,11 @@ public: rust_error_at (r, "redefined multiple times"); }); - mappings->insert_canonical_path (item.get_node_id (), cpath); + mappings.insert_canonical_path (item.get_node_id (), cpath); NodeId current_module = resolver->peek_current_module_scope (); - mappings->insert_module_child_item (current_module, decl); - mappings->insert_module_child (current_module, item.get_node_id ()); + mappings.insert_module_child_item (current_module, decl); + mappings.insert_module_child (current_module, item.get_node_id ()); } void visit (AST::StructStruct &struct_decl) override @@ -252,8 +252,8 @@ public: }); NodeId current_module = resolver->peek_current_module_scope (); - mappings->insert_module_child_item (current_module, decl); - mappings->insert_canonical_path (struct_decl.get_node_id (), cpath); + mappings.insert_module_child_item (current_module, decl); + mappings.insert_canonical_path (struct_decl.get_node_id (), cpath); } void visit (AST::Union &union_decl) override @@ -274,8 +274,8 @@ public: }); NodeId current_module = resolver->peek_current_module_scope (); - mappings->insert_module_child_item (current_module, decl); - mappings->insert_canonical_path (union_decl.get_node_id (), cpath); + mappings.insert_module_child_item (current_module, decl); + mappings.insert_canonical_path (union_decl.get_node_id (), cpath); } void visit (AST::StaticItem &var) override @@ -294,8 +294,8 @@ public: }); NodeId current_module = resolver->peek_current_module_scope (); - mappings->insert_module_child_item (current_module, decl); - mappings->insert_canonical_path (var.get_node_id (), cpath); + mappings.insert_module_child_item (current_module, decl); + mappings.insert_canonical_path (var.get_node_id (), cpath); } void visit (AST::ConstantItem &constant) override @@ -315,8 +315,8 @@ public: }); NodeId current_module = resolver->peek_current_module_scope (); - mappings->insert_module_child_item (current_module, decl); - mappings->insert_canonical_path (constant.get_node_id (), cpath); + mappings.insert_module_child_item (current_module, decl); + mappings.insert_canonical_path (constant.get_node_id (), cpath); } void visit (AST::Function &function) override @@ -337,8 +337,8 @@ public: }); NodeId current_module = resolver->peek_current_module_scope (); - mappings->insert_module_child_item (current_module, decl); - mappings->insert_canonical_path (function.get_node_id (), cpath); + mappings.insert_module_child_item (current_module, decl); + mappings.insert_canonical_path (function.get_node_id (), cpath); } void visit (AST::InherentImpl &impl_block) override @@ -408,8 +408,8 @@ public: ResolveTopLevelTraitItems::go (item.get (), path, cpath); NodeId current_module = resolver->peek_current_module_scope (); - mappings->insert_module_child_item (current_module, decl); - mappings->insert_canonical_path (trait.get_node_id (), cpath); + mappings.insert_module_child_item (current_module, decl); + mappings.insert_canonical_path (trait.get_node_id (), cpath); } void visit (AST::ExternBlock &extern_block) override @@ -428,16 +428,16 @@ public: NodeId resolved_crate = UNKNOWN_NODEID; if (extern_crate.references_self ()) { - CrateNum crate_num = mappings->get_current_crate (); - bool ok = mappings->crate_num_to_nodeid (crate_num, resolved_crate); + CrateNum crate_num = mappings.get_current_crate (); + bool ok = mappings.crate_num_to_nodeid (crate_num, resolved_crate); rust_assert (ok); } else { CrateNum found_crate_num = UNKNOWN_CRATENUM; bool found - = mappings->lookup_crate_name (extern_crate.get_referenced_crate (), - found_crate_num); + = mappings.lookup_crate_name (extern_crate.get_referenced_crate (), + found_crate_num); if (!found) { rust_error_at (extern_crate.get_locus (), "unknown crate %qs", @@ -446,7 +446,7 @@ public: } bool ok - = mappings->crate_num_to_nodeid (found_crate_num, resolved_crate); + = mappings.crate_num_to_nodeid (found_crate_num, resolved_crate); if (!ok) { rust_internal_error_at (extern_crate.get_locus (), |