3
3
//! This file provides API for compiler consumers.
4
4
5
5
use rustc_hir:: def_id:: LocalDefId ;
6
- use rustc_index:: IndexSlice ;
6
+ use rustc_index:: { IndexSlice , IndexVec } ;
7
7
use rustc_infer:: infer:: { DefiningAnchor , TyCtxtInferExt } ;
8
- use rustc_middle:: mir:: Body ;
8
+ use rustc_middle:: mir:: { Body , Promoted } ;
9
9
use rustc_middle:: ty:: TyCtxt ;
10
+ use std:: rc:: Rc ;
11
+
12
+ use crate :: borrow_set:: BorrowSet ;
10
13
11
14
pub use super :: {
12
15
dataflow:: { calculate_borrows_out_of_scope_at_location, BorrowIndex , Borrows } ,
@@ -16,7 +19,6 @@ pub use super::{
16
19
place_ext:: PlaceExt ,
17
20
places_conflict:: { places_conflict, PlaceConflictBias } ,
18
21
region_infer:: RegionInferenceContext ,
19
- BodyWithBorrowckFacts ,
20
22
} ;
21
23
22
24
/// Options determining the output behavior of [`get_body_with_borrowck_facts`].
@@ -56,6 +58,34 @@ impl ConsumerOptions {
56
58
}
57
59
}
58
60
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
+
59
89
/// This function computes borrowck facts for the given body. The [`ConsumerOptions`]
60
90
/// determine which facts are returned. This function makes a copy of the body because
61
91
/// it needs to regenerate the region identifiers. It should never be invoked during a
0 commit comments