]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
gccrs: scan-deadcode: Do not warn unused fields if they start with '_'
authorArthur Cohen <arthur.cohen@embecosm.com>
Thu, 30 Jan 2025 12:08:33 +0000 (13:08 +0100)
committerArthur Cohen <arthur.cohen@embecosm.com>
Mon, 24 Mar 2025 12:06:59 +0000 (13:06 +0100)
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

index e6ef1392c89ecfa7a5fc9e38582a8f36443ef927..0fc203b03189355f6295b345cc87a62bdc92ccd7 100644 (file)
@@ -93,7 +93,8 @@ 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: %qs",