1 use rustc_data_structures
::fx
::FxHashMap
;
2 use rustc_hir
::def_id
::DefId
;
3 use rustc_middle
::ty
::{self, OutlivesPredicate, TyCtxt}
;
8 pub struct ExplicitPredicatesMap
<'tcx
> {
9 map
: FxHashMap
<DefId
, RequiredPredicates
<'tcx
>>,
12 impl<'tcx
> ExplicitPredicatesMap
<'tcx
> {
13 pub fn new() -> ExplicitPredicatesMap
<'tcx
> {
14 ExplicitPredicatesMap { map: FxHashMap::default() }
17 pub fn explicit_predicates_of(
21 ) -> &RequiredPredicates
<'tcx
> {
22 self.map
.entry(def_id
).or_insert_with(|| {
23 let predicates
= if def_id
.is_local() {
24 tcx
.explicit_predicates_of(def_id
)
26 tcx
.predicates_of(def_id
)
28 let mut required_predicates
= RequiredPredicates
::default();
30 // process predicates and convert to `RequiredPredicates` entry, see below
31 for &(predicate
, span
) in predicates
.predicates
{
32 match predicate
.skip_binders() {
33 ty
::PredicateAtom
::TypeOutlives(OutlivesPredicate(ref ty
, ref reg
)) => {
34 insert_outlives_predicate(
39 &mut required_predicates
,
43 ty
::PredicateAtom
::RegionOutlives(OutlivesPredicate(ref reg1
, ref reg2
)) => {
44 insert_outlives_predicate(
49 &mut required_predicates
,
53 ty
::PredicateAtom
::Trait(..)
54 | ty
::PredicateAtom
::Projection(..)
55 | ty
::PredicateAtom
::WellFormed(..)
56 | ty
::PredicateAtom
::ObjectSafe(..)
57 | ty
::PredicateAtom
::ClosureKind(..)
58 | ty
::PredicateAtom
::Subtype(..)
59 | ty
::PredicateAtom
::ConstEvaluatable(..)
60 | ty
::PredicateAtom
::ConstEquate(..) => (),