@@ -138,7 +138,7 @@ pub enum StabilityLevel {
138
138
/// `#[unstable]`
139
139
Unstable {
140
140
/// Reason for the current stability level.
141
- reason : Option < Symbol > ,
141
+ reason : UnstableReason ,
142
142
/// Relevant `rust-lang/rust` issue.
143
143
issue : Option < NonZeroU32 > ,
144
144
is_soft : bool ,
@@ -182,6 +182,32 @@ impl StabilityLevel {
182
182
}
183
183
}
184
184
185
+ #[ derive( Encodable , Decodable , PartialEq , Copy , Clone , Debug , Eq , Hash ) ]
186
+ #[ derive( HashStable_Generic ) ]
187
+ pub enum UnstableReason {
188
+ None ,
189
+ Default ,
190
+ Some ( Symbol ) ,
191
+ }
192
+
193
+ impl UnstableReason {
194
+ fn from_opt_reason ( reason : Option < Symbol > ) -> Self {
195
+ // UnstableReason::Default constructed manually
196
+ match reason {
197
+ Some ( r) => Self :: Some ( r) ,
198
+ None => Self :: None ,
199
+ }
200
+ }
201
+
202
+ pub fn to_opt_reason ( & self ) -> Option < Symbol > {
203
+ match self {
204
+ Self :: None => None ,
205
+ Self :: Default => Some ( sym:: unstable_location_reason_default) ,
206
+ Self :: Some ( r) => Some ( * r) ,
207
+ }
208
+ }
209
+ }
210
+
185
211
/// Collects stability info from all stability attributes in `attrs`.
186
212
/// Returns `None` if no stability attributes are found.
187
213
pub fn find_stability (
@@ -371,7 +397,12 @@ where
371
397
) ;
372
398
continue ;
373
399
}
374
- let level = Unstable { reason, issue : issue_num, is_soft, implied_by } ;
400
+ let level = Unstable {
401
+ reason : UnstableReason :: from_opt_reason ( reason) ,
402
+ issue : issue_num,
403
+ is_soft,
404
+ implied_by,
405
+ } ;
375
406
if sym:: unstable == meta_name {
376
407
stab = Some ( ( Stability { level, feature } , attr. span ) ) ;
377
408
} else {
0 commit comments