Skip to content

Commit

Permalink
Change class RichLocation into typedef
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
powerboat9 authored and philberty committed Jul 12, 2023
1 parent 486c8b8 commit b75357f
Show file tree
Hide file tree
Showing 22 changed files with 97 additions and 156 deletions.
2 changes: 1 addition & 1 deletion gcc/rust/expand/rust-macro-expand.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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 ();
Expand Down
2 changes: 1 addition & 1 deletion gcc/rust/hir/rust-ast-lower-base.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
20 changes: 10 additions & 10 deletions gcc/rust/resolve/rust-ast-resolve-implitem.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class ResolveToplevelImplItem : public ResolverBase
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");
});
Expand All @@ -74,7 +74,7 @@ class ResolveToplevelImplItem : public ResolverBase
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");
});
Expand All @@ -91,7 +91,7 @@ class ResolveToplevelImplItem : public ResolverBase
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");
});
Expand All @@ -107,7 +107,7 @@ class ResolveToplevelImplItem : public ResolverBase
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");
});
Expand Down Expand Up @@ -147,7 +147,7 @@ class ResolveTopLevelTraitItems : public ResolverBase
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");
});
Expand All @@ -167,7 +167,7 @@ class ResolveTopLevelTraitItems : public ResolverBase
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");
});
Expand All @@ -187,7 +187,7 @@ class ResolveTopLevelTraitItems : public ResolverBase
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");
});
Expand All @@ -205,7 +205,7 @@ class ResolveTopLevelTraitItems : public ResolverBase
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");
});
Expand Down Expand Up @@ -245,7 +245,7 @@ class ResolveToplevelExternItem : public ResolverBase
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");
});
Expand All @@ -264,7 +264,7 @@ class ResolveToplevelExternItem : public ResolverBase
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");
});
Expand Down
20 changes: 10 additions & 10 deletions gcc/rust/resolve/rust-ast-resolve-stmt.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class ResolveStmt : public ResolverBase
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");
});
Expand Down Expand Up @@ -95,7 +95,7 @@ class ResolveStmt : public ResolverBase
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");
});
Expand Down Expand Up @@ -128,7 +128,7 @@ class ResolveStmt : public ResolverBase
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");
});
Expand Down Expand Up @@ -160,7 +160,7 @@ class ResolveStmt : public ResolverBase
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");
});
Expand All @@ -180,7 +180,7 @@ class ResolveStmt : public ResolverBase
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");
});
Expand All @@ -206,7 +206,7 @@ class ResolveStmt : public ResolverBase
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");
});
Expand All @@ -232,7 +232,7 @@ class ResolveStmt : public ResolverBase
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");
});
Expand All @@ -253,7 +253,7 @@ class ResolveStmt : public ResolverBase
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");
});
Expand Down Expand Up @@ -291,7 +291,7 @@ class ResolveStmt : public ResolverBase
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");
});
Expand Down Expand Up @@ -327,7 +327,7 @@ class ResolveStmt : public ResolverBase
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");
});
Expand Down
32 changes: 16 additions & 16 deletions gcc/rust/resolve/rust-ast-resolve-toplevel.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class ResolveTopLevel : public ResolverBase
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");
});
Expand Down Expand Up @@ -86,7 +86,7 @@ class ResolveTopLevel : public ResolverBase
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");
});
Expand All @@ -108,7 +108,7 @@ class ResolveTopLevel : public ResolverBase
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");
});
Expand All @@ -130,7 +130,7 @@ class ResolveTopLevel : public ResolverBase
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");
});
Expand All @@ -156,7 +156,7 @@ class ResolveTopLevel : public ResolverBase
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");
});
Expand All @@ -178,7 +178,7 @@ class ResolveTopLevel : public ResolverBase
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");
});
Expand All @@ -200,7 +200,7 @@ class ResolveTopLevel : public ResolverBase
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");
});
Expand All @@ -222,7 +222,7 @@ class ResolveTopLevel : public ResolverBase
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");
});
Expand All @@ -246,7 +246,7 @@ class ResolveTopLevel : public ResolverBase
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");
});
Expand All @@ -268,7 +268,7 @@ class ResolveTopLevel : public ResolverBase
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");
});
Expand All @@ -288,7 +288,7 @@ class ResolveTopLevel : public ResolverBase
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");
});
Expand All @@ -309,7 +309,7 @@ class ResolveTopLevel : public ResolverBase
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");
});
Expand All @@ -331,7 +331,7 @@ class ResolveTopLevel : public ResolverBase
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");
});
Expand Down Expand Up @@ -375,7 +375,7 @@ class ResolveTopLevel : public ResolverBase
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");
});
Expand All @@ -395,7 +395,7 @@ class ResolveTopLevel : public ResolverBase
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");
});
Expand Down Expand Up @@ -471,7 +471,7 @@ class ResolveTopLevel : public ResolverBase
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");
});
Expand Down
4 changes: 2 additions & 2 deletions gcc/rust/rust-diagnostics.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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 ());
}

Expand Down
Loading

0 comments on commit b75357f

Please sign in to comment.