Why is TyCtxt required for borrow checking?

I’m studying rustc and am currently looking into the rustc_borrowck crate. I noticed that the mir_borrowck function takes a TyCtxt object as an argument. Likewise, the do_mir_borrowck function receives a BorrowCheckRootCtxt, which also contains a TyCtxt.

Why does the borrow-checker need access to a TyCtxt? Isn’t it possible to perform borrow checking using only the MIR body (Body) of the function being checked?

Borrow checking needs to invoke the trait solver among other things, which needs the TyCtxt.

Thank you for your reply!

If I understand your comment correctly, TyCtxt is required for MIR typeck, right? Do you know why this type checking is performed inside the mir_borrowck function? I am interested in the reason why borrowck is not defined only for the MIR body.

Borrowck does MIR typeck to collect all outlives constraints between lifetimes. Among other things borrowck checks if all outlives constraints are satisfiable.

I see. Thank you very much!