aboutsummaryrefslogtreecommitdiff
path: root/gcc/rust
diff options
context:
space:
mode:
authorPhilip Herron <philip.herron@embecosm.com>2021-06-29 21:24:47 +0100
committerPhilip Herron <philip.herron@embecosm.com>2021-06-29 21:24:47 +0100
commit59897751aa797c9c6e7e1d795bbc1afbb9c81e32 (patch)
treedf151d2709a246dd0d5d2aba94327d7227eb0b30 /gcc/rust
parente0c0ef46d21609326927986f4f8efb0e24638ab9 (diff)
downloadgcc-59897751aa797c9c6e7e1d795bbc1afbb9c81e32.zip
gcc-59897751aa797c9c6e7e1d795bbc1afbb9c81e32.tar.gz
gcc-59897751aa797c9c6e7e1d795bbc1afbb9c81e32.tar.bz2
Revert change to ScanUnused to not scan Types
The scan dead-code pass will take over this role, but lets keep both running for a while and then we can update ScanUnused to only scan for unused labels and variables. Its not possible to rely on name resolution to know what symbols are used or not used. Further resolution occurs during type resolution and the dead code pass runs after type resolution.
Diffstat (limited to 'gcc/rust')
-rw-r--r--gcc/rust/resolve/rust-ast-resolve-unused.h19
1 files changed, 3 insertions, 16 deletions
diff --git a/gcc/rust/resolve/rust-ast-resolve-unused.h b/gcc/rust/resolve/rust-ast-resolve-unused.h
index f60093c..18d02a1 100644
--- a/gcc/rust/resolve/rust-ast-resolve-unused.h
+++ b/gcc/rust/resolve/rust-ast-resolve-unused.h
@@ -19,7 +19,6 @@
#ifndef RUST_AST_RESOLVE_UNUSED_H
#define RUST_AST_RESOLVE_UNUSED_H
-#include "rust-hir-map.h"
#include "rust-ast-resolve-base.h"
namespace Rust {
@@ -36,20 +35,9 @@ public:
bool ok = r->lookup_canonical_path (decl_node_id, &ident);
rust_assert (ok);
- Analysis::Mappings *map = Analysis::Mappings::get ();
- HirId decl_hir_id;
- // ScanUnused is conflicting with the dead code analysis here on types and
- // functions. So just ignoring the warnings of item which will be handled
- // by dead code analysis.
- HIR::Item *found_item = nullptr;
- if (map->lookup_node_to_hir (r->get_crate_num (), decl_node_id,
- &decl_hir_id))
- {
- found_item = map->lookup_hir_item (r->get_crate_num (), decl_hir_id);
- }
-
+ bool name_starts_with_underscore = ident.get ().at (0) == '_';
if (!r->have_references_for_node (decl_node_id)
- && ident.get ().at (0) != '_' && !found_item)
+ && !name_starts_with_underscore)
{
rust_warning_at (locus, 0, "unused name '%s'", ident.get ().c_str ());
}
@@ -61,8 +49,7 @@ public:
{
auto resolver = Resolver::get ();
resolver->iterate_name_ribs ([&] (Rib *r) -> void { ScanRib (r); });
- // ScanUnused is conflicting with the dead code analysis here on types.
- // resolver->iterate_type_ribs ([&] (Rib *r) -> void { ScanRib (r); });
+ resolver->iterate_type_ribs ([&] (Rib *r) -> void { ScanRib (r); });
resolver->iterate_label_ribs ([&] (Rib *r) -> void { ScanRib (r); });
}
};