1
Fork 0

auto merge of #10696 : fhahn/rust/issue9543-remove-extern-mod-foo, r=pcwalton

This patch for  #9543 throws an `obsolete syntax` error for `extern mod foo (name="bar")` . 
I was wondering if [this](https://github.com/fhahn/rust/compare/mozilla:master...fhahn:issue9543-remove-extern-mod-foo?expand=1#diff-da9d34ca1d0f6beee2838cf02e07345cR4444) is the correct place to do this?

I think the wording of the error message could probably be improved as well.

If this approach is OK, I'm going to run the whole test suite tomorrow and update the old syntax to the new one.
This commit is contained in:
bors 2014-01-02 11:32:09 -08:00
commit 0df9b850ac
18 changed files with 62 additions and 37 deletions

View file

@ -21,7 +21,7 @@ use syntax::fold;
use syntax::opt_vec;
use syntax::util::small_vector::SmallVector;
static STD_VERSION: &'static str = "0.9-pre";
pub static VERSION: &'static str = "0.9-pre";
pub fn maybe_inject_libstd_ref(sess: Session, crate: ast::Crate)
-> ast::Crate {
@ -57,12 +57,10 @@ struct StandardLibraryInjector {
impl fold::ast_fold for StandardLibraryInjector {
fn fold_crate(&mut self, crate: ast::Crate) -> ast::Crate {
let version = STD_VERSION.to_managed();
let vers_item = attr::mk_name_value_item_str(@"vers", version);
let mut vis = ~[ast::view_item {
node: ast::view_item_extern_mod(self.sess.ident_of("std"),
None,
~[vers_item.clone()],
Some((format!("std\\#{}", VERSION).to_managed(),
ast::CookedStr)),
ast::DUMMY_NODE_ID),
attrs: ~[],
vis: ast::private,
@ -72,8 +70,8 @@ impl fold::ast_fold for StandardLibraryInjector {
if use_uv(&crate) && !self.sess.building_library.get() {
vis.push(ast::view_item {
node: ast::view_item_extern_mod(self.sess.ident_of("green"),
None,
~[vers_item],
Some((format!("green\\#{}", VERSION).to_managed(),
ast::CookedStr)),
ast::DUMMY_NODE_ID),
attrs: ~[],
vis: ast::private,
@ -81,8 +79,8 @@ impl fold::ast_fold for StandardLibraryInjector {
});
vis.push(ast::view_item {
node: ast::view_item_extern_mod(self.sess.ident_of("rustuv"),
None,
~[vers_item],
Some((format!("rustuv\\#{}", VERSION).to_managed(),
ast::CookedStr)),
ast::DUMMY_NODE_ID),
attrs: ~[],
vis: ast::private,