Skip to content

Commit dbe5392

Browse files
committed
Auto merge of #15760 - ChristianSchott:master, r=HKalbasi
make mir::ProjectionStore-impls pub-accessible When using RA as a crate the `mir::Place` `projection` is accessible, however there is no way to translate the `ProjectionId` to a `&[PlaceElem]`, as the `ProjectionId::lookup` is private. Personally, I would only need the `ProjectionId::lookup`-fn to be `pub`, but I don't see any reason why the others should be kept private.. am I missing something `@HKalbasi` ? Relates to: rust-lang/rust-analyzer#15575
2 parents 16ac6c2 + 8217ff9 commit dbe5392

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

crates/hir-ty/src/mir.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -243,16 +243,16 @@ impl Default for ProjectionStore {
243243
}
244244

245245
impl ProjectionStore {
246-
fn shrink_to_fit(&mut self) {
246+
pub fn shrink_to_fit(&mut self) {
247247
self.id_to_proj.shrink_to_fit();
248248
self.proj_to_id.shrink_to_fit();
249249
}
250250

251-
fn intern_if_exist(&self, projection: &[PlaceElem]) -> Option<ProjectionId> {
251+
pub fn intern_if_exist(&self, projection: &[PlaceElem]) -> Option<ProjectionId> {
252252
self.proj_to_id.get(projection).copied()
253253
}
254254

255-
fn intern(&mut self, projection: Box<[PlaceElem]>) -> ProjectionId {
255+
pub fn intern(&mut self, projection: Box<[PlaceElem]>) -> ProjectionId {
256256
let new_id = ProjectionId(self.proj_to_id.len() as u32);
257257
match self.proj_to_id.entry(projection) {
258258
Entry::Occupied(id) => *id.get(),
@@ -267,13 +267,13 @@ impl ProjectionStore {
267267
}
268268

269269
impl ProjectionId {
270-
const EMPTY: ProjectionId = ProjectionId(0);
270+
pub const EMPTY: ProjectionId = ProjectionId(0);
271271

272-
fn lookup(self, store: &ProjectionStore) -> &[PlaceElem] {
272+
pub fn lookup(self, store: &ProjectionStore) -> &[PlaceElem] {
273273
store.id_to_proj.get(&self).unwrap()
274274
}
275275

276-
fn project(self, projection: PlaceElem, store: &mut ProjectionStore) -> ProjectionId {
276+
pub fn project(self, projection: PlaceElem, store: &mut ProjectionStore) -> ProjectionId {
277277
let mut current = self.lookup(store).to_vec();
278278
current.push(projection);
279279
store.intern(current.into())

0 commit comments

Comments
 (0)