@@ -17,13 +17,14 @@ use tracing::instrument;
17
17
18
18
use crate :: thir:: pattern:: pat_from_hir;
19
19
20
+ /// Query implementation for [`TyCtxt::thir_body`].
20
21
pub ( crate ) fn thir_body (
21
22
tcx : TyCtxt < ' _ > ,
22
23
owner_def : LocalDefId ,
23
24
) -> Result < ( & Steal < Thir < ' _ > > , ExprId ) , ErrorGuaranteed > {
24
25
let hir = tcx. hir ( ) ;
25
26
let body = hir. body_owned_by ( owner_def) ;
26
- let mut cx = Cx :: new ( tcx, owner_def) ;
27
+ let mut cx = ThirBuildCx :: new ( tcx, owner_def) ;
27
28
if let Some ( reported) = cx. typeck_results . tainted_by_errors {
28
29
return Err ( reported) ;
29
30
}
@@ -51,8 +52,10 @@ pub(crate) fn thir_body(
51
52
Ok ( ( tcx. alloc_steal_thir ( cx. thir ) , expr) )
52
53
}
53
54
54
- struct Cx < ' tcx > {
55
+ /// Context for lowering HIR to THIR for a single function body (or other kind of body).
56
+ struct ThirBuildCx < ' tcx > {
55
57
tcx : TyCtxt < ' tcx > ,
58
+ /// The THIR data that this context is building.
56
59
thir : Thir < ' tcx > ,
57
60
58
61
typing_env : ty:: TypingEnv < ' tcx > ,
@@ -68,8 +71,8 @@ struct Cx<'tcx> {
68
71
body_owner : DefId ,
69
72
}
70
73
71
- impl < ' tcx > Cx < ' tcx > {
72
- fn new ( tcx : TyCtxt < ' tcx > , def : LocalDefId ) -> Cx < ' tcx > {
74
+ impl < ' tcx > ThirBuildCx < ' tcx > {
75
+ fn new ( tcx : TyCtxt < ' tcx > , def : LocalDefId ) -> Self {
73
76
let typeck_results = tcx. typeck ( def) ;
74
77
let hir = tcx. hir ( ) ;
75
78
let hir_id = tcx. local_def_id_to_hir_id ( def) ;
@@ -93,7 +96,7 @@ impl<'tcx> Cx<'tcx> {
93
96
BodyTy :: Const ( typeck_results. node_type ( hir_id) )
94
97
} ;
95
98
96
- Cx {
99
+ Self {
97
100
tcx,
98
101
thir : Thir :: new ( body_type) ,
99
102
// FIXME(#132279): We're in a body, we should use a typing
0 commit comments