Line data Source code
1 : // Copyright (C) 2025-2026 Free Software Foundation, Inc.
2 :
3 : // This file is part of GCC.
4 :
5 : // GCC is free software; you can redistribute it and/or modify it under
6 : // the terms of the GNU General Public License as published by the Free
7 : // Software Foundation; either version 3, or (at your option) any later
8 : // version.
9 :
10 : // GCC is distributed in the hope that it will be useful, but WITHOUT ANY
11 : // WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 : // FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13 : // for more details.
14 :
15 : // You should have received a copy of the GNU General Public License
16 : // along with GCC; see the file COPYING3. If not see
17 : // <http://www.gnu.org/licenses/>.
18 :
19 : #include "rust-hir-expr.h"
20 : #include "rust-hir-generic-param.h"
21 : #include "rust-hir-item.h"
22 : #include "rust-hir-pattern.h"
23 : #include "rust-hir-visitor.h"
24 : #include "rust-unused-collector.h"
25 : #include "rust-immutable-name-resolution-context.h"
26 :
27 : namespace Rust {
28 : namespace Analysis {
29 9 : class UnusedChecker : public HIR::DefaultHIRVisitor
30 : {
31 : public:
32 : UnusedChecker ();
33 : void go (HIR::Crate &crate);
34 :
35 : private:
36 : const Resolver2_0::NameResolutionContext &nr_context;
37 : Analysis::Mappings &mappings;
38 : UnusedContext unused_context;
39 :
40 : using HIR::DefaultHIRVisitor::visit;
41 : virtual void visit (HIR::TraitItemFunc &decl) override;
42 : virtual void visit (HIR::ConstantItem &item) override;
43 : virtual void visit (HIR::StaticItem &item) override;
44 : virtual void visit (HIR::IdentifierPattern &identifier) override;
45 : virtual void visit (HIR::AssignmentExpr &identifier) override;
46 : virtual void visit (HIR::StructPatternFieldIdent &identifier) override;
47 : virtual void visit (HIR::EmptyStmt &stmt) override;
48 : virtual void visit (HIR::Function &fct) override;
49 : virtual void visit (HIR::Module &mod) override;
50 : virtual void visit (HIR::LifetimeParam &lft) override;
51 : virtual void visit_loop_label (HIR::LoopLabel &label) override;
52 : };
53 : } // namespace Analysis
54 : } // namespace Rust
|