|
1 | 1 | use std::assert_matches::assert_matches; |
2 | 2 |
|
3 | 3 | use hir::Node; |
| 4 | +use rustc_attr_data_structures::{AttributeKind, find_attr}; |
4 | 5 | use rustc_data_structures::fx::FxIndexSet; |
5 | 6 | use rustc_hir as hir; |
6 | 7 | use rustc_hir::def::DefKind; |
@@ -318,6 +319,16 @@ fn gather_explicit_predicates_of(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::Gen |
318 | 319 | predicates.extend(const_evaluatable_predicates_of(tcx, def_id, &predicates)); |
319 | 320 | } |
320 | 321 |
|
| 322 | + let attrs = tcx.hir_attrs(tcx.local_def_id_to_hir_id(def_id)); |
| 323 | + let allow_unstable_feature_attr = |
| 324 | + find_attr!(attrs, AttributeKind::AllowUnstableFeature(i) => i) |
| 325 | + .map(|i| i.as_slice()) |
| 326 | + .unwrap_or_default(); |
| 327 | + |
| 328 | + for (feat_name, span) in allow_unstable_feature_attr { |
| 329 | + predicates.insert((ty::ClauseKind::UnstableFeature(*feat_name).upcast(tcx), *span)); |
| 330 | + } |
| 331 | + |
321 | 332 | let mut predicates: Vec<_> = predicates.into_iter().collect(); |
322 | 333 |
|
323 | 334 | // Subtle: before we store the predicates into the tcx, we |
@@ -747,6 +758,7 @@ pub(super) fn assert_only_contains_predicates_from<'tcx>( |
747 | 758 | ty::ClauseKind::RegionOutlives(_) |
748 | 759 | | ty::ClauseKind::ConstArgHasType(_, _) |
749 | 760 | | ty::ClauseKind::WellFormed(_) |
| 761 | + | ty::ClauseKind::UnstableFeature(_) |
750 | 762 | | ty::ClauseKind::ConstEvaluatable(_) => { |
751 | 763 | bug!( |
752 | 764 | "unexpected non-`Self` predicate when computing \ |
@@ -774,6 +786,7 @@ pub(super) fn assert_only_contains_predicates_from<'tcx>( |
774 | 786 | | ty::ClauseKind::ConstArgHasType(_, _) |
775 | 787 | | ty::ClauseKind::WellFormed(_) |
776 | 788 | | ty::ClauseKind::ConstEvaluatable(_) |
| 789 | + | ty::ClauseKind::UnstableFeature(_) |
777 | 790 | | ty::ClauseKind::HostEffect(..) => { |
778 | 791 | bug!( |
779 | 792 | "unexpected non-`Self` predicate when computing \ |
|
0 commit comments