@@ -48,47 +48,47 @@ Macros
48
48
// Compliant implementation
49
49
}
50
50
51
- .. guideline :: Shall not use Procedural Macros
52
- :id: gui_m6BKTDzO2rdL
53
- :category: mandatory
51
+ .. guideline :: Procedural macros should not be used
52
+ :id: gui_66FSqzD55VRZ
53
+ :category: advisory
54
54
:status: draft
55
- :release: todo
55
+ :release: 1.85.0;1.85.1
56
56
:fls: fls_wn1i6hzg2ff7
57
57
:decidability: decidable
58
- :scope: system
59
- :tags: reduce-human-error
58
+ :scope: crate
59
+ :tags: readability, reduce-human-error
60
60
61
- Description of the guideline goes here.
61
+ Macros should be expressed using declarative syntax
62
+ in preference to procedural syntax.
62
63
63
64
.. rationale ::
64
- :id: rat_kAcNBmDhJ5W8
65
+ :id: rat_AmCavSymv3Ev
65
66
:status: draft
66
67
67
- Explanation of why this guideline is important.
68
+ Procedural macros are not restricted to pure transcription and can contain arbitrary Rust code.
69
+ This means they can be harder to understand, and cannot be as easily proved to work as intended.
70
+ Procedural macros can have arbitrary side effects, which can exhaust compiler resources or
71
+ expose a vulnerability for users of adopted code.
68
72
69
73
.. non_compliant_example ::
70
- :id: non_compl_ex_xhIwlJPZYbVb
74
+ :id: non_compl_ex_pJhVZW6a1HP9
71
75
:status: draft
72
76
73
- Explanation of code example.
77
+ (example of a simple expansion using a proc-macro)
74
78
75
79
.. code-block :: rust
76
80
77
- fn example_function() {
78
- // Non-compliant implementation
79
- }
81
+ // TODO
80
82
81
83
.. compliant_example ::
82
- :id: compl_ex_JxmIfJ7plkEf
84
+ :id: compl_ex_4VFyucETB7C3
83
85
:status: draft
84
86
85
- Explanation of code example.
87
+ (example of the same simple expansion using a declarative macro)
86
88
87
89
.. code-block :: rust
88
90
89
- fn example_function() {
90
- // Compliant implementation
91
- }
91
+ // TODO
92
92
93
93
.. guideline :: Shall not invoke macros
94
94
:id: gui_a1mHfjgKk4Xr
0 commit comments