use dep_graph::DepNode;
use front::map as ast_map;
-use middle::def;
+use middle::def::Def;
use middle::def_id::DefId;
use middle::ty;
use middle::privacy;
use util::nodemap::NodeSet;
use std::collections::HashSet;
-use syntax::abi;
+use syntax::abi::Abi;
use syntax::ast;
use syntax::attr;
use rustc_front::hir;
// If this path leads to a constant, then we need to
// recurse into the constant to continue finding
// items that are reachable.
- def::DefConst(..) | def::DefAssociatedConst(..) => {
+ Def::Const(..) | Def::AssociatedConst(..) => {
self.worklist.push(node_id);
}
fn propagate_node(&mut self, node: &ast_map::Node,
search_item: ast::NodeId) {
if !self.any_library {
- // If we are building an executable, then there's no need to flag
- // anything as external except for `extern fn` types. These
- // functions may still participate in some form of native interface,
- // but all other rust-only interfaces can be private (they will not
- // participate in linkage after this product is produced)
+ // If we are building an executable, only explicitly extern
+ // types need to be exported.
if let ast_map::NodeItem(item) = *node {
- if let hir::ItemFn(_, _, _, abi, _, _) = item.node {
- if abi != abi::Rust {
- self.reachable_symbols.insert(search_item);
- }
+ let reachable = if let hir::ItemFn(_, _, _, abi, _, _) = item.node {
+ abi != Abi::Rust
+ } else {
+ false
+ };
+ if reachable || attr::contains_extern_indicator(&item.attrs) {
+ self.reachable_symbols.insert(search_item);
}
}
} else {
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);