33//! This file provides API for compiler consumers.
44
55use rustc_hir:: def_id:: LocalDefId ;
6- use rustc_index:: IndexSlice ;
6+ use rustc_index:: { IndexSlice , IndexVec } ;
77use rustc_infer:: infer:: { DefiningAnchor , TyCtxtInferExt } ;
8- use rustc_middle:: mir:: Body ;
8+ use rustc_middle:: mir:: { Body , Promoted } ;
99use rustc_middle:: ty:: TyCtxt ;
10+ use std:: rc:: Rc ;
11+
12+ use crate :: borrow_set:: BorrowSet ;
1013
1114pub use super :: {
1215 dataflow:: { calculate_borrows_out_of_scope_at_location, BorrowIndex , Borrows } ,
@@ -16,7 +19,6 @@ pub use super::{
1619 place_ext:: PlaceExt ,
1720 places_conflict:: { places_conflict, PlaceConflictBias } ,
1821 region_infer:: RegionInferenceContext ,
19- BodyWithBorrowckFacts ,
2022} ;
2123
2224/// Options determining the output behavior of [`get_body_with_borrowck_facts`].
@@ -56,6 +58,34 @@ impl ConsumerOptions {
5658 }
5759}
5860
61+ /// A `Body` with information computed by the borrow checker. This struct is
62+ /// intended to be consumed by compiler consumers.
63+ ///
64+ /// We need to include the MIR body here because the region identifiers must
65+ /// match the ones in the Polonius facts.
66+ pub struct BodyWithBorrowckFacts < ' tcx > {
67+ /// A mir body that contains region identifiers.
68+ pub body : Body < ' tcx > ,
69+ /// The mir bodies of promoteds.
70+ pub promoted : IndexVec < Promoted , Body < ' tcx > > ,
71+ /// The set of borrows occurring in `body` with data about them.
72+ pub borrow_set : Rc < BorrowSet < ' tcx > > ,
73+ /// Context generated during borrowck, intended to be passed to
74+ /// [`calculate_borrows_out_of_scope_at_location`].
75+ pub region_inference_context : Rc < RegionInferenceContext < ' tcx > > ,
76+ /// The table that maps Polonius points to locations in the table.
77+ /// Populated when using [`ConsumerOptions::PoloniusInputFacts`]
78+ /// or [`ConsumerOptions::PoloniusOutputFacts`].
79+ pub location_table : Option < LocationTable > ,
80+ /// Polonius input facts.
81+ /// Populated when using [`ConsumerOptions::PoloniusInputFacts`]
82+ /// or [`ConsumerOptions::PoloniusOutputFacts`].
83+ pub input_facts : Option < Box < PoloniusInput > > ,
84+ /// Polonius output facts. Populated when using
85+ /// [`ConsumerOptions::PoloniusOutputFacts`].
86+ pub output_facts : Option < Rc < PoloniusOutput > > ,
87+ }
88+
5989/// This function computes borrowck facts for the given body. The [`ConsumerOptions`]
6090/// determine which facts are returned. This function makes a copy of the body because
6191/// it needs to regenerate the region identifiers. It should never be invoked during a
0 commit comments