1 // Copyright 2016 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
11 use rustc::hir::itemlikevisit::ItemLikeVisitor;
12 use rustc::hir::map::Map;
17 pub fn find(hir_map: &Map) -> Option<ast::NodeId> {
18 let krate = hir_map.krate();
20 let mut finder = Finder { registrar: None };
21 krate.visit_all_item_likes(&mut finder);
26 registrar: Option<ast::NodeId>,
29 impl<'v> ItemLikeVisitor<'v> for Finder {
30 fn visit_item(&mut self, item: &hir::Item) {
31 if attr::contains_name(&item.attrs, "rustc_derive_registrar") {
32 self.registrar = Some(item.id);
36 fn visit_trait_item(&mut self, _trait_item: &hir::TraitItem) {
39 fn visit_impl_item(&mut self, _impl_item: &hir::ImplItem) {