Skip to content

Commit 8c262fc

Browse files
committed
Lower the unstable feature bound attribute to UnstableFeature predicate
1 parent e144c89 commit 8c262fc

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

compiler/rustc_hir_analysis/src/collect/predicates_of.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
use std::assert_matches::assert_matches;
22

33
use hir::Node;
4+
use rustc_attr_data_structures::{AttributeKind, find_attr};
45
use rustc_data_structures::fx::FxIndexSet;
56
use rustc_hir as hir;
67
use rustc_hir::def::DefKind;
@@ -333,6 +334,19 @@ fn gather_explicit_predicates_of(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::Gen
333334
predicates.extend(const_evaluatable_predicates_of(tcx, def_id, &predicates));
334335
}
335336

337+
let attrs = tcx.hir_attrs(tcx.local_def_id_to_hir_id(def_id));
338+
// FIXME(staged_api): We might want to look at the normal stability attributes too but
339+
// first we would need a way to let std/core use APIs with unstable feature bounds from
340+
// within stable APIs.
341+
let allow_unstable_feature_attr =
342+
find_attr!(attrs, AttributeKind::UnstableFeatureBound(i) => i)
343+
.map(|i| i.as_slice())
344+
.unwrap_or_default();
345+
346+
for (feat_name, span) in allow_unstable_feature_attr {
347+
predicates.insert((ty::ClauseKind::UnstableFeature(*feat_name).upcast(tcx), *span));
348+
}
349+
336350
let mut predicates: Vec<_> = predicates.into_iter().collect();
337351

338352
// Subtle: before we store the predicates into the tcx, we

0 commit comments

Comments
 (0)