aboutsummaryrefslogtreecommitdiff
path: root/gcc/rust/typecheck
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/rust/typecheck')
-rw-r--r--gcc/rust/typecheck/rust-autoderef.cc10
-rw-r--r--gcc/rust/typecheck/rust-coercion.cc22
-rw-r--r--gcc/rust/typecheck/rust-coercion.h2
-rw-r--r--gcc/rust/typecheck/rust-hir-dot-operator.cc4
-rw-r--r--gcc/rust/typecheck/rust-hir-inherent-impl-overlap.h2
-rw-r--r--gcc/rust/typecheck/rust-hir-path-probe.cc6
-rw-r--r--gcc/rust/typecheck/rust-hir-trait-resolve.cc8
-rw-r--r--gcc/rust/typecheck/rust-hir-type-check-base.cc10
-rw-r--r--gcc/rust/typecheck/rust-hir-type-check-base.h2
-rw-r--r--gcc/rust/typecheck/rust-hir-type-check-enumitem.cc22
-rw-r--r--gcc/rust/typecheck/rust-hir-type-check-expr.cc38
-rw-r--r--gcc/rust/typecheck/rust-hir-type-check-implitem.cc16
-rw-r--r--gcc/rust/typecheck/rust-hir-type-check-item.cc22
-rw-r--r--gcc/rust/typecheck/rust-hir-type-check-path.cc10
-rw-r--r--gcc/rust/typecheck/rust-hir-type-check-pattern.cc6
-rw-r--r--gcc/rust/typecheck/rust-hir-type-check-struct.cc4
-rw-r--r--gcc/rust/typecheck/rust-hir-type-check-type.cc14
-rw-r--r--gcc/rust/typecheck/rust-hir-type-check.cc14
-rw-r--r--gcc/rust/typecheck/rust-type-util.cc18
-rw-r--r--gcc/rust/typecheck/rust-typecheck-context.cc8
-rw-r--r--gcc/rust/typecheck/rust-tyty-bounds.cc14
-rw-r--r--gcc/rust/typecheck/rust-tyty-call.cc4
-rw-r--r--gcc/rust/typecheck/rust-tyty-call.h4
-rw-r--r--gcc/rust/typecheck/rust-tyty-cmp.h96
-rw-r--r--gcc/rust/typecheck/rust-tyty-subst.cc6
-rw-r--r--gcc/rust/typecheck/rust-tyty-util.cc18
-rw-r--r--gcc/rust/typecheck/rust-tyty.cc53
-rw-r--r--gcc/rust/typecheck/rust-tyty.h2
-rw-r--r--gcc/rust/typecheck/rust-unify.cc4
29 files changed, 219 insertions, 220 deletions
diff --git a/gcc/rust/typecheck/rust-autoderef.cc b/gcc/rust/typecheck/rust-autoderef.cc
index 232ee61..1d0e7ad 100644
--- a/gcc/rust/typecheck/rust-autoderef.cc
+++ b/gcc/rust/typecheck/rust-autoderef.cc
@@ -104,14 +104,14 @@ Adjuster::try_unsize_type (TyTy::BaseType *ty)
if (!is_valid_type)
return Adjustment::get_error ();
- auto mappings = Analysis::Mappings::get ();
+ auto &mappings = Analysis::Mappings::get ();
auto context = TypeCheckContext::get ();
const auto ref_base = static_cast<const TyTy::ArrayType *> (ty);
auto slice_elem = ref_base->get_element_type ();
auto slice
- = new TyTy::SliceType (mappings->get_next_hir_id (), ty->get_ident ().locus,
+ = new TyTy::SliceType (mappings.get_next_hir_id (), ty->get_ident ().locus,
TyTy::TyVar (slice_elem->get_ref ()));
context->insert_implicit_type (slice);
@@ -125,13 +125,13 @@ resolve_operator_overload_fn (
Adjustment::AdjustmentType *requires_ref_adjustment)
{
auto context = TypeCheckContext::get ();
- auto mappings = Analysis::Mappings::get ();
+ auto &mappings = Analysis::Mappings::get ();
// look up lang item for arithmetic type
std::string associated_item_name = LangItem::ToString (lang_item_type);
DefId respective_lang_item_id = UNKNOWN_DEFID;
bool lang_item_defined
- = mappings->lookup_lang_item (lang_item_type, &respective_lang_item_id);
+ = mappings.lookup_lang_item (lang_item_type, &respective_lang_item_id);
if (!lang_item_defined)
return false;
@@ -293,7 +293,7 @@ resolve_operator_overload_fn (
rust_assert (lookup->get_kind () == TyTy::TypeKind::FNDEF);
fn = static_cast<TyTy::FnType *> (lookup);
- location_t unify_locus = mappings->lookup_location (lhs->get_ref ());
+ location_t unify_locus = mappings.lookup_location (lhs->get_ref ());
unify_site (lhs->get_ref (),
TyTy::TyWithLocation (fn->get_self_type ()),
TyTy::TyWithLocation (adjusted_self), unify_locus);
diff --git a/gcc/rust/typecheck/rust-coercion.cc b/gcc/rust/typecheck/rust-coercion.cc
index 9577d42..f9956b0 100644
--- a/gcc/rust/typecheck/rust-coercion.cc
+++ b/gcc/rust/typecheck/rust-coercion.cc
@@ -74,7 +74,7 @@ TypeCoercionRules::do_coercion (TyTy::BaseType *receiver)
// here, we would coerce from `!` to `?T`.
if (expected->has_substitutions_defined () && !expected->is_concrete ())
{
- location_t locus = mappings->lookup_location (receiver->get_ref ());
+ location_t locus = mappings.lookup_location (receiver->get_ref ());
TyTy::TyVar implicit_var
= TyTy::TyVar::get_implicit_infer_var (locus);
try_result = CoercionResult{{}, implicit_var.get_tyty ()};
@@ -116,8 +116,8 @@ TypeCoercionRules::do_coercion (TyTy::BaseType *receiver)
}
else if (unsafe_error)
{
- // location_t lhs = mappings->lookup_location (receiver->get_ref ());
- // location_t rhs = mappings->lookup_location (expected->get_ref ());
+ // location_t lhs = mappings.lookup_location (receiver->get_ref ());
+ // location_t rhs = mappings.lookup_location (expected->get_ref ());
// object_unsafe_error (locus, lhs, rhs);
return false;
}
@@ -215,8 +215,8 @@ TypeCoercionRules::coerce_unsafe_ptr (TyTy::BaseType *receiver,
if (!coerceable_mutability (from_mutbl, to_mutbl))
{
- location_t lhs = mappings->lookup_location (receiver->get_ref ());
- location_t rhs = mappings->lookup_location (expected->get_ref ());
+ location_t lhs = mappings.lookup_location (receiver->get_ref ());
+ location_t rhs = mappings.lookup_location (expected->get_ref ());
mismatched_mutability_error (locus, lhs, rhs);
return TypeCoercionRules::CoercionResult::get_error ();
}
@@ -294,8 +294,8 @@ TypeCoercionRules::coerce_borrowed_pointer (TyTy::BaseType *receiver,
if (!coerceable_mutability (from_mutbl, to_mutbl))
{
- location_t lhs = mappings->lookup_location (receiver->get_ref ());
- location_t rhs = mappings->lookup_location (expected->get_ref ());
+ location_t lhs = mappings.lookup_location (receiver->get_ref ());
+ location_t rhs = mappings.lookup_location (expected->get_ref ());
mismatched_mutability_error (locus, lhs, rhs);
return TypeCoercionRules::CoercionResult::get_error ();
}
@@ -339,8 +339,8 @@ TypeCoercionRules::coerce_unsized (TyTy::BaseType *source,
if (!coerceable_mutability (from_mutbl, to_mutbl))
{
unsafe_error = true;
- location_t lhs = mappings->lookup_location (source->get_ref ());
- location_t rhs = mappings->lookup_location (target->get_ref ());
+ location_t lhs = mappings.lookup_location (source->get_ref ());
+ location_t rhs = mappings.lookup_location (target->get_ref ());
mismatched_mutability_error (locus, lhs, rhs);
return TypeCoercionRules::CoercionResult::get_error ();
}
@@ -364,8 +364,8 @@ TypeCoercionRules::coerce_unsized (TyTy::BaseType *source,
if (!coerceable_mutability (from_mutbl, to_mutbl))
{
unsafe_error = true;
- location_t lhs = mappings->lookup_location (source->get_ref ());
- location_t rhs = mappings->lookup_location (target->get_ref ());
+ location_t lhs = mappings.lookup_location (source->get_ref ());
+ location_t rhs = mappings.lookup_location (target->get_ref ());
mismatched_mutability_error (locus, lhs, rhs);
return TypeCoercionRules::CoercionResult::get_error ();
}
diff --git a/gcc/rust/typecheck/rust-coercion.h b/gcc/rust/typecheck/rust-coercion.h
index 069927b..7dda868 100644
--- a/gcc/rust/typecheck/rust-coercion.h
+++ b/gcc/rust/typecheck/rust-coercion.h
@@ -81,7 +81,7 @@ protected:
private:
// context info
- Analysis::Mappings *mappings;
+ Analysis::Mappings &mappings;
TypeCheckContext *context;
// search
diff --git a/gcc/rust/typecheck/rust-hir-dot-operator.cc b/gcc/rust/typecheck/rust-hir-dot-operator.cc
index 85544a0..2c8e53e 100644
--- a/gcc/rust/typecheck/rust-hir-dot-operator.cc
+++ b/gcc/rust/typecheck/rust-hir-dot-operator.cc
@@ -122,7 +122,7 @@ MethodResolver::select (TyTy::BaseType &receiver)
// assemble inherent impl items
std::vector<impl_item_candidate> inherent_impl_fns;
- mappings->iterate_impl_items (
+ mappings.iterate_impl_items (
[&] (HirId id, HIR::ImplItem *item, HIR::ImplBlock *impl) mutable -> bool {
bool is_trait_impl = impl->has_trait_ref ();
if (is_trait_impl)
@@ -200,7 +200,7 @@ MethodResolver::select (TyTy::BaseType &receiver)
};
std::vector<trait_item_candidate> trait_fns;
- mappings->iterate_impl_blocks (
+ mappings.iterate_impl_blocks (
[&] (HirId id, HIR::ImplBlock *impl) mutable -> bool {
bool is_trait_impl = impl->has_trait_ref ();
if (!is_trait_impl)
diff --git a/gcc/rust/typecheck/rust-hir-inherent-impl-overlap.h b/gcc/rust/typecheck/rust-hir-inherent-impl-overlap.h
index abb93ca..a9edc42 100644
--- a/gcc/rust/typecheck/rust-hir-inherent-impl-overlap.h
+++ b/gcc/rust/typecheck/rust-hir-inherent-impl-overlap.h
@@ -33,7 +33,7 @@ public:
OverlappingImplItemPass pass;
// generate mappings
- pass.mappings->iterate_impl_items (
+ pass.mappings.iterate_impl_items (
[&] (HirId id, HIR::ImplItem *impl_item, HIR::ImplBlock *impl) -> bool {
// ignoring trait-impls might need thought later on
if (impl->has_trait_ref ())
diff --git a/gcc/rust/typecheck/rust-hir-path-probe.cc b/gcc/rust/typecheck/rust-hir-path-probe.cc
index 85cdc04..aa74f2e 100644
--- a/gcc/rust/typecheck/rust-hir-path-probe.cc
+++ b/gcc/rust/typecheck/rust-hir-path-probe.cc
@@ -277,7 +277,7 @@ PathProbeType::process_enum_item_for_candiates (const TyTy::ADTType *adt)
PathProbeCandidate::EnumItemCandidate enum_item_candidate{adt, v};
PathProbeCandidate candidate{PathProbeCandidate::CandidateType::ENUM_VARIANT,
receiver->clone (),
- mappings->lookup_location (adt->get_ty_ref ()),
+ mappings.lookup_location (adt->get_ty_ref ()),
enum_item_candidate};
candidates.insert (std::move (candidate));
}
@@ -285,7 +285,7 @@ PathProbeType::process_enum_item_for_candiates (const TyTy::ADTType *adt)
void
PathProbeType::process_impl_items_for_candidates ()
{
- mappings->iterate_impl_items (
+ mappings.iterate_impl_items (
[&] (HirId id, HIR::ImplItem *item, HIR::ImplBlock *impl) mutable -> bool {
process_impl_item_candidate (id, item, impl);
return true;
@@ -465,7 +465,7 @@ PathProbeImplTrait::Probe (const TyTy::BaseType *receiver,
void
PathProbeImplTrait::process_trait_impl_items_for_candidates ()
{
- mappings->iterate_impl_items (
+ mappings.iterate_impl_items (
[&] (HirId id, HIR::ImplItem *item, HIR::ImplBlock *impl) mutable -> bool {
// just need to check if this is an impl block for this trait the next
// function checks the receiver
diff --git a/gcc/rust/typecheck/rust-hir-trait-resolve.cc b/gcc/rust/typecheck/rust-hir-trait-resolve.cc
index a300cec..6eb045c 100644
--- a/gcc/rust/typecheck/rust-hir-trait-resolve.cc
+++ b/gcc/rust/typecheck/rust-hir-trait-resolve.cc
@@ -118,13 +118,13 @@ TraitResolver::resolve_path_to_trait (const HIR::TypePath &path,
}
HirId hir_node = UNKNOWN_HIRID;
- if (!mappings->lookup_node_to_hir (ref, &hir_node))
+ if (!mappings.lookup_node_to_hir (ref, &hir_node))
{
rust_error_at (path.get_locus (), "Failed to resolve path to hir-id");
return false;
}
- HIR::Item *resolved_item = mappings->lookup_hir_item (hir_node);
+ HIR::Item *resolved_item = mappings.lookup_hir_item (hir_node);
rust_assert (resolved_item != nullptr);
rust_assert (resolved_item->get_item_kind () == HIR::Item::ItemKind::Trait);
*resolved = static_cast<HIR::Trait *> (resolved_item);
@@ -665,10 +665,10 @@ AssociatedImplTrait::reset_associated_types ()
Analysis::NodeMapping
TraitItemReference::get_parent_trait_mappings () const
{
- auto mappings = Analysis::Mappings::get ();
+ auto &mappings = Analysis::Mappings::get ();
HIR::Trait *trait
- = mappings->lookup_trait_item_mapping (get_mappings ().get_hirid ());
+ = mappings.lookup_trait_item_mapping (get_mappings ().get_hirid ());
rust_assert (trait != nullptr);
return trait->get_mappings ();
diff --git a/gcc/rust/typecheck/rust-hir-type-check-base.cc b/gcc/rust/typecheck/rust-hir-type-check-base.cc
index f3edfef..4d92f0c 100644
--- a/gcc/rust/typecheck/rust-hir-type-check-base.cc
+++ b/gcc/rust/typecheck/rust-hir-type-check-base.cc
@@ -238,9 +238,9 @@ TypeCheckBase::resolve_literal (const Analysis::NodeMapping &expr_mappings,
auto ok = context->lookup_builtin ("u8", &u8);
rust_assert (ok);
- auto crate_num = mappings->get_current_crate ();
+ auto crate_num = mappings.get_current_crate ();
Analysis::NodeMapping capacity_mapping (crate_num, UNKNOWN_NODEID,
- mappings->get_next_hir_id (
+ mappings.get_next_hir_id (
crate_num),
UNKNOWN_LOCAL_DEFID);
@@ -260,7 +260,7 @@ TypeCheckBase::resolve_literal (const Analysis::NodeMapping &expr_mappings,
context->insert_type (capacity_mapping, expected_ty);
Analysis::NodeMapping array_mapping (crate_num, UNKNOWN_NODEID,
- mappings->get_next_hir_id (
+ mappings.get_next_hir_id (
crate_num),
UNKNOWN_LOCAL_DEFID);
@@ -413,8 +413,8 @@ TypeCheckBase::resolve_generic_params (
TyTy::TypeBoundPredicate
TypeCheckBase::get_marker_predicate (LangItem::Kind item_type, location_t locus)
{
- DefId item_id = mappings->get_lang_item (item_type, locus);
- HIR::Item *item = mappings->lookup_defid (item_id);
+ DefId item_id = mappings.get_lang_item (item_type, locus);
+ HIR::Item *item = mappings.lookup_defid (item_id);
rust_assert (item != nullptr);
rust_assert (item->get_item_kind () == HIR::Item::ItemKind::Trait);
diff --git a/gcc/rust/typecheck/rust-hir-type-check-base.h b/gcc/rust/typecheck/rust-hir-type-check-base.h
index 11a3a68..b085b4b 100644
--- a/gcc/rust/typecheck/rust-hir-type-check-base.h
+++ b/gcc/rust/typecheck/rust-hir-type-check-base.h
@@ -61,7 +61,7 @@ protected:
TyTy::TypeBoundPredicate get_marker_predicate (LangItem::Kind item_type,
location_t locus);
- Analysis::Mappings *mappings;
+ Analysis::Mappings &mappings;
Resolver *resolver;
TypeCheckContext *context;
};
diff --git a/gcc/rust/typecheck/rust-hir-type-check-enumitem.cc b/gcc/rust/typecheck/rust-hir-type-check-enumitem.cc
index 9fcb442..62c370f 100644
--- a/gcc/rust/typecheck/rust-hir-type-check-enumitem.cc
+++ b/gcc/rust/typecheck/rust-hir-type-check-enumitem.cc
@@ -61,7 +61,7 @@ TypeCheckEnumItem::visit (HIR::EnumItem &item)
Analysis::NodeMapping mapping (item.get_mappings ().get_crate_num (),
item.get_mappings ().get_nodeid (),
- mappings->get_next_hir_id (
+ mappings.get_next_hir_id (
item.get_mappings ().get_crate_num ()),
item.get_mappings ().get_local_defid ());
HIR::LiteralExpr *discim_expr
@@ -76,8 +76,8 @@ TypeCheckEnumItem::visit (HIR::EnumItem &item)
context->insert_type (mapping, isize);
const CanonicalPath *canonical_path = nullptr;
- ok = mappings->lookup_canonical_path (item.get_mappings ().get_nodeid (),
- &canonical_path);
+ ok = mappings.lookup_canonical_path (item.get_mappings ().get_nodeid (),
+ &canonical_path);
rust_assert (ok);
RustIdent ident{*canonical_path, item.get_locus ()};
@@ -107,8 +107,8 @@ TypeCheckEnumItem::visit (HIR::EnumItemDiscriminant &item)
TyTy::TyWithLocation (capacity_type), item.get_locus ());
const CanonicalPath *canonical_path = nullptr;
- bool ok = mappings->lookup_canonical_path (item.get_mappings ().get_nodeid (),
- &canonical_path);
+ bool ok = mappings.lookup_canonical_path (item.get_mappings ().get_nodeid (),
+ &canonical_path);
rust_assert (ok);
RustIdent ident{*canonical_path, item.get_locus ()};
@@ -141,7 +141,7 @@ TypeCheckEnumItem::visit (HIR::EnumItemTuple &item)
Analysis::NodeMapping mapping (item.get_mappings ().get_crate_num (),
item.get_mappings ().get_nodeid (),
- mappings->get_next_hir_id (
+ mappings.get_next_hir_id (
item.get_mappings ().get_crate_num ()),
item.get_mappings ().get_local_defid ());
HIR::LiteralExpr *discim_expr
@@ -156,8 +156,8 @@ TypeCheckEnumItem::visit (HIR::EnumItemTuple &item)
context->insert_type (mapping, isize);
const CanonicalPath *canonical_path = nullptr;
- ok = mappings->lookup_canonical_path (item.get_mappings ().get_nodeid (),
- &canonical_path);
+ ok = mappings.lookup_canonical_path (item.get_mappings ().get_nodeid (),
+ &canonical_path);
rust_assert (ok);
RustIdent ident{*canonical_path, item.get_locus ()};
@@ -189,7 +189,7 @@ TypeCheckEnumItem::visit (HIR::EnumItemStruct &item)
Analysis::NodeMapping mapping (item.get_mappings ().get_crate_num (),
item.get_mappings ().get_nodeid (),
- mappings->get_next_hir_id (
+ mappings.get_next_hir_id (
item.get_mappings ().get_crate_num ()),
item.get_mappings ().get_local_defid ());
HIR::LiteralExpr *discrim_expr
@@ -204,8 +204,8 @@ TypeCheckEnumItem::visit (HIR::EnumItemStruct &item)
context->insert_type (mapping, isize);
const CanonicalPath *canonical_path = nullptr;
- ok = mappings->lookup_canonical_path (item.get_mappings ().get_nodeid (),
- &canonical_path);
+ ok = mappings.lookup_canonical_path (item.get_mappings ().get_nodeid (),
+ &canonical_path);
rust_assert (ok);
RustIdent ident{*canonical_path, item.get_locus ()};
diff --git a/gcc/rust/typecheck/rust-hir-type-check-expr.cc b/gcc/rust/typecheck/rust-hir-type-check-expr.cc
index 224d2ff..57739e5 100644
--- a/gcc/rust/typecheck/rust-hir-type-check-expr.cc
+++ b/gcc/rust/typecheck/rust-hir-type-check-expr.cc
@@ -630,7 +630,7 @@ TypeCheckExpr::visit (HIR::RangeFromToExpr &expr)
DefId respective_lang_item_id = UNKNOWN_DEFID;
bool lang_item_defined
- = mappings->lookup_lang_item (lang_item_type, &respective_lang_item_id);
+ = mappings.lookup_lang_item (lang_item_type, &respective_lang_item_id);
// we need to have it maybe
if (!lang_item_defined)
@@ -642,7 +642,7 @@ TypeCheckExpr::visit (HIR::RangeFromToExpr &expr)
}
// look it up and it _must_ be a struct definition
- HIR::Item *item = mappings->lookup_defid (respective_lang_item_id);
+ HIR::Item *item = mappings.lookup_defid (respective_lang_item_id);
rust_assert (item != nullptr);
TyTy::BaseType *item_type = nullptr;
@@ -685,7 +685,7 @@ TypeCheckExpr::visit (HIR::RangeFromExpr &expr)
DefId respective_lang_item_id = UNKNOWN_DEFID;
bool lang_item_defined
- = mappings->lookup_lang_item (lang_item_type, &respective_lang_item_id);
+ = mappings.lookup_lang_item (lang_item_type, &respective_lang_item_id);
// we need to have it maybe
if (!lang_item_defined)
@@ -697,7 +697,7 @@ TypeCheckExpr::visit (HIR::RangeFromExpr &expr)
}
// look it up and it _must_ be a struct definition
- HIR::Item *item = mappings->lookup_defid (respective_lang_item_id);
+ HIR::Item *item = mappings.lookup_defid (respective_lang_item_id);
rust_assert (item != nullptr);
TyTy::BaseType *item_type = nullptr;
@@ -733,7 +733,7 @@ TypeCheckExpr::visit (HIR::RangeToExpr &expr)
DefId respective_lang_item_id = UNKNOWN_DEFID;
bool lang_item_defined
- = mappings->lookup_lang_item (lang_item_type, &respective_lang_item_id);
+ = mappings.lookup_lang_item (lang_item_type, &respective_lang_item_id);
// we need to have it maybe
if (!lang_item_defined)
@@ -745,7 +745,7 @@ TypeCheckExpr::visit (HIR::RangeToExpr &expr)
}
// look it up and it _must_ be a struct definition
- HIR::Item *item = mappings->lookup_defid (respective_lang_item_id);
+ HIR::Item *item = mappings.lookup_defid (respective_lang_item_id);
rust_assert (item != nullptr);
TyTy::BaseType *item_type = nullptr;
@@ -780,7 +780,7 @@ TypeCheckExpr::visit (HIR::RangeFullExpr &expr)
DefId respective_lang_item_id = UNKNOWN_DEFID;
bool lang_item_defined
- = mappings->lookup_lang_item (lang_item_type, &respective_lang_item_id);
+ = mappings.lookup_lang_item (lang_item_type, &respective_lang_item_id);
// we need to have it maybe
if (!lang_item_defined)
@@ -792,7 +792,7 @@ TypeCheckExpr::visit (HIR::RangeFullExpr &expr)
}
// look it up and it _must_ be a struct definition
- HIR::Item *item = mappings->lookup_defid (respective_lang_item_id);
+ HIR::Item *item = mappings.lookup_defid (respective_lang_item_id);
rust_assert (item != nullptr);
TyTy::BaseType *item_type = nullptr;
@@ -811,7 +811,7 @@ TypeCheckExpr::visit (HIR::RangeFromToInclExpr &expr)
DefId respective_lang_item_id = UNKNOWN_DEFID;
bool lang_item_defined
- = mappings->lookup_lang_item (lang_item_type, &respective_lang_item_id);
+ = mappings.lookup_lang_item (lang_item_type, &respective_lang_item_id);
// we need to have it maybe
if (!lang_item_defined)
@@ -823,7 +823,7 @@ TypeCheckExpr::visit (HIR::RangeFromToInclExpr &expr)
}
// look it up and it _must_ be a struct definition
- HIR::Item *item = mappings->lookup_defid (respective_lang_item_id);
+ HIR::Item *item = mappings.lookup_defid (respective_lang_item_id);
rust_assert (item != nullptr);
TyTy::BaseType *item_type = nullptr;
@@ -982,9 +982,9 @@ TypeCheckExpr::visit (HIR::ArrayExpr &expr)
expr.get_locus ());
}
- auto crate_num = mappings->get_current_crate ();
+ auto crate_num = mappings.get_current_crate ();
Analysis::NodeMapping mapping (crate_num, UNKNOWN_NODEID,
- mappings->get_next_hir_id (crate_num),
+ mappings.get_next_hir_id (crate_num),
UNKNOWN_LOCAL_DEFID);
std::string capacity_str = std::to_string (elems.get_num_elements ());
capacity_expr = new HIR::LiteralExpr (mapping, capacity_str,
@@ -1548,7 +1548,7 @@ TypeCheckExpr::visit (HIR::ClosureExpr &expr)
}
// we generate an implicit hirid for the closure args
- HirId implicit_args_id = mappings->get_next_hir_id ();
+ HirId implicit_args_id = mappings.get_next_hir_id ();
TyTy::TupleType *closure_args
= new TyTy::TupleType (implicit_args_id, expr.get_locus (),
parameter_types);
@@ -1587,7 +1587,7 @@ TypeCheckExpr::visit (HIR::ClosureExpr &expr)
LangItem::Kind lang_item_type = LangItem::Kind::FN_ONCE;
DefId respective_lang_item_id = UNKNOWN_DEFID;
bool lang_item_defined
- = mappings->lookup_lang_item (lang_item_type, &respective_lang_item_id);
+ = mappings.lookup_lang_item (lang_item_type, &respective_lang_item_id);
if (!lang_item_defined)
{
// FIXME
@@ -1599,7 +1599,7 @@ TypeCheckExpr::visit (HIR::ClosureExpr &expr)
rust_assert (lang_item_defined);
// these lang items are always traits
- HIR::Item *item = mappings->lookup_defid (respective_lang_item_id);
+ HIR::Item *item = mappings.lookup_defid (respective_lang_item_id);
rust_assert (item->get_item_kind () == HIR::Item::ItemKind::Trait);
HIR::Trait *trait_item = static_cast<HIR::Trait *> (item);
@@ -1614,7 +1614,7 @@ TypeCheckExpr::visit (HIR::ClosureExpr &expr)
// lets generate an implicit Type so that it resolves to the implict tuple
// type we have created
- auto crate_num = mappings->get_current_crate ();
+ auto crate_num = mappings.get_current_crate ();
Analysis::NodeMapping mapping (crate_num, expr.get_mappings ().get_nodeid (),
implicit_args_id, UNKNOWN_LOCAL_DEFID);
HIR::TupleType *implicit_tuple
@@ -1642,7 +1642,7 @@ TypeCheckExpr::resolve_operator_overload (LangItem::Kind lang_item_type,
std::string associated_item_name = LangItem::ToString (lang_item_type);
DefId respective_lang_item_id = UNKNOWN_DEFID;
bool lang_item_defined
- = mappings->lookup_lang_item (lang_item_type, &respective_lang_item_id);
+ = mappings.lookup_lang_item (lang_item_type, &respective_lang_item_id);
// probe for the lang-item
if (!lang_item_defined)
@@ -1972,8 +1972,8 @@ TypeCheckExpr::resolve_fn_trait_call (HIR::CallExpr &expr,
}
// crate implicit tuple
- HirId implicit_arg_id = mappings->get_next_hir_id ();
- Analysis::NodeMapping mapping (mappings->get_current_crate (), UNKNOWN_NODEID,
+ HirId implicit_arg_id = mappings.get_next_hir_id ();
+ Analysis::NodeMapping mapping (mappings.get_current_crate (), UNKNOWN_NODEID,
implicit_arg_id, UNKNOWN_LOCAL_DEFID);
TyTy::TupleType *tuple
diff --git a/gcc/rust/typecheck/rust-hir-type-check-implitem.cc b/gcc/rust/typecheck/rust-hir-type-check-implitem.cc
index 8a9a3f3..1ae6952 100644
--- a/gcc/rust/typecheck/rust-hir-type-check-implitem.cc
+++ b/gcc/rust/typecheck/rust-hir-type-check-implitem.cc
@@ -134,9 +134,9 @@ TypeCheckTopLevelExternItem::visit (HIR::ExternalFunctionItem &function)
auto param_tyty = TypeCheckType::Resolve (param.get_type ().get ());
// these are implicit mappings and not used
- auto crate_num = mappings->get_current_crate ();
- Analysis::NodeMapping mapping (crate_num, mappings->get_next_node_id (),
- mappings->get_next_hir_id (crate_num),
+ auto crate_num = mappings.get_current_crate ();
+ Analysis::NodeMapping mapping (crate_num, mappings.get_next_node_id (),
+ mappings.get_next_hir_id (crate_num),
UNKNOWN_LOCAL_DEFID);
HIR::IdentifierPattern *param_pattern
@@ -377,9 +377,9 @@ TypeCheckImplItem::visit (HIR::Function &function)
if (function.is_method ())
{
// these are implicit mappings and not used
- auto crate_num = mappings->get_current_crate ();
- Analysis::NodeMapping mapping (crate_num, mappings->get_next_node_id (),
- mappings->get_next_hir_id (crate_num),
+ auto crate_num = mappings.get_current_crate ();
+ Analysis::NodeMapping mapping (crate_num, mappings.get_next_node_id (),
+ mappings.get_next_hir_id (crate_num),
UNKNOWN_LOCAL_DEFID);
// add the synthetic self param at the front, this is a placeholder for
@@ -463,8 +463,8 @@ TypeCheckImplItem::visit (HIR::Function &function)
const CanonicalPath *canonical_path = nullptr;
bool ok
- = mappings->lookup_canonical_path (function.get_mappings ().get_nodeid (),
- &canonical_path);
+ = mappings.lookup_canonical_path (function.get_mappings ().get_nodeid (),
+ &canonical_path);
rust_assert (ok);
RustIdent ident{*canonical_path, function.get_locus ()};
diff --git a/gcc/rust/typecheck/rust-hir-type-check-item.cc b/gcc/rust/typecheck/rust-hir-type-check-item.cc
index 3e504e5..7e59d9e 100644
--- a/gcc/rust/typecheck/rust-hir-type-check-item.cc
+++ b/gcc/rust/typecheck/rust-hir-type-check-item.cc
@@ -206,7 +206,7 @@ TypeCheckItem::visit (HIR::TupleStruct &struct_decl)
else
{
const CanonicalPath *canonical_path = nullptr;
- bool ok = mappings->lookup_canonical_path (
+ bool ok = mappings.lookup_canonical_path (
struct_decl.get_mappings ().get_nodeid (), &canonical_path);
rust_assert (ok);
@@ -230,7 +230,7 @@ TypeCheckItem::visit (HIR::TupleStruct &struct_decl)
= parse_repr_options (attrs, struct_decl.get_locus ());
auto *type = new TyTy::ADTType (
- struct_decl.get_mappings ().get_hirid (), mappings->get_next_hir_id (),
+ struct_decl.get_mappings ().get_hirid (), mappings.get_next_hir_id (),
struct_decl.get_identifier ().as_string (), ident,
TyTy::ADTType::ADTKind::TUPLE_STRUCT, std::move (variants),
std::move (substitutions), repr,
@@ -289,7 +289,7 @@ TypeCheckItem::visit (HIR::StructStruct &struct_decl)
else
{
const CanonicalPath *canonical_path = nullptr;
- bool ok = mappings->lookup_canonical_path (
+ bool ok = mappings.lookup_canonical_path (
struct_decl.get_mappings ().get_nodeid (), &canonical_path);
rust_assert (ok);
@@ -313,7 +313,7 @@ TypeCheckItem::visit (HIR::StructStruct &struct_decl)
= parse_repr_options (attrs, struct_decl.get_locus ());
auto *type = new TyTy::ADTType (
- struct_decl.get_mappings ().get_hirid (), mappings->get_next_hir_id (),
+ struct_decl.get_mappings ().get_hirid (), mappings.get_next_hir_id (),
struct_decl.get_identifier ().as_string (), ident,
TyTy::ADTType::ADTKind::STRUCT_STRUCT, std::move (variants),
std::move (substitutions), repr,
@@ -349,15 +349,15 @@ TypeCheckItem::visit (HIR::Enum &enum_decl)
// get the path
const CanonicalPath *canonical_path = nullptr;
bool ok
- = mappings->lookup_canonical_path (enum_decl.get_mappings ().get_nodeid (),
- &canonical_path);
+ = mappings.lookup_canonical_path (enum_decl.get_mappings ().get_nodeid (),
+ &canonical_path);
rust_assert (ok);
RustIdent ident{*canonical_path, enum_decl.get_locus ()};
// multi variant ADT
auto *type
= new TyTy::ADTType (enum_decl.get_mappings ().get_hirid (),
- mappings->get_next_hir_id (),
+ mappings.get_next_hir_id (),
enum_decl.get_identifier ().as_string (), ident,
TyTy::ADTType::ADTKind::ENUM, std::move (variants),
std::move (substitutions));
@@ -399,8 +399,8 @@ TypeCheckItem::visit (HIR::Union &union_decl)
// get the path
const CanonicalPath *canonical_path = nullptr;
bool ok
- = mappings->lookup_canonical_path (union_decl.get_mappings ().get_nodeid (),
- &canonical_path);
+ = mappings.lookup_canonical_path (union_decl.get_mappings ().get_nodeid (),
+ &canonical_path);
rust_assert (ok);
RustIdent ident{*canonical_path, union_decl.get_locus ()};
@@ -415,7 +415,7 @@ TypeCheckItem::visit (HIR::Union &union_decl)
auto *type
= new TyTy::ADTType (union_decl.get_mappings ().get_hirid (),
- mappings->get_next_hir_id (),
+ mappings.get_next_hir_id (),
union_decl.get_identifier ().as_string (), ident,
TyTy::ADTType::ADTKind::UNION, std::move (variants),
std::move (substitutions));
@@ -568,7 +568,7 @@ TypeCheckItem::visit (HIR::Function &function)
else
{
const CanonicalPath *canonical_path = nullptr;
- bool ok = mappings->lookup_canonical_path (
+ bool ok = mappings.lookup_canonical_path (
function.get_mappings ().get_nodeid (), &canonical_path);
rust_assert (ok);
diff --git a/gcc/rust/typecheck/rust-hir-type-check-path.cc b/gcc/rust/typecheck/rust-hir-type-check-path.cc
index dd6ab03..3c7dc29 100644
--- a/gcc/rust/typecheck/rust-hir-type-check-path.cc
+++ b/gcc/rust/typecheck/rust-hir-type-check-path.cc
@@ -230,7 +230,7 @@ TypeCheckExpr::resolve_root_path (HIR::PathInExpression &expr, size_t *offset,
// node back to HIR
HirId ref;
- if (!mappings->lookup_node_to_hir (ref_node_id, &ref))
+ if (!mappings.lookup_node_to_hir (ref_node_id, &ref))
{
rust_error_at (seg.get_locus (), "456 reverse lookup failure");
rust_debug_loc (seg.get_locus (),
@@ -242,8 +242,8 @@ TypeCheckExpr::resolve_root_path (HIR::PathInExpression &expr, size_t *offset,
return new TyTy::ErrorType (expr.get_mappings ().get_hirid ());
}
- auto seg_is_module = (nullptr != mappings->lookup_module (ref));
- auto seg_is_crate = mappings->is_local_hirid_crate (ref);
+ auto seg_is_module = (nullptr != mappings.lookup_module (ref));
+ auto seg_is_crate = mappings.is_local_hirid_crate (ref);
if (seg_is_module || seg_is_crate)
{
// A::B::C::this_is_a_module::D::E::F
@@ -279,7 +279,7 @@ TypeCheckExpr::resolve_root_path (HIR::PathInExpression &expr, size_t *offset,
// is it an enum item?
std::pair<HIR::Enum *, HIR::EnumItem *> enum_item_lookup
- = mappings->lookup_hir_enumitem (ref);
+ = mappings.lookup_hir_enumitem (ref);
bool is_enum_item = enum_item_lookup.first != nullptr
&& enum_item_lookup.second != nullptr;
if (is_enum_item)
@@ -389,7 +389,7 @@ TypeCheckExpr::resolve_segments (NodeId root_resolved_node_id,
HirId variant_id = variant->get_id ();
std::pair<HIR::Enum *, HIR::EnumItem *> enum_item_lookup
- = mappings->lookup_hir_enumitem (variant_id);
+ = mappings.lookup_hir_enumitem (variant_id);
bool enum_item_ok = enum_item_lookup.first != nullptr
&& enum_item_lookup.second != nullptr;
rust_assert (enum_item_ok);
diff --git a/gcc/rust/typecheck/rust-hir-type-check-pattern.cc b/gcc/rust/typecheck/rust-hir-type-check-pattern.cc
index c7f29e2..a871ae7 100644
--- a/gcc/rust/typecheck/rust-hir-type-check-pattern.cc
+++ b/gcc/rust/typecheck/rust-hir-type-check-pattern.cc
@@ -421,7 +421,7 @@ TypeCheckPattern::emit_pattern_size_error (const HIR::Pattern &pattern,
size_t got_field_count)
{
rich_location r (line_table, pattern.get_locus ());
- r.add_range (mappings->lookup_location (parent->get_ref ()));
+ r.add_range (mappings.lookup_location (parent->get_ref ()));
rust_error_at (r,
"expected a tuple with %lu %s, found one "
"with %lu %s",
@@ -505,8 +505,8 @@ ClosureParamInfer::Resolve (HIR::Pattern *pattern)
if (resolver.infered->get_kind () != TyTy::TypeKind::ERROR)
{
resolver.context->insert_implicit_type (resolver.infered);
- resolver.mappings->insert_location (resolver.infered->get_ref (),
- pattern->get_locus ());
+ resolver.mappings.insert_location (resolver.infered->get_ref (),
+ pattern->get_locus ());
}
return resolver.infered;
}
diff --git a/gcc/rust/typecheck/rust-hir-type-check-struct.cc b/gcc/rust/typecheck/rust-hir-type-check-struct.cc
index d2977ac..5999b2d 100644
--- a/gcc/rust/typecheck/rust-hir-type-check-struct.cc
+++ b/gcc/rust/typecheck/rust-hir-type-check-struct.cc
@@ -195,12 +195,12 @@ TypeCheckStructExpr::resolve (HIR::StructExprStructFields &struct_expr)
HIR::StructExprField *implicit_field = nullptr;
AST::AttrVec outer_attribs;
- auto crate_num = mappings->get_current_crate ();
+ auto crate_num = mappings.get_current_crate ();
Analysis::NodeMapping mapping (
crate_num,
struct_expr.struct_base->base_struct->get_mappings ()
.get_nodeid (),
- mappings->get_next_hir_id (crate_num), UNKNOWN_LOCAL_DEFID);
+ mappings.get_next_hir_id (crate_num), UNKNOWN_LOCAL_DEFID);
HIR::Expr *field_value = new HIR::FieldAccessExpr (
mapping, std::unique_ptr<HIR::Expr> (receiver), missing,
diff --git a/gcc/rust/typecheck/rust-hir-type-check-type.cc b/gcc/rust/typecheck/rust-hir-type-check-type.cc
index 44ebc15..3392fff 100644
--- a/gcc/rust/typecheck/rust-hir-type-check-type.cc
+++ b/gcc/rust/typecheck/rust-hir-type-check-type.cc
@@ -87,7 +87,7 @@ TypeCheckType::visit (HIR::BareFunctionType &fntype)
else
{
// needs a new implicit ID
- HirId ref = mappings->get_next_hir_id ();
+ HirId ref = mappings.get_next_hir_id ();
return_type = TyTy::TupleType::get_unit_type (ref);
context->insert_implicit_type (ref, return_type);
}
@@ -373,7 +373,7 @@ TypeCheckType::resolve_root_path (HIR::TypePath &path, size_t *offset,
// node back to HIR
HirId ref = UNKNOWN_HIRID;
- if (!mappings->lookup_node_to_hir (ref_node_id, &ref))
+ if (!mappings.lookup_node_to_hir (ref_node_id, &ref))
{
if (is_root)
{
@@ -390,8 +390,8 @@ TypeCheckType::resolve_root_path (HIR::TypePath &path, size_t *offset,
return root_tyty;
}
- auto seg_is_module = (nullptr != mappings->lookup_module (ref));
- auto seg_is_crate = mappings->is_local_hirid_crate (ref);
+ auto seg_is_module = (nullptr != mappings.lookup_module (ref));
+ auto seg_is_crate = mappings.is_local_hirid_crate (ref);
if (seg_is_module || seg_is_crate)
{
// A::B::C::this_is_a_module::D::E::F
@@ -780,7 +780,7 @@ TypeResolveGenericParam::visit (HIR::TypeParam &param)
// We need two possible parameter types. One with no Bounds and one with
// the bounds. the Self type for the bounds cannot itself contain the
// bounds otherwise it will be a trait cycle
- HirId implicit_id = mappings->get_next_hir_id ();
+ HirId implicit_id = mappings.get_next_hir_id ();
TyTy::ParamType *p
= new TyTy::ParamType (param.get_type_representation ().as_string (),
param.get_locus (), implicit_id, param,
@@ -998,7 +998,7 @@ ResolveWhereClauseItem::visit (HIR::TypeBoundWhereClauseItem &item)
// node back to HIR
HirId ref;
- if (!mappings->lookup_node_to_hir (ref_node_id, &ref))
+ if (!mappings.lookup_node_to_hir (ref_node_id, &ref))
{
// FIXME
rust_error_at (UNDEF_LOCATION, "where-clause reverse lookup failure");
@@ -1009,7 +1009,7 @@ ResolveWhereClauseItem::visit (HIR::TypeBoundWhereClauseItem &item)
TyTy::BaseType *lookup;
if (!context->lookup_type (ref, &lookup))
{
- rust_error_at (mappings->lookup_location (ref),
+ rust_error_at (mappings.lookup_location (ref),
"Failed to resolve where-clause binding type: %s",
binding_type_path->as_string ().c_str ());
return;
diff --git a/gcc/rust/typecheck/rust-hir-type-check.cc b/gcc/rust/typecheck/rust-hir-type-check.cc
index 0bc72d3..14a578e1 100644
--- a/gcc/rust/typecheck/rust-hir-type-check.cc
+++ b/gcc/rust/typecheck/rust-hir-type-check.cc
@@ -222,10 +222,10 @@ TraitItemReference::get_type_from_fn (/*const*/ HIR::TraitItemFunc &fn) const
if (function.is_method ())
{
// these are implicit mappings and not used
- auto mappings = Analysis::Mappings::get ();
- auto crate_num = mappings->get_current_crate ();
- Analysis::NodeMapping mapping (crate_num, mappings->get_next_node_id (),
- mappings->get_next_hir_id (crate_num),
+ auto &mappings = Analysis::Mappings::get ();
+ auto crate_num = mappings.get_current_crate ();
+ Analysis::NodeMapping mapping (crate_num, mappings.get_next_node_id (),
+ mappings.get_next_hir_id (crate_num),
UNKNOWN_LOCAL_DEFID);
// add the synthetic self param at the front, this is a placeholder
@@ -298,10 +298,10 @@ TraitItemReference::get_type_from_fn (/*const*/ HIR::TraitItemFunc &fn) const
TypeCheckPattern::Resolve (param.get_param_name ().get (), param_tyty);
}
- auto mappings = Analysis::Mappings::get ();
+ auto &mappings = Analysis::Mappings::get ();
const CanonicalPath *canonical_path = nullptr;
- bool ok = mappings->lookup_canonical_path (fn.get_mappings ().get_nodeid (),
- &canonical_path);
+ bool ok = mappings.lookup_canonical_path (fn.get_mappings ().get_nodeid (),
+ &canonical_path);
rust_assert (ok);
RustIdent ident{*canonical_path, fn.get_locus ()};
diff --git a/gcc/rust/typecheck/rust-type-util.cc b/gcc/rust/typecheck/rust-type-util.cc
index eed3ff4..05bf7ae 100644
--- a/gcc/rust/typecheck/rust-type-util.cc
+++ b/gcc/rust/typecheck/rust-type-util.cc
@@ -33,7 +33,7 @@ namespace Resolver {
bool
query_type (HirId reference, TyTy::BaseType **result)
{
- Analysis::Mappings *mappings = Analysis::Mappings::get ();
+ auto &mappings = Analysis::Mappings::get ();
TypeCheckContext *context = TypeCheckContext::get ();
if (context->query_in_progress (reference))
@@ -45,7 +45,7 @@ query_type (HirId reference, TyTy::BaseType **result)
context->insert_query (reference);
std::pair<HIR::Enum *, HIR::EnumItem *> enum_candidiate
- = mappings->lookup_hir_enumitem (reference);
+ = mappings.lookup_hir_enumitem (reference);
bool enum_candidiate_ok
= enum_candidiate.first != nullptr && enum_candidiate.second != nullptr;
if (enum_candidiate_ok)
@@ -61,7 +61,7 @@ query_type (HirId reference, TyTy::BaseType **result)
return true;
}
- HIR::Item *item = mappings->lookup_hir_item (reference);
+ HIR::Item *item = mappings.lookup_hir_item (reference);
if (item != nullptr)
{
rust_debug_loc (item->get_locus (), "resolved item {%u} to", reference);
@@ -72,11 +72,11 @@ query_type (HirId reference, TyTy::BaseType **result)
HirId parent_impl_id = UNKNOWN_HIRID;
HIR::ImplItem *impl_item
- = mappings->lookup_hir_implitem (reference, &parent_impl_id);
+ = mappings.lookup_hir_implitem (reference, &parent_impl_id);
if (impl_item != nullptr)
{
HIR::ImplBlock *impl_block
- = mappings->lookup_hir_impl_block (parent_impl_id);
+ = mappings.lookup_hir_impl_block (parent_impl_id);
rust_assert (impl_block != nullptr);
// found an impl item
@@ -91,7 +91,7 @@ query_type (HirId reference, TyTy::BaseType **result)
// is it an impl_type?
HIR::ImplBlock *impl_block_by_type = nullptr;
bool found_impl_block_type
- = mappings->lookup_impl_block_type (reference, &impl_block_by_type);
+ = mappings.lookup_impl_block_type (reference, &impl_block_by_type);
if (found_impl_block_type)
{
*result = TypeCheckItem::ResolveImplBlockSelf (*impl_block_by_type);
@@ -102,11 +102,11 @@ query_type (HirId reference, TyTy::BaseType **result)
// is it an extern item?
HirId parent_extern_block_id = UNKNOWN_HIRID;
HIR::ExternalItem *extern_item
- = mappings->lookup_hir_extern_item (reference, &parent_extern_block_id);
+ = mappings.lookup_hir_extern_item (reference, &parent_extern_block_id);
if (extern_item != nullptr)
{
HIR::ExternBlock *block
- = mappings->lookup_hir_extern_block (parent_extern_block_id);
+ = mappings.lookup_hir_extern_block (parent_extern_block_id);
rust_assert (block != nullptr);
*result = TypeCheckTopLevelExternItem::Resolve (extern_item, *block);
@@ -115,7 +115,7 @@ query_type (HirId reference, TyTy::BaseType **result)
}
// more?
- location_t possible_locus = mappings->lookup_location (reference);
+ location_t possible_locus = mappings.lookup_location (reference);
rust_debug_loc (possible_locus, "query system failed to resolve: [%u]",
reference);
context->query_completed (reference);
diff --git a/gcc/rust/typecheck/rust-typecheck-context.cc b/gcc/rust/typecheck/rust-typecheck-context.cc
index ab0093a..b4ff6d6 100644
--- a/gcc/rust/typecheck/rust-typecheck-context.cc
+++ b/gcc/rust/typecheck/rust-typecheck-context.cc
@@ -580,7 +580,7 @@ TypeCheckContext::regions_from_generic_args (const HIR::GenericArgs &args) const
void
TypeCheckContext::compute_inference_variables (bool error)
{
- auto mappings = Analysis::Mappings::get ();
+ auto &mappings = Analysis::Mappings::get ();
// default inference variables if possible
iterate ([&] (HirId id, TyTy::BaseType *ty) mutable -> bool {
@@ -591,14 +591,14 @@ TypeCheckContext::compute_inference_variables (bool error)
TyTy::InferType *infer_var = static_cast<TyTy::InferType *> (ty);
TyTy::BaseType *default_type;
- rust_debug_loc (mappings->lookup_location (id),
+ rust_debug_loc (mappings.lookup_location (id),
"trying to default infer-var: %s",
infer_var->as_string ().c_str ());
bool ok = infer_var->default_type (&default_type);
if (!ok)
{
if (error)
- rust_error_at (mappings->lookup_location (id), ErrorCode::E0282,
+ rust_error_at (mappings.lookup_location (id), ErrorCode::E0282,
"type annotations needed");
return true;
}
@@ -609,7 +609,7 @@ TypeCheckContext::compute_inference_variables (bool error)
rust_assert (result);
rust_assert (result->get_kind () != TyTy::TypeKind::ERROR);
result->set_ref (id);
- insert_type (Analysis::NodeMapping (mappings->get_current_crate (), 0, id,
+ insert_type (Analysis::NodeMapping (mappings.get_current_crate (), 0, id,
UNKNOWN_LOCAL_DEFID),
result);
diff --git a/gcc/rust/typecheck/rust-tyty-bounds.cc b/gcc/rust/typecheck/rust-tyty-bounds.cc
index 6e4c345..f1abfa9 100644
--- a/gcc/rust/typecheck/rust-tyty-bounds.cc
+++ b/gcc/rust/typecheck/rust-tyty-bounds.cc
@@ -64,7 +64,7 @@ TypeBoundsProbe::scan ()
{
std::vector<std::pair<HIR::TypePath *, HIR::ImplBlock *>>
possible_trait_paths;
- mappings->iterate_impl_blocks (
+ mappings.iterate_impl_blocks (
[&] (HirId id, HIR::ImplBlock *impl) mutable -> bool {
// we are filtering for trait-impl-blocks
if (!impl->has_trait_ref ())
@@ -153,11 +153,11 @@ void
TypeBoundsProbe::assemble_builtin_candidate (LangItem::Kind lang_item)
{
DefId id;
- bool found_lang_item = mappings->lookup_lang_item (lang_item, &id);
+ bool found_lang_item = mappings.lookup_lang_item (lang_item, &id);
if (!found_lang_item)
return;
- HIR::Item *item = mappings->lookup_defid (id);
+ HIR::Item *item = mappings.lookup_defid (id);
if (item == nullptr)
return;
@@ -167,7 +167,7 @@ TypeBoundsProbe::assemble_builtin_candidate (LangItem::Kind lang_item)
// assemble the reference
TraitReference *trait_ref = TraitResolver::Resolve (*trait);
- trait_references.push_back ({trait_ref, mappings->lookup_builtin_marker ()});
+ trait_references.push_back ({trait_ref, mappings.lookup_builtin_marker ()});
rust_debug ("Added builtin lang_item: %s for %s",
LangItem::ToString (lang_item).c_str (),
@@ -220,8 +220,8 @@ TypeCheckBase::get_predicate_from_bound (HIR::TypePath &type_path,
// we need to make implicit generic args which must be an implicit
// Tuple
- auto crate_num = mappings->get_current_crate ();
- HirId implicit_args_id = mappings->get_next_hir_id ();
+ auto crate_num = mappings.get_current_crate ();
+ HirId implicit_args_id = mappings.get_next_hir_id ();
Analysis::NodeMapping mapping (crate_num,
final_seg->get_mappings ().get_nodeid (),
implicit_args_id, UNKNOWN_LOCAL_DEFID);
@@ -244,7 +244,7 @@ TypeCheckBase::get_predicate_from_bound (HIR::TypePath &type_path,
rust_assert (fn.has_return_type ());
TypeCheckType::Resolve (fn.get_return_type ().get ());
- HIR::TraitItem *trait_item = mappings->lookup_trait_item_lang_item (
+ HIR::TraitItem *trait_item = mappings.lookup_trait_item_lang_item (
LangItem::Kind::FN_ONCE_OUTPUT, final_seg->get_locus ());
std::vector<HIR::GenericArgsBinding> bindings;
diff --git a/gcc/rust/typecheck/rust-tyty-call.cc b/gcc/rust/typecheck/rust-tyty-call.cc
index a28780b..f5d12b8 100644
--- a/gcc/rust/typecheck/rust-tyty-call.cc
+++ b/gcc/rust/typecheck/rust-tyty-call.cc
@@ -157,7 +157,7 @@ TypeCheckCallExpr::visit (FnType &type)
BaseType *param_ty = fnparam.second;
location_t param_locus
= fn_param_pattern == nullptr
- ? mappings->lookup_location (param_ty->get_ref ())
+ ? mappings.lookup_location (param_ty->get_ref ())
: fn_param_pattern->get_locus ();
HirId coercion_side_id = argument->get_mappings ().get_hirid ();
@@ -382,7 +382,7 @@ TypeCheckMethodCallExpr::check (FnType &type)
BaseType *param_ty = fnparam.second;
location_t param_locus
= fn_param_pattern == nullptr
- ? mappings->lookup_location (param_ty->get_ref ())
+ ? mappings.lookup_location (param_ty->get_ref ())
: fn_param_pattern->get_locus ();
auto argument_expr_tyty = argument.get_argument_type ();
diff --git a/gcc/rust/typecheck/rust-tyty-call.h b/gcc/rust/typecheck/rust-tyty-call.h
index 0d3c0c6..9d79552 100644
--- a/gcc/rust/typecheck/rust-tyty-call.h
+++ b/gcc/rust/typecheck/rust-tyty-call.h
@@ -81,7 +81,7 @@ private:
HIR::CallExpr &call;
TyTy::VariantDef &variant;
Resolver::TypeCheckContext *context;
- Analysis::Mappings *mappings;
+ Analysis::Mappings &mappings;
};
class Argument
@@ -131,7 +131,7 @@ protected:
location_t receiver_locus;
TyTy::BaseType *adjusted_self;
Resolver::TypeCheckContext *context;
- Analysis::Mappings *mappings;
+ Analysis::Mappings &mappings;
};
} // namespace TyTy
diff --git a/gcc/rust/typecheck/rust-tyty-cmp.h b/gcc/rust/typecheck/rust-tyty-cmp.h
index 98ff1dc..d455215 100644
--- a/gcc/rust/typecheck/rust-tyty-cmp.h
+++ b/gcc/rust/typecheck/rust-tyty-cmp.h
@@ -62,9 +62,9 @@ public:
if (emit_error_flag)
{
- location_t ref_locus = mappings->lookup_location (type.get_ref ());
+ location_t ref_locus = mappings.lookup_location (type.get_ref ());
location_t base_locus
- = mappings->lookup_location (get_base ()->get_ref ());
+ = mappings.lookup_location (get_base ()->get_ref ());
rich_location r (line_table, ref_locus);
r.add_range (base_locus);
rust_error_at (r, "expected [%s] got [%s]",
@@ -78,9 +78,9 @@ public:
ok = false;
if (emit_error_flag)
{
- location_t ref_locus = mappings->lookup_location (type.get_ref ());
+ location_t ref_locus = mappings.lookup_location (type.get_ref ());
location_t base_locus
- = mappings->lookup_location (get_base ()->get_ref ());
+ = mappings.lookup_location (get_base ()->get_ref ());
rich_location r (line_table, ref_locus);
r.add_range (base_locus);
rust_error_at (r, "expected [%s] got [%s]",
@@ -94,9 +94,9 @@ public:
ok = false;
if (emit_error_flag)
{
- location_t ref_locus = mappings->lookup_location (type.get_ref ());
+ location_t ref_locus = mappings.lookup_location (type.get_ref ());
location_t base_locus
- = mappings->lookup_location (get_base ()->get_ref ());
+ = mappings.lookup_location (get_base ()->get_ref ());
rich_location r (line_table, ref_locus);
r.add_range (base_locus);
rust_error_at (r, "expected [%s] got [%s]",
@@ -110,9 +110,9 @@ public:
ok = false;
if (emit_error_flag)
{
- location_t ref_locus = mappings->lookup_location (type.get_ref ());
+ location_t ref_locus = mappings.lookup_location (type.get_ref ());
location_t base_locus
- = mappings->lookup_location (get_base ()->get_ref ());
+ = mappings.lookup_location (get_base ()->get_ref ());
rich_location r (line_table, ref_locus);
r.add_range (base_locus);
rust_error_at (r, "expected [%s] got [%s]",
@@ -126,9 +126,9 @@ public:
ok = false;
if (emit_error_flag)
{
- location_t ref_locus = mappings->lookup_location (type.get_ref ());
+ location_t ref_locus = mappings.lookup_location (type.get_ref ());
location_t base_locus
- = mappings->lookup_location (get_base ()->get_ref ());
+ = mappings.lookup_location (get_base ()->get_ref ());
rich_location r (line_table, ref_locus);
r.add_range (base_locus);
rust_error_at (r, "expected [%s] got [%s]",
@@ -142,9 +142,9 @@ public:
ok = false;
if (emit_error_flag)
{
- location_t ref_locus = mappings->lookup_location (type.get_ref ());
+ location_t ref_locus = mappings.lookup_location (type.get_ref ());
location_t base_locus
- = mappings->lookup_location (get_base ()->get_ref ());
+ = mappings.lookup_location (get_base ()->get_ref ());
rich_location r (line_table, ref_locus);
r.add_range (base_locus);
rust_error_at (r, "expected [%s] got [%s]",
@@ -158,9 +158,9 @@ public:
ok = false;
if (emit_error_flag)
{
- location_t ref_locus = mappings->lookup_location (type.get_ref ());
+ location_t ref_locus = mappings.lookup_location (type.get_ref ());
location_t base_locus
- = mappings->lookup_location (get_base ()->get_ref ());
+ = mappings.lookup_location (get_base ()->get_ref ());
rich_location r (line_table, ref_locus);
r.add_range (base_locus);
rust_error_at (r, "expected [%s] got [%s]",
@@ -174,9 +174,9 @@ public:
ok = false;
if (emit_error_flag)
{
- location_t ref_locus = mappings->lookup_location (type.get_ref ());
+ location_t ref_locus = mappings.lookup_location (type.get_ref ());
location_t base_locus
- = mappings->lookup_location (get_base ()->get_ref ());
+ = mappings.lookup_location (get_base ()->get_ref ());
rich_location r (line_table, ref_locus);
r.add_range (base_locus);
rust_error_at (r, "expected [%s] got [%s]",
@@ -190,9 +190,9 @@ public:
ok = false;
if (emit_error_flag)
{
- location_t ref_locus = mappings->lookup_location (type.get_ref ());
+ location_t ref_locus = mappings.lookup_location (type.get_ref ());
location_t base_locus
- = mappings->lookup_location (get_base ()->get_ref ());
+ = mappings.lookup_location (get_base ()->get_ref ());
rich_location r (line_table, ref_locus);
r.add_range (base_locus);
rust_error_at (r, "expected [%s] got [%s]",
@@ -206,9 +206,9 @@ public:
ok = false;
if (emit_error_flag)
{
- location_t ref_locus = mappings->lookup_location (type.get_ref ());
+ location_t ref_locus = mappings.lookup_location (type.get_ref ());
location_t base_locus
- = mappings->lookup_location (get_base ()->get_ref ());
+ = mappings.lookup_location (get_base ()->get_ref ());
rich_location r (line_table, ref_locus);
r.add_range (base_locus);
rust_error_at (r, "expected [%s] got [%s]",
@@ -222,9 +222,9 @@ public:
ok = false;
if (emit_error_flag)
{
- location_t ref_locus = mappings->lookup_location (type.get_ref ());
+ location_t ref_locus = mappings.lookup_location (type.get_ref ());
location_t base_locus
- = mappings->lookup_location (get_base ()->get_ref ());
+ = mappings.lookup_location (get_base ()->get_ref ());
rich_location r (line_table, ref_locus);
r.add_range (base_locus);
rust_error_at (r, "expected [%s] got [%s]",
@@ -238,9 +238,9 @@ public:
ok = false;
if (emit_error_flag)
{
- location_t ref_locus = mappings->lookup_location (type.get_ref ());
+ location_t ref_locus = mappings.lookup_location (type.get_ref ());
location_t base_locus
- = mappings->lookup_location (get_base ()->get_ref ());
+ = mappings.lookup_location (get_base ()->get_ref ());
rich_location r (line_table, ref_locus);
r.add_range (base_locus);
rust_error_at (r, "expected [%s] got [%s]",
@@ -254,9 +254,9 @@ public:
ok = false;
if (emit_error_flag)
{
- location_t ref_locus = mappings->lookup_location (type.get_ref ());
+ location_t ref_locus = mappings.lookup_location (type.get_ref ());
location_t base_locus
- = mappings->lookup_location (get_base ()->get_ref ());
+ = mappings.lookup_location (get_base ()->get_ref ());
rich_location r (line_table, ref_locus);
r.add_range (base_locus);
rust_error_at (r, "expected [%s] got [%s]",
@@ -270,9 +270,9 @@ public:
ok = false;
if (emit_error_flag)
{
- location_t ref_locus = mappings->lookup_location (type.get_ref ());
+ location_t ref_locus = mappings.lookup_location (type.get_ref ());
location_t base_locus
- = mappings->lookup_location (get_base ()->get_ref ());
+ = mappings.lookup_location (get_base ()->get_ref ());
rich_location r (line_table, ref_locus);
r.add_range (base_locus);
rust_error_at (r, "expected [%s] got [%s]",
@@ -286,9 +286,9 @@ public:
ok = false;
if (emit_error_flag)
{
- location_t ref_locus = mappings->lookup_location (type.get_ref ());
+ location_t ref_locus = mappings.lookup_location (type.get_ref ());
location_t base_locus
- = mappings->lookup_location (get_base ()->get_ref ());
+ = mappings.lookup_location (get_base ()->get_ref ());
rich_location r (line_table, ref_locus);
r.add_range (base_locus);
rust_error_at (r, "expected [%s] got [%s]",
@@ -302,9 +302,9 @@ public:
ok = false;
if (emit_error_flag)
{
- location_t ref_locus = mappings->lookup_location (type.get_ref ());
+ location_t ref_locus = mappings.lookup_location (type.get_ref ());
location_t base_locus
- = mappings->lookup_location (get_base ()->get_ref ());
+ = mappings.lookup_location (get_base ()->get_ref ());
rich_location r (line_table, ref_locus);
r.add_range (base_locus);
rust_error_at (r, "expected [%s] got [%s]",
@@ -318,9 +318,9 @@ public:
ok = false;
if (emit_error_flag)
{
- location_t ref_locus = mappings->lookup_location (type.get_ref ());
+ location_t ref_locus = mappings.lookup_location (type.get_ref ());
location_t base_locus
- = mappings->lookup_location (get_base ()->get_ref ());
+ = mappings.lookup_location (get_base ()->get_ref ());
rich_location r (line_table, ref_locus);
r.add_range (base_locus);
rust_error_at (r, "expected [%s] got [%s]",
@@ -334,9 +334,9 @@ public:
ok = false;
if (emit_error_flag)
{
- location_t ref_locus = mappings->lookup_location (type.get_ref ());
+ location_t ref_locus = mappings.lookup_location (type.get_ref ());
location_t base_locus
- = mappings->lookup_location (get_base ()->get_ref ());
+ = mappings.lookup_location (get_base ()->get_ref ());
rich_location r (line_table, ref_locus);
r.add_range (base_locus);
rust_error_at (r, "expected [%s] got [%s]",
@@ -350,9 +350,9 @@ public:
ok = false;
if (emit_error_flag)
{
- location_t ref_locus = mappings->lookup_location (type.get_ref ());
+ location_t ref_locus = mappings.lookup_location (type.get_ref ());
location_t base_locus
- = mappings->lookup_location (get_base ()->get_ref ());
+ = mappings.lookup_location (get_base ()->get_ref ());
rich_location r (line_table, ref_locus);
r.add_range (base_locus);
rust_error_at (r, "expected [%s] got [%s]",
@@ -366,9 +366,9 @@ public:
ok = false;
if (emit_error_flag)
{
- location_t ref_locus = mappings->lookup_location (type.get_ref ());
+ location_t ref_locus = mappings.lookup_location (type.get_ref ());
location_t base_locus
- = mappings->lookup_location (get_base ()->get_ref ());
+ = mappings.lookup_location (get_base ()->get_ref ());
rich_location r (line_table, ref_locus);
r.add_range (base_locus);
rust_error_at (r, "expected [%s] got [%s]",
@@ -388,9 +388,9 @@ public:
ok = false;
if (emit_error_flag)
{
- location_t ref_locus = mappings->lookup_location (type.get_ref ());
+ location_t ref_locus = mappings.lookup_location (type.get_ref ());
location_t base_locus
- = mappings->lookup_location (get_base ()->get_ref ());
+ = mappings.lookup_location (get_base ()->get_ref ());
rich_location r (line_table, ref_locus);
r.add_range (base_locus);
rust_error_at (r, "expected [%s] got [%s]",
@@ -404,9 +404,9 @@ public:
ok = false;
if (emit_error_flag)
{
- location_t ref_locus = mappings->lookup_location (type.get_ref ());
+ location_t ref_locus = mappings.lookup_location (type.get_ref ());
location_t base_locus
- = mappings->lookup_location (get_base ()->get_ref ());
+ = mappings.lookup_location (get_base ()->get_ref ());
rich_location r (line_table, ref_locus);
r.add_range (base_locus);
rust_error_at (r, "expected [%s] got [%s]",
@@ -420,9 +420,9 @@ public:
ok = false;
if (emit_error_flag)
{
- location_t ref_locus = mappings->lookup_location (type.get_ref ());
+ location_t ref_locus = mappings.lookup_location (type.get_ref ());
location_t base_locus
- = mappings->lookup_location (get_base ()->get_ref ());
+ = mappings.lookup_location (get_base ()->get_ref ());
rich_location r (line_table, ref_locus);
r.add_range (base_locus);
rust_error_at (r, "expected [%s] got [%s]",
@@ -438,7 +438,7 @@ protected:
emit_error_flag (emit_errors)
{}
- Analysis::Mappings *mappings;
+ Analysis::Mappings &mappings;
Resolver::TypeCheckContext *context;
bool ok;
@@ -1561,7 +1561,7 @@ public:
return;
}
- location_t ref_locus = mappings->lookup_location (type.get_ref ());
+ location_t ref_locus = mappings.lookup_location (type.get_ref ());
ok = base->bounds_compatible (type, ref_locus, false);
}
diff --git a/gcc/rust/typecheck/rust-tyty-subst.cc b/gcc/rust/typecheck/rust-tyty-subst.cc
index 8c80155..48dcd95 100644
--- a/gcc/rust/typecheck/rust-tyty-subst.cc
+++ b/gcc/rust/typecheck/rust-tyty-subst.cc
@@ -157,10 +157,10 @@ SubstitutionParamMapping::override_context ()
if (!param->can_resolve ())
return;
- auto mappings = Analysis::Mappings::get ();
+ auto &mappings = Analysis::Mappings::get ();
auto context = Resolver::TypeCheckContext::get ();
- context->insert_type (Analysis::NodeMapping (mappings->get_current_crate (),
+ context->insert_type (Analysis::NodeMapping (mappings.get_current_crate (),
UNKNOWN_NODEID,
param->get_ref (),
UNKNOWN_LOCAL_DEFID),
@@ -940,7 +940,7 @@ SubstitutionRef::monomorphize ()
if (associated == nullptr && ambigious)
{
// go for the first one? or error out?
- auto &mappings = *Analysis::Mappings::get ();
+ auto &mappings = Analysis::Mappings::get ();
const auto &type_param = subst.get_generic_param ();
const auto *trait_ref = bound.get ();
diff --git a/gcc/rust/typecheck/rust-tyty-util.cc b/gcc/rust/typecheck/rust-tyty-util.cc
index 37c2d8b..e18246d 100644
--- a/gcc/rust/typecheck/rust-tyty-util.cc
+++ b/gcc/rust/typecheck/rust-tyty-util.cc
@@ -44,18 +44,18 @@ TyVar::get_tyty () const
TyVar
TyVar::get_implicit_infer_var (location_t locus)
{
- auto mappings = Analysis::Mappings::get ();
+ auto &mappings = Analysis::Mappings::get ();
auto context = Resolver::TypeCheckContext::get ();
- InferType *infer = new InferType (mappings->get_next_hir_id (),
+ InferType *infer = new InferType (mappings.get_next_hir_id (),
InferType::InferTypeKind::GENERAL,
InferType::TypeHint::Default (), locus);
- context->insert_type (Analysis::NodeMapping (mappings->get_current_crate (),
+ context->insert_type (Analysis::NodeMapping (mappings.get_current_crate (),
UNKNOWN_NODEID,
infer->get_ref (),
UNKNOWN_LOCAL_DEFID),
infer);
- mappings->insert_location (infer->get_ref (), locus);
+ mappings.insert_location (infer->get_ref (), locus);
return TyVar (infer->get_ref ());
}
@@ -87,15 +87,15 @@ TyVar::clone () const
TyVar
TyVar::monomorphized_clone () const
{
- auto mappings = Analysis::Mappings::get ();
+ auto &mappings = Analysis::Mappings::get ();
auto context = Resolver::TypeCheckContext::get ();
// this needs a new hirid
TyTy::BaseType *c = get_tyty ()->monomorphized_clone ();
- c->set_ref (mappings->get_next_hir_id ());
+ c->set_ref (mappings.get_next_hir_id ());
// insert it
- context->insert_type (Analysis::NodeMapping (mappings->get_current_crate (),
+ context->insert_type (Analysis::NodeMapping (mappings.get_current_crate (),
UNKNOWN_NODEID, c->get_ref (),
UNKNOWN_LOCAL_DEFID),
c);
@@ -109,8 +109,8 @@ TyWithLocation::TyWithLocation (BaseType *ty, location_t locus)
TyWithLocation::TyWithLocation (BaseType *ty) : ty (ty)
{
- auto mappings = Analysis::Mappings::get ();
- locus = mappings->lookup_location (ty->get_ref ());
+ auto &mappings = Analysis::Mappings::get ();
+ locus = mappings.lookup_location (ty->get_ref ());
}
} // namespace TyTy
diff --git a/gcc/rust/typecheck/rust-tyty.cc b/gcc/rust/typecheck/rust-tyty.cc
index 51960ef..8d3d377 100644
--- a/gcc/rust/typecheck/rust-tyty.cc
+++ b/gcc/rust/typecheck/rust-tyty.cc
@@ -350,9 +350,9 @@ BaseType::satisfies_bound (const TypeBoundPredicate &predicate,
if (emit_error)
{
rich_location r (line_table,
- mappings->lookup_location (get_ref ()));
+ mappings.lookup_location (get_ref ()));
r.add_range (predicate.get_locus ());
- r.add_range (mappings->lookup_location (i.get_hirid ()));
+ r.add_range (mappings.lookup_location (i.get_hirid ()));
std::string rich_msg
= "expected " + bound_ty->destructure ()->get_name ()
@@ -960,20 +960,20 @@ InferType::clone () const
// chain of references accordingly to ensure we don't loose the ability to
// update the inference variables when we solve the type
- auto mappings = Analysis::Mappings::get ();
+ auto &mappings = Analysis::Mappings::get ();
auto context = Resolver::TypeCheckContext::get ();
InferType *clone
- = new InferType (mappings->get_next_hir_id (), get_infer_kind (),
+ = new InferType (mappings.get_next_hir_id (), get_infer_kind (),
default_hint, get_ident ().locus, get_combined_refs ());
- context->insert_type (Analysis::NodeMapping (mappings->get_current_crate (),
+ context->insert_type (Analysis::NodeMapping (mappings.get_current_crate (),
UNKNOWN_NODEID,
clone->get_ref (),
UNKNOWN_LOCAL_DEFID),
clone);
- mappings->insert_location (clone->get_ref (),
- mappings->lookup_location (get_ref ()));
+ mappings.insert_location (clone->get_ref (),
+ mappings.lookup_location (get_ref ()));
// setup the chain to reference this
clone->append_reference (get_ref ());
@@ -1702,7 +1702,7 @@ ADTType *
ADTType::handle_substitions (SubstitutionArgumentMappings &subst_mappings)
{
auto adt = clone ()->as<ADTType> ();
- adt->set_ty_ref (mappings->get_next_hir_id ());
+ adt->set_ty_ref (mappings.get_next_hir_id ());
adt->used_arguments = subst_mappings;
for (auto &sub : adt->get_substs ())
@@ -1851,11 +1851,11 @@ TupleType::clone () const
TupleType *
TupleType::handle_substitions (SubstitutionArgumentMappings &mappings)
{
- auto mappings_table = Analysis::Mappings::get ();
+ auto &mappings_table = Analysis::Mappings::get ();
auto tuple = clone ()->as<TupleType> ();
- tuple->set_ref (mappings_table->get_next_hir_id ());
- tuple->set_ty_ref (mappings_table->get_next_hir_id ());
+ tuple->set_ref (mappings_table.get_next_hir_id ());
+ tuple->set_ty_ref (mappings_table.get_next_hir_id ());
for (size_t i = 0; i < tuple->fields.size (); i++)
{
@@ -1974,7 +1974,7 @@ FnType *
FnType::handle_substitions (SubstitutionArgumentMappings &subst_mappings)
{
FnType *fn = static_cast<FnType *> (clone ());
- fn->set_ty_ref (mappings->get_next_hir_id ());
+ fn->set_ty_ref (mappings.get_next_hir_id ());
fn->used_arguments = subst_mappings;
for (auto &sub : fn->get_substs ())
@@ -2220,16 +2220,16 @@ ClosureType::setup_fn_once_output () const
DefId trait_id = UNKNOWN_DEFID;
bool trait_lang_item_defined
- = mappings->lookup_lang_item (fn_once_lang_item, &trait_id);
+ = mappings.lookup_lang_item (fn_once_lang_item, &trait_id);
rust_assert (trait_lang_item_defined);
DefId trait_item_id = UNKNOWN_DEFID;
bool trait_item_lang_item_defined
- = mappings->lookup_lang_item (fn_once_output_lang_item, &trait_item_id);
+ = mappings.lookup_lang_item (fn_once_output_lang_item, &trait_item_id);
rust_assert (trait_item_lang_item_defined);
// resolve to the trait
- HIR::Item *item = mappings->lookup_defid (trait_id);
+ HIR::Item *item = mappings.lookup_defid (trait_id);
rust_assert (item->get_item_kind () == HIR::Item::ItemKind::Trait);
HIR::Trait *trait = static_cast<HIR::Trait *> (item);
@@ -2238,8 +2238,7 @@ ClosureType::setup_fn_once_output () const
rust_assert (!trait_ref->is_error ());
// resolve to trait item
- HIR::TraitItem *trait_item
- = mappings->lookup_trait_item_defid (trait_item_id);
+ HIR::TraitItem *trait_item = mappings.lookup_trait_item_defid (trait_item_id);
rust_assert (trait_item != nullptr);
rust_assert (trait_item->get_item_kind ()
== HIR::TraitItem::TraitItemKind::TYPE);
@@ -2317,10 +2316,10 @@ ArrayType::clone () const
ArrayType *
ArrayType::handle_substitions (SubstitutionArgumentMappings &mappings)
{
- auto mappings_table = Analysis::Mappings::get ();
+ auto &mappings_table = Analysis::Mappings::get ();
ArrayType *ref = static_cast<ArrayType *> (clone ());
- ref->set_ty_ref (mappings_table->get_next_hir_id ());
+ ref->set_ty_ref (mappings_table.get_next_hir_id ());
// might be &T or &ADT so this needs to be recursive
auto base = ref->get_element_type ();
@@ -2391,10 +2390,10 @@ SliceType::clone () const
SliceType *
SliceType::handle_substitions (SubstitutionArgumentMappings &mappings)
{
- auto mappings_table = Analysis::Mappings::get ();
+ auto &mappings_table = Analysis::Mappings::get ();
SliceType *ref = static_cast<SliceType *> (clone ());
- ref->set_ty_ref (mappings_table->get_next_hir_id ());
+ ref->set_ty_ref (mappings_table.get_next_hir_id ());
// might be &T or &ADT so this needs to be recursive
auto base = ref->get_element_type ();
@@ -3005,10 +3004,10 @@ ReferenceType::clone () const
ReferenceType *
ReferenceType::handle_substitions (SubstitutionArgumentMappings &mappings)
{
- auto mappings_table = Analysis::Mappings::get ();
+ auto &mappings_table = Analysis::Mappings::get ();
ReferenceType *ref = static_cast<ReferenceType *> (clone ());
- ref->set_ty_ref (mappings_table->get_next_hir_id ());
+ ref->set_ty_ref (mappings_table.get_next_hir_id ());
// might be &T or &ADT so this needs to be recursive
auto base = ref->get_base ();
@@ -3167,10 +3166,10 @@ PointerType::clone () const
PointerType *
PointerType::handle_substitions (SubstitutionArgumentMappings &mappings)
{
- auto mappings_table = Analysis::Mappings::get ();
+ auto &mappings_table = Analysis::Mappings::get ();
PointerType *ref = static_cast<PointerType *> (clone ());
- ref->set_ty_ref (mappings_table->get_next_hir_id ());
+ ref->set_ty_ref (mappings_table.get_next_hir_id ());
// might be &T or &ADT so this needs to be recursive
auto base = ref->get_base ();
@@ -3339,7 +3338,7 @@ ParamType::handle_substitions (SubstitutionArgumentMappings &subst_mappings)
}
// this is the new subst that this needs to pass
- p->set_ref (mappings->get_next_hir_id ());
+ p->set_ref (mappings.get_next_hir_id ());
p->set_ty_ref (arg.get_tyty ()->get_ref ());
return p;
@@ -3668,7 +3667,7 @@ ProjectionType::handle_substitions (
// }
ProjectionType *projection = static_cast<ProjectionType *> (clone ());
- projection->set_ty_ref (mappings->get_next_hir_id ());
+ projection->set_ty_ref (mappings.get_next_hir_id ());
projection->used_arguments = subst_mappings;
auto context = Resolver::TypeCheckContext::get ();
diff --git a/gcc/rust/typecheck/rust-tyty.h b/gcc/rust/typecheck/rust-tyty.h
index 27a4aa2..3222e3e 100644
--- a/gcc/rust/typecheck/rust-tyty.h
+++ b/gcc/rust/typecheck/rust-tyty.h
@@ -248,7 +248,7 @@ protected:
std::set<HirId> combined;
RustIdent ident;
- Analysis::Mappings *mappings;
+ Analysis::Mappings &mappings;
};
/** Unified interface for all function-like types. */
diff --git a/gcc/rust/typecheck/rust-unify.cc b/gcc/rust/typecheck/rust-unify.cc
index 7d1042d..8163d55 100644
--- a/gcc/rust/typecheck/rust-unify.cc
+++ b/gcc/rust/typecheck/rust-unify.cc
@@ -28,7 +28,7 @@ UnifyRules::UnifyRules (TyTy::TyWithLocation lhs, TyTy::TyWithLocation rhs,
std::vector<InferenceSite> &infers)
: lhs (lhs), rhs (rhs), locus (locus), commit_flag (commit_flag),
emit_error (emit_error), infer_flag (infer), commits (commits),
- infers (infers), mappings (*Analysis::Mappings::get ()),
+ infers (infers), mappings (Analysis::Mappings::get ()),
context (*TypeCheckContext::get ())
{}
@@ -70,7 +70,7 @@ UnifyRules::commit (TyTy::BaseType *base, TyTy::BaseType *other,
TyTy::BaseType *resolved)
{
TypeCheckContext &context = *TypeCheckContext::get ();
- Analysis::Mappings &mappings = *Analysis::Mappings::get ();
+ Analysis::Mappings &mappings = Analysis::Mappings::get ();
TyTy::BaseType *b = base->destructure ();
TyTy::BaseType *o = other->destructure ();