// Parse the attributes relating to macros.
let mut import = ImportSelection::Some(FnvHashMap());
let mut reexport = FnvHashMap();
+ let mut no_link = false;
for attr in &extern_crate.attrs {
let mut used = true;
}
}
}
+ "no_link" => no_link = true,
_ => used = false,
}
if used {
}
}
- self.load_macros(extern_crate, allows_macros, import, reexport)
+ self.load_macros(extern_crate, allows_macros, import, reexport, no_link)
}
fn load_macros<'b>(&mut self,
vi: &ast::Item,
allows_macros: bool,
import: ImportSelection,
- reexport: MacroSelection)
+ reexport: MacroSelection,
+ no_link: bool)
-> Vec<LoadedMacro> {
if let ImportSelection::Some(ref sel) = import {
if sel.is_empty() && reexport.is_empty() {
+ // Make sure we can read macros from `#[no_link]` crates.
+ if no_link {
+ self.creader.read_macros(vi);
+ }
return Vec::new();
}
}
self.define(parent, name, TypeNS, (module, sp, vis));
self.populate_module_if_necessary(module);
- } else if custom_derive_crate {
+ } else {
// Define an empty module
let def = Def::Mod(self.definitions.local_def_id(item.id));
let module = ModuleS::new(Some(parent), ModuleKind::Def(def, name));
extern crate macro_crate_test;
fn main() {
- macro_crate_test::foo();
- //~^ ERROR failed to resolve. Use of undeclared type or module `macro_crate_test`
+ macro_crate_test::foo(); //~ ERROR unresolved name
}
+++ /dev/null
-// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-#[macro_use] #[no_link]
-extern crate doesnt_exist; //~ ERROR can't find crate
-
-fn main() {}
--- /dev/null
+// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+#[no_link]
+extern crate doesnt_exist; //~ ERROR can't find crate
+
+fn main() {}
fn main() {
unsafe {
- libc::abs(0); //~ ERROR Use of undeclared type or module `libc`
+ libc::abs(0); //~ ERROR unresolved name
}
}