Remove extern mod foo (name="bar")
syntax, closes #9543
This commit is contained in:
parent
51ace54597
commit
f42a36cded
17 changed files with 29 additions and 32 deletions
|
@ -21,8 +21,6 @@ use syntax::fold;
|
||||||
use syntax::opt_vec;
|
use syntax::opt_vec;
|
||||||
use syntax::util::small_vector::SmallVector;
|
use syntax::util::small_vector::SmallVector;
|
||||||
|
|
||||||
static STD_VERSION: &'static str = "0.9-pre";
|
|
||||||
|
|
||||||
pub fn maybe_inject_libstd_ref(sess: Session, crate: ast::Crate)
|
pub fn maybe_inject_libstd_ref(sess: Session, crate: ast::Crate)
|
||||||
-> ast::Crate {
|
-> ast::Crate {
|
||||||
if use_std(&crate) {
|
if use_std(&crate) {
|
||||||
|
@ -57,12 +55,9 @@ struct StandardLibraryInjector {
|
||||||
|
|
||||||
impl fold::ast_fold for StandardLibraryInjector {
|
impl fold::ast_fold for StandardLibraryInjector {
|
||||||
fn fold_crate(&mut self, crate: ast::Crate) -> ast::Crate {
|
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 {
|
let mut vis = ~[ast::view_item {
|
||||||
node: ast::view_item_extern_mod(self.sess.ident_of("std"),
|
node: ast::view_item_extern_mod(self.sess.ident_of("std"),
|
||||||
None,
|
None,
|
||||||
~[vers_item.clone()],
|
|
||||||
ast::DUMMY_NODE_ID),
|
ast::DUMMY_NODE_ID),
|
||||||
attrs: ~[],
|
attrs: ~[],
|
||||||
vis: ast::private,
|
vis: ast::private,
|
||||||
|
@ -73,7 +68,6 @@ impl fold::ast_fold for StandardLibraryInjector {
|
||||||
vis.push(ast::view_item {
|
vis.push(ast::view_item {
|
||||||
node: ast::view_item_extern_mod(self.sess.ident_of("green"),
|
node: ast::view_item_extern_mod(self.sess.ident_of("green"),
|
||||||
None,
|
None,
|
||||||
~[vers_item],
|
|
||||||
ast::DUMMY_NODE_ID),
|
ast::DUMMY_NODE_ID),
|
||||||
attrs: ~[],
|
attrs: ~[],
|
||||||
vis: ast::private,
|
vis: ast::private,
|
||||||
|
@ -82,7 +76,6 @@ impl fold::ast_fold for StandardLibraryInjector {
|
||||||
vis.push(ast::view_item {
|
vis.push(ast::view_item {
|
||||||
node: ast::view_item_extern_mod(self.sess.ident_of("rustuv"),
|
node: ast::view_item_extern_mod(self.sess.ident_of("rustuv"),
|
||||||
None,
|
None,
|
||||||
~[vers_item],
|
|
||||||
ast::DUMMY_NODE_ID),
|
ast::DUMMY_NODE_ID),
|
||||||
attrs: ~[],
|
attrs: ~[],
|
||||||
vis: ast::private,
|
vis: ast::private,
|
||||||
|
|
|
@ -291,8 +291,7 @@ fn mk_std(cx: &TestCtxt) -> ast::view_item {
|
||||||
path_node(~[id_extra]),
|
path_node(~[id_extra]),
|
||||||
ast::DUMMY_NODE_ID))])
|
ast::DUMMY_NODE_ID))])
|
||||||
} else {
|
} else {
|
||||||
let mi = attr::mk_name_value_item_str(@"vers", @"0.9-pre");
|
ast::view_item_extern_mod(id_extra, None, ast::DUMMY_NODE_ID)
|
||||||
ast::view_item_extern_mod(id_extra, None, ~[mi], ast::DUMMY_NODE_ID)
|
|
||||||
};
|
};
|
||||||
ast::view_item {
|
ast::view_item {
|
||||||
node: vi,
|
node: vi,
|
||||||
|
|
|
@ -132,7 +132,7 @@ fn visit_crate(e: &Env, c: &ast::Crate) {
|
||||||
|
|
||||||
fn visit_view_item(e: &mut Env, i: &ast::view_item) {
|
fn visit_view_item(e: &mut Env, i: &ast::view_item) {
|
||||||
match i.node {
|
match i.node {
|
||||||
ast::view_item_extern_mod(ident, path_opt, _, id) => {
|
ast::view_item_extern_mod(ident, path_opt, id) => {
|
||||||
let ident = token::ident_to_str(&ident);
|
let ident = token::ident_to_str(&ident);
|
||||||
debug!("resolving extern mod stmt. ident: {:?} path_opt: {:?}",
|
debug!("resolving extern mod stmt. ident: {:?} path_opt: {:?}",
|
||||||
ident, path_opt);
|
ident, path_opt);
|
||||||
|
|
|
@ -1507,7 +1507,7 @@ impl Resolver {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
view_item_extern_mod(name, _, _, node_id) => {
|
view_item_extern_mod(name, _, node_id) => {
|
||||||
// n.b. we don't need to look at the path option here, because cstore already did
|
// n.b. we don't need to look at the path option here, because cstore already did
|
||||||
match self.session.cstore.find_extern_mod_stmt_cnum(node_id) {
|
match self.session.cstore.find_extern_mod_stmt_cnum(node_id) {
|
||||||
Some(crate_id) => {
|
Some(crate_id) => {
|
||||||
|
|
|
@ -994,15 +994,15 @@ impl Clean<Item> for ast::view_item {
|
||||||
|
|
||||||
#[deriving(Clone, Encodable, Decodable)]
|
#[deriving(Clone, Encodable, Decodable)]
|
||||||
pub enum ViewItemInner {
|
pub enum ViewItemInner {
|
||||||
ExternMod(~str, Option<~str>, ~[Attribute], ast::NodeId),
|
ExternMod(~str, Option<~str>, ast::NodeId),
|
||||||
Import(~[ViewPath])
|
Import(~[ViewPath])
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Clean<ViewItemInner> for ast::view_item_ {
|
impl Clean<ViewItemInner> for ast::view_item_ {
|
||||||
fn clean(&self) -> ViewItemInner {
|
fn clean(&self) -> ViewItemInner {
|
||||||
match self {
|
match self {
|
||||||
&ast::view_item_extern_mod(ref i, ref p, ref mi, ref id) =>
|
&ast::view_item_extern_mod(ref i, ref p, ref id) =>
|
||||||
ExternMod(i.clean(), p.map(|(ref x, _)| x.to_owned()), mi.clean(), *id),
|
ExternMod(i.clean(), p.map(|(ref x, _)| x.to_owned()), *id),
|
||||||
&ast::view_item_use(ref vp) => Import(vp.clean())
|
&ast::view_item_use(ref vp) => Import(vp.clean())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -995,7 +995,7 @@ fn item_module(w: &mut Writer, cx: &Context,
|
||||||
|
|
||||||
clean::ViewItemItem(ref item) => {
|
clean::ViewItemItem(ref item) => {
|
||||||
match item.inner {
|
match item.inner {
|
||||||
clean::ExternMod(ref name, ref src, _, _) => {
|
clean::ExternMod(ref name, ref src, _) => {
|
||||||
write!(w, "<tr><td><code>extern mod {}",
|
write!(w, "<tr><td><code>extern mod {}",
|
||||||
name.as_slice());
|
name.as_slice());
|
||||||
match *src {
|
match *src {
|
||||||
|
|
|
@ -461,7 +461,7 @@ impl<'a> Visitor<()> for ViewItemVisitor<'a> {
|
||||||
|
|
||||||
match vi.node {
|
match vi.node {
|
||||||
// ignore metadata, I guess
|
// ignore metadata, I guess
|
||||||
ast::view_item_extern_mod(lib_ident, path_opt, _, _) => {
|
ast::view_item_extern_mod(lib_ident, path_opt, _) => {
|
||||||
let lib_name = match path_opt {
|
let lib_name = match path_opt {
|
||||||
Some((p, _)) => p,
|
Some((p, _)) => p,
|
||||||
None => self.sess.str_of(lib_ident)
|
None => self.sess.str_of(lib_ident)
|
||||||
|
|
|
@ -1057,7 +1057,7 @@ pub enum view_item_ {
|
||||||
// optional @str: if present, this is a location (containing
|
// optional @str: if present, this is a location (containing
|
||||||
// arbitrary characters) from which to fetch the crate sources
|
// arbitrary characters) from which to fetch the crate sources
|
||||||
// For example, extern mod whatever = "github.com/mozilla/rust"
|
// For example, extern mod whatever = "github.com/mozilla/rust"
|
||||||
view_item_extern_mod(Ident, Option<(@str, StrStyle)>, ~[@MetaItem], NodeId),
|
view_item_extern_mod(Ident, Option<(@str, StrStyle)>, NodeId),
|
||||||
view_item_use(~[@view_path]),
|
view_item_use(~[@view_path]),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -419,7 +419,7 @@ impl<'a, O: IdVisitingOperation> Visitor<()> for IdVisitor<'a, O> {
|
||||||
|
|
||||||
fn visit_view_item(&mut self, view_item: &view_item, env: ()) {
|
fn visit_view_item(&mut self, view_item: &view_item, env: ()) {
|
||||||
match view_item.node {
|
match view_item.node {
|
||||||
view_item_extern_mod(_, _, _, node_id) => {
|
view_item_extern_mod(_, _, node_id) => {
|
||||||
self.operation.visit_id(node_id)
|
self.operation.visit_id(node_id)
|
||||||
}
|
}
|
||||||
view_item_use(ref view_paths) => {
|
view_item_use(ref view_paths) => {
|
||||||
|
|
|
@ -66,11 +66,9 @@ pub trait ast_fold {
|
||||||
let inner_view_item = match vi.node {
|
let inner_view_item = match vi.node {
|
||||||
view_item_extern_mod(ref ident,
|
view_item_extern_mod(ref ident,
|
||||||
string,
|
string,
|
||||||
ref meta_items,
|
|
||||||
node_id) => {
|
node_id) => {
|
||||||
view_item_extern_mod(ident.clone(),
|
view_item_extern_mod(ident.clone(),
|
||||||
string,
|
string,
|
||||||
self.fold_meta_items(*meta_items),
|
|
||||||
self.new_id(node_id))
|
self.new_id(node_id))
|
||||||
}
|
}
|
||||||
view_item_use(ref view_paths) => {
|
view_item_use(ref view_paths) => {
|
||||||
|
|
|
@ -45,6 +45,7 @@ pub enum ObsoleteSyntax {
|
||||||
ObsoleteBoxedClosure,
|
ObsoleteBoxedClosure,
|
||||||
ObsoleteClosureType,
|
ObsoleteClosureType,
|
||||||
ObsoleteMultipleImport,
|
ObsoleteMultipleImport,
|
||||||
|
ObsoleteExternModAttributesInParens
|
||||||
}
|
}
|
||||||
|
|
||||||
impl to_bytes::IterBytes for ObsoleteSyntax {
|
impl to_bytes::IterBytes for ObsoleteSyntax {
|
||||||
|
@ -145,6 +146,11 @@ impl ParserObsoleteMethods for Parser {
|
||||||
"multiple imports",
|
"multiple imports",
|
||||||
"only one import is allowed per `use` statement"
|
"only one import is allowed per `use` statement"
|
||||||
),
|
),
|
||||||
|
ObsoleteExternModAttributesInParens => (
|
||||||
|
"`extern mod` with linkage attribute list",
|
||||||
|
"use `extern mod foo = \"bar\";` instead of \
|
||||||
|
`extern mod foo (name = \"bar\")`"
|
||||||
|
)
|
||||||
};
|
};
|
||||||
|
|
||||||
self.report(sp, kind, kind_str, desc);
|
self.report(sp, kind, kind_str, desc);
|
||||||
|
|
|
@ -4446,11 +4446,18 @@ impl Parser {
|
||||||
self.span_err(*self.span, "an ABI may not be specified here");
|
self.span_err(*self.span, "an ABI may not be specified here");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if *self.token == token::LPAREN {
|
||||||
|
// `extern mod foo (name = "bar"[,vers = "version"]) is obsolete,
|
||||||
|
// `extern mod foo = "bar#[version]";` should be used.
|
||||||
|
// Parse obsolete options to avoid wired parser errors
|
||||||
|
self.parse_optional_meta();
|
||||||
|
self.obsolete(*self.span, ObsoleteExternModAttributesInParens);
|
||||||
|
}
|
||||||
// extern mod foo;
|
// extern mod foo;
|
||||||
let metadata = self.parse_optional_meta();
|
|
||||||
self.expect(&token::SEMI);
|
self.expect(&token::SEMI);
|
||||||
iovi_view_item(ast::view_item {
|
iovi_view_item(ast::view_item {
|
||||||
node: view_item_extern_mod(ident, maybe_path, metadata, ast::DUMMY_NODE_ID),
|
node: view_item_extern_mod(ident, maybe_path, ast::DUMMY_NODE_ID),
|
||||||
attrs: attrs,
|
attrs: attrs,
|
||||||
vis: visibility,
|
vis: visibility,
|
||||||
span: mk_sp(lo, self.last_span.hi)
|
span: mk_sp(lo, self.last_span.hi)
|
||||||
|
|
|
@ -1952,7 +1952,7 @@ pub fn print_view_item(s: @ps, item: &ast::view_item) {
|
||||||
print_outer_attributes(s, item.attrs);
|
print_outer_attributes(s, item.attrs);
|
||||||
print_visibility(s, item.vis);
|
print_visibility(s, item.vis);
|
||||||
match item.node {
|
match item.node {
|
||||||
ast::view_item_extern_mod(id, ref optional_path, ref mta, _) => {
|
ast::view_item_extern_mod(id, ref optional_path, _) => {
|
||||||
head(s, "extern mod");
|
head(s, "extern mod");
|
||||||
print_ident(s, id);
|
print_ident(s, id);
|
||||||
for &(ref p, style) in optional_path.iter() {
|
for &(ref p, style) in optional_path.iter() {
|
||||||
|
@ -1961,11 +1961,6 @@ pub fn print_view_item(s: @ps, item: &ast::view_item) {
|
||||||
space(s.s);
|
space(s.s);
|
||||||
print_string(s, *p, style);
|
print_string(s, *p, style);
|
||||||
}
|
}
|
||||||
if !mta.is_empty() {
|
|
||||||
popen(s);
|
|
||||||
commasep(s, consistent, *mta, |p, &i| print_meta_item(p, i));
|
|
||||||
pclose(s);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ast::view_item_use(ref vps) => {
|
ast::view_item_use(ref vps) => {
|
||||||
|
|
|
@ -139,7 +139,7 @@ pub fn walk_mod<E:Clone, V:Visitor<E>>(visitor: &mut V, module: &_mod, env: E) {
|
||||||
|
|
||||||
pub fn walk_view_item<E:Clone, V:Visitor<E>>(visitor: &mut V, vi: &view_item, env: E) {
|
pub fn walk_view_item<E:Clone, V:Visitor<E>>(visitor: &mut V, vi: &view_item, env: E) {
|
||||||
match vi.node {
|
match vi.node {
|
||||||
view_item_extern_mod(name, _, _, _) => {
|
view_item_extern_mod(name, _, _) => {
|
||||||
visitor.visit_ident(vi.span, name, env)
|
visitor.visit_ident(vi.span, name, env)
|
||||||
}
|
}
|
||||||
view_item_use(ref paths) => {
|
view_item_use(ref paths) => {
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
|
|
||||||
#[crate_id="crateresolve8#0.1"];
|
#[crate_id="crateresolve8#0.1"];
|
||||||
|
|
||||||
extern mod crateresolve8(vers = "0.1", package_id="crateresolve8#0.1");
|
extern mod crateresolve8 = "crateresolve8#0.1";
|
||||||
//extern mod crateresolve8(vers = "0.1");
|
//extern mod crateresolve8(vers = "0.1");
|
||||||
|
|
||||||
pub fn main() {
|
pub fn main() {
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
// xfail-fast
|
// xfail-fast
|
||||||
//aux-build:extern-crosscrate-source.rs
|
//aux-build:extern-crosscrate-source.rs
|
||||||
|
|
||||||
extern mod externcallback(vers = "0.1");
|
extern mod externcallback = "externcallback#0.1";
|
||||||
|
|
||||||
fn fact(n: uint) -> uint {
|
fn fact(n: uint) -> uint {
|
||||||
unsafe {
|
unsafe {
|
||||||
|
|
|
@ -12,7 +12,6 @@
|
||||||
// xfail-fast
|
// xfail-fast
|
||||||
|
|
||||||
#[crate_id="issue-6919"];
|
#[crate_id="issue-6919"];
|
||||||
|
|
||||||
extern mod issue6919_3;
|
extern mod issue6919_3;
|
||||||
|
|
||||||
pub fn main() {
|
pub fn main() {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue