2
2
//! `ty` form from the HIR.
3
3
4
4
use rustc_hir::LangItem;
5
+ use rustc_middle::ty::Binder;
5
6
use rustc_middle::ty::{self, ToPredicate, Ty, TyCtxt};
6
7
use rustc_span::Span;
7
8
@@ -23,52 +24,58 @@ use rustc_span::Span;
23
24
/// include the self type (e.g., `trait_bounds`) but in others we do not
24
25
#[derive(Default, PartialEq, Eq, Clone, Debug)]
25
26
pub struct Bounds<'tcx> {
26
- pub predicates: Vec<(ty::Predicate <'tcx>, Span)>,
27
+ pub predicates: Vec<(Binder<'tcx, ty::Clause <'tcx> >, Span)>,
27
28
}
28
29
29
30
impl<'tcx> Bounds<'tcx> {
30
31
pub fn push_region_bound(
31
32
&mut self,
32
- tcx : TyCtxt<'tcx>,
33
+ _tcx : TyCtxt<'tcx>,
33
34
region: ty::PolyTypeOutlivesPredicate<'tcx>,
34
35
span: Span,
35
36
) {
36
- self.predicates.push((region.to_predicate(tcx ), span));
37
+ self.predicates.push((region.map_bound(|p| ty::Clause::TypeOutlives(p) ), span));
37
38
}
38
39
39
40
pub fn push_trait_bound(
40
41
&mut self,
41
- tcx : TyCtxt<'tcx>,
42
+ _tcx : TyCtxt<'tcx>,
42
43
trait_ref: ty::PolyTraitRef<'tcx>,
43
44
span: Span,
44
45
constness: ty::BoundConstness,
45
46
polarity: ty::ImplPolarity,
46
47
) {
47
48
self.predicates.push((
48
- trait_ref
49
- .map_bound(|trait_ref| ty::TraitPredicate { trait_ref, constness, polarity })
50
- .to_predicate(tcx ),
49
+ trait_ref.map_bound(|trait_ref| {
50
+ ty::Clause::Trait( ty::TraitPredicate { trait_ref, constness, polarity })
51
+ } ),
51
52
span,
52
53
));
53
54
}
54
55
55
56
pub fn push_projection_bound(
56
57
&mut self,
57
- tcx : TyCtxt<'tcx>,
58
+ _tcx : TyCtxt<'tcx>,
58
59
projection: ty::PolyProjectionPredicate<'tcx>,
59
60
span: Span,
60
61
) {
61
- self.predicates.push((projection.to_predicate(tcx ), span));
62
+ self.predicates.push((projection.map_bound(|proj| ty::Clause::Projection(proj) ), span));
62
63
}
63
64
64
65
pub fn push_sized(&mut self, tcx: TyCtxt<'tcx>, ty: Ty<'tcx>, span: Span) {
65
66
let sized_def_id = tcx.require_lang_item(LangItem::Sized, Some(span));
66
67
let trait_ref = ty::TraitRef::new(tcx, sized_def_id, [ty]);
67
68
// Preferable to put this obligation first, since we report better errors for sized ambiguity.
68
- self.predicates.insert(0, (trait_ref.without_const().to_predicate(tcx), span));
69
+ self.predicates.insert(
70
+ 0,
71
+ (
72
+ ty::Binder::dummy(ty::Clause::Trait(trait_ref.without_const().to_predicate(tcx))),
73
+ span,
74
+ ),
75
+ );
69
76
}
70
77
71
- pub fn predicates(&self) -> impl Iterator<Item = (ty::Predicate <'tcx>, Span)> + '_ {
78
+ pub fn predicates(&self) -> impl Iterator<Item = (Binder<'tcx, ty::Clause <'tcx> >, Span)> + '_ {
72
79
self.predicates.iter().cloned()
73
80
}
74
81
}
0 commit comments