diff --git a/src/librustc_trans/collector.rs b/src/librustc_trans/collector.rs index f23f931d753a..3675bf4b8cef 100644 --- a/src/librustc_trans/collector.rs +++ b/src/librustc_trans/collector.rs @@ -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 diff --git a/src/test/codegen-units/item-collection/static-init.rs b/src/test/codegen-units/item-collection/static-init.rs new file mode 100644 index 000000000000..41c0f46f80bf --- /dev/null +++ b/src/test/codegen-units/item-collection/static-init.rs @@ -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 or the MIT license +// , 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::; + +pub fn foo() { } + +//~ TRANS_ITEM fn static_init::foo[0] +//~ TRANS_ITEM static static_init::FN[0] + +fn main() { } + +//~ TRANS_ITEM fn static_init::main[0] +//~ TRANS_ITEM drop-glue i8