Skip to content

Commit e0f09cd

Browse files
committed
Document the ordering constraint on Binders and Substitution
1 parent 5c79421 commit e0f09cd

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

Diff for: crates/hir-ty/src/lib.rs

+13
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,20 @@ pub type PlaceholderIndex = chalk_ir::PlaceholderIndex;
8181
pub type VariableKind = chalk_ir::VariableKind<Interner>;
8282
pub type VariableKinds = chalk_ir::VariableKinds<Interner>;
8383
pub type CanonicalVarKinds = chalk_ir::CanonicalVarKinds<Interner>;
84+
/// Represents generic parameters and an item bound by them. When the item has parent, the binders
85+
/// also contain the generic parameters for its parent. See chalk's documentation for details.
86+
///
87+
/// One thing to keep in mind when working with `Binders` (and `Substitution`s, which represent
88+
/// generic arguments) in rust-analyzer is that the ordering within *is* significant - the generic
89+
/// parameters/arguments for an item MUST come before those for its parent. This is to facilitate
90+
/// the integration with chalk-solve, which mildly puts constraints as such. See #13335 for its
91+
/// motivation in detail.
8492
pub type Binders<T> = chalk_ir::Binders<T>;
93+
/// Interned list of generic arguments for an item. When an item has parent, the `Substitution` for
94+
/// it contains generic arguments for both its parent and itself. See chalk's documentation for
95+
/// details.
96+
///
97+
/// See `Binders` for the constraint on the ordering.
8598
pub type Substitution = chalk_ir::Substitution<Interner>;
8699
pub type GenericArg = chalk_ir::GenericArg<Interner>;
87100
pub type GenericArgData = chalk_ir::GenericArgData<Interner>;

0 commit comments

Comments
 (0)