]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
gccrs: Change class RichLocation into typedef
authorOwen Avery <powerboat9.gamer@gmail.com>
Mon, 10 Jul 2023 15:42:12 +0000 (11:42 -0400)
committerArthur Cohen <arthur.cohen@embecosm.com>
Tue, 16 Jan 2024 17:49:36 +0000 (18:49 +0100)
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>
22 files changed:
gcc/rust/expand/rust-macro-expand.cc
gcc/rust/hir/rust-ast-lower-base.cc
gcc/rust/resolve/rust-ast-resolve-implitem.h
gcc/rust/resolve/rust-ast-resolve-stmt.h
gcc/rust/resolve/rust-ast-resolve-toplevel.h
gcc/rust/rust-diagnostics.cc
gcc/rust/rust-linemap.cc
gcc/rust/rust-location.h
gcc/rust/rust-session-manager.cc
gcc/rust/typecheck/rust-casts.cc
gcc/rust/typecheck/rust-coercion.cc
gcc/rust/typecheck/rust-hir-inherent-impl-overlap.h
gcc/rust/typecheck/rust-hir-path-probe.h
gcc/rust/typecheck/rust-hir-trait-reference.cc
gcc/rust/typecheck/rust-hir-type-check-expr.cc
gcc/rust/typecheck/rust-hir-type-check-implitem.cc
gcc/rust/typecheck/rust-hir-type-check-item.cc
gcc/rust/typecheck/rust-hir-type-check-pattern.cc
gcc/rust/typecheck/rust-tyty-cmp.h
gcc/rust/typecheck/rust-tyty-subst.cc
gcc/rust/typecheck/rust-tyty.cc
gcc/rust/typecheck/rust-unify.cc

index abe8f20ed9c395d0503958764457d36e0c4916ba..c908e3b2745f35fbc636ef8bae265d0b94962edb 100644 (file)
@@ -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 ();
index 5a1ce74588a284da3c435b620ddf98af6b135edc..413a77243d42ffa9857a75811ab3cb8e69d99111 100644 (file)
@@ -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",
index 126fc299f17bb1ebb771066dd4f3ef5bc7b461bd..f8af57ab7c61195a70899715b0dbca180e695d5b 100644 (file)
@@ -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");
       });
index 5c33712e1029aaf1676cefbdb9719ffb97efe39e..4ba44253fba1ec8cd9c73ed14859ea5cdf251fd9 100644 (file)
@@ -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");
       });
index bd918dffcb0d03bd9284c22252c05b28ac5ed0f9..d72f4c9390595d8b7877c5100383d3debd56f6a7 100644 (file)
@@ -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");
       });
index 113a128a3866facf98fdb0b0dc0a5cb84f2ad65b..0f9eb79fb5c7e325cb58552e0693447d30798cf2 100644 (file)
@@ -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 ());
 }
 
index 6caa49410a4ed658ff1eb6b99fed3dc029acb56d..627f904ce28541c8ac110be29af8c7dbd8516817 100644 (file)
@@ -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 ());
-}
index 1944bb7b84aabba32d026f239e9a687f9ac5f057..ae38b2b96047a67433f8b45f87bb8235cafbe340 100644 (file)
 
 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)
index fb856c6a927b535cb16f76caae5e89181f73fd23..6de15655a964304f5cd15214020bfa27367e1abb 100644 (file)
@@ -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");
index 86c1b5faf41f98182efa5a7a28189ae3f614191f..d64851391605f6c2bbaef2c53bfcdd0aec21fad8 100644 (file)
@@ -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%>",
index f1f349ad6ec3a169482a13b400120e0ff6c2796a..5ee1c351ef8bcf6480555a6ab404d98f90421c95 100644 (file)
@@ -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");
index 6ab5dc020077098ce39bec88c5e078dc46069ff2..be8f794b54dc8f2ef0ae118dd20838b8b30c2e15 100644 (file)
@@ -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 ());
   }
index 82fb8bf7eec074bf74c3a6bc2115c203f6b51453..bf29060ee4e0da73a9ddb3077d41f948d4461a64 100644 (file)
@@ -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);
 
index 72069caaf0ccb4fad63c62cc1b4182d5728cf876..8433103cb251658f3b7d6dda72d8a6d6a8cb67c5 100644 (file)
@@ -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)
index b9c7f72acf93c1796863d52626d5231645e2ee74..d78da22694abc895514a1fb93e7f16219bab1467 100644 (file)
@@ -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;
index b12dc258c517e95aef9824ed2744074a213e765b..d7fb36e48577ca0d612c02a1016c4e619558120b 100644 (file)
@@ -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"),
index 6c526302beb4fd7a78365a93727d731bc482a7eb..800057985f992ca21fc7bdf901685890e763194f 100644 (file)
@@ -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 ();
index b407e1f40056410ded3fc0477be787c99410d5b5..421ec27b2387379a4cba0b5596904902d5b5192d 100644 (file)
@@ -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 "
index 49a2bde46ea98dc222c55e7adec72e73fca6a5e4..459628819db9856d5373854f9b8a772864c32ae6 100644 (file)
@@ -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 (),
index 07ce8d4f4d8358d808c02a92690d6d59424a2616..bf440dfe2e1d0bee57e52c1a87187ee8f59da4fe 100644 (file)
@@ -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 ()));
 
index 94d765009e4a270f5e2fd4b326b67211470a6f38..e64b89cd82cc309a677a8dd72b99891c18613c8c 100644 (file)
@@ -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++)
        {
index 0e62a21dc25c94f9f236e080016ed43821ffee83..39bc7ca4ac6fce0116a0aea2cd3fb19f366f4129 100644 (file)
@@ -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%>",