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
::dep_graph
::DepNode
;
12 use rustc
::hir
::intravisit
::Visitor
;
13 use rustc
::hir
::map
::Map
;
18 pub fn find(hir_map
: &Map
) -> Option
<ast
::NodeId
> {
19 let _task
= hir_map
.dep_graph
.in_task(DepNode
::PluginRegistrar
);
20 let krate
= hir_map
.krate();
22 let mut finder
= Finder { registrar: None }
;
23 krate
.visit_all_items(&mut finder
);
28 registrar
: Option
<ast
::NodeId
>,
31 impl<'v
> Visitor
<'v
> for Finder
{
32 fn visit_item(&mut self, item
: &hir
::Item
) {
33 if attr
::contains_name(&item
.attrs
, "rustc_derive_registrar") {
34 self.registrar
= Some(item
.id
);