Skip to content

Commit fb62fae

Browse files
committed
---
yaml --- r: 44142 b: refs/heads/snap-stage3 c: 0f09c10 h: refs/heads/master v: v3
1 parent 50f890b commit fb62fae

File tree

13 files changed

+50
-85
lines changed

13 files changed

+50
-85
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
refs/heads/master: 19dfec2aaf746535de1521f68421f9980dbf25de
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
4-
refs/heads/snap-stage3: 612553cb3921f428668602afda1b106e0fd54d73
4+
refs/heads/snap-stage3: 0f09c106f00d774a6e59b1245edcc536cc2bf459
55
refs/heads/try: ef355f6332f83371e4acf04fc4eb940ab41d78d3
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b

branches/snap-stage3/src/librustc/front/core_inject.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@ fn inject_libcore_ref(sess: Session,
4545
fold_crate: |crate, span, fld| {
4646
let n1 = sess.next_node_id();
4747
let vi1 = @ast::view_item {
48-
node: ast::view_item_use(sess.ident_of(~"core"), ~[], n1),
48+
node: ast::view_item_extern_mod(
49+
sess.ident_of(~"core"), ~[], n1),
4950
attrs: ~[
5051
spanned(ast::attribute_ {
5152
style: ast::attr_inner,
@@ -86,7 +87,7 @@ fn inject_libcore_ref(sess: Session,
8687
};
8788

8889
let vp = @spanned(ast::view_path_glob(prelude_path, n2));
89-
let vi2 = @ast::view_item { node: ast::view_item_import(~[vp]),
90+
let vi2 = @ast::view_item { node: ast::view_item_use(~[vp]),
9091
attrs: ~[],
9192
vis: ast::private,
9293
span: dummy_sp() };

branches/snap-stage3/src/librustc/front/test.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -266,13 +266,13 @@ fn mk_std(cx: &TestCtxt) -> @ast::view_item {
266266
let mi = nospan(mi);
267267
let id_std = cx.sess.ident_of(~"std");
268268
let vi = if is_std(cx) {
269-
ast::view_item_import(
269+
ast::view_item_use(
270270
~[@nospan(ast::view_path_simple(id_std,
271271
path_node(~[id_std]),
272272
ast::type_value_ns,
273273
cx.sess.next_node_id()))])
274274
} else {
275-
ast::view_item_use(id_std, ~[@mi],
275+
ast::view_item_extern_mod(id_std, ~[@mi],
276276
cx.sess.next_node_id())
277277
};
278278
let vi = ast::view_item {

branches/snap-stage3/src/librustc/metadata/creader.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -127,10 +127,11 @@ struct Env {
127127

128128
fn visit_view_item(e: @mut Env, i: @ast::view_item) {
129129
match /*bad*/copy i.node {
130-
ast::view_item_use(ident, meta_items, id) => {
131-
debug!("resolving use stmt. ident: %?, meta: %?", ident, meta_items);
130+
ast::view_item_extern_mod(ident, meta_items, id) => {
131+
debug!("resolving extern mod stmt. ident: %?, meta: %?",
132+
ident, meta_items);
132133
let cnum = resolve_crate(e, ident, meta_items, ~"", i.span);
133-
cstore::add_use_stmt_cnum(e.cstore, id, cnum);
134+
cstore::add_extern_mod_stmt_cnum(e.cstore, id, cnum);
134135
}
135136
_ => ()
136137
}

branches/snap-stage3/src/librustc/metadata/cstore.rs

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -40,22 +40,22 @@ pub type crate_metadata = @{name: ~str,
4040

4141
pub struct CStore {
4242
priv metas: oldmap::HashMap<ast::crate_num, crate_metadata>,
43-
priv use_crate_map: use_crate_map,
43+
priv extern_mod_crate_map: extern_mod_crate_map,
4444
priv used_crate_files: ~[Path],
4545
priv used_libraries: ~[~str],
4646
priv used_link_args: ~[~str],
4747
intr: @ident_interner
4848
}
4949

50-
// Map from node_id's of local use statements to crate numbers
51-
type use_crate_map = oldmap::HashMap<ast::node_id, ast::crate_num>;
50+
// Map from node_id's of local extern mod statements to crate numbers
51+
type extern_mod_crate_map = oldmap::HashMap<ast::node_id, ast::crate_num>;
5252

5353
pub fn mk_cstore(intr: @ident_interner) -> CStore {
5454
let meta_cache = oldmap::HashMap();
5555
let crate_map = oldmap::HashMap();
5656
return CStore {
5757
metas: meta_cache,
58-
use_crate_map: crate_map,
58+
extern_mod_crate_map: crate_map,
5959
used_crate_files: ~[],
6060
used_libraries: ~[],
6161
used_link_args: ~[],
@@ -127,18 +127,18 @@ pub fn get_used_link_args(cstore: @mut CStore) -> ~[~str] {
127127
return /*bad*/copy cstore.used_link_args;
128128
}
129129

130-
pub fn add_use_stmt_cnum(cstore: @mut CStore,
131-
use_id: ast::node_id,
132-
cnum: ast::crate_num) {
133-
let use_crate_map = cstore.use_crate_map;
134-
use_crate_map.insert(use_id, cnum);
130+
pub fn add_extern_mod_stmt_cnum(cstore: @mut CStore,
131+
emod_id: ast::node_id,
132+
cnum: ast::crate_num) {
133+
let extern_mod_crate_map = cstore.extern_mod_crate_map;
134+
extern_mod_crate_map.insert(emod_id, cnum);
135135
}
136136

137-
pub fn find_use_stmt_cnum(cstore: @mut CStore,
138-
use_id: ast::node_id)
137+
pub fn find_extern_mod_stmt_cnum(cstore: @mut CStore,
138+
emod_id: ast::node_id)
139139
-> Option<ast::crate_num> {
140-
let use_crate_map = cstore.use_crate_map;
141-
use_crate_map.find(&use_id)
140+
let extern_mod_crate_map = cstore.extern_mod_crate_map;
141+
extern_mod_crate_map.find(&emod_id)
142142
}
143143

144144
// returns hashes of crates directly used by this crate. Hashes are
@@ -147,8 +147,8 @@ pub fn get_dep_hashes(cstore: @mut CStore) -> ~[~str] {
147147
type crate_hash = {name: ~str, hash: ~str};
148148
let mut result = ~[];
149149

150-
let use_crate_map = cstore.use_crate_map;
151-
for use_crate_map.each_value |&cnum| {
150+
let extern_mod_crate_map = cstore.extern_mod_crate_map;
151+
for extern_mod_crate_map.each_value |&cnum| {
152152
let cdata = cstore::get_crate_data(cstore, cnum);
153153
let hash = decoder::get_crate_hash(cdata.data);
154154
debug!("Add hash[%s]: %s", cdata.name, hash);

branches/snap-stage3/src/librustc/middle/resolve.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ use driver::session::Session;
1515
use metadata::csearch::{each_path, get_method_names_if_trait};
1616
use metadata::csearch::{get_static_methods_if_impl, get_struct_fields};
1717
use metadata::csearch::{get_type_name_if_impl};
18-
use metadata::cstore::find_use_stmt_cnum;
18+
use metadata::cstore::find_extern_mod_stmt_cnum;
1919
use metadata::decoder::{def_like, dl_def, dl_field, dl_impl};
2020
use middle::lang_items::LanguageItems;
2121
use middle::lint::{deny, allow, forbid, level, unused_imports, warn};
@@ -55,7 +55,7 @@ use syntax::ast::{ty_bool, ty_char, ty_f, ty_f32, ty_f64, ty_float, ty_i};
5555
use syntax::ast::{ty_i16, ty_i32, ty_i64, ty_i8, ty_int, ty_param, ty_path};
5656
use syntax::ast::{ty_str, ty_u, ty_u16, ty_u32, ty_u64, ty_u8, ty_uint};
5757
use syntax::ast::{type_value_ns, ty_param_bound, unnamed_field};
58-
use syntax::ast::{variant, view_item, view_item_import};
58+
use syntax::ast::{variant, view_item, view_item_extern_mod};
5959
use syntax::ast::{view_item_use, view_path_glob, view_path_list};
6060
use syntax::ast::{view_path_simple, visibility, anonymous, named, not};
6161
use syntax::ast::{unsafe_fn};
@@ -1388,7 +1388,7 @@ pub impl Resolver {
13881388
&&_visitor: vt<ReducedGraphParent>) {
13891389
let privacy = visibility_to_privacy(view_item.vis);
13901390
match /*bad*/copy view_item.node {
1391-
view_item_import(view_paths) => {
1391+
view_item_use(view_paths) => {
13921392
for view_paths.each |view_path| {
13931393
// Extract and intern the module part of the path. For
13941394
// globs and lists, the path is found directly in the AST;
@@ -1462,8 +1462,8 @@ pub impl Resolver {
14621462
}
14631463
}
14641464
1465-
view_item_use(name, _, node_id) => {
1466-
match find_use_stmt_cnum(self.session.cstore, node_id) {
1465+
view_item_extern_mod(name, _, node_id) => {
1466+
match find_extern_mod_stmt_cnum(self.session.cstore, node_id) {
14671467
Some(crate_id) => {
14681468
let (child_name_bindings, new_parent) =
14691469
self.add_child(name, parent, ForbidDuplicateTypes,

branches/snap-stage3/src/libsyntax/ast.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1121,8 +1121,8 @@ pub struct view_item {
11211121
#[auto_decode]
11221122
#[deriving_eq]
11231123
pub enum view_item_ {
1124-
view_item_use(ident, ~[@meta_item], node_id),
1125-
view_item_import(~[@view_path]),
1124+
view_item_extern_mod(ident, ~[@meta_item], node_id),
1125+
view_item_use(~[@view_path]),
11261126
}
11271127
11281128
// Meta-data associated with an item

branches/snap-stage3/src/libsyntax/ast_util.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -395,8 +395,8 @@ pub fn id_visitor(vfn: fn@(node_id)) -> visit::vt<()> {
395395

396396
visit_view_item: fn@(vi: @view_item) {
397397
match vi.node {
398-
view_item_use(_, _, id) => vfn(id),
399-
view_item_import(vps) => {
398+
view_item_extern_mod(_, _, id) => vfn(id),
399+
view_item_use(vps) => {
400400
for vec::each(vps) |vp| {
401401
match vp.node {
402402
view_path_simple(_, _, _, id) => vfn(id),

branches/snap-stage3/src/libsyntax/ext/build.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ pub fn mk_glob_use(cx: ext_ctxt,
192192
node: ast::view_path_glob(mk_raw_path(sp, path), cx.next_id()),
193193
span: sp,
194194
};
195-
@ast::view_item { node: ast::view_item_import(~[glob]),
195+
@ast::view_item { node: ast::view_item_use(~[glob]),
196196
attrs: ~[],
197197
vis: ast::private,
198198
span: sp }

branches/snap-stage3/src/libsyntax/ext/pipes/ast_builder.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,7 @@ pub impl ext_ctxt_ast_builder for ext_ctxt {
310310
+items: ~[@ast::item]) -> @ast::item {
311311
// XXX: Total hack: import `core::kinds::Owned` to work around a
312312
// parser bug whereby `fn f<T: ::kinds::Owned>` doesn't parse.
313-
let vi = ast::view_item_import(~[
313+
let vi = ast::view_item_use(~[
314314
@codemap::spanned {
315315
node: ast::view_path_simple(
316316
self.ident_of(~"Owned"),

branches/snap-stage3/src/libsyntax/parse/parser.rs

Lines changed: 12 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ use ast::{ty_infer, ty_mac, ty_method};
5454
use ast::{ty_nil, ty_param, ty_param_bound, ty_path, ty_ptr, ty_rec, ty_rptr};
5555
use ast::{ty_tup, ty_u32, ty_uniq, ty_vec, type_value_ns, uniq};
5656
use ast::{unnamed_field, unsafe_blk, unsafe_fn, variant, view_item};
57-
use ast::{view_item_, view_item_import, view_item_use};
57+
use ast::{view_item_, view_item_extern_mod, view_item_use};
5858
use ast::{view_path, view_path_glob, view_path_list, view_path_simple};
5959
use ast::{visibility, vstore, vstore_box, vstore_fixed, vstore_slice};
6060
use ast::{vstore_uniq};
@@ -1061,9 +1061,6 @@ pub impl Parser {
10611061

10621062
if self.token == token::LPAREN {
10631063
self.bump();
1064-
// (e) is parenthesized e
1065-
// (e,) is a tuple with only one field, e
1066-
let mut one_tuple = false;
10671064
if self.token == token::RPAREN {
10681065
hi = self.span.hi;
10691066
self.bump();
@@ -1072,18 +1069,12 @@ pub impl Parser {
10721069
}
10731070
let mut es = ~[self.parse_expr()];
10741071
while self.token == token::COMMA {
1075-
self.bump();
1076-
if self.token != token::RPAREN {
1077-
es.push(self.parse_expr());
1078-
}
1079-
else {
1080-
one_tuple = true;
1081-
}
1072+
self.bump(); es.push(self.parse_expr());
10821073
}
10831074
hi = self.span.hi;
10841075
self.expect(token::RPAREN);
10851076

1086-
return if es.len() == 1 && !one_tuple {
1077+
return if es.len() == 1 {
10871078
self.mk_expr(lo, self.span.hi, expr_paren(es[0]))
10881079
}
10891080
else {
@@ -2167,13 +2158,11 @@ pub impl Parser {
21672158
pat = pat_lit(expr);
21682159
} else {
21692160
let mut fields = ~[self.parse_pat(refutable)];
2170-
if self.look_ahead(1) != token::RPAREN {
2171-
while self.token == token::COMMA {
2172-
self.bump();
2173-
fields.push(self.parse_pat(refutable));
2174-
}
2161+
while self.token == token::COMMA {
2162+
self.bump();
2163+
fields.push(self.parse_pat(refutable));
21752164
}
2176-
if fields.len() == 1 { self.expect(token::COMMA); }
2165+
if vec::len(fields) == 1u { self.expect(token::COMMA); }
21772166
hi = self.span.hi;
21782167
self.expect(token::RPAREN);
21792168
pat = pat_tup(fields);
@@ -3514,7 +3503,7 @@ pub impl Parser {
35143503
let metadata = self.parse_optional_meta();
35153504
self.expect(token::SEMI);
35163505
iovi_view_item(@ast::view_item {
3517-
node: view_item_use(ident, metadata, self.get_id()),
3506+
node: view_item_extern_mod(ident, metadata, self.get_id()),
35183507
attrs: attrs,
35193508
vis: visibility,
35203509
span: mk_sp(lo, self.last_span.hi)
@@ -3895,7 +3884,7 @@ pub impl Parser {
38953884
}
38963885

38973886
fn parse_use() -> view_item_ {
3898-
return view_item_import(self.parse_view_paths());
3887+
return view_item_use(self.parse_view_paths());
38993888
}
39003889

39013890
fn parse_view_path() -> @view_path {
@@ -4017,7 +4006,7 @@ pub impl Parser {
40174006
self.expect_keyword(~"mod");
40184007
let ident = self.parse_ident();
40194008
let metadata = self.parse_optional_meta();
4020-
view_item_use(ident, metadata, self.get_id())
4009+
view_item_extern_mod(ident, metadata, self.get_id())
40214010
} else {
40224011
fail!();
40234012
};
@@ -4064,8 +4053,8 @@ pub impl Parser {
40644053
iovi_view_item(view_item) => {
40654054
if restricted_to_imports {
40664055
match view_item.node {
4067-
view_item_import(_) => {}
4068-
view_item_use(*) =>
4056+
view_item_use(*) => {}
4057+
view_item_extern_mod(*) =>
40694058
self.fatal(~"\"extern mod\" \
40704059
declarations are not \
40714060
allowed here")

branches/snap-stage3/src/libsyntax/print/pprust.rs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1199,9 +1199,6 @@ pub fn print_expr(s: @ps, &&expr: @ast::expr) {
11991199
ast::expr_tup(exprs) => {
12001200
popen(s);
12011201
commasep_exprs(s, inconsistent, exprs);
1202-
if exprs.len() == 1 {
1203-
word(s.s, ~",");
1204-
}
12051202
pclose(s);
12061203
}
12071204
ast::expr_call(func, args, sugar) => {
@@ -1637,9 +1634,6 @@ pub fn print_pat(s: @ps, &&pat: @ast::pat, refutable: bool) {
16371634
ast::pat_tup(elts) => {
16381635
popen(s);
16391636
commasep(s, inconsistent, elts, |s, p| print_pat(s, p, refutable));
1640-
if elts.len() == 1 {
1641-
word(s.s, ~",");
1642-
}
16431637
pclose(s);
16441638
}
16451639
ast::pat_box(inner) => {
@@ -1865,7 +1859,7 @@ pub fn print_view_item(s: @ps, item: @ast::view_item) {
18651859
print_outer_attributes(s, item.attrs);
18661860
print_visibility(s, item.vis);
18671861
match item.node {
1868-
ast::view_item_use(id, mta, _) => {
1862+
ast::view_item_extern_mod(id, mta, _) => {
18691863
head(s, ~"extern mod");
18701864
print_ident(s, id);
18711865
if !mta.is_empty() {
@@ -1875,7 +1869,7 @@ pub fn print_view_item(s: @ps, item: @ast::view_item) {
18751869
}
18761870
}
18771871
1878-
ast::view_item_import(vps) => {
1872+
ast::view_item_use(vps) => {
18791873
head(s, ~"use");
18801874
print_view_paths(s, vps);
18811875
}

branches/snap-stage3/src/test/run-pass/one-tuple.rs

Lines changed: 0 additions & 20 deletions
This file was deleted.

0 commit comments

Comments
 (0)