Skip to content

Commit 1f75142

Browse files
committed
Add some high-level docs to FnCtxt and ItemCtxt
I haven't understood the difference between these before, but `@compiler-errors` helped me clear it up. Hopefully this will help other people who've been confused!
1 parent 93ab13b commit 1f75142

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

compiler/rustc_typeck/src/check/fn_ctxt/mod.rs

+2
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ use rustc_trait_selection::traits::{ObligationCause, ObligationCauseCode};
2626
use std::cell::{Cell, RefCell};
2727
use std::ops::Deref;
2828

29+
/// The `FnCtxt` stores type-checking context needed to type-check function bodies,
30+
/// in contrast to [`ItemCtxt`], which is used to type-check item *signatures*.
2931
pub struct FnCtxt<'a, 'tcx> {
3032
pub(super) body_id: hir::HirId,
3133

compiler/rustc_typeck/src/collect.rs

+6-1
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,12 @@ pub fn provide(providers: &mut Providers) {
9494
///////////////////////////////////////////////////////////////////////////
9595

9696
/// Context specific to some particular item. This is what implements
97-
/// `AstConv`. It has information about the predicates that are defined
97+
/// `AstConv`.
98+
///
99+
/// `ItemCtxt` is primarily used to type-check item signatures, in contrast to [`FnCtxt`],
100+
/// which is used to type-check function bodies.
101+
///
102+
/// It has information about the predicates that are defined
98103
/// on the trait. Unfortunately, this predicate information is
99104
/// available in various different forms at various points in the
100105
/// process. So we can't just store a pointer to e.g., the AST or the

0 commit comments

Comments
 (0)