rustc_middle/ty/
elaborate_impl.rs
1use rustc_span::Span;
2use rustc_type_ir::elaborate::Elaboratable;
3
4use crate::ty::{self, TyCtxt};
5
6impl<'tcx> Elaboratable<TyCtxt<'tcx>> for ty::Clause<'tcx> {
7 fn predicate(&self) -> ty::Predicate<'tcx> {
8 self.as_predicate()
9 }
10
11 fn child(&self, clause: ty::Clause<'tcx>) -> Self {
12 clause
13 }
14
15 fn child_with_derived_cause(
16 &self,
17 clause: ty::Clause<'tcx>,
18 _span: Span,
19 _parent_trait_pred: ty::PolyTraitPredicate<'tcx>,
20 _index: usize,
21 ) -> Self {
22 clause
23 }
24}
25
26impl<'tcx> Elaboratable<TyCtxt<'tcx>> for ty::Predicate<'tcx> {
27 fn predicate(&self) -> ty::Predicate<'tcx> {
28 *self
29 }
30
31 fn child(&self, clause: ty::Clause<'tcx>) -> Self {
32 clause.as_predicate()
33 }
34
35 fn child_with_derived_cause(
36 &self,
37 clause: ty::Clause<'tcx>,
38 _span: Span,
39 _parent_trait_pred: ty::PolyTraitPredicate<'tcx>,
40 _index: usize,
41 ) -> Self {
42 clause.as_predicate()
43 }
44}
45
46impl<'tcx> Elaboratable<TyCtxt<'tcx>> for (ty::Predicate<'tcx>, Span) {
47 fn predicate(&self) -> ty::Predicate<'tcx> {
48 self.0
49 }
50
51 fn child(&self, clause: ty::Clause<'tcx>) -> Self {
52 (clause.as_predicate(), self.1)
53 }
54
55 fn child_with_derived_cause(
56 &self,
57 clause: ty::Clause<'tcx>,
58 _span: Span,
59 _parent_trait_pred: ty::PolyTraitPredicate<'tcx>,
60 _index: usize,
61 ) -> Self {
62 (clause.as_predicate(), self.1)
63 }
64}
65
66impl<'tcx> Elaboratable<TyCtxt<'tcx>> for (ty::Clause<'tcx>, Span) {
67 fn predicate(&self) -> ty::Predicate<'tcx> {
68 self.0.as_predicate()
69 }
70
71 fn child(&self, clause: ty::Clause<'tcx>) -> Self {
72 (clause, self.1)
73 }
74
75 fn child_with_derived_cause(
76 &self,
77 clause: ty::Clause<'tcx>,
78 _span: Span,
79 _parent_trait_pred: ty::PolyTraitPredicate<'tcx>,
80 _index: usize,
81 ) -> Self {
82 (clause, self.1)
83 }
84}