Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 0aeaa5e

Browse files
committedDec 14, 2024·
Auto merge of rust-lang#134305 - matthiaskrgr:rollup-bja3lsz, r=matthiaskrgr
Rollup of 6 pull requests Successful merges: - rust-lang#133221 (Add external macros specific diagnostics for check-cfg) - rust-lang#133386 (Update linux_musl base to dynamically link the crt by default) - rust-lang#134191 (Make some types and methods related to Polonius + Miri public) - rust-lang#134227 (Update wasi-sdk used to build WASI targets) - rust-lang#134279 ((Re-)return adjustment target if adjust kind is never-to-any) - rust-lang#134295 (Encode coroutine-closures in SMIR) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 85641f7 + b0597b4 commit 0aeaa5e

File tree

55 files changed

+592
-72
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+592
-72
lines changed
 

‎compiler/rustc_borrowck/src/borrow_set.rs

Lines changed: 48 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,25 @@ pub struct BorrowSet<'tcx> {
3434
pub(crate) locals_state_at_exit: LocalsStateAtExit,
3535
}
3636

37+
// These methods are public to support borrowck consumers.
38+
impl<'tcx> BorrowSet<'tcx> {
39+
pub fn location_map(&self) -> &FxIndexMap<Location, BorrowData<'tcx>> {
40+
&self.location_map
41+
}
42+
43+
pub fn activation_map(&self) -> &FxIndexMap<Location, Vec<BorrowIndex>> {
44+
&self.activation_map
45+
}
46+
47+
pub fn local_map(&self) -> &FxIndexMap<mir::Local, FxIndexSet<BorrowIndex>> {
48+
&self.local_map
49+
}
50+
51+
pub fn locals_state_at_exit(&self) -> &LocalsStateAtExit {
52+
&self.locals_state_at_exit
53+
}
54+
}
55+
3756
impl<'tcx> Index<BorrowIndex> for BorrowSet<'tcx> {
3857
type Output = BorrowData<'tcx>;
3958

@@ -45,7 +64,7 @@ impl<'tcx> Index<BorrowIndex> for BorrowSet<'tcx> {
4564
/// Location where a two-phase borrow is activated, if a borrow
4665
/// is in fact a two-phase borrow.
4766
#[derive(Copy, Clone, PartialEq, Eq, Debug)]
48-
pub(crate) enum TwoPhaseActivation {
67+
pub enum TwoPhaseActivation {
4968
NotTwoPhase,
5069
NotActivated,
5170
ActivatedAt(Location),
@@ -68,6 +87,33 @@ pub struct BorrowData<'tcx> {
6887
pub(crate) assigned_place: mir::Place<'tcx>,
6988
}
7089

90+
// These methods are public to support borrowck consumers.
91+
impl<'tcx> BorrowData<'tcx> {
92+
pub fn reserve_location(&self) -> Location {
93+
self.reserve_location
94+
}
95+
96+
pub fn activation_location(&self) -> TwoPhaseActivation {
97+
self.activation_location
98+
}
99+
100+
pub fn kind(&self) -> mir::BorrowKind {
101+
self.kind
102+
}
103+
104+
pub fn region(&self) -> RegionVid {
105+
self.region
106+
}
107+
108+
pub fn borrowed_place(&self) -> mir::Place<'tcx> {
109+
self.borrowed_place
110+
}
111+
112+
pub fn assigned_place(&self) -> mir::Place<'tcx> {
113+
self.assigned_place
114+
}
115+
}
116+
71117
impl<'tcx> fmt::Display for BorrowData<'tcx> {
72118
fn fmt(&self, w: &mut fmt::Formatter<'_>) -> fmt::Result {
73119
let kind = match self.kind {
@@ -120,7 +166,7 @@ impl LocalsStateAtExit {
120166
}
121167

122168
impl<'tcx> BorrowSet<'tcx> {
123-
pub(crate) fn build(
169+
pub fn build(
124170
tcx: TyCtxt<'tcx>,
125171
body: &Body<'tcx>,
126172
locals_are_invalidated_at_exit: bool,

‎compiler/rustc_borrowck/src/consumers.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@ use rustc_index::{IndexSlice, IndexVec};
55
use rustc_middle::mir::{Body, Promoted};
66
use rustc_middle::ty::TyCtxt;
77

8+
pub use super::borrow_set::{BorrowData, BorrowSet, TwoPhaseActivation};
89
pub use super::constraints::OutlivesConstraint;
910
pub use super::dataflow::{BorrowIndex, Borrows, calculate_borrows_out_of_scope_at_location};
10-
pub use super::facts::{AllFacts as PoloniusInput, RustcFacts};
11+
pub use super::facts::{AllFacts as PoloniusInput, PoloniusRegionVid, RustcFacts};
1112
pub use super::location::{LocationTable, RichLocation};
1213
pub use super::nll::PoloniusOutput;
1314
pub use super::place_ext::PlaceExt;
1415
pub use super::places_conflict::{PlaceConflictBias, places_conflict};
1516
pub use super::region_infer::RegionInferenceContext;
16-
use crate::borrow_set::BorrowSet;
1717

1818
/// Options determining the output behavior of [`get_body_with_borrowck_facts`].
1919
///

0 commit comments

Comments
 (0)
This repository has been archived.