]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
gccrs: [E0603] Use of private item outside scope
authorMuhammad Mahad <mahadtxt@gmail.com>
Sun, 3 Sep 2023 06:13:53 +0000 (11:13 +0500)
committerArthur Cohen <arthur.cohen@embecosm.com>
Tue, 16 Jan 2024 18:04:31 +0000 (19:04 +0100)
gcc/rust/ChangeLog:

* checks/errors/privacy/rust-privacy-reporter.cc
(PrivacyReporter::check_for_privacy_violation):
Added errorcode & richlocation.

gcc/testsuite/ChangeLog:

* rust/compile/privacy1.rs: Added errorcode.
* rust/compile/privacy3.rs: likewise.
* rust/compile/privacy4.rs: likewise.
* rust/compile/privacy5.rs: likewise.

Signed-off-by: Muhammad Mahad <mahadtxt@gmail.com>
gcc/rust/checks/errors/privacy/rust-privacy-reporter.cc
gcc/testsuite/rust/compile/privacy1.rs
gcc/testsuite/rust/compile/privacy3.rs
gcc/testsuite/rust/compile/privacy4.rs
gcc/testsuite/rust/compile/privacy5.rs

index 2c9f4b75a065274d05af475781a24b8f7fdf07c3..7c3b4149d61d9e87e8db84e74444ebd702da1ab7 100644 (file)
@@ -166,7 +166,12 @@ PrivacyReporter::check_for_privacy_violation (const NodeId &use_id,
     }
 
   if (!valid)
-    rust_error_at (locus, "definition is private in this context");
+    {
+      rich_location richloc (line_table, locus);
+      richloc.add_fixit_replace ("item is private");
+      rust_error_at (richloc, ErrorCode::E0603,
+                    "definition is private in this context");
+    }
 }
 
 void
index 1cc83c04abe8c6568e3b8f81ec9f84db85087a77..61a2ae936356f0c8c8e85235a10bc7f74b892beb 100644 (file)
@@ -4,7 +4,7 @@ mod orange {
         pub fn doux() {}
     }
 
-    fn brown() {
+    fn brown() {// E0603
         green::sain(); // { dg-error "definition is private in this context" }
         green::doux();
     }
index d48acea4786842ddb7bb589a125538e3744db85f..8c8c199258f1b32499a0337388824a47118d3168 100644 (file)
@@ -8,7 +8,7 @@ mod orange {
     }
 
     fn brown() {
-        if green::sain() {
+        if green::sain() {// E0603
             // { dg-error "definition is private in this context" "" { target *-*-* } .-1 }
             green::doux();
         }
index 648b7b9adb763ac5eaff4d65220f71e63d1ea944..7865f6a3d479f7982ae300dc139320515cb03fac 100644 (file)
@@ -8,7 +8,7 @@ mod orange {
         }
     }
 
-    fn brown() {
+    fn brown() {// E0603
         green::bean::<bool>(false);
         // { dg-error "definition is private in this context" "" { target *-*-* } .-1 }
         let a = green::bean::<i32>(15);
index 0e0e496dde234b6f7c33eb8c1a858ac2f3010624..16445ddc3e3be52c4cc8642af006c721efcc5122 100644 (file)
@@ -5,7 +5,7 @@ mod orange {
         pub struct Baz;
     }
 
-    fn brown() {
+    fn brown() {// E0603
         let _ = green::Foo; // { dg-error "definition is private in this context" }
         let _ = green::Bar;
         let _ = green::Baz;