]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
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)
committerCohenArthur <arthur.cohen@embecosm.com>
Sun, 2 Feb 2025 18:29:18 +0000 (18:29 +0000)
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 672c7611f5394ee7f2c4745cfda041ea47d8f292..f6a208c939de19290aab6c67c5e0095a13c45c45 100644 (file)
@@ -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 ());
              }
          }