@@ -114,6 +114,8 @@ pub struct Stability {
114
114
pub const_stability : Option < Symbol > ,
115
115
/// whether the function has a `#[rustc_promotable]` attribute
116
116
pub promotable : bool ,
117
+ /// whether the function has a `#[rustc_allow_const_fn_ptr]` attribute
118
+ pub allow_const_fn_ptr : bool ,
117
119
}
118
120
119
121
/// The available stability levels.
@@ -178,6 +180,7 @@ fn find_stability_generic<'a, I>(sess: &ParseSess,
178
180
let mut rustc_depr: Option < RustcDeprecation > = None ;
179
181
let mut rustc_const_unstable: Option < Symbol > = None ;
180
182
let mut promotable = false ;
183
+ let mut allow_const_fn_ptr = false ;
181
184
let diagnostic = & sess. span_diagnostic ;
182
185
183
186
' outer: for attr in attrs_iter {
@@ -187,6 +190,7 @@ fn find_stability_generic<'a, I>(sess: &ParseSess,
187
190
"unstable" ,
188
191
"stable" ,
189
192
"rustc_promotable" ,
193
+ "rustc_allow_const_fn_ptr" ,
190
194
] . iter ( ) . any ( |& s| attr. path == s) {
191
195
continue // not a stability level
192
196
}
@@ -198,6 +202,9 @@ fn find_stability_generic<'a, I>(sess: &ParseSess,
198
202
if attr. path == "rustc_promotable" {
199
203
promotable = true ;
200
204
}
205
+ if attr. path == "rustc_allow_const_fn_ptr" {
206
+ allow_const_fn_ptr = true ;
207
+ }
201
208
// attributes with data
202
209
else if let Some ( MetaItem { node : MetaItemKind :: List ( ref metas) , .. } ) = meta {
203
210
let meta = meta. as_ref ( ) . unwrap ( ) ;
@@ -354,6 +361,7 @@ fn find_stability_generic<'a, I>(sess: &ParseSess,
354
361
rustc_depr : None ,
355
362
const_stability : None ,
356
363
promotable : false ,
364
+ allow_const_fn_ptr : false ,
357
365
} )
358
366
}
359
367
( None , _, _) => {
@@ -418,6 +426,7 @@ fn find_stability_generic<'a, I>(sess: &ParseSess,
418
426
rustc_depr : None ,
419
427
const_stability : None ,
420
428
promotable : false ,
429
+ allow_const_fn_ptr : false ,
421
430
} )
422
431
}
423
432
( None , _) => {
@@ -458,13 +467,14 @@ fn find_stability_generic<'a, I>(sess: &ParseSess,
458
467
}
459
468
460
469
// Merge the const-unstable info into the stability info
461
- if promotable {
470
+ if promotable || allow_const_fn_ptr {
462
471
if let Some ( ref mut stab) = stab {
463
- stab. promotable = true ;
472
+ stab. promotable = promotable;
473
+ stab. allow_const_fn_ptr = allow_const_fn_ptr;
464
474
} else {
465
475
span_err ! ( diagnostic, item_sp, E0717 ,
466
- "rustc_promotable attribute must be paired with \
467
- either stable or unstable attribute") ;
476
+ "rustc_promotable and rustc_allow_const_fn_ptr attributes \
477
+ must be paired with either stable or unstable attribute") ;
468
478
}
469
479
}
470
480
0 commit comments