aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastien Lacoste <dev@graphman.fr>2022-06-23 13:29:36 +0200
committerSebastien Lacoste <dev@graphman.fr>2022-06-23 15:58:56 +0200
commit5d7841fa235cd53a807dae813d20f474362fb5c1 (patch)
tree387b5e3734c1da8487a42d603ddbdf35172bfbb5
parentd114e48ce6e6a4d6b1b4021640cbdfa3a32c05bb (diff)
downloadgcc-5d7841fa235cd53a807dae813d20f474362fb5c1.zip
gcc-5d7841fa235cd53a807dae813d20f474362fb5c1.tar.gz
gcc-5d7841fa235cd53a807dae813d20f474362fb5c1.tar.bz2
Use HIR::Type's location when checking privacy
This improves privacy errors reporting location Signed-off-by: Sebastien Lacoste <dev@graphman.fr>
-rw-r--r--gcc/rust/privacy/rust-privacy-reporter.cc12
-rw-r--r--gcc/rust/privacy/rust-privacy-reporter.h3
-rw-r--r--gcc/testsuite/rust/compile/privacy5.rs3
3 files changed, 6 insertions, 12 deletions
diff --git a/gcc/rust/privacy/rust-privacy-reporter.cc b/gcc/rust/privacy/rust-privacy-reporter.cc
index f2752b6..77f477b 100644
--- a/gcc/rust/privacy/rust-privacy-reporter.cc
+++ b/gcc/rust/privacy/rust-privacy-reporter.cc
@@ -188,8 +188,7 @@ PrivacyReporter::check_base_type_privacy (Analysis::NodeMapping &node_mappings,
}
void
-PrivacyReporter::check_type_privacy (const HIR::Type *type,
- const Location &locus)
+PrivacyReporter::check_type_privacy (const HIR::Type *type)
{
rust_assert (type);
@@ -198,7 +197,7 @@ PrivacyReporter::check_type_privacy (const HIR::Type *type,
ty_ctx.lookup_type (type->get_mappings ().get_hirid (), &lookup));
auto node_mappings = type->get_mappings ();
- return check_base_type_privacy (node_mappings, lookup, locus);
+ return check_base_type_privacy (node_mappings, lookup, type->get_locus ());
}
void
@@ -634,9 +633,7 @@ void
PrivacyReporter::visit (HIR::Function &function)
{
for (auto &param : function.get_function_params ())
- check_type_privacy (param.get_type (), param.get_locus ());
-
- // FIXME: It would be better if it was specifically the type's locus (#1256)
+ check_type_privacy (param.get_type ());
function.get_definition ()->accept_vis (*this);
}
@@ -737,8 +734,7 @@ PrivacyReporter::visit (HIR::LetStmt &stmt)
{
auto type = stmt.get_type ();
if (type)
- check_type_privacy (type, stmt.get_locus ());
- // FIXME: #1256
+ check_type_privacy (type);
auto init_expr = stmt.get_init_expr ();
if (init_expr)
diff --git a/gcc/rust/privacy/rust-privacy-reporter.h b/gcc/rust/privacy/rust-privacy-reporter.h
index 234bea7..a04e318 100644
--- a/gcc/rust/privacy/rust-privacy-reporter.h
+++ b/gcc/rust/privacy/rust-privacy-reporter.h
@@ -74,9 +74,8 @@ types
*
* @param type Reference to an explicit type used in a statement, expression
* or parameter
- * @param locus Location of said type
*/
- void check_type_privacy (const HIR::Type *type, const Location &locus);
+ void check_type_privacy (const HIR::Type *type);
virtual void visit (HIR::StructExprFieldIdentifier &field);
virtual void visit (HIR::StructExprFieldIdentifierValue &field);
diff --git a/gcc/testsuite/rust/compile/privacy5.rs b/gcc/testsuite/rust/compile/privacy5.rs
index ad552c7..0e0e496 100644
--- a/gcc/testsuite/rust/compile/privacy5.rs
+++ b/gcc/testsuite/rust/compile/privacy5.rs
@@ -12,7 +12,6 @@ mod orange {
let _: green::Foo; // { dg-error "definition is private in this context" }
- fn any(a0: green::Foo, a1: green::Bar) {}
- // { dg-error "definition is private in this context" "" { target *-*-* } .-1 }
+ fn any(a0: green::Foo, a1: green::Bar) {} // { dg-error "20:definition is private in this context" }
}
}