use plugin::registry::Registry;
use std::mem;
-use std::os;
+use std::env;
use std::dynamic_lib::DynamicLibrary;
use std::collections::HashSet;
use syntax::ast;
// We need to error on `#[macro_use] extern crate` when it isn't at the
// crate root, because `$crate` won't work properly. Identify these by
// spans, because the crate map isn't set up yet.
- for vi in krate.module.view_items.iter() {
- loader.span_whitelist.insert(vi.span);
+ for item in &krate.module.items {
+ if let ast::ItemExternCrate(_) = item.node {
+ loader.span_whitelist.insert(item.span);
+ }
}
visit::walk_crate(&mut loader, krate);
if let Some(plugins) = addl_plugins {
- for plugin in plugins.iter() {
+ for plugin in &plugins {
loader.load_plugin(CrateOrString::Str(plugin.as_slice()),
None, None, None)
}
// note that macros aren't expanded yet, and therefore macros can't add plugins.
impl<'a, 'v> Visitor<'v> for PluginLoader<'a> {
- fn visit_view_item(&mut self, vi: &ast::ViewItem) {
+ fn visit_item(&mut self, item: &ast::Item) {
// We're only interested in `extern crate`.
- match vi.node {
- ast::ViewItemExternCrate(..) => (),
- _ => return,
+ match item.node {
+ ast::ItemExternCrate(_) => {}
+ _ => {
+ visit::walk_item(self, item);
+ return;
+ }
}
// Parse the attributes relating to macro / plugin loading.
let mut plugin_attr = None;
let mut macro_selection = Some(HashSet::new()); // None => load all
let mut reexport = HashSet::new();
- for attr in vi.attrs.iter() {
+ for attr in &item.attrs {
let mut used = true;
match attr.name().get() {
"phase" => {
macro_selection = None;
}
if let (Some(sel), Some(names)) = (macro_selection.as_mut(), names) {
- for name in names.iter() {
+ for name in names {
if let ast::MetaWord(ref name) = name.node {
sel.insert(name.clone());
} else {
}
};
- for name in names.iter() {
+ for name in names {
if let ast::MetaWord(ref name) = name.node {
reexport.insert(name.clone());
} else {
}
}
- self.load_plugin(CrateOrString::Krate(vi), plugin_attr, macro_selection, Some(reexport))
+ self.load_plugin(CrateOrString::Krate(item),
+ plugin_attr,
+ macro_selection,
+ Some(reexport))
}
fn visit_mac(&mut self, _: &ast::Mac) {
}
}
- for mut def in macros.into_iter() {
+ for mut def in macros {
let name = token::get_ident(def.ident);
def.use_locally = match macro_selection.as_ref() {
None => true,
path: Path,
symbol: String) -> PluginRegistrarFun {
// Make sure the path contains a / or the linker will search for it.
- let path = os::make_absolute(&path).unwrap();
+ let path = env::current_dir().unwrap().join(&path);
let lib = match DynamicLibrary::open(Some(&path)) {
Ok(lib) => lib,