Skip to content

Commit 393fa4f

Browse files
committed
rename from item_mir to optimized_mir
1 parent c7023d1 commit 393fa4f

File tree

11 files changed

+33
-42
lines changed

11 files changed

+33
-42
lines changed

src/librustc/ty/maps.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,7 @@ impl<'tcx> QueryDescription for queries::const_is_rvalue_promotable_to_static<'t
333333
}
334334
}
335335

336-
impl<'tcx> QueryDescription for queries::is_item_mir_available<'tcx> {
336+
impl<'tcx> QueryDescription for queries::is_mir_available<'tcx> {
337337
fn describe(tcx: TyCtxt, def_id: DefId) -> String {
338338
format!("checking if item is mir available: `{}`",
339339
tcx.item_path_str(def_id))
@@ -770,7 +770,7 @@ define_maps! { <'tcx>
770770

771771
[] item_body_nested_bodies: metadata_dep_node(DefId) -> Rc<BTreeMap<hir::BodyId, hir::Body>>,
772772
[] const_is_rvalue_promotable_to_static: metadata_dep_node(DefId) -> bool,
773-
[] is_item_mir_available: metadata_dep_node(DefId) -> bool,
773+
[] is_mir_available: metadata_dep_node(DefId) -> bool,
774774
}
775775

776776
fn coherent_trait_dep_node((_, def_id): (CrateNum, DefId)) -> DepNode<DefId> {

src/librustc/ty/mod.rs

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2324,18 +2324,13 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
23242324
}
23252325
}
23262326

2327-
/// Given the did of an item, returns its (optimized) MIR, borrowed immutably.
2328-
pub fn item_mir(self, did: DefId) -> &'gcx Mir<'gcx> {
2329-
self.optimized_mir(did)
2330-
}
2331-
23322327
/// Return the possibly-auto-generated MIR of a (DefId, Subst) pair.
23332328
pub fn instance_mir(self, instance: ty::InstanceDef<'gcx>)
23342329
-> &'gcx Mir<'gcx>
23352330
{
23362331
match instance {
23372332
ty::InstanceDef::Item(did) => {
2338-
self.item_mir(did)
2333+
self.optimized_mir(did)
23392334
}
23402335
ty::InstanceDef::Intrinsic(..) |
23412336
ty::InstanceDef::FnPtrShim(..) |
@@ -2349,16 +2344,12 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
23492344

23502345
/// Given the DefId of an item, returns its MIR, borrowed immutably.
23512346
/// Returns None if there is no MIR for the DefId
2352-
pub fn maybe_item_mir(self, did: DefId) -> Option<&'gcx Mir<'gcx>> {
2353-
if did.is_local() && !self.mir_keys(LOCAL_CRATE).contains(&did) {
2354-
return None;
2355-
}
2356-
2357-
if !did.is_local() && !self.is_item_mir_available(did) {
2358-
return None;
2347+
pub fn maybe_optimized_mir(self, did: DefId) -> Option<&'gcx Mir<'gcx>> {
2348+
if self.is_mir_available(did) {
2349+
Some(self.optimized_mir(did))
2350+
} else {
2351+
None
23592352
}
2360-
2361-
Some(self.item_mir(did))
23622353
}
23632354

23642355
/// Get the attributes of a definition.

src/librustc_metadata/cstore_impl.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,8 @@ provide! { <'tcx> tcx, def_id, cdata
9595
})
9696
}
9797
optimized_mir => {
98-
let mir = cdata.maybe_get_item_mir(tcx, def_id.index).unwrap_or_else(|| {
99-
bug!("get_item_mir: missing MIR for `{:?}`", def_id)
98+
let mir = cdata.maybe_get_optimized_mir(tcx, def_id.index).unwrap_or_else(|| {
99+
bug!("get_optimized_mir: missing MIR for `{:?}`", def_id)
100100
});
101101

102102
let mir = tcx.alloc_mir(mir);
@@ -122,7 +122,7 @@ provide! { <'tcx> tcx, def_id, cdata
122122
cdata.entry(def_id.index).ast.expect("const item missing `ast`")
123123
.decode(cdata).rvalue_promotable_to_static
124124
}
125-
is_item_mir_available => {
125+
is_mir_available => {
126126
!cdata.is_proc_macro(def_id.index) &&
127127
cdata.maybe_entry(def_id.index).and_then(|item| item.decode(cdata).mir).is_some()
128128
}

src/librustc_metadata/decoder.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -779,10 +779,10 @@ impl<'a, 'tcx> CrateMetadata {
779779
tcx.alloc_tables(ast.tables.decode((self, tcx)))
780780
}
781781

782-
pub fn maybe_get_item_mir(&self,
783-
tcx: TyCtxt<'a, 'tcx, 'tcx>,
784-
id: DefIndex)
785-
-> Option<Mir<'tcx>> {
782+
pub fn maybe_get_optimized_mir(&self,
783+
tcx: TyCtxt<'a, 'tcx, 'tcx>,
784+
id: DefIndex)
785+
-> Option<Mir<'tcx>> {
786786
match self.is_proc_macro(id) {
787787
true => None,
788788
false => self.entry(id).mir.map(|mir| mir.decode((self, tcx))),

src/librustc_metadata/encoder.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@ impl<'a, 'b: 'a, 'tcx: 'b> EntryBuilder<'a, 'b, 'tcx> {
295295
predicates: Some(self.encode_predicates(def_id)),
296296

297297
ast: None,
298-
mir: self.encode_mir(def_id),
298+
mir: self.encode_optimized_mir(def_id),
299299
}
300300
}
301301

@@ -433,7 +433,7 @@ impl<'a, 'b: 'a, 'tcx: 'b> EntryBuilder<'a, 'b, 'tcx> {
433433
predicates: Some(self.encode_predicates(def_id)),
434434

435435
ast: None,
436-
mir: self.encode_mir(def_id),
436+
mir: self.encode_optimized_mir(def_id),
437437
}
438438
}
439439

@@ -528,7 +528,7 @@ impl<'a, 'b: 'a, 'tcx: 'b> EntryBuilder<'a, 'b, 'tcx> {
528528
} else {
529529
None
530530
},
531-
mir: self.encode_mir(def_id),
531+
mir: self.encode_optimized_mir(def_id),
532532
}
533533
}
534534

@@ -598,7 +598,7 @@ impl<'a, 'b: 'a, 'tcx: 'b> EntryBuilder<'a, 'b, 'tcx> {
598598
predicates: Some(self.encode_predicates(def_id)),
599599

600600
ast: ast.map(|body| self.encode_body(body)),
601-
mir: if mir { self.encode_mir(def_id) } else { None },
601+
mir: if mir { self.encode_optimized_mir(def_id) } else { None },
602602
}
603603
}
604604

@@ -619,10 +619,10 @@ impl<'a, 'b: 'a, 'tcx: 'b> EntryBuilder<'a, 'b, 'tcx> {
619619
self.lazy_seq(names.iter().map(|name| name.node))
620620
}
621621

622-
fn encode_mir(&mut self, def_id: DefId) -> Option<Lazy<mir::Mir<'tcx>>> {
622+
fn encode_optimized_mir(&mut self, def_id: DefId) -> Option<Lazy<mir::Mir<'tcx>>> {
623623
debug!("EntryBuilder::encode_mir({:?})", def_id);
624624
if self.tcx.mir_keys(LOCAL_CRATE).contains(&def_id) {
625-
let mir = self.tcx.item_mir(def_id);
625+
let mir = self.tcx.optimized_mir(def_id);
626626
Some(self.lazy(&mir))
627627
} else {
628628
None
@@ -861,15 +861,15 @@ impl<'a, 'b: 'a, 'tcx: 'b> EntryBuilder<'a, 'b, 'tcx> {
861861
},
862862
mir: match item.node {
863863
hir::ItemStatic(..) if self.tcx.sess.opts.debugging_opts.always_encode_mir => {
864-
self.encode_mir(def_id)
864+
self.encode_optimized_mir(def_id)
865865
}
866-
hir::ItemConst(..) => self.encode_mir(def_id),
866+
hir::ItemConst(..) => self.encode_optimized_mir(def_id),
867867
hir::ItemFn(_, _, constness, _, ref generics, _) => {
868868
let tps_len = generics.ty_params.len();
869869
let needs_inline = tps_len > 0 || attr::requests_inline(&item.attrs);
870870
let always_encode_mir = self.tcx.sess.opts.debugging_opts.always_encode_mir;
871871
if needs_inline || constness == hir::Constness::Const || always_encode_mir {
872-
self.encode_mir(def_id)
872+
self.encode_optimized_mir(def_id)
873873
} else {
874874
None
875875
}
@@ -1166,7 +1166,7 @@ impl<'a, 'b: 'a, 'tcx: 'b> EntryBuilder<'a, 'b, 'tcx> {
11661166
predicates: None,
11671167

11681168
ast: None,
1169-
mir: self.encode_mir(def_id),
1169+
mir: self.encode_optimized_mir(def_id),
11701170
}
11711171
}
11721172

@@ -1192,7 +1192,7 @@ impl<'a, 'b: 'a, 'tcx: 'b> EntryBuilder<'a, 'b, 'tcx> {
11921192
predicates: Some(self.encode_predicates(def_id)),
11931193

11941194
ast: Some(self.encode_body(body)),
1195-
mir: self.encode_mir(def_id),
1195+
mir: self.encode_optimized_mir(def_id),
11961196
}
11971197
}
11981198

src/librustc_mir/queries.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,12 @@ pub fn provide(providers: &mut Providers) {
3838
mir_const,
3939
mir_validated,
4040
optimized_mir,
41-
is_item_mir_available,
41+
is_mir_available,
4242
..*providers
4343
};
4444
}
4545

46-
fn is_item_mir_available<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> bool {
46+
fn is_mir_available<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> bool {
4747
tcx.mir_keys(def_id.krate).contains(&def_id)
4848
}
4949

src/librustc_mir/transform/inline.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ impl<'a, 'tcx> Inliner<'a, 'tcx> {
104104
loop {
105105
local_change = false;
106106
while let Some(callsite) = callsites.pop_front() {
107-
if !self.tcx.is_item_mir_available(callsite.callee) {
107+
if !self.tcx.is_mir_available(callsite.callee) {
108108
continue;
109109
}
110110

src/librustc_mir/util/graphviz.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ pub fn write_mir_graphviz<'a, 'tcx, W>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
2929
{
3030
for def_id in dump_mir_def_ids(tcx, single) {
3131
let nodeid = tcx.hir.as_local_node_id(def_id).unwrap();
32-
let mir = &tcx.item_mir(def_id);
32+
let mir = &tcx.optimized_mir(def_id);
3333

3434
writeln!(w, "digraph Mir_{} {{", nodeid)?;
3535

src/librustc_mir/util/pretty.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ pub fn write_mir_pretty<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
127127

128128
let mut first = true;
129129
for def_id in dump_mir_def_ids(tcx, single) {
130-
let mir = &tcx.item_mir(def_id);
130+
let mir = &tcx.optimized_mir(def_id);
131131

132132
if first {
133133
first = false;

src/librustc_passes/mir_stats.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ pub fn print_mir_stats<'tcx, 'a>(tcx: TyCtxt<'a, 'tcx, 'tcx>, title: &str) {
4646
// about maintaining the dep graph.
4747
let _ignore = tcx.dep_graph.in_ignore();
4848
for &def_id in tcx.mir_keys(LOCAL_CRATE).iter() {
49-
let mir = tcx.item_mir(def_id);
49+
let mir = tcx.optimized_mir(def_id);
5050
collector.visit_mir(&mir);
5151
}
5252
collector.print(title);

src/librustc_trans/collector.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -659,7 +659,7 @@ fn should_trans_locally<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, instance: &Instan
659659
// in this crate
660660
false
661661
} else {
662-
if !tcx.is_item_mir_available(def_id) {
662+
if !tcx.is_mir_available(def_id) {
663663
bug!("Cannot create local trans-item for {:?}", def_id)
664664
}
665665
true

0 commit comments

Comments
 (0)