1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
//! Performance suggestions - Detect performance improvement opportunities
//!
//! This module provides suggestions for improving code performance by analyzing
//! data flow patterns, type usage, and ownership semantics.
//!
//! # Available Suggestions
//!
//! | Code | Name | Description |
//! |------|------|-------------|
//! | RP001 | `UnnecessaryClone` | Detect clone() calls where ownership is not needed |
//!
//! # Architecture
//!
//! Performance suggestions leverage multiple analysis layers:
//!
//! ```text
//! ┌─────────────────────────────────────────────────────────────────┐
//! │ Performance Suggest Detection │
//! │ ──────────────────────────── │
//! │ │
//! │ Layer 1: DataFlowGraphV2 (Variable-level flow) │
//! │ ├─ FlowKind::Clone detection │
//! │ ├─ impact() - downstream variable tracking │
//! │ └─ provenance() - upstream value tracking │
//! │ │
//! │ Layer 2: CodeGraphV2 (Symbol-level relationships) │
//! │ └─ callers_chain() - call site analysis │
//! │ │
//! │ Layer 3: TypeFlowGraphV2 (Type relationships) │
//! │ ├─ type_users_chain() - type usage patterns │
//! │ ├─ UsageContext - how types are used │
//! │ └─ RefKind - ownership vs borrowing │
//! └─────────────────────────────────────────────────────────────────┘
//! ```
pub use UnnecessaryClone;
use crate::;
/// Performance diagnostic details: current pattern, suggested pattern, and confidence.
/// Trait for performance-related suggestions
///
/// Provides common utilities for performance detection patterns.