Synthesize calls to box_free language item
This gets rid of Drop(Free, _) MIR construct by synthesizing a call to language item which takes care of dropping instead.
This commit is contained in:
parent
7b9d6d3bc8
commit
432460a6fc
20 changed files with 127 additions and 69 deletions
|
|
@ -435,7 +435,7 @@ impl<'a, 'tcx> DeadVisitor<'a, 'tcx> {
|
|||
let is_named = node.name().is_some();
|
||||
let field_type = self.tcx.node_id_to_type(node.id);
|
||||
let is_marker_field = match field_type.ty_to_def_id() {
|
||||
Some(def_id) => self.tcx.lang_items.items().any(|(_, item)| *item == Some(def_id)),
|
||||
Some(def_id) => self.tcx.lang_items.items().iter().any(|item| *item == Some(def_id)),
|
||||
_ => false
|
||||
};
|
||||
is_named
|
||||
|
|
|
|||
|
|
@ -36,9 +36,6 @@ use syntax::parse::token::InternedString;
|
|||
use rustc_front::intravisit::Visitor;
|
||||
use rustc_front::hir;
|
||||
|
||||
use std::iter::Enumerate;
|
||||
use std::slice;
|
||||
|
||||
// The actual lang items defined come at the end of this file in one handy table.
|
||||
// So you probably just want to nip down to the end.
|
||||
macro_rules! lets_do_this {
|
||||
|
|
@ -69,8 +66,8 @@ impl LanguageItems {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn items<'a>(&'a self) -> Enumerate<slice::Iter<'a, Option<DefId>>> {
|
||||
self.items.iter().enumerate()
|
||||
pub fn items(&self) -> &[Option<DefId>] {
|
||||
&*self.items
|
||||
}
|
||||
|
||||
pub fn item_name(index: usize) -> &'static str {
|
||||
|
|
@ -334,6 +331,7 @@ lets_do_this! {
|
|||
|
||||
ExchangeMallocFnLangItem, "exchange_malloc", exchange_malloc_fn;
|
||||
ExchangeFreeFnLangItem, "exchange_free", exchange_free_fn;
|
||||
BoxFreeFnLangItem, "box_free", box_free_fn;
|
||||
StrDupUniqFnLangItem, "strdup_uniq", strdup_uniq_fn;
|
||||
|
||||
StartFnLangItem, "start", start_fn;
|
||||
|
|
|
|||
|
|
@ -362,7 +362,7 @@ pub fn find_reachable(tcx: &ty::ctxt,
|
|||
for (id, _) in &access_levels.map {
|
||||
reachable_context.worklist.push(*id);
|
||||
}
|
||||
for (_, item) in tcx.lang_items.items() {
|
||||
for item in tcx.lang_items.items().iter() {
|
||||
if let Some(did) = *item {
|
||||
if let Some(node_id) = tcx.map.as_local_node_id(did) {
|
||||
reachable_context.worklist.push(node_id);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue