Skip to content

Commit cbd5ba0

Browse files
committed
Add documentation to trait data
1 parent eb257f4 commit cbd5ba0

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

chalk-solve/src/rust_ir.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,21 @@ pub struct AssociatedTyValueId<I: Interner>(pub I::DefId);
2222
chalk_ir::id_visit!(AssociatedTyValueId);
2323
chalk_ir::id_fold!(AssociatedTyValueId);
2424

25+
/// Data about a trait implementation.
2526
#[derive(Clone, Debug, PartialEq, Eq, Hash, Visit)]
2627
pub struct ImplDatum<I: Interner> {
28+
/// Whether this is an `impl Trait` or `impl !Trait`
2729
pub polarity: Polarity,
30+
/// Bindings of variables from the where clauses in the trait.
2831
pub binders: Binders<ImplDatumBound<I>>,
32+
/// Whether this impl is local to this crate or from an external crate
2933
pub impl_type: ImplType,
34+
/// IDs for associated types `type T = SomeTy`
3035
pub associated_ty_value_ids: Vec<AssociatedTyValueId<I>>,
3136
}
3237

3338
impl<I: Interner> ImplDatum<I> {
39+
/// True if this is an `impl Trait`, false if `impl !Trait`
3440
pub fn is_positive(&self) -> bool {
3541
self.polarity.is_positive()
3642
}
@@ -39,6 +45,7 @@ impl<I: Interner> ImplDatum<I> {
3945
self.binders.skip_binders().trait_ref.trait_id
4046
}
4147

48+
/// Gets the [`AdtId`] for the `Self` type of this impl.
4249
pub fn self_type_adt_id(&self, interner: &I) -> Option<AdtId<I>> {
4350
match self
4451
.binders
@@ -59,6 +66,7 @@ pub struct ImplDatumBound<I: Interner> {
5966
pub where_clauses: Vec<QuantifiedWhereClause<I>>,
6067
}
6168

69+
/// Whether this impl is local to this crate or from an external crate
6270
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)]
6371
pub enum ImplType {
6472
Local,
@@ -712,7 +720,9 @@ pub struct GeneratorWitnessExistential<I: Interner> {
712720

713721
#[derive(Copy, Clone, PartialEq, Eq, Hash, PartialOrd, Ord, Debug)]
714722
pub enum Polarity {
723+
/// `impl Trait for ..`
715724
Positive,
725+
/// `impl !Trait for ..`
716726
Negative,
717727
}
718728

0 commit comments

Comments
 (0)