}
// Information needed while computing reachability.
-struct ReachableContext<'a> {
+struct ReachableContext<'a, 'tcx: 'a> {
// The type context.
- tcx: &'a ty::ctxt,
+ tcx: &'a ty::ctxt<'tcx>,
// The set of items which must be exported in the linkage sense.
reachable_symbols: NodeSet,
// A worklist of item IDs. Each item ID in this worklist will be inlined
any_library: bool,
}
-impl<'a> Visitor<()> for ReachableContext<'a> {
+impl<'a, 'tcx, 'v> Visitor<'v> for ReachableContext<'a, 'tcx> {
- fn visit_expr(&mut self, expr: &ast::Expr, _: ()) {
+ fn visit_expr(&mut self, expr: &ast::Expr) {
match expr.node {
ast::ExprPath(_) => {
_ => {}
}
- visit::walk_expr(self, expr, ())
+ visit::walk_expr(self, expr)
}
- fn visit_item(&mut self, _item: &ast::Item, _: ()) {
+ fn visit_item(&mut self, _item: &ast::Item) {
// Do not recurse into items. These items will be added to the worklist
// and recursed into manually if necessary.
}
}
-impl<'a> ReachableContext<'a> {
+impl<'a, 'tcx> ReachableContext<'a, 'tcx> {
// Creates a new reachability computation context.
- fn new(tcx: &'a ty::ctxt) -> ReachableContext<'a> {
+ fn new(tcx: &'a ty::ctxt<'tcx>) -> ReachableContext<'a, 'tcx> {
let any_library = tcx.sess.crate_types.borrow().iter().any(|ty| {
*ty != config::CrateTypeExecutable
});
_ => false,
}
}
- Some(ast_map::NodeTraitMethod(trait_method)) => {
+ Some(ast_map::NodeTraitItem(trait_method)) => {
match *trait_method {
- ast::Required(_) => false,
- ast::Provided(_) => true,
+ ast::RequiredMethod(_) => false,
+ ast::ProvidedMethod(_) => true,
+ ast::TypeTraitItem(_) => false,
}
}
- Some(ast_map::NodeMethod(method)) => {
- if generics_require_inlining(method.pe_generics()) ||
- attributes_specify_inlining(method.attrs.as_slice()) {
- true
- } else {
- let impl_did = self.tcx.map.get_parent_did(node_id);
- // Check the impl. If the generics on the self type of the
- // impl require inlining, this method does too.
- assert!(impl_did.krate == ast::LOCAL_CRATE);
- match self.tcx.map.expect_item(impl_did.node).node {
- ast::ItemImpl(ref generics, _, _, _) => {
- generics_require_inlining(generics)
+ Some(ast_map::NodeImplItem(impl_item)) => {
+ match *impl_item {
+ ast::MethodImplItem(ref method) => {
+ if generics_require_inlining(method.pe_generics()) ||
+ attributes_specify_inlining(
+ method.attrs.as_slice()) {
+ true
+ } else {
+ let impl_did = self.tcx
+ .map
+ .get_parent_did(node_id);
+ // Check the impl. If the generics on the self
+ // type of the impl require inlining, this method
+ // does too.
+ assert!(impl_did.krate == ast::LOCAL_CRATE);
+ match self.tcx
+ .map
+ .expect_item(impl_did.node)
+ .node {
+ ast::ItemImpl(ref generics, _, _, _) => {
+ generics_require_inlining(generics)
+ }
+ _ => false
+ }
}
- _ => false
}
+ ast::TypeImplItem(_) => false,
}
}
Some(_) => false,
match item.node {
ast::ItemFn(_, _, _, _, ref search_block) => {
if item_might_be_inlined(&*item) {
- visit::walk_block(self, &**search_block, ())
+ visit::walk_block(self, &**search_block)
}
}
item.attrs.as_slice()) {
self.reachable_symbols.remove(&search_item);
}
- visit::walk_expr(self, &**init, ());
+ visit::walk_expr(self, &**init);
}
// These are normal, nothing reachable about these
}
}
}
- ast_map::NodeTraitMethod(trait_method) => {
+ ast_map::NodeTraitItem(trait_method) => {
match *trait_method {
- ast::Required(..) => {
+ ast::RequiredMethod(..) => {
// Keep going, nothing to get exported
}
- ast::Provided(ref method) => {
- visit::walk_block(self, &*method.pe_body(), ())
+ ast::ProvidedMethod(ref method) => {
+ visit::walk_block(self, &*method.pe_body());
}
+ ast::TypeTraitItem(_) => {}
}
}
- ast_map::NodeMethod(method) => {
- let did = self.tcx.map.get_parent_did(search_item);
- if method_might_be_inlined(self.tcx, &*method, did) {
- visit::walk_block(self, &*method.pe_body(), ())
+ ast_map::NodeImplItem(impl_item) => {
+ match *impl_item {
+ ast::MethodImplItem(ref method) => {
+ let did = self.tcx.map.get_parent_did(search_item);
+ if method_might_be_inlined(self.tcx, &**method, did) {
+ visit::walk_block(self, method.pe_body())
+ }
+ }
+ ast::TypeImplItem(_) => {}
}
}
// Nothing to recurse on for these