File tree Expand file tree Collapse file tree 1 file changed +12
-0
lines changed
compiler/rustc_middle/src/ty Expand file tree Collapse file tree 1 file changed +12
-0
lines changed Original file line number Diff line number Diff line change @@ -478,6 +478,17 @@ impl<'tcx> TyCtxtFeed<'tcx, LocalDefId> {
478
478
/// [rustc dev guide] for more details.
479
479
///
480
480
/// [rustc dev guide]: https://rustc-dev-guide.rust-lang.org/ty.html
481
+ ///
482
+ /// An implementation detail: `TyCtxt` is a wrapper type for [GlobalCtxt],
483
+ /// which is the struct that actually holds all the data. `TyCtxt` derefs to
484
+ /// `GlobalCtxt`, and in practice `TyCtxt` is passed around everywhere, and all
485
+ /// operations are done via `TyCtxt`. A `TyCtxt` is obtained for a `GlobalCtxt`
486
+ /// by calling `enter` with a closure `f`. That function creates both the
487
+ /// `TyCtxt`, and an `ImplicitCtxt` around it that is put into TLS. Within `f`:
488
+ /// - The `ImplicitCtxt` is available implicitly via TLS.
489
+ /// - The `TyCtxt` is available explicitly via the `tcx` parameter, and also
490
+ /// implicitly within the `ImplicitCtxt`. Explicit access is preferred when
491
+ /// possible.
481
492
#[derive(Copy, Clone)]
482
493
#[rustc_diagnostic_item = "TyCtxt"]
483
494
#[rustc_pass_by_value]
@@ -493,6 +504,7 @@ impl<'tcx> Deref for TyCtxt<'tcx> {
493
504
}
494
505
}
495
506
507
+ /// See [TyCtxt] for details about this type.
496
508
pub struct GlobalCtxt<'tcx> {
497
509
pub arena: &'tcx WorkerLocal<Arena<'tcx>>,
498
510
pub hir_arena: &'tcx WorkerLocal<hir::Arena<'tcx>>,
You can’t perform that action at this time.
0 commit comments