aboutsummaryrefslogtreecommitdiff
path: root/gcc/rust/ast
diff options
context:
space:
mode:
authorArthur Cohen <arthur.cohen@embecosm.com>2023-03-28 14:22:21 +0200
committerPhilip Herron <philip.herron@embecosm.com>2023-03-29 21:14:15 +0000
commit70b889b90ae982a2c0c6fe8596d9885d5dcc644f (patch)
tree0426b76c85262fa4dd8836eceebd7003cd0117fd /gcc/rust/ast
parentff4d4570b44baf6a106cb0cfde3a1fe9ff0ed09f (diff)
downloadgcc-70b889b90ae982a2c0c6fe8596d9885d5dcc644f.zip
gcc-70b889b90ae982a2c0c6fe8596d9885d5dcc644f.tar.gz
gcc-70b889b90ae982a2c0c6fe8596d9885d5dcc644f.tar.bz2
privacy: Check for pub(crate) when resolving visibility path.
This causes the function to return true and the checks to pass, but it requires more thinking - how do we deal with pub(crate) in the current system? Should we simply treat it as a pub item in the current crate, but export it as a private item in the metadata? gcc/rust/ChangeLog: * ast/rust-item.h: Fix `Visibility::has_path()` implementation. * checks/errors/privacy/rust-visibility-resolver.cc (VisibilityResolver::resolve_module_path): Check if we are dealing with pub(crate) properly. gcc/testsuite/ChangeLog: * rust/compile/privacy8.rs: New test.
Diffstat (limited to 'gcc/rust/ast')
-rw-r--r--gcc/rust/ast/rust-item.h2
1 files changed, 1 insertions, 1 deletions
diff --git a/gcc/rust/ast/rust-item.h b/gcc/rust/ast/rust-item.h
index 80421c5..a96076e 100644
--- a/gcc/rust/ast/rust-item.h
+++ b/gcc/rust/ast/rust-item.h
@@ -642,7 +642,7 @@ public:
}
// Returns whether a visibility has a path
- bool has_path () const { return !(is_error ()) && vis_type == PUB_IN_PATH; }
+ bool has_path () const { return !is_error () && vis_type >= PUB_CRATE; }
// Returns whether visibility is public or not.
bool is_public () const { return vis_type != PRIV && !is_error (); }