@@ -9,7 +9,7 @@ use rustc_middle::ty::{
9
9
self , GenericPredicates , ImplTraitInTraitData , Ty , TyCtxt , TypeVisitable , TypeVisitor , Upcast ,
10
10
} ;
11
11
use rustc_middle:: { bug, span_bug} ;
12
- use rustc_span:: { DUMMY_SP , Ident , Span , sym } ;
12
+ use rustc_span:: { DUMMY_SP , Ident , Span } ;
13
13
use tracing:: { debug, instrument, trace} ;
14
14
15
15
use super :: item_bounds:: explicit_item_bounds_with_filter;
@@ -18,6 +18,9 @@ use crate::constrained_generic_params as cgp;
18
18
use crate :: delegation:: inherit_predicates_for_delegation_item;
19
19
use crate :: hir_ty_lowering:: { HirTyLowerer , PredicateFilter , RegionInferReason } ;
20
20
21
+
22
+ use rustc_attr_data_structures:: { AttributeKind , find_attr} ;
23
+
21
24
/// Returns a list of all type predicates (explicit and implicit) for the definition with
22
25
/// ID `def_id`. This includes all predicates returned by `explicit_predicates_of`, plus
23
26
/// inferred constraints concerning which regions outlive other regions.
@@ -318,18 +321,18 @@ fn gather_explicit_predicates_of(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::Gen
318
321
predicates. extend ( const_evaluatable_predicates_of ( tcx, def_id, & predicates) ) ;
319
322
}
320
323
321
- for attr in tcx. get_attrs ( def_id, sym :: unstable_feature_bound ) {
322
- if let Some ( list ) = attr . meta_item_list ( ) {
323
- for item in list . iter ( ) {
324
- if let Some ( feature_name ) = item . name ( ) {
325
- predicates . insert ( (
326
- ty :: ClauseKind :: UnstableFeature ( feature_name ) . upcast ( tcx ) ,
327
- tcx . def_span ( def_id ) ,
328
- ) ) ;
329
- }
330
- }
331
- }
332
- }
324
+ let attrs = tcx. hir_attrs ( tcx . local_def_id_to_hir_id ( def_id) ) ;
325
+ let allow_unstable_feature_attr =
326
+ find_attr ! ( attrs , AttributeKind :: AllowUnstableFeature ( i ) => i )
327
+ . map ( |i| i . as_slice ( ) )
328
+ . unwrap_or_default ( ) ;
329
+
330
+ for ( feat_name , span ) in allow_unstable_feature_attr {
331
+ predicates . insert ( (
332
+ ty :: ClauseKind :: UnstableFeature ( * feat_name ) . upcast ( tcx ) ,
333
+ * span
334
+ ) ) ;
335
+ }
333
336
334
337
let mut predicates: Vec < _ > = predicates. into_iter ( ) . collect ( ) ;
335
338
0 commit comments