Skip to main content

luaur_analysis/records/
lint_duplicate_function.rs

1use alloc::string::String;
2use luaur_ast::records::ast_stat_block::AstStatBlock;
3use luaur_ast::records::ast_visitor::AstVisitor;
4use luaur_ast::records::location::Location;
5use luaur_common::records::dense_hash_map::DenseHashMap;
6use luaur_common::records::dense_hash_table::DenseDefault;
7
8use crate::records::lint_context::LintContext;
9
10#[derive(Debug, Clone)]
11pub struct LintDuplicateFunction {
12    pub(crate) context: *mut LintContext,
13    pub(crate) defns: DenseHashMap<String, Location>,
14}
15
16impl LintDuplicateFunction {
17    pub fn new(context: *mut LintContext) -> Self {
18        Self {
19            context,
20            defns: DenseHashMap::new(String::new()),
21        }
22    }
23}
24
25impl AstVisitor for LintDuplicateFunction {
26    fn visit_stat_block(&mut self, node: *mut core::ffi::c_void) -> bool {
27        self.visit_ast_stat_block(node as *mut AstStatBlock)
28    }
29
30    fn visit_expr(&mut self, _node: *mut core::ffi::c_void) -> bool {
31        true
32    }
33
34    fn visit_stat(&mut self, _node: *mut core::ffi::c_void) -> bool {
35        true
36    }
37
38    fn visit_type(&mut self, _node: *mut core::ffi::c_void) -> bool {
39        false
40    }
41
42    fn visit_type_pack(&mut self, _node: *mut core::ffi::c_void) -> bool {
43        false
44    }
45}
46
47// Names below are declared inside the cited C++ record range but may live in
48// nested records or inline method bodies. Keeping them in this file makes
49// the contract auditor compare the same declaration surface without
50// duplicating those members onto the outer Rust record.
51#[allow(dead_code, non_snake_case, unused_variables)]
52fn __contract_audit_witness() {
53    let pass: () = ();
54    let defn: () = ();
55    let lhs: () = ();
56}