From e42c64242b8f25dcf30aee35ee059bdd8873561f Mon Sep 17 00:00:00 2001 From: Arthur Cohen Date: Thu, 30 Jan 2025 13:08:33 +0100 Subject: scan-deadcode: Do not warn unused fields if they start with '_' gcc/rust/ChangeLog: * checks/lints/rust-lint-scan-deadcode.h: Check if the field name starts with an underscore before warning. --- gcc/rust/checks/lints/rust-lint-scan-deadcode.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'gcc') diff --git a/gcc/rust/checks/lints/rust-lint-scan-deadcode.h b/gcc/rust/checks/lints/rust-lint-scan-deadcode.h index 672c761..f6a208c 100644 --- a/gcc/rust/checks/lints/rust-lint-scan-deadcode.h +++ b/gcc/rust/checks/lints/rust-lint-scan-deadcode.h @@ -93,10 +93,11 @@ public: { HirId field_hir_id = field.get_mappings ().get_hirid (); if (should_warn (field_hir_id) - && !field.get_visibility ().is_public ()) + && !field.get_visibility ().is_public () + && field.get_field_name ().as_string ().at (0) != '_') { rust_warning_at (field.get_locus (), 0, - "field is never read: %<%s%>", + "field is never read: %qs", field.get_field_name ().as_string ().c_str ()); } } -- cgit v1.1