Add test for collecting items in statics

This commit is contained in:
James Miller 2016-05-10 10:14:41 +12:00 committed by Michael Woerister
parent dace30659f
commit f4dd4be86a
2 changed files with 26 additions and 4 deletions

View File

@ -213,7 +213,6 @@ use meth;
use monomorphize::{self, Instance};
use util::nodemap::{FnvHashSet, FnvHashMap, DefIdMap};
use std::hash::{Hash, Hasher};
use trans_item::{TransItem, type_to_string, def_id_to_string};
#[derive(PartialEq, Eq, Hash, Clone, Copy, Debug)]
@ -346,12 +345,12 @@ fn collect_items_rec<'a, 'tcx: 'a>(scx: &SharedCrateContext<'a, 'tcx>,
// Scan the MIR in order to find function calls, closures, and
// drop-glue
let mir = errors::expect(ccx.sess().diagnostic(), ccx.get_mir(def_id),
let mir = errors::expect(scx.sess().diagnostic(), scx.get_mir(def_id),
|| format!("Could not find MIR for static: {:?}", def_id));
let empty_substs = ccx.tcx().mk_substs(Substs::empty());
let empty_substs = scx.tcx().mk_substs(Substs::empty());
let mut visitor = MirNeighborCollector {
ccx: ccx,
scx: scx,
mir: &mir,
output: &mut neighbors,
param_substs: empty_substs

View File

@ -0,0 +1,23 @@
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// compile-flags:-Zprint-trans-items=eager
pub static FN : fn() = foo::<i32>;
pub fn foo<T>() { }
//~ TRANS_ITEM fn static_init::foo[0]<i32>
//~ TRANS_ITEM static static_init::FN[0]
fn main() { }
//~ TRANS_ITEM fn static_init::main[0]
//~ TRANS_ITEM drop-glue i8