Function get_bodies_with_borrowck_facts

Source
pub fn get_bodies_with_borrowck_facts(
    tcx: TyCtxt<'_>,
    root_def_id: LocalDefId,
    options: ConsumerOptions,
) -> FxHashMap<LocalDefId, BodyWithBorrowckFacts<'_>>
Expand description

This function computes borrowck facts for the given def id and all its nested bodies. It must be called with a typeck root which will then borrowck all nested bodies as well. The ConsumerOptions determine which facts are returned. This function makes a copy of the bodies because it needs to regenerate the region identifiers. It should never be invoked during a typical compilation session due to the unnecessary overhead of returning BodyWithBorrowckFacts.

Note:

  • This function will panic if the required bodies were already stolen. This can, for example, happen when requesting a body of a const function because they are evaluated during typechecking. The panic can be avoided by overriding the mir_borrowck query. You can find a complete example that shows how to do this at tests/ui-fulldeps/obtain-borrowck.rs.

  • Polonius is highly unstable, so expect regular changes in its signature or other details.