Rollup merge of #151927 - tshepang:patch-1, r=Kivooeo

typeck_root_def_id: improve doc comment

This was initially written to be exhaustive, but one more type that can only be type-checked with its containing item has since been added, and was not mentioned. So, make it future-proof by mentioning just the one example.

Also, a previous refactor left this less readable.
This commit is contained in:
Stuart Cook 2026-02-01 14:26:46 +11:00 committed by GitHub
commit 394e519690
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -642,12 +642,8 @@ impl<'tcx> TyCtxt<'tcx> {
/// has its own type-checking context or "inference environment".
///
/// For example, a closure has its own `DefId`, but it is type-checked
/// with the containing item. Similarly, an inline const block has its
/// own `DefId` but it is type-checked together with the containing item.
///
/// Therefore, when we fetch the
/// `typeck` the closure, for example, we really wind up
/// fetching the `typeck` the enclosing fn item.
/// with the containing item. Therefore, when we fetch the `typeck` of the closure,
/// for example, we really wind up fetching the `typeck` of the enclosing fn item.
pub fn typeck_root_def_id(self, def_id: DefId) -> DefId {
let mut def_id = def_id;
while self.is_typeck_child(def_id) {