@@ -114,6 +114,8 @@ pub struct Stability {
114114 pub const_stability : Option < Symbol > ,
115115 /// whether the function has a `#[rustc_promotable]` attribute
116116 pub promotable : bool ,
117+ /// whether the function has a `#[rustc_allow_const_fn_ptr]` attribute
118+ pub allow_const_fn_ptr : bool ,
117119}
118120
119121/// The available stability levels.
@@ -178,6 +180,7 @@ fn find_stability_generic<'a, I>(sess: &ParseSess,
178180 let mut rustc_depr: Option < RustcDeprecation > = None ;
179181 let mut rustc_const_unstable: Option < Symbol > = None ;
180182 let mut promotable = false ;
183+ let mut allow_const_fn_ptr = false ;
181184 let diagnostic = & sess. span_diagnostic ;
182185
183186 ' outer: for attr in attrs_iter {
@@ -187,6 +190,7 @@ fn find_stability_generic<'a, I>(sess: &ParseSess,
187190 "unstable" ,
188191 "stable" ,
189192 "rustc_promotable" ,
193+ "rustc_allow_const_fn_ptr" ,
190194 ] . iter ( ) . any ( |& s| attr. path == s) {
191195 continue // not a stability level
192196 }
@@ -198,6 +202,9 @@ fn find_stability_generic<'a, I>(sess: &ParseSess,
198202 if attr. path == "rustc_promotable" {
199203 promotable = true ;
200204 }
205+ if attr. path == "rustc_allow_const_fn_ptr" {
206+ allow_const_fn_ptr = true ;
207+ }
201208 // attributes with data
202209 else if let Some ( MetaItem { node : MetaItemKind :: List ( ref metas) , .. } ) = meta {
203210 let meta = meta. as_ref ( ) . unwrap ( ) ;
@@ -354,6 +361,7 @@ fn find_stability_generic<'a, I>(sess: &ParseSess,
354361 rustc_depr : None ,
355362 const_stability : None ,
356363 promotable : false ,
364+ allow_const_fn_ptr : false ,
357365 } )
358366 }
359367 ( None , _, _) => {
@@ -418,6 +426,7 @@ fn find_stability_generic<'a, I>(sess: &ParseSess,
418426 rustc_depr : None ,
419427 const_stability : None ,
420428 promotable : false ,
429+ allow_const_fn_ptr : false ,
421430 } )
422431 }
423432 ( None , _) => {
@@ -458,13 +467,14 @@ fn find_stability_generic<'a, I>(sess: &ParseSess,
458467 }
459468
460469 // Merge the const-unstable info into the stability info
461- if promotable {
470+ if promotable || allow_const_fn_ptr {
462471 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;
464474 } else {
465475 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") ;
468478 }
469479 }
470480
0 commit comments