Skip to content

Commit 6233993

Browse files
varkorAvi-D-coder
authored andcommitted
Add a comment explaining how to go about handling stability attribute on a new node
1 parent f5edbe9 commit 6233993

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

src/librustc_passes/stability.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,20 @@ use std::cmp::Ordering;
2626
use std::mem::replace;
2727
use std::num::NonZeroU32;
2828

29+
/// *** Adding stability attributes to a new kind of node ***
30+
///
31+
/// 1. In `<Annotator as Visitor>`, visit the node and call `self.annotate` to record the new
32+
/// stability attribute. This will also do some validity checking for the attributes.
33+
/// 2. If stability attributes should be required, visit the node in
34+
/// `<MissingStabilityAnnotations as Visitor>` and call `self.check_missing_stability`.
35+
/// 3. If using `check_missing_stability`, you'll also need to make sure the node is reachable. In
36+
/// `ReachableContext::propagate_node` in `src/librustc_passes/reachable.rs`, make sure the node
37+
/// is handled. Then, in `<EmbargoVisitor as Visitor>` in `src/librustc_privacy`, visit the node
38+
/// and call `self.reach`.
39+
/// 4. Finally, we need to make sure that stability information is recorded in crate metadata. In
40+
/// `src/librustc_metadata/rmeta/encoder.rs`, make sure that `self.encode_stability(def_id)` is
41+
/// called in the relevant `encode_info_for_[your node]` method.
42+
2943
#[derive(PartialEq)]
3044
enum AnnotationKind {
3145
// Annotation is required if not inherited from unstable parents.

0 commit comments

Comments
 (0)