aboutsummaryrefslogtreecommitdiff
path: root/gcc/rust
diff options
context:
space:
mode:
authorArthur Cohen <arthur.cohen@embecosm.com>2022-08-26 14:09:24 +0200
committerArthur Cohen <arthur.cohen@embecosm.com>2022-08-26 14:34:18 +0200
commit702bb4bb01b93bb7c0f070883baf547ffdbebd17 (patch)
tree2a1f604b1416211e28363de52deb46569a2bab84 /gcc/rust
parent595cbafdf342369ceaffd8fb4d909a9c31bef207 (diff)
downloadgcc-702bb4bb01b93bb7c0f070883baf547ffdbebd17.zip
gcc-702bb4bb01b93bb7c0f070883baf547ffdbebd17.tar.gz
gcc-702bb4bb01b93bb7c0f070883baf547ffdbebd17.tar.bz2
lint: Do not emit unused warnings for public items
Diffstat (limited to 'gcc/rust')
-rw-r--r--gcc/rust/checks/lints/rust-lint-scan-deadcode.h9
1 files changed, 5 insertions, 4 deletions
diff --git a/gcc/rust/checks/lints/rust-lint-scan-deadcode.h b/gcc/rust/checks/lints/rust-lint-scan-deadcode.h
index 591cb30..3e1df39 100644
--- a/gcc/rust/checks/lints/rust-lint-scan-deadcode.h
+++ b/gcc/rust/checks/lints/rust-lint-scan-deadcode.h
@@ -53,7 +53,7 @@ public:
void visit (HIR::Function &function) override
{
HirId hirId = function.get_mappings ().get_hirid ();
- if (should_warn (hirId))
+ if (should_warn (hirId) && !function.get_visibility ().is_public ())
{
if (mappings->is_impl_item (hirId))
{
@@ -78,7 +78,7 @@ public:
void visit (HIR::StructStruct &stct) override
{
HirId hirId = stct.get_mappings ().get_hirid ();
- if (should_warn (hirId))
+ if (should_warn (hirId) && !stct.get_visibility ().is_public ())
{
bool name_starts_underscore = stct.get_identifier ().at (0) == '_';
if (!name_starts_underscore)
@@ -92,7 +92,8 @@ public:
for (auto &field : stct.get_fields ())
{
HirId field_hir_id = field.get_mappings ().get_hirid ();
- if (should_warn (field_hir_id))
+ if (should_warn (field_hir_id)
+ && !field.get_visibility ().is_public ())
{
rust_warning_at (field.get_locus (), 0,
"field is never read: %<%s%>",
@@ -106,7 +107,7 @@ public:
{
// only warn tuple struct unconstructed, and ignoring unused field
HirId hirId = stct.get_mappings ().get_hirid ();
- if (should_warn (hirId))
+ if (should_warn (hirId) && !stct.get_visibility ().is_public ())
{
rust_warning_at (stct.get_locus (), 0,
"struct is never constructed: %<%s%>",