Skip to content

Commit 826055d

Browse files
committed
Document chalk-rust-ir representation of FnDef
1 parent 4b0c376 commit 826055d

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

chalk-rust-ir/src/lib.rs

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,15 +104,45 @@ pub struct StructFlags {
104104
}
105105

106106
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
107+
/// A rust intermediate represention (rust_ir) of a function definition/declaration.
108+
/// For example, in the following rust code:
109+
///
110+
/// ```ignore
111+
/// fn foo<T>() -> i32 where T: Eq;
112+
/// ```
113+
///
114+
/// This would represent the declaration of `foo`.
115+
///
116+
/// Note this is distinct from a function pointer, which points to
117+
/// a function with a given type signature, whereas this represents
118+
/// a specific function definition.
107119
pub struct FnDefDatum<I: Interner> {
108120
pub id: FnDefId<I>,
109121
pub binders: Binders<FnDefDatumBound<I>>,
110122
}
111123

112124
#[derive(Clone, Debug, PartialEq, Eq, Hash, Fold, HasInterner)]
125+
/// Represents the bounds on a `FnDefDatum`, including
126+
/// the function definition's type signature and where clauses.
113127
pub struct FnDefDatumBound<I: Interner> {
128+
/// Types of the function's arguments
129+
/// ```ignore
130+
/// fn foo<T>(bar: i32, baz: T);
131+
/// ^^^ ^
132+
/// ```
133+
///
114134
pub argument_types: Vec<Ty<I>>,
135+
/// Return type of the function
136+
/// ```ignore
137+
/// fn foo<T>() -> i32;
138+
/// ^^^
139+
/// ```
115140
pub return_type: Ty<I>,
141+
/// Where clauses defined on the function
142+
/// ```ignore
143+
/// fn foo<T>() where T: Eq;
144+
/// ^^^^^^^^^^^
145+
/// ```
116146
pub where_clauses: Vec<QuantifiedWhereClause<I>>,
117147
}
118148

0 commit comments

Comments
 (0)