@@ -9,7 +9,7 @@ use rustc_middle::ty::{
99 self , GenericPredicates , ImplTraitInTraitData , Ty , TyCtxt , TypeVisitable , TypeVisitor , Upcast ,
1010} ;
1111use rustc_middle:: { bug, span_bug} ;
12- use rustc_span:: { DUMMY_SP , Ident , Span , sym } ;
12+ use rustc_span:: { DUMMY_SP , Ident , Span } ;
1313use tracing:: { debug, instrument, trace} ;
1414
1515use super :: item_bounds:: explicit_item_bounds_with_filter;
@@ -18,6 +18,9 @@ use crate::constrained_generic_params as cgp;
1818use crate :: delegation:: inherit_predicates_for_delegation_item;
1919use crate :: hir_ty_lowering:: { HirTyLowerer , PredicateFilter , RegionInferReason } ;
2020
21+
22+ use rustc_attr_data_structures:: { AttributeKind , find_attr} ;
23+
2124/// Returns a list of all type predicates (explicit and implicit) for the definition with
2225/// ID `def_id`. This includes all predicates returned by `explicit_predicates_of`, plus
2326/// inferred constraints concerning which regions outlive other regions.
@@ -318,18 +321,18 @@ fn gather_explicit_predicates_of(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::Gen
318321 predicates. extend ( const_evaluatable_predicates_of ( tcx, def_id, & predicates) ) ;
319322 }
320323
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+ }
333336
334337 let mut predicates: Vec < _ > = predicates. into_iter ( ) . collect ( ) ;
335338
0 commit comments