diff options
author | Owen Avery <powerboat9.gamer@gmail.com> | 2023-07-10 11:42:12 -0400 |
---|---|---|
committer | Arthur Cohen <arthur.cohen@embecosm.com> | 2024-01-16 18:49:36 +0100 |
commit | eb241224a9f63afc92dcd744d74de8a8ec007f95 (patch) | |
tree | da54fd6f7d6dceb543e4010906fb6b604907c928 /gcc | |
parent | 75763b4c50e6d1ffb8cae6d34d5ffd40add1f8d4 (diff) | |
download | gcc-eb241224a9f63afc92dcd744d74de8a8ec007f95.zip gcc-eb241224a9f63afc92dcd744d74de8a8ec007f95.tar.gz gcc-eb241224a9f63afc92dcd744d74de8a8ec007f95.tar.bz2 |
gccrs: Change class RichLocation into typedef
gcc/rust/ChangeLog:
* rust-linemap.cc
(RichLocation::RichLocation): Remove.
(RichLocation::~RichLocation): Remove.
(RichLocation::add_range): Remove.
(RichLocation::add_fixit_insert_before): Remove.
(RichLocation::add_fixit_insert_after): Remove.
* rust-location.h
(class RichLocation): Remove.
* rust-diagnostics.cc
(rust_be_error_at): Remove RichLocation::get invocation.
* expand/rust-macro-expand.cc: Fix RichLocation constructor.
* hir/rust-ast-lower-base.cc: Likewise.
* resolve/rust-ast-resolve-implitem.h: Likewise.
* resolve/rust-ast-resolve-stmt.h: Likewise.
* resolve/rust-ast-resolve-toplevel.h: Likewise.
* rust-session-manager.cc: Likewise.
* typecheck/rust-casts.cc: Likewise.
* typecheck/rust-coercion.cc: Likewise.
* typecheck/rust-hir-inherent-impl-overlap.h: Likewise.
* typecheck/rust-hir-path-probe.h: Likewise.
* typecheck/rust-hir-trait-reference.cc: Likewise.
* typecheck/rust-hir-type-check-expr.cc: Likewise.
* typecheck/rust-hir-type-check-implitem.cc: Likewise.
* typecheck/rust-hir-type-check-item.cc: Likewise.
* typecheck/rust-hir-type-check-pattern.cc: Likewise.
* typecheck/rust-tyty-cmp.h: Likewise.
* typecheck/rust-tyty-subst.cc: Likewise.
* typecheck/rust-tyty.cc: Likewise.
* typecheck/rust-unify.cc: Likewise.
Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
Diffstat (limited to 'gcc')
22 files changed, 97 insertions, 156 deletions
diff --git a/gcc/rust/expand/rust-macro-expand.cc b/gcc/rust/expand/rust-macro-expand.cc index abe8f20..c908e3b 100644 --- a/gcc/rust/expand/rust-macro-expand.cc +++ b/gcc/rust/expand/rust-macro-expand.cc @@ -104,7 +104,7 @@ MacroExpander::expand_decl_macro (Location invoc_locus, if (matched_rule == nullptr) { - RichLocation r (invoc_locus); + RichLocation r (line_table, invoc_locus); r.add_range (rules_def.get_locus ()); rust_error_at (r, "Failed to match any rule within macro"); return AST::Fragment::create_error (); diff --git a/gcc/rust/hir/rust-ast-lower-base.cc b/gcc/rust/hir/rust-ast-lower-base.cc index 5a1ce74..413a772 100644 --- a/gcc/rust/hir/rust-ast-lower-base.cc +++ b/gcc/rust/hir/rust-ast-lower-base.cc @@ -679,7 +679,7 @@ struct_field_name_exists (std::vector<HIR::StructField> &fields, new_field.get_field_name ().as_string ()) == 0) { - RichLocation r (new_field.get_locus ()); + RichLocation r (line_table, new_field.get_locus ()); r.add_range (field.get_locus ()); rust_error_at (r, ErrorCode ("E0124"), "field %qs is already declared", diff --git a/gcc/rust/resolve/rust-ast-resolve-implitem.h b/gcc/rust/resolve/rust-ast-resolve-implitem.h index 126fc29..f8af57a 100644 --- a/gcc/rust/resolve/rust-ast-resolve-implitem.h +++ b/gcc/rust/resolve/rust-ast-resolve-implitem.h @@ -58,7 +58,7 @@ public: resolver->get_type_scope ().insert ( path, type.get_node_id (), type.get_locus (), false, Rib::ItemType::Type, [&] (const CanonicalPath &, NodeId, Location locus) -> void { - RichLocation r (type.get_locus ()); + RichLocation r (line_table, type.get_locus ()); r.add_range (locus); rust_error_at (r, "redefined multiple times"); }); @@ -74,7 +74,7 @@ public: path, constant.get_node_id (), constant.get_locus (), false, Rib::ItemType::Const, [&] (const CanonicalPath &, NodeId, Location locus) -> void { - RichLocation r (constant.get_locus ()); + RichLocation r (line_table, constant.get_locus ()); r.add_range (locus); rust_error_at (r, "redefined multiple times"); }); @@ -91,7 +91,7 @@ public: path, function.get_node_id (), function.get_locus (), false, Rib::ItemType::Function, [&] (const CanonicalPath &, NodeId, Location locus) -> void { - RichLocation r (function.get_locus ()); + RichLocation r (line_table, function.get_locus ()); r.add_range (locus); rust_error_at (r, "redefined multiple times"); }); @@ -107,7 +107,7 @@ public: path, method.get_node_id (), method.get_locus (), false, Rib::ItemType::Function, [&] (const CanonicalPath &, NodeId, Location locus) -> void { - RichLocation r (method.get_locus ()); + RichLocation r (line_table, method.get_locus ()); r.add_range (locus); rust_error_at (r, "redefined multiple times"); }); @@ -147,7 +147,7 @@ public: path, function.get_node_id (), function.get_locus (), false, Rib::ItemType::Function, [&] (const CanonicalPath &, NodeId, Location locus) -> void { - RichLocation r (function.get_locus ()); + RichLocation r (line_table, function.get_locus ()); r.add_range (locus); rust_error_at (r, "redefined multiple times"); }); @@ -167,7 +167,7 @@ public: path, method.get_node_id (), method.get_locus (), false, Rib::ItemType::Function, [&] (const CanonicalPath &, NodeId, Location locus) -> void { - RichLocation r (method.get_locus ()); + RichLocation r (line_table, method.get_locus ()); r.add_range (locus); rust_error_at (r, "redefined multiple times"); }); @@ -187,7 +187,7 @@ public: path, constant.get_node_id (), constant.get_locus (), false, Rib::ItemType::Const, [&] (const CanonicalPath &, NodeId, Location locus) -> void { - RichLocation r (constant.get_locus ()); + RichLocation r (line_table, constant.get_locus ()); r.add_range (locus); rust_error_at (r, "redefined multiple times"); }); @@ -205,7 +205,7 @@ public: resolver->get_type_scope ().insert ( path, type.get_node_id (), type.get_locus (), false, Rib::ItemType::Type, [&] (const CanonicalPath &, NodeId, Location locus) -> void { - RichLocation r (type.get_locus ()); + RichLocation r (line_table, type.get_locus ()); r.add_range (locus); rust_error_at (r, "redefined multiple times"); }); @@ -245,7 +245,7 @@ public: path, function.get_node_id (), function.get_locus (), false, Rib::ItemType::Function, [&] (const CanonicalPath &, NodeId, Location locus) -> void { - RichLocation r (function.get_locus ()); + RichLocation r (line_table, function.get_locus ()); r.add_range (locus); rust_error_at (r, "redefined multiple times"); }); @@ -264,7 +264,7 @@ public: path, item.get_node_id (), item.get_locus (), false, Rib::ItemType::Static, [&] (const CanonicalPath &, NodeId, Location locus) -> void { - RichLocation r (item.get_locus ()); + RichLocation r (line_table, item.get_locus ()); r.add_range (locus); rust_error_at (r, "redefined multiple times"); }); diff --git a/gcc/rust/resolve/rust-ast-resolve-stmt.h b/gcc/rust/resolve/rust-ast-resolve-stmt.h index 5c33712..4ba4425 100644 --- a/gcc/rust/resolve/rust-ast-resolve-stmt.h +++ b/gcc/rust/resolve/rust-ast-resolve-stmt.h @@ -60,7 +60,7 @@ public: path, constant.get_node_id (), constant.get_locus (), false, Rib::ItemType::Const, [&] (const CanonicalPath &, NodeId, Location locus) -> void { - RichLocation r (constant.get_locus ()); + RichLocation r (line_table, constant.get_locus ()); r.add_range (locus); rust_error_at (r, "redefined multiple times"); }); @@ -95,7 +95,7 @@ public: path, struct_decl.get_node_id (), struct_decl.get_locus (), false, Rib::ItemType::Type, [&] (const CanonicalPath &, NodeId, Location locus) -> void { - RichLocation r (struct_decl.get_locus ()); + RichLocation r (line_table, struct_decl.get_locus ()); r.add_range (locus); rust_error_at (r, "redefined multiple times"); }); @@ -128,7 +128,7 @@ public: path, enum_decl.get_node_id (), enum_decl.get_locus (), false, Rib::ItemType::Type, [&] (const CanonicalPath &, NodeId, Location locus) -> void { - RichLocation r (enum_decl.get_locus ()); + RichLocation r (line_table, enum_decl.get_locus ()); r.add_range (locus); rust_error_at (r, "redefined multiple times"); }); @@ -160,7 +160,7 @@ public: resolver->get_type_scope ().insert ( path, item.get_node_id (), item.get_locus (), false, Rib::ItemType::Type, [&] (const CanonicalPath &, NodeId, Location locus) -> void { - RichLocation r (item.get_locus ()); + RichLocation r (line_table, item.get_locus ()); r.add_range (locus); rust_error_at (r, "redefined multiple times"); }); @@ -180,7 +180,7 @@ public: resolver->get_type_scope ().insert ( path, item.get_node_id (), item.get_locus (), false, Rib::ItemType::Type, [&] (const CanonicalPath &, NodeId, Location locus) -> void { - RichLocation r (item.get_locus ()); + RichLocation r (line_table, item.get_locus ()); r.add_range (locus); rust_error_at (r, "redefined multiple times"); }); @@ -206,7 +206,7 @@ public: resolver->get_type_scope ().insert ( path, item.get_node_id (), item.get_locus (), false, Rib::ItemType::Type, [&] (const CanonicalPath &, NodeId, Location locus) -> void { - RichLocation r (item.get_locus ()); + RichLocation r (line_table, item.get_locus ()); r.add_range (locus); rust_error_at (r, "redefined multiple times"); }); @@ -232,7 +232,7 @@ public: resolver->get_type_scope ().insert ( path, item.get_node_id (), item.get_locus (), false, Rib::ItemType::Type, [&] (const CanonicalPath &, NodeId, Location locus) -> void { - RichLocation r (item.get_locus ()); + RichLocation r (line_table, item.get_locus ()); r.add_range (locus); rust_error_at (r, "redefined multiple times"); }); @@ -253,7 +253,7 @@ public: path, struct_decl.get_node_id (), struct_decl.get_locus (), false, Rib::ItemType::Type, [&] (const CanonicalPath &, NodeId, Location locus) -> void { - RichLocation r (struct_decl.get_locus ()); + RichLocation r (line_table, struct_decl.get_locus ()); r.add_range (locus); rust_error_at (r, "redefined multiple times"); }); @@ -291,7 +291,7 @@ public: path, union_decl.get_node_id (), union_decl.get_locus (), false, Rib::ItemType::Type, [&] (const CanonicalPath &, NodeId, Location locus) -> void { - RichLocation r (union_decl.get_locus ()); + RichLocation r (line_table, union_decl.get_locus ()); r.add_range (locus); rust_error_at (r, "redefined multiple times"); }); @@ -327,7 +327,7 @@ public: path, function.get_node_id (), function.get_locus (), false, Rib::ItemType::Function, [&] (const CanonicalPath &, NodeId, Location locus) -> void { - RichLocation r (function.get_locus ()); + RichLocation r (line_table, function.get_locus ()); r.add_range (locus); rust_error_at (r, "redefined multiple times"); }); diff --git a/gcc/rust/resolve/rust-ast-resolve-toplevel.h b/gcc/rust/resolve/rust-ast-resolve-toplevel.h index bd918df..d72f4c9 100644 --- a/gcc/rust/resolve/rust-ast-resolve-toplevel.h +++ b/gcc/rust/resolve/rust-ast-resolve-toplevel.h @@ -56,7 +56,7 @@ public: path, module.get_node_id (), module.get_locus (), false, Rib::ItemType::Module, [&] (const CanonicalPath &, NodeId, Location locus) -> void { - RichLocation r (module.get_locus ()); + RichLocation r (line_table, module.get_locus ()); r.add_range (locus); rust_error_at (r, "redefined multiple times"); }); @@ -86,7 +86,7 @@ public: path, alias.get_node_id (), alias.get_locus (), false, Rib::ItemType::Type, [&] (const CanonicalPath &, NodeId, Location locus) -> void { - RichLocation r (alias.get_locus ()); + RichLocation r (line_table, alias.get_locus ()); r.add_range (locus); rust_error_at (r, "redefined multiple times"); }); @@ -108,7 +108,7 @@ public: path, struct_decl.get_node_id (), struct_decl.get_locus (), false, Rib::ItemType::Type, [&] (const CanonicalPath &, NodeId, Location locus) -> void { - RichLocation r (struct_decl.get_locus ()); + RichLocation r (line_table, struct_decl.get_locus ()); r.add_range (locus); rust_error_at (r, "redefined multiple times"); }); @@ -130,7 +130,7 @@ public: path, enum_decl.get_node_id (), enum_decl.get_locus (), false, Rib::ItemType::Type, [&] (const CanonicalPath &, NodeId, Location locus) -> void { - RichLocation r (enum_decl.get_locus ()); + RichLocation r (line_table, enum_decl.get_locus ()); r.add_range (locus); rust_error_at (r, "redefined multiple times"); }); @@ -156,7 +156,7 @@ public: resolver->get_type_scope ().insert ( path, item.get_node_id (), item.get_locus (), false, Rib::ItemType::Type, [&] (const CanonicalPath &, NodeId, Location locus) -> void { - RichLocation r (item.get_locus ()); + RichLocation r (line_table, item.get_locus ()); r.add_range (locus); rust_error_at (r, "redefined multiple times"); }); @@ -178,7 +178,7 @@ public: resolver->get_type_scope ().insert ( path, item.get_node_id (), item.get_locus (), false, Rib::ItemType::Type, [&] (const CanonicalPath &, NodeId, Location locus) -> void { - RichLocation r (item.get_locus ()); + RichLocation r (line_table, item.get_locus ()); r.add_range (locus); rust_error_at (r, "redefined multiple times"); }); @@ -200,7 +200,7 @@ public: resolver->get_type_scope ().insert ( path, item.get_node_id (), item.get_locus (), false, Rib::ItemType::Type, [&] (const CanonicalPath &, NodeId, Location locus) -> void { - RichLocation r (item.get_locus ()); + RichLocation r (line_table, item.get_locus ()); r.add_range (locus); rust_error_at (r, "redefined multiple times"); }); @@ -222,7 +222,7 @@ public: resolver->get_type_scope ().insert ( path, item.get_node_id (), item.get_locus (), false, Rib::ItemType::Type, [&] (const CanonicalPath &, NodeId, Location locus) -> void { - RichLocation r (item.get_locus ()); + RichLocation r (line_table, item.get_locus ()); r.add_range (locus); rust_error_at (r, "redefined multiple times"); }); @@ -246,7 +246,7 @@ public: path, struct_decl.get_node_id (), struct_decl.get_locus (), false, Rib::ItemType::Type, [&] (const CanonicalPath &, NodeId, Location locus) -> void { - RichLocation r (struct_decl.get_locus ()); + RichLocation r (line_table, struct_decl.get_locus ()); r.add_range (locus); rust_error_at (r, "redefined multiple times"); }); @@ -268,7 +268,7 @@ public: path, union_decl.get_node_id (), union_decl.get_locus (), false, Rib::ItemType::Type, [&] (const CanonicalPath &, NodeId, Location locus) -> void { - RichLocation r (union_decl.get_locus ()); + RichLocation r (line_table, union_decl.get_locus ()); r.add_range (locus); rust_error_at (r, "redefined multiple times"); }); @@ -288,7 +288,7 @@ public: resolver->get_name_scope ().insert ( path, var.get_node_id (), var.get_locus (), false, Rib::ItemType::Static, [&] (const CanonicalPath &, NodeId, Location locus) -> void { - RichLocation r (var.get_locus ()); + RichLocation r (line_table, var.get_locus ()); r.add_range (locus); rust_error_at (r, "redefined multiple times"); }); @@ -309,7 +309,7 @@ public: path, constant.get_node_id (), constant.get_locus (), false, Rib::ItemType::Const, [&] (const CanonicalPath &, NodeId, Location locus) -> void { - RichLocation r (constant.get_locus ()); + RichLocation r (line_table, constant.get_locus ()); r.add_range (locus); rust_error_at (r, "redefined multiple times"); }); @@ -331,7 +331,7 @@ public: path, function.get_node_id (), function.get_locus (), false, Rib::ItemType::Function, [&] (const CanonicalPath &, NodeId, Location locus) -> void { - RichLocation r (function.get_locus ()); + RichLocation r (line_table, function.get_locus ()); r.add_range (locus); rust_error_at (r, "redefined multiple times"); }); @@ -375,7 +375,7 @@ public: impl_prefix, impl_block.get_node_id (), impl_block.get_locus (), false, Rib::ItemType::TraitImpl, [&] (const CanonicalPath &, NodeId, Location locus) -> void { - RichLocation r (impl_block.get_locus ()); + RichLocation r (line_table, impl_block.get_locus ()); r.add_range (locus); rust_error_at (r, "redefined multiple times"); }); @@ -395,7 +395,7 @@ public: path, trait.get_node_id (), trait.get_locus (), false, Rib::ItemType::Trait, [&] (const CanonicalPath &, NodeId, Location locus) -> void { - RichLocation r (trait.get_locus ()); + RichLocation r (line_table, trait.get_locus ()); r.add_range (locus); rust_error_at (r, "redefined multiple times"); }); @@ -471,7 +471,7 @@ public: decl, resolved_crate, extern_crate.get_locus (), false, Rib::ItemType::ExternCrate, [&] (const CanonicalPath &, NodeId, Location locus) -> void { - RichLocation r (extern_crate.get_locus ()); + RichLocation r (line_table, extern_crate.get_locus ()); r.add_range (locus); rust_error_at (r, "redefined multiple times"); }); diff --git a/gcc/rust/rust-diagnostics.cc b/gcc/rust/rust-diagnostics.cc index 113a128..0f9eb79 100644 --- a/gcc/rust/rust-diagnostics.cc +++ b/gcc/rust/rust-diagnostics.cc @@ -239,7 +239,7 @@ rust_be_error_at (const RichLocation &location, const ErrorCode code, const std::string &errmsg) { /* TODO: 'error_at' would like a non-'const' 'rich_location *'. */ - rich_location &gcc_loc = const_cast<rich_location &> (location.get ()); + rich_location &gcc_loc = const_cast<rich_location &> (location); diagnostic_metadata m; rust_error_code_rule rule (code); m.add_rule (rule); @@ -311,7 +311,7 @@ void rust_be_error_at (const RichLocation &location, const std::string &errmsg) { /* TODO: 'error_at' would like a non-'const' 'rich_location *'. */ - rich_location &gcc_loc = const_cast<rich_location &> (location.get ()); + rich_location &gcc_loc = const_cast<rich_location &> (location); error_at (&gcc_loc, "%s", errmsg.c_str ()); } diff --git a/gcc/rust/rust-linemap.cc b/gcc/rust/rust-linemap.cc index 6caa494..627f904 100644 --- a/gcc/rust/rust-linemap.cc +++ b/gcc/rust/rust-linemap.cc @@ -82,43 +82,3 @@ rust_get_linemap () { return new Linemap; } - -RichLocation::RichLocation (Location root) : gcc_rich_loc (line_table, root) -{ - /*rich_location (line_maps *set, location_t loc, - const range_label *label = NULL);*/ -} - -RichLocation::~RichLocation () {} - -void -RichLocation::add_range (Location loc) -{ - gcc_rich_loc.add_range (loc); -} - -void -RichLocation::add_fixit_insert_before (const std::string &new_parent) -{ - gcc_rich_loc.add_fixit_insert_before (new_parent.c_str ()); -} - -void -RichLocation::add_fixit_insert_before (Location where, - const std::string &new_parent) -{ - gcc_rich_loc.add_fixit_insert_before (where, new_parent.c_str ()); -} - -void -RichLocation::add_fixit_insert_after (const std::string &new_parent) -{ - gcc_rich_loc.add_fixit_insert_after (new_parent.c_str ()); -} - -void -RichLocation::add_fixit_insert_after (Location where, - const std::string &new_parent) -{ - gcc_rich_loc.add_fixit_insert_after (where, new_parent.c_str ()); -} diff --git a/gcc/rust/rust-location.h b/gcc/rust/rust-location.h index 1944bb7..ae38b2b 100644 --- a/gcc/rust/rust-location.h +++ b/gcc/rust/rust-location.h @@ -31,26 +31,6 @@ typedef location_t Location; -class RichLocation -{ -public: - RichLocation (Location root); - ~RichLocation (); - - void add_range (Location loc); - - void add_fixit_insert_before (const std::string &new_parent); - - void add_fixit_insert_before (Location where, const std::string &new_parent); - - void add_fixit_insert_after (const std::string &new_parent); - - void add_fixit_insert_after (Location where, const std::string &new_parent); - - const rich_location &get () const { return gcc_rich_loc; } - -private: - rich_location gcc_rich_loc; -}; +typedef rich_location RichLocation; #endif // !defined(RUST_LOCATION_H) diff --git a/gcc/rust/rust-session-manager.cc b/gcc/rust/rust-session-manager.cc index fb856c6..6de15655 100644 --- a/gcc/rust/rust-session-manager.cc +++ b/gcc/rust/rust-session-manager.cc @@ -882,7 +882,7 @@ Session::expansion (AST::Crate &crate) rust_assert (last_def && last_invoc); - RichLocation range (last_invoc->get_locus ()); + RichLocation range (line_table, last_invoc->get_locus ()); range.add_range (last_def->get_locus ()); rust_error_at (range, "reached recursion limit"); diff --git a/gcc/rust/typecheck/rust-casts.cc b/gcc/rust/typecheck/rust-casts.cc index 86c1b5f..d648513 100644 --- a/gcc/rust/typecheck/rust-casts.cc +++ b/gcc/rust/typecheck/rust-casts.cc @@ -301,7 +301,7 @@ void TypeCastRules::emit_cast_error () const { // error[E0604] - RichLocation r (locus); + RichLocation r (line_table, locus); r.add_range (from.get_locus ()); r.add_range (to.get_locus ()); rust_error_at (r, ErrorCode ("E0054"), "invalid cast %<%s%> to %<%s%>", diff --git a/gcc/rust/typecheck/rust-coercion.cc b/gcc/rust/typecheck/rust-coercion.cc index f1f349a..5ee1c35 100644 --- a/gcc/rust/typecheck/rust-coercion.cc +++ b/gcc/rust/typecheck/rust-coercion.cc @@ -464,7 +464,7 @@ TypeCoercionRules::mismatched_mutability_error (Location expr_locus, if (!emit_errors) return; - RichLocation r (expr_locus); + RichLocation r (line_table, expr_locus); r.add_range (lhs); r.add_range (rhs); rust_error_at (r, "mismatched mutability"); @@ -477,7 +477,7 @@ TypeCoercionRules::object_unsafe_error (Location expr_locus, Location lhs, if (!emit_errors) return; - RichLocation r (expr_locus); + RichLocation r (line_table, expr_locus); r.add_range (lhs); r.add_range (rhs); rust_error_at (r, "unsafe unsize coercion"); diff --git a/gcc/rust/typecheck/rust-hir-inherent-impl-overlap.h b/gcc/rust/typecheck/rust-hir-inherent-impl-overlap.h index 6ab5dc0..be8f794 100644 --- a/gcc/rust/typecheck/rust-hir-inherent-impl-overlap.h +++ b/gcc/rust/typecheck/rust-hir-inherent-impl-overlap.h @@ -128,7 +128,7 @@ public: void collision_detected (HIR::ImplItem *query, HIR::ImplItem *dup, const std::string &name) { - RichLocation r (dup->get_locus ()); + RichLocation r (line_table, dup->get_locus ()); r.add_range (query->get_locus ()); rust_error_at (r, "duplicate definitions with name %s", name.c_str ()); } diff --git a/gcc/rust/typecheck/rust-hir-path-probe.h b/gcc/rust/typecheck/rust-hir-path-probe.h index 82fb8bf..bf29060 100644 --- a/gcc/rust/typecheck/rust-hir-path-probe.h +++ b/gcc/rust/typecheck/rust-hir-path-probe.h @@ -160,7 +160,7 @@ public: static void Report (std::set<PathProbeCandidate> &candidates, const HIR::PathIdentSegment &query, Location query_locus) { - RichLocation r (query_locus); + RichLocation r (line_table, query_locus); for (auto &c : candidates) r.add_range (c.locus); diff --git a/gcc/rust/typecheck/rust-hir-trait-reference.cc b/gcc/rust/typecheck/rust-hir-trait-reference.cc index 72069ca..8433103 100644 --- a/gcc/rust/typecheck/rust-hir-trait-reference.cc +++ b/gcc/rust/typecheck/rust-hir-trait-reference.cc @@ -402,7 +402,7 @@ TraitReference::is_object_safe (bool emit_error, Location locus) const = non_object_super_traits.empty () && non_object_safe_items.empty (); if (emit_error && !is_safe) { - RichLocation r (locus); + RichLocation r (line_table, locus); for (auto &item : non_object_super_traits) r.add_range (item->get_locus ()); for (auto &item : non_object_safe_items) diff --git a/gcc/rust/typecheck/rust-hir-type-check-expr.cc b/gcc/rust/typecheck/rust-hir-type-check-expr.cc index b9c7f72..d78da22 100644 --- a/gcc/rust/typecheck/rust-hir-type-check-expr.cc +++ b/gcc/rust/typecheck/rust-hir-type-check-expr.cc @@ -867,7 +867,7 @@ TypeCheckExpr::visit (HIR::ArrayIndexExpr &expr) } // error[E0277]: the type `[{integer}]` cannot be indexed by `u32` - RichLocation r (expr.get_locus ()); + RichLocation r (line_table, expr.get_locus ()); r.add_range (expr.get_array_expr ()->get_locus ()); r.add_range (expr.get_index_expr ()->get_locus ()); rust_error_at (r, ErrorCode ("E0277"), @@ -1054,7 +1054,7 @@ TypeCheckExpr::visit (HIR::MethodCallExpr &expr) if (candidates.size () > 1) { - RichLocation r (expr.get_method_name ().get_locus ()); + RichLocation r (line_table, expr.get_method_name ().get_locus ()); for (auto &c : candidates) r.add_range (c.candidate.locus); @@ -1096,7 +1096,7 @@ TypeCheckExpr::visit (HIR::MethodCallExpr &expr) if (lookup_tyty->get_kind () != TyTy::TypeKind::FNDEF) { - RichLocation r (expr.get_method_name ().get_locus ()); + RichLocation r (line_table, expr.get_method_name ().get_locus ()); r.add_range (resolved_candidate.locus); rust_error_at (r, "associated impl item is not a method"); return; @@ -1106,7 +1106,7 @@ TypeCheckExpr::visit (HIR::MethodCallExpr &expr) TyTy::FnType *fn = static_cast<TyTy::FnType *> (lookup); if (!fn->is_method ()) { - RichLocation r (expr.get_method_name ().get_locus ()); + RichLocation r (line_table, expr.get_method_name ().get_locus ()); r.add_range (resolved_candidate.locus); rust_error_at (r, "associated function is not a method"); return; @@ -1637,7 +1637,7 @@ TypeCheckExpr::resolve_operator_overload ( if (selected_candidates.size () > 1) { // mutliple candidates - RichLocation r (expr.get_locus ()); + RichLocation r (line_table, expr.get_locus ()); for (auto &c : resolved_candidates) r.add_range (c.candidate.locus); @@ -1883,7 +1883,7 @@ TypeCheckExpr::resolve_fn_trait_call (HIR::CallExpr &expr, if (candidates.size () > 1) { - RichLocation r (expr.get_locus ()); + RichLocation r (line_table, expr.get_locus ()); for (auto &c : candidates) r.add_range (c.candidate.locus); @@ -1929,7 +1929,7 @@ TypeCheckExpr::resolve_fn_trait_call (HIR::CallExpr &expr, if (lookup_tyty->get_kind () != TyTy::TypeKind::FNDEF) { - RichLocation r (expr.get_locus ()); + RichLocation r (line_table, expr.get_locus ()); r.add_range (resolved_candidate.locus); rust_error_at (r, "associated impl item is not a method"); return false; @@ -1939,7 +1939,7 @@ TypeCheckExpr::resolve_fn_trait_call (HIR::CallExpr &expr, TyTy::FnType *fn = static_cast<TyTy::FnType *> (lookup); if (!fn->is_method ()) { - RichLocation r (expr.get_locus ()); + RichLocation r (line_table, expr.get_locus ()); r.add_range (resolved_candidate.locus); rust_error_at (r, "associated function is not a method"); return false; diff --git a/gcc/rust/typecheck/rust-hir-type-check-implitem.cc b/gcc/rust/typecheck/rust-hir-type-check-implitem.cc index b12dc25..d7fb36e 100644 --- a/gcc/rust/typecheck/rust-hir-type-check-implitem.cc +++ b/gcc/rust/typecheck/rust-hir-type-check-implitem.cc @@ -392,7 +392,7 @@ TypeCheckImplItemWithTrait::visit (HIR::ConstantItem &constant) // unknown trait item if (!found || raw_trait_item->is_error ()) { - RichLocation r (constant.get_locus ()); + RichLocation r (line_table, constant.get_locus ()); r.add_range (trait_reference.get_locus ()); rust_error_at (r, "constant %<%s%> is not a member of trait %<%s%>", constant.get_identifier ().as_string ().c_str (), @@ -415,7 +415,7 @@ TypeCheckImplItemWithTrait::visit (HIR::ConstantItem &constant) TyTy::TyWithLocation (lookup), constant.get_locus (), true /*emit_errors*/)) { - RichLocation r (constant.get_locus ()); + RichLocation r (line_table, constant.get_locus ()); r.add_range (resolved_trait_item.get_locus ()); rust_error_at ( @@ -443,7 +443,7 @@ TypeCheckImplItemWithTrait::visit (HIR::TypeAlias &type) // unknown trait item if (!found || raw_trait_item->is_error ()) { - RichLocation r (type.get_locus ()); + RichLocation r (line_table, type.get_locus ()); r.add_range (trait_reference.get_locus ()); rust_error_at (r, "type alias %<%s%> is not a member of trait %<%s%>", type.get_new_type_name ().as_string ().c_str (), @@ -466,7 +466,7 @@ TypeCheckImplItemWithTrait::visit (HIR::TypeAlias &type) TyTy::TyWithLocation (lookup), type.get_locus (), true /*emit_errors*/)) { - RichLocation r (type.get_locus ()); + RichLocation r (line_table, type.get_locus ()); r.add_range (resolved_trait_item.get_locus ()); rust_error_at ( @@ -503,7 +503,7 @@ TypeCheckImplItemWithTrait::visit (HIR::Function &function) // unknown trait item if (!found || raw_trait_item->is_error ()) { - RichLocation r (function.get_locus ()); + RichLocation r (line_table, function.get_locus ()); r.add_range (trait_reference.get_locus ()); rust_error_at (r, "method %<%s%> is not a member of trait %<%s%>", function.get_function_name ().as_string ().c_str (), @@ -526,7 +526,7 @@ TypeCheckImplItemWithTrait::visit (HIR::Function &function) TyTy::TyWithLocation (lookup), function.get_locus (), true /*emit_errors*/)) { - RichLocation r (function.get_locus ()); + RichLocation r (line_table, function.get_locus ()); r.add_range (resolved_trait_item.get_locus ()); rust_error_at (r, ErrorCode ("E0053"), diff --git a/gcc/rust/typecheck/rust-hir-type-check-item.cc b/gcc/rust/typecheck/rust-hir-type-check-item.cc index 6c52630..8000579 100644 --- a/gcc/rust/typecheck/rust-hir-type-check-item.cc +++ b/gcc/rust/typecheck/rust-hir-type-check-item.cc @@ -648,7 +648,7 @@ TypeCheckItem::validate_trait_impl_block ( if (missing_trait_items.size () > 0) { std::string missing_items_buf; - RichLocation r (impl_block.get_locus ()); + RichLocation r (line_table, impl_block.get_locus ()); for (size_t i = 0; i < missing_trait_items.size (); i++) { bool has_more = (i + 1) < missing_trait_items.size (); diff --git a/gcc/rust/typecheck/rust-hir-type-check-pattern.cc b/gcc/rust/typecheck/rust-hir-type-check-pattern.cc index b407e1f..421ec27 100644 --- a/gcc/rust/typecheck/rust-hir-type-check-pattern.cc +++ b/gcc/rust/typecheck/rust-hir-type-check-pattern.cc @@ -412,7 +412,7 @@ TypeCheckPattern::emit_pattern_size_error (const HIR::Pattern &pattern, size_t expected_field_count, size_t got_field_count) { - RichLocation r (pattern.get_locus ()); + RichLocation r (line_table, pattern.get_locus ()); r.add_range (mappings->lookup_location (parent->get_ref ())); rust_error_at (r, "expected a tuple with %lu %s, found one " diff --git a/gcc/rust/typecheck/rust-tyty-cmp.h b/gcc/rust/typecheck/rust-tyty-cmp.h index 49a2bde..4596288 100644 --- a/gcc/rust/typecheck/rust-tyty-cmp.h +++ b/gcc/rust/typecheck/rust-tyty-cmp.h @@ -65,7 +65,7 @@ public: Location ref_locus = mappings->lookup_location (type.get_ref ()); Location base_locus = mappings->lookup_location (get_base ()->get_ref ()); - RichLocation r (ref_locus); + RichLocation r (line_table, ref_locus); r.add_range (base_locus); rust_error_at (r, "expected [%s] got [%s]", get_base ()->as_string ().c_str (), @@ -81,7 +81,7 @@ public: Location ref_locus = mappings->lookup_location (type.get_ref ()); Location base_locus = mappings->lookup_location (get_base ()->get_ref ()); - RichLocation r (ref_locus); + RichLocation r (line_table, ref_locus); r.add_range (base_locus); rust_error_at (r, "expected [%s] got [%s]", get_base ()->as_string ().c_str (), @@ -97,7 +97,7 @@ public: Location ref_locus = mappings->lookup_location (type.get_ref ()); Location base_locus = mappings->lookup_location (get_base ()->get_ref ()); - RichLocation r (ref_locus); + RichLocation r (line_table, ref_locus); r.add_range (base_locus); rust_error_at (r, "expected [%s] got [%s]", get_base ()->as_string ().c_str (), @@ -113,7 +113,7 @@ public: Location ref_locus = mappings->lookup_location (type.get_ref ()); Location base_locus = mappings->lookup_location (get_base ()->get_ref ()); - RichLocation r (ref_locus); + RichLocation r (line_table, ref_locus); r.add_range (base_locus); rust_error_at (r, "expected [%s] got [%s]", get_base ()->as_string ().c_str (), @@ -129,7 +129,7 @@ public: Location ref_locus = mappings->lookup_location (type.get_ref ()); Location base_locus = mappings->lookup_location (get_base ()->get_ref ()); - RichLocation r (ref_locus); + RichLocation r (line_table, ref_locus); r.add_range (base_locus); rust_error_at (r, "expected [%s] got [%s]", get_base ()->as_string ().c_str (), @@ -145,7 +145,7 @@ public: Location ref_locus = mappings->lookup_location (type.get_ref ()); Location base_locus = mappings->lookup_location (get_base ()->get_ref ()); - RichLocation r (ref_locus); + RichLocation r (line_table, ref_locus); r.add_range (base_locus); rust_error_at (r, "expected [%s] got [%s]", get_base ()->as_string ().c_str (), @@ -161,7 +161,7 @@ public: Location ref_locus = mappings->lookup_location (type.get_ref ()); Location base_locus = mappings->lookup_location (get_base ()->get_ref ()); - RichLocation r (ref_locus); + RichLocation r (line_table, ref_locus); r.add_range (base_locus); rust_error_at (r, "expected [%s] got [%s]", get_base ()->as_string ().c_str (), @@ -177,7 +177,7 @@ public: Location ref_locus = mappings->lookup_location (type.get_ref ()); Location base_locus = mappings->lookup_location (get_base ()->get_ref ()); - RichLocation r (ref_locus); + RichLocation r (line_table, ref_locus); r.add_range (base_locus); rust_error_at (r, "expected [%s] got [%s]", get_base ()->as_string ().c_str (), @@ -193,7 +193,7 @@ public: Location ref_locus = mappings->lookup_location (type.get_ref ()); Location base_locus = mappings->lookup_location (get_base ()->get_ref ()); - RichLocation r (ref_locus); + RichLocation r (line_table, ref_locus); r.add_range (base_locus); rust_error_at (r, "expected [%s] got [%s]", get_base ()->as_string ().c_str (), @@ -209,7 +209,7 @@ public: Location ref_locus = mappings->lookup_location (type.get_ref ()); Location base_locus = mappings->lookup_location (get_base ()->get_ref ()); - RichLocation r (ref_locus); + RichLocation r (line_table, ref_locus); r.add_range (base_locus); rust_error_at (r, "expected [%s] got [%s]", get_base ()->as_string ().c_str (), @@ -225,7 +225,7 @@ public: Location ref_locus = mappings->lookup_location (type.get_ref ()); Location base_locus = mappings->lookup_location (get_base ()->get_ref ()); - RichLocation r (ref_locus); + RichLocation r (line_table, ref_locus); r.add_range (base_locus); rust_error_at (r, "expected [%s] got [%s]", get_base ()->as_string ().c_str (), @@ -241,7 +241,7 @@ public: Location ref_locus = mappings->lookup_location (type.get_ref ()); Location base_locus = mappings->lookup_location (get_base ()->get_ref ()); - RichLocation r (ref_locus); + RichLocation r (line_table, ref_locus); r.add_range (base_locus); rust_error_at (r, "expected [%s] got [%s]", get_base ()->as_string ().c_str (), @@ -257,7 +257,7 @@ public: Location ref_locus = mappings->lookup_location (type.get_ref ()); Location base_locus = mappings->lookup_location (get_base ()->get_ref ()); - RichLocation r (ref_locus); + RichLocation r (line_table, ref_locus); r.add_range (base_locus); rust_error_at (r, "expected [%s] got [%s]", get_base ()->as_string ().c_str (), @@ -273,7 +273,7 @@ public: Location ref_locus = mappings->lookup_location (type.get_ref ()); Location base_locus = mappings->lookup_location (get_base ()->get_ref ()); - RichLocation r (ref_locus); + RichLocation r (line_table, ref_locus); r.add_range (base_locus); rust_error_at (r, "expected [%s] got [%s]", get_base ()->as_string ().c_str (), @@ -289,7 +289,7 @@ public: Location ref_locus = mappings->lookup_location (type.get_ref ()); Location base_locus = mappings->lookup_location (get_base ()->get_ref ()); - RichLocation r (ref_locus); + RichLocation r (line_table, ref_locus); r.add_range (base_locus); rust_error_at (r, "expected [%s] got [%s]", get_base ()->as_string ().c_str (), @@ -305,7 +305,7 @@ public: Location ref_locus = mappings->lookup_location (type.get_ref ()); Location base_locus = mappings->lookup_location (get_base ()->get_ref ()); - RichLocation r (ref_locus); + RichLocation r (line_table, ref_locus); r.add_range (base_locus); rust_error_at (r, "expected [%s] got [%s]", get_base ()->as_string ().c_str (), @@ -321,7 +321,7 @@ public: Location ref_locus = mappings->lookup_location (type.get_ref ()); Location base_locus = mappings->lookup_location (get_base ()->get_ref ()); - RichLocation r (ref_locus); + RichLocation r (line_table, ref_locus); r.add_range (base_locus); rust_error_at (r, "expected [%s] got [%s]", get_base ()->as_string ().c_str (), @@ -337,7 +337,7 @@ public: Location ref_locus = mappings->lookup_location (type.get_ref ()); Location base_locus = mappings->lookup_location (get_base ()->get_ref ()); - RichLocation r (ref_locus); + RichLocation r (line_table, ref_locus); r.add_range (base_locus); rust_error_at (r, "expected [%s] got [%s]", get_base ()->as_string ().c_str (), @@ -353,7 +353,7 @@ public: Location ref_locus = mappings->lookup_location (type.get_ref ()); Location base_locus = mappings->lookup_location (get_base ()->get_ref ()); - RichLocation r (ref_locus); + RichLocation r (line_table, ref_locus); r.add_range (base_locus); rust_error_at (r, "expected [%s] got [%s]", get_base ()->as_string ().c_str (), @@ -369,7 +369,7 @@ public: Location ref_locus = mappings->lookup_location (type.get_ref ()); Location base_locus = mappings->lookup_location (get_base ()->get_ref ()); - RichLocation r (ref_locus); + RichLocation r (line_table, ref_locus); r.add_range (base_locus); rust_error_at (r, "expected [%s] got [%s]", get_base ()->as_string ().c_str (), @@ -391,7 +391,7 @@ public: Location ref_locus = mappings->lookup_location (type.get_ref ()); Location base_locus = mappings->lookup_location (get_base ()->get_ref ()); - RichLocation r (ref_locus); + RichLocation r (line_table, ref_locus); r.add_range (base_locus); rust_error_at (r, "expected [%s] got [%s]", get_base ()->as_string ().c_str (), @@ -407,7 +407,7 @@ public: Location ref_locus = mappings->lookup_location (type.get_ref ()); Location base_locus = mappings->lookup_location (get_base ()->get_ref ()); - RichLocation r (ref_locus); + RichLocation r (line_table, ref_locus); r.add_range (base_locus); rust_error_at (r, "expected [%s] got [%s]", get_base ()->as_string ().c_str (), @@ -423,7 +423,7 @@ public: Location ref_locus = mappings->lookup_location (type.get_ref ()); Location base_locus = mappings->lookup_location (get_base ()->get_ref ()); - RichLocation r (ref_locus); + RichLocation r (line_table, ref_locus); r.add_range (base_locus); rust_error_at (r, "expected [%s] got [%s]", get_base ()->as_string ().c_str (), diff --git a/gcc/rust/typecheck/rust-tyty-subst.cc b/gcc/rust/typecheck/rust-tyty-subst.cc index 07ce8d4..bf440df 100644 --- a/gcc/rust/typecheck/rust-tyty-subst.cc +++ b/gcc/rust/typecheck/rust-tyty-subst.cc @@ -563,7 +563,7 @@ SubstitutionRef::get_mappings_from_generic_args (HIR::GenericArgs &args) { if (args.get_binding_args ().size () > get_num_associated_bindings ()) { - RichLocation r (args.get_locus ()); + RichLocation r (line_table, args.get_locus ()); rust_error_at (r, "generic item takes at most %lu type binding " @@ -602,7 +602,7 @@ SubstitutionRef::get_mappings_from_generic_args (HIR::GenericArgs &args) } else { - RichLocation r (args.get_locus ()); + RichLocation r (line_table, args.get_locus ()); for (auto &binding : args.get_binding_args ()) r.add_range (binding.get_locus ()); @@ -616,7 +616,7 @@ SubstitutionRef::get_mappings_from_generic_args (HIR::GenericArgs &args) size_t offs = used_arguments.size (); if (args.get_type_args ().size () + offs > substitutions.size ()) { - RichLocation r (args.get_locus ()); + RichLocation r (line_table, args.get_locus ()); r.add_range (substitutions.front ().get_param_locus ()); rust_error_at ( @@ -629,7 +629,7 @@ SubstitutionRef::get_mappings_from_generic_args (HIR::GenericArgs &args) if (args.get_type_args ().size () + offs < min_required_substitutions ()) { - RichLocation r (args.get_locus ()); + RichLocation r (line_table, args.get_locus ()); r.add_range (substitutions.front ().get_param_locus ()); rust_error_at ( @@ -884,7 +884,7 @@ SubstitutionRef::monomorphize () const auto &type_param = subst.get_generic_param (); const auto *trait_ref = bound.get (); - RichLocation r (type_param.get_locus ()); + RichLocation r (line_table, type_param.get_locus ()); r.add_range (bound.get_locus ()); r.add_range (mappings.lookup_location (binding->get_ref ())); diff --git a/gcc/rust/typecheck/rust-tyty.cc b/gcc/rust/typecheck/rust-tyty.cc index 94d7650..e64b89c 100644 --- a/gcc/rust/typecheck/rust-tyty.cc +++ b/gcc/rust/typecheck/rust-tyty.cc @@ -346,7 +346,8 @@ BaseType::satisfies_bound (const TypeBoundPredicate &predicate, { if (emit_error) { - RichLocation r (mappings->lookup_location (get_ref ())); + RichLocation r (line_table, + mappings->lookup_location (get_ref ())); r.add_range (predicate.get_locus ()); r.add_range (mappings->lookup_location (i.get_hirid ())); @@ -381,7 +382,7 @@ BaseType::bounds_compatible (const BaseType &other, Location locus, // lets emit a single error for this if (unsatisfied_bounds.size () > 0) { - RichLocation r (locus); + RichLocation r (line_table, locus); std::string missing_preds; for (size_t i = 0; i < unsatisfied_bounds.size (); i++) { diff --git a/gcc/rust/typecheck/rust-unify.cc b/gcc/rust/typecheck/rust-unify.cc index 0e62a21..39bc7ca 100644 --- a/gcc/rust/typecheck/rust-unify.cc +++ b/gcc/rust/typecheck/rust-unify.cc @@ -119,7 +119,7 @@ UnifyRules::emit_type_mismatch () const TyTy::BaseType *expected = lhs.get_ty (); TyTy::BaseType *expr = rhs.get_ty (); - RichLocation r (locus); + RichLocation r (line_table, locus); r.add_range (lhs.get_locus ()); r.add_range (rhs.get_locus ()); rust_error_at (r, "expected %<%s%> got %<%s%>", @@ -130,7 +130,7 @@ void UnifyRules::emit_abi_mismatch (const TyTy::FnType &expected, const TyTy::FnType &got) const { - RichLocation r (locus); + RichLocation r (line_table, locus); r.add_range (lhs.get_locus ()); r.add_range (rhs.get_locus ()); rust_error_at (r, "mistached abi %<%s%> got %<%s%>", |