Skip to content

Commit 624898a

Browse files
committed
---
yaml --- r: 47093 b: refs/heads/try c: 9ba2e65 h: refs/heads/master i: 47091: 8cbc596 v: v3
1 parent 2796e1e commit 624898a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+297
-304
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
refs/heads/master: 3bbcac322669cff3abde5be937cc4ec3860f3985
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: a6d9689399d091c3265f00434a69c551a61c28dc
5-
refs/heads/try: aa284de1fc246b55fb53783ded3e9786e04b03d0
5+
refs/heads/try: 9ba2e65fd6892d2200b517d11e95870e4b2ece12
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: 147ecfdd8221e4a4d4e090486829a06da1e0ca3c

branches/try/src/libcore/to_str.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,6 @@ impl ToStr for @str {
4343
pure fn to_str(&self) -> ~str { ::str::from_slice(*self) }
4444
}
4545

46-
// FIXME #4898: impl for one-tuples
47-
4846
impl<A: ToStr, B: ToStr> ToStr for (A, B) {
4947
#[inline(always)]
5048
pure fn to_str(&self) -> ~str {

branches/try/src/libcore/tuple.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,6 @@ impl<A: Copy, B: Copy> ExtendedTupleOps<A,B> for (~[A], ~[B]) {
111111
}
112112
}
113113

114-
// FIXME #4898: impl for one-tuples
115-
116114
#[cfg(notest)]
117115
impl<A: Eq, B: Eq> Eq for (A, B) {
118116
#[inline(always)]

branches/try/src/libcore/vec.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1865,6 +1865,7 @@ pub trait OwnedVector<T> {
18651865
fn consume(self, f: fn(uint, v: T));
18661866
fn filter(self, f: fn(t: &T) -> bool) -> ~[T];
18671867
fn partition(self, f: pure fn(&T) -> bool) -> (~[T], ~[T]);
1868+
fn grow_fn(&mut self, n: uint, op: iter::InitOp<T>);
18681869
}
18691870

18701871
impl<T> OwnedVector<T> for ~[T] {
@@ -1936,6 +1937,11 @@ impl<T> OwnedVector<T> for ~[T] {
19361937
fn partition(self, f: fn(&T) -> bool) -> (~[T], ~[T]) {
19371938
partition(self, f)
19381939
}
1940+
1941+
#[inline]
1942+
fn grow_fn(&mut self, n: uint, op: iter::InitOp<T>) {
1943+
grow_fn(self, n, op);
1944+
}
19391945
}
19401946

19411947
impl<T> Mutable for ~[T] {
@@ -1946,7 +1952,6 @@ impl<T> Mutable for ~[T] {
19461952
pub trait OwnedCopyableVector<T: Copy> {
19471953
fn push_all(&mut self, rhs: &[const T]);
19481954
fn grow(&mut self, n: uint, initval: &T);
1949-
fn grow_fn(&mut self, n: uint, op: iter::InitOp<T>);
19501955
fn grow_set(&mut self, index: uint, initval: &T, val: T);
19511956
}
19521957

@@ -1961,11 +1966,6 @@ impl<T: Copy> OwnedCopyableVector<T> for ~[T] {
19611966
grow(self, n, initval);
19621967
}
19631968

1964-
#[inline]
1965-
fn grow_fn(&mut self, n: uint, op: iter::InitOp<T>) {
1966-
grow_fn(self, n, op);
1967-
}
1968-
19691969
#[inline]
19701970
fn grow_set(&mut self, index: uint, initval: &T, val: T) {
19711971
grow_set(self, index, initval, val);

branches/try/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/try/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/try/src/librustc/metadata/creader.rs

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ pub fn read_crates(diag: span_handler,
5555
visit_view_item: |a| visit_view_item(e, a),
5656
visit_item: |a| visit_item(e, a),
5757
.. *visit::default_simple_visitor()});
58+
visit_crate(e, crate);
5859
visit::visit_crate(crate, (), v);
5960
dump_crates(e.crate_cache);
6061
warn_if_multiple_versions(e, diag, e.crate_cache);
@@ -125,12 +126,27 @@ struct Env {
125126
intr: @ident_interner
126127
}
127128

129+
fn visit_crate(e: @mut Env, c: ast::crate) {
130+
let cstore = e.cstore;
131+
let link_args = attr::find_attrs_by_name(c.node.attrs, "link_args");
132+
133+
for link_args.each |a| {
134+
match attr::get_meta_item_value_str(attr::attr_meta(*a)) {
135+
Some(ref linkarg) => {
136+
cstore::add_used_link_args(cstore, (/*bad*/copy *linkarg));
137+
}
138+
None => {/* fallthrough */ }
139+
}
140+
}
141+
}
142+
128143
fn visit_view_item(e: @mut Env, i: @ast::view_item) {
129144
match /*bad*/copy i.node {
130-
ast::view_item_use(ident, meta_items, id) => {
131-
debug!("resolving use stmt. ident: %?, meta: %?", ident, meta_items);
145+
ast::view_item_extern_mod(ident, meta_items, id) => {
146+
debug!("resolving extern mod stmt. ident: %?, meta: %?",
147+
ident, meta_items);
132148
let cnum = resolve_crate(e, ident, meta_items, ~"", i.span);
133-
cstore::add_use_stmt_cnum(e.cstore, id, cnum);
149+
cstore::add_extern_mod_stmt_cnum(e.cstore, id, cnum);
134150
}
135151
_ => ()
136152
}
@@ -181,7 +197,7 @@ fn visit_item(e: @mut Env, i: @ast::item) {
181197
for link_args.each |a| {
182198
match attr::get_meta_item_value_str(attr::attr_meta(*a)) {
183199
Some(ref linkarg) => {
184-
cstore::add_used_link_args(cstore, (/*bad*/copy *linkarg));
200+
cstore::add_used_link_args(cstore, *linkarg);
185201
}
186202
None => {/* fallthrough */ }
187203
}

branches/try/src/librustc/metadata/cstore.rs

Lines changed: 16 additions & 16 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: ~[],
@@ -119,26 +119,26 @@ pub fn get_used_libraries(cstore: @mut CStore) -> ~[~str] {
119119
return /*bad*/copy cstore.used_libraries;
120120
}
121121

122-
pub fn add_used_link_args(cstore: @mut CStore, args: ~str) {
122+
pub fn add_used_link_args(cstore: @mut CStore, args: &str) {
123123
cstore.used_link_args.push_all(str::split_char(args, ' '));
124124
}
125125

126126
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/try/src/librustc/middle/resolve.rs

Lines changed: 6 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,9 @@ 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,
1467+
node_id) {
14671468
Some(crate_id) => {
14681469
let (child_name_bindings, new_parent) =
14691470
self.add_child(name, parent, ForbidDuplicateTypes,

branches/try/src/librustc/middle/trans/type_of.rs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -328,11 +328,20 @@ pub fn type_of(cx: @crate_ctxt, t: ty::t) -> TypeRef {
328328
pub fn enum_body_types(cx: @crate_ctxt, did: ast::def_id, t: ty::t)
329329
-> ~[TypeRef] {
330330
let univar = ty::enum_is_univariant(cx.tcx, did);
331-
let size = machine::static_size_of_enum(cx, t);
332331
if !univar {
332+
let size = machine::static_size_of_enum(cx, t);
333333
~[T_enum_discrim(cx), T_array(T_i8(), size)]
334-
} else {
335-
~[T_array(T_i8(), size)]
334+
}
335+
else {
336+
// Use the actual fields, so we get the alignment right.
337+
match ty::get(t).sty {
338+
ty::ty_enum(_, ref substs) => {
339+
do ty::enum_variants(cx.tcx, did)[0].args.map |&field_ty| {
340+
sizing_type_of(cx, ty::subst(cx.tcx, substs, field_ty))
341+
}
342+
}
343+
_ => cx.sess.bug(~"enum is not an enum")
344+
}
336345
}
337346
}
338347

branches/try/src/libstd/deque.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ fn grow<T>(nelts: uint, lo: uint, elts: &mut [Option<T>]) -> ~[Option<T>] {
100100
assert nelts == elts.len();
101101
let mut rv = ~[];
102102

103-
do vec::grow_fn(&mut rv, nelts + 1) |i| {
103+
do rv.grow_fn(nelts + 1) |i| {
104104
let mut element = None;
105105
element <-> elts[(lo + i) % nelts];
106106
element

branches/try/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/try/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/try/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 }

0 commit comments

Comments
 (0)