public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc/devel/rust/master] Use HIR::Type's location when checking privacy
@ 2022-06-25  9:32 Thomas Schwinge
  0 siblings, 0 replies; only message in thread
From: Thomas Schwinge @ 2022-06-25  9:32 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:5d7841fa235cd53a807dae813d20f474362fb5c1

commit 5d7841fa235cd53a807dae813d20f474362fb5c1
Author: Sebastien Lacoste <dev@graphman.fr>
Date:   Thu Jun 23 13:29:36 2022 +0200

    Use HIR::Type's location when checking privacy
    
    This improves privacy errors reporting location
    
    Signed-off-by: Sebastien Lacoste <dev@graphman.fr>

Diff:
---
 gcc/rust/privacy/rust-privacy-reporter.cc | 12 ++++--------
 gcc/rust/privacy/rust-privacy-reporter.h  |  3 +--
 gcc/testsuite/rust/compile/privacy5.rs    |  3 +--
 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 f2752b6b965..77f477b8303 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 234bea718dc..a04e318e9ea 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 ad552c73abe..0e0e496dde2 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" }
     }
 }


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-06-25  9:32 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-25  9:32 [gcc/devel/rust/master] Use HIR::Type's location when checking privacy Thomas Schwinge

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).