Skip to content

Commit afdd0b8

Browse files
committed
auto merge of #5143 : erickt/rust/incoming, r=pcwalton
Good morning, It's taken a long time, but I finally am almost done freeing libsyntax of `vecs_implicitly_copyable` in this pull request, but I'm running into some issues. I've confirmed that all but the last commit (which only disables `vecs_implicitly_copyable` pass the `check` tests. The last commit errors with this message, which makes no sense to me: ``` /Users/erickt/rust/rust/src/libcore/num/f32.rs:35:37: 35:43 error: expected `,` but found `=` /Users/erickt/rust/rust/src/libcore/num/f32.rs:35 pub pure fn $name($( $arg : $arg_ty ),*) -> $rv { ^~~~~~ ``` and this stack trace: ``` #1 0x00000001000b059b in sys::begin_unwind_::_a923ca4ae164c::_06 () #2 0x00000001000b0542 in sys::begin_unwind::anon::anon::expr_fn_13876 () #3 0x00000001000048a1 in sys::begin_unwind::_8ec273289fc0adc0::_06 () #4 0x00000001005df999 in diagnostic::__extensions__::meth_7941::span_fatal::_efdf2d14612d79ec::_06 () #5 0x0000000100682d48 in parse::parser::__extensions__::meth_16938::fatal::_8aa3239426747a3::_06 () #6 0x00000001006850b8 in parse::common::__extensions__::meth_17005::expect::_d3604ec6c7698d5f::_06 () #7 0x00000001006b59f1 in parse::common::__extensions__::parse_seq_to_before_end_17860::_48c79835f9eb1011::_06 () #8 0x00000001006a50f7 in parse::parser::__extensions__::meth_17606::parse_fn_decl::_14f3785fe78967d::_06 () #9 0x00000001006b6f59 in parse::parser::__extensions__::meth_17987::parse_item_fn::_8a6be529cf7b2ca5::_06 () #10 0x00000001006ac839 in parse::parser::__extensions__::meth_17761::parse_item_or_view_item::_bfead947d6dd7d25::_06 () #11 0x00000001006c8b8f in parse::parser::__extensions__::meth_18364::parse_item::_96b54e33f65abe76::_06 () #12 0x000000010076179f in ext::tt::macro_rules::add_new_extension::generic_extension::anon::anon::expr_fn_23365 () #13 0x000000010072e793 in ext::expand::expand_item_mac::_a4f486c4465cfb1b::_06 () #14 0x00000001007b5ad3 in __morestack () ``` There also a bunch of new warnings that I haven't cleaned up yet: https://gist.github.com/erickt/5048251. @nikomatsakis thought there might be some scary bug in the parser caused by moving a vector in the parser instead of copying it, which is why I'm filing this pull request before it's ready. Thanks for any help!
2 parents 2304fe6 + 5515fd5 commit afdd0b8

Some content is hidden

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

77 files changed

+2868
-2257
lines changed

src/libfuzzer/fuzzer.rc

+9-9
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ pub pure fn safe_to_use_expr(e: ast::expr, tm: test_mode) -> bool {
134134

135135
pub fn safe_to_steal_ty(t: @ast::Ty, tm: test_mode) -> bool {
136136
// Restrictions happen to be the same.
137-
safe_to_replace_ty(t.node, tm)
137+
safe_to_replace_ty(&t.node, tm)
138138
}
139139

140140
// Not type-parameterized: https://github.com/mozilla/rust/issues/898 (FIXED)
@@ -175,8 +175,8 @@ pub fn steal(crate: ast::crate, tm: test_mode) -> StolenStuff {
175175
}
176176

177177

178-
pub fn safe_to_replace_expr(e: ast::expr_, _tm: test_mode) -> bool {
179-
match e {
178+
pub fn safe_to_replace_expr(e: &ast::expr_, _tm: test_mode) -> bool {
179+
match *e {
180180
// https://github.com/mozilla/rust/issues/652
181181
ast::expr_if(*) => { false }
182182
ast::expr_block(_) => { false }
@@ -188,8 +188,8 @@ pub fn safe_to_replace_expr(e: ast::expr_, _tm: test_mode) -> bool {
188188
}
189189
}
190190

191-
pub fn safe_to_replace_ty(t: ast::ty_, _tm: test_mode) -> bool {
192-
match t {
191+
pub fn safe_to_replace_ty(t: &ast::ty_, _tm: test_mode) -> bool {
192+
match *t {
193193
ast::ty_infer => { false } // always implicit, always top level
194194
ast::ty_bot => { false } // in source, can only appear
195195
// as the out type of a function
@@ -204,7 +204,7 @@ pub fn replace_expr_in_crate(crate: ast::crate, i: uint,
204204
ast::crate {
205205
let j: @mut uint = @mut 0u;
206206
fn fold_expr_rep(j_: @mut uint, i_: uint, newexpr_: ast::expr_,
207-
original: ast::expr_, fld: fold::ast_fold,
207+
original: &ast::expr_, fld: fold::ast_fold,
208208
tm_: test_mode) ->
209209
ast::expr_ {
210210
*j_ += 1u;
@@ -221,7 +221,7 @@ pub fn replace_expr_in_crate(crate: ast::crate, i: uint,
221221
.. *fold::default_ast_fold()
222222
};
223223
let af = fold::make_fold(afp);
224-
let crate2: @ast::crate = @af.fold_crate(crate);
224+
let crate2: @ast::crate = @af.fold_crate(&crate);
225225
*crate2
226226
}
227227

@@ -231,7 +231,7 @@ pub fn replace_ty_in_crate(crate: ast::crate, i: uint, newty: ast::Ty,
231231
tm: test_mode) -> ast::crate {
232232
let j: @mut uint = @mut 0u;
233233
fn fold_ty_rep(j_: @mut uint, i_: uint, newty_: ast::ty_,
234-
original: ast::ty_, fld: fold::ast_fold,
234+
original: &ast::ty_, fld: fold::ast_fold,
235235
tm_: test_mode) ->
236236
ast::ty_ {
237237
*j_ += 1u;
@@ -244,7 +244,7 @@ pub fn replace_ty_in_crate(crate: ast::crate, i: uint, newty: ast::Ty,
244244
.. *fold::default_ast_fold()
245245
};
246246
let af = fold::make_fold(afp);
247-
let crate2: @ast::crate = @af.fold_crate(crate);
247+
let crate2: @ast::crate = @af.fold_crate(&crate);
248248
*crate2
249249
}
250250

src/librustc/driver/driver.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,7 @@ pub fn pretty_print_input(sess: Session, +cfg: ast::crate_cfg, input: input,
396396
pprust::node_block(s, ref blk) => {
397397
pp::space(s.s);
398398
pprust::synth_comment(
399-
s, ~"block " + int::to_str((*blk).node.id));
399+
s, ~"block " + int::to_str(blk.node.id));
400400
}
401401
pprust::node_expr(s, expr) => {
402402
pp::space(s.s);

src/librustc/driver/session.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,7 @@ pub mod test {
358358
pub fn make_crate_type_attr(+t: ~str) -> ast::attribute {
359359
codemap::respan(codemap::dummy_sp(), ast::attribute_ {
360360
style: ast::attr_outer,
361-
value: codemap::respan(codemap::dummy_sp(),
361+
value: @codemap::respan(codemap::dummy_sp(),
362362
ast::meta_name_value(
363363
@~"crate_type",
364364
codemap::respan(codemap::dummy_sp(),

src/librustc/front/config.rs

+10-10
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ pub fn strip_items(crate: @ast::crate, in_cfg: in_cfg_pred)
4545
.. *fold::default_ast_fold()};
4646

4747
let fold = fold::make_fold(precursor);
48-
let res = @fold.fold_crate(*crate);
48+
let res = @fold.fold_crate(&*crate);
4949
return res;
5050
}
5151

@@ -63,7 +63,7 @@ fn filter_view_item(cx: @Context, &&view_item: @ast::view_item
6363
}
6464
}
6565

66-
fn fold_mod(cx: @Context, m: ast::_mod, fld: fold::ast_fold) -> ast::_mod {
66+
fn fold_mod(cx: @Context, m: &ast::_mod, fld: fold::ast_fold) -> ast::_mod {
6767
let filtered_items =
6868
m.items.filter_mapped(|a| filter_item(cx, *a));
6969
let filtered_view_items =
@@ -83,7 +83,7 @@ fn filter_foreign_item(cx: @Context, &&item: @ast::foreign_item) ->
8383

8484
fn fold_foreign_mod(
8585
cx: @Context,
86-
nm: ast::foreign_mod,
86+
nm: &ast::foreign_mod,
8787
fld: fold::ast_fold
8888
) -> ast::foreign_mod {
8989
let filtered_items =
@@ -98,21 +98,21 @@ fn fold_foreign_mod(
9898
}
9999
}
100100

101-
fn fold_item_underscore(cx: @Context, +item: ast::item_,
101+
fn fold_item_underscore(cx: @Context, item: &ast::item_,
102102
fld: fold::ast_fold) -> ast::item_ {
103-
let item = match item {
104-
ast::item_impl(a, b, c, methods) => {
103+
let item = match *item {
104+
ast::item_impl(ref a, b, c, ref methods) => {
105105
let methods = methods.filtered(|m| method_in_cfg(cx, *m) );
106-
ast::item_impl(a, b, c, methods)
106+
ast::item_impl(/*bad*/ copy *a, b, c, methods)
107107
}
108108
ast::item_trait(ref a, ref b, ref methods) => {
109109
let methods = methods.filtered(|m| trait_method_in_cfg(cx, m) );
110110
ast::item_trait(/*bad*/copy *a, /*bad*/copy *b, methods)
111111
}
112-
item => item
112+
ref item => /*bad*/ copy *item
113113
};
114114

115-
fold::noop_fold_item_underscore(item, fld)
115+
fold::noop_fold_item_underscore(&item, fld)
116116
}
117117

118118
fn filter_stmt(cx: @Context, &&stmt: @ast::stmt) ->
@@ -134,7 +134,7 @@ fn filter_stmt(cx: @Context, &&stmt: @ast::stmt) ->
134134

135135
fn fold_block(
136136
cx: @Context,
137-
b: ast::blk_,
137+
b: &ast::blk_,
138138
fld: fold::ast_fold
139139
) -> ast::blk_ {
140140
let filtered_stmts =

src/librustc/front/core_inject.rs

+12-6
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ fn inject_libcore_ref(sess: Session,
5050
attrs: ~[
5151
spanned(ast::attribute_ {
5252
style: ast::attr_inner,
53-
value: spanned(ast::meta_name_value(
53+
value: @spanned(ast::meta_name_value(
5454
@~"vers",
5555
spanned(ast::lit_str(@CORE_VERSION.to_str()))
5656
)),
@@ -66,10 +66,13 @@ fn inject_libcore_ref(sess: Session,
6666
view_items: vis,
6767
../*bad*/copy crate.module
6868
};
69-
new_module = fld.fold_mod(new_module);
69+
new_module = fld.fold_mod(&new_module);
7070

7171
// FIXME #2543: Bad copy.
72-
let new_crate = ast::crate_ { module: new_module, ..copy crate };
72+
let new_crate = ast::crate_ {
73+
module: new_module,
74+
..copy *crate
75+
};
7376
(new_crate, span)
7477
},
7578
fold_mod: |module, fld| {
@@ -95,12 +98,15 @@ fn inject_libcore_ref(sess: Session,
9598
let vis = vec::append(~[vi2], module.view_items);
9699

97100
// FIXME #2543: Bad copy.
98-
let new_module = ast::_mod { view_items: vis, ..copy module };
99-
fold::noop_fold_mod(new_module, fld)
101+
let new_module = ast::_mod {
102+
view_items: vis,
103+
..copy *module
104+
};
105+
fold::noop_fold_mod(&new_module, fld)
100106
},
101107
..*fold::default_ast_fold()
102108
};
103109

104110
let fold = fold::make_fold(precursor);
105-
@fold.fold_crate(*crate)
111+
@fold.fold_crate(crate)
106112
}

src/librustc/front/test.rs

+10-8
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ fn generate_test_harness(sess: session::Session,
9191
fold_mod: |a,b| fold_mod(cx, a, b),.. *fold::default_ast_fold()};
9292

9393
let fold = fold::make_fold(precursor);
94-
let res = @fold.fold_crate(*crate);
94+
let res = @fold.fold_crate(&*crate);
9595
cx.ext_cx.bt_pop();
9696
return res;
9797
}
@@ -106,7 +106,7 @@ fn strip_test_functions(crate: @ast::crate) -> @ast::crate {
106106
}
107107

108108
fn fold_mod(cx: @mut TestCtxt,
109-
m: ast::_mod,
109+
m: &ast::_mod,
110110
fld: fold::ast_fold)
111111
-> ast::_mod {
112112
// Remove any #[main] from the AST so it doesn't clash with
@@ -125,19 +125,21 @@ fn fold_mod(cx: @mut TestCtxt,
125125
items: vec::map(m.items, |i| nomain(cx, *i)),
126126
};
127127

128-
fold::noop_fold_mod(mod_nomain, fld)
128+
fold::noop_fold_mod(&mod_nomain, fld)
129129
}
130130

131131
fn fold_crate(cx: @mut TestCtxt,
132-
c: ast::crate_,
132+
c: &ast::crate_,
133133
fld: fold::ast_fold)
134134
-> ast::crate_ {
135135
let folded = fold::noop_fold_crate(c, fld);
136136

137137
// Add a special __test module to the crate that will contain code
138138
// generated for the test harness
139-
ast::crate_ { module: add_test_module(cx, /*bad*/copy folded.module),
140-
.. folded }
139+
ast::crate_ {
140+
module: add_test_module(cx, &folded.module),
141+
.. folded
142+
}
141143
}
142144

143145

@@ -238,11 +240,11 @@ fn should_fail(i: @ast::item) -> bool {
238240
vec::len(attr::find_attrs_by_name(i.attrs, ~"should_fail")) > 0u
239241
}
240242

241-
fn add_test_module(cx: &TestCtxt, +m: ast::_mod) -> ast::_mod {
243+
fn add_test_module(cx: &TestCtxt, m: &ast::_mod) -> ast::_mod {
242244
let testmod = mk_test_module(cx);
243245
ast::_mod {
244246
items: vec::append_one(/*bad*/copy m.items, testmod),
245-
.. m
247+
.. /*bad*/ copy *m
246248
}
247249
}
248250

src/librustc/metadata/decoder.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1009,7 +1009,7 @@ fn get_attributes(md: ebml::Doc) -> ~[ast::attribute] {
10091009
codemap::spanned {
10101010
node: ast::attribute_ {
10111011
style: ast::attr_outer,
1012-
value: /*bad*/copy *meta_item,
1012+
value: meta_item,
10131013
is_sugared_doc: false,
10141014
},
10151015
span: codemap::dummy_sp()

src/librustc/metadata/encoder.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,7 @@ fn encode_path(ecx: @EncodeContext, ebml_w: writer::Encoder,
326326
}
327327

328328
fn encode_info_for_mod(ecx: @EncodeContext, ebml_w: writer::Encoder,
329-
md: _mod, id: node_id, path: &[ast_map::path_elt],
329+
md: &_mod, id: node_id, path: &[ast_map::path_elt],
330330
name: ident) {
331331
ebml_w.start_tag(tag_items_data_item);
332332
encode_def_id(ebml_w, local_def(id));
@@ -659,7 +659,7 @@ fn encode_info_for_item(ecx: @EncodeContext, ebml_w: writer::Encoder,
659659
}
660660
ebml_w.end_tag();
661661
}
662-
item_mod(m) => {
662+
item_mod(ref m) => {
663663
add_to_index();
664664
encode_info_for_mod(ecx, ebml_w, m, item.id, path, item.ident);
665665
}
@@ -912,8 +912,8 @@ fn encode_info_for_item(ecx: @EncodeContext, ebml_w: writer::Encoder,
912912
// method info, we output static methods with type signatures as
913913
// written. Here, we output the *real* type signatures. I feel like
914914
// maybe we should only ever handle the real type signatures.
915-
for vec::each((*ms)) |m| {
916-
let ty_m = ast_util::trait_method_to_ty_method(*m);
915+
for ms.each |m| {
916+
let ty_m = ast_util::trait_method_to_ty_method(m);
917917
if ty_m.self_ty.node != ast::sty_static { loop; }
918918
919919
index.push(entry { val: ty_m.id, pos: ebml_w.writer.tell() });
@@ -995,7 +995,7 @@ fn encode_info_for_items(ecx: @EncodeContext, ebml_w: writer::Encoder,
995995
let index = @mut ~[];
996996
ebml_w.start_tag(tag_items_data);
997997
index.push(entry { val: crate_node_id, pos: ebml_w.writer.tell() });
998-
encode_info_for_mod(ecx, ebml_w, crate.node.module,
998+
encode_info_for_mod(ecx, ebml_w, &crate.node.module,
999999
crate_node_id, ~[],
10001000
syntax::parse::token::special_idents::invalid);
10011001
visit::visit_crate(*crate, (), visit::mk_vt(@visit::Visitor {
@@ -1088,7 +1088,7 @@ fn write_int(writer: io::Writer, &&n: int) {
10881088
writer.write_be_u32(n as u32);
10891089
}
10901090
1091-
fn encode_meta_item(ebml_w: writer::Encoder, mi: meta_item) {
1091+
fn encode_meta_item(ebml_w: writer::Encoder, mi: @meta_item) {
10921092
match mi.node {
10931093
meta_word(name) => {
10941094
ebml_w.start_tag(tag_meta_item_word);
@@ -1118,7 +1118,7 @@ fn encode_meta_item(ebml_w: writer::Encoder, mi: meta_item) {
11181118
ebml_w.writer.write(str::to_bytes(*name));
11191119
ebml_w.end_tag();
11201120
for items.each |inner_item| {
1121-
encode_meta_item(ebml_w, **inner_item);
1121+
encode_meta_item(ebml_w, *inner_item);
11221122
}
11231123
ebml_w.end_tag();
11241124
}

src/librustc/middle/astencode.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@ fn encode_ast(ebml_w: writer::Encoder, item: ast::inlined_item) {
298298
// nested items, as otherwise it would get confused when translating
299299
// inlined items.
300300
fn simplify_ast(ii: ast::inlined_item) -> ast::inlined_item {
301-
fn drop_nested_items(blk: ast::blk_, fld: fold::ast_fold) -> ast::blk_ {
301+
fn drop_nested_items(blk: &ast::blk_, fld: fold::ast_fold) -> ast::blk_ {
302302
let stmts_sans_items = do blk.stmts.filtered |stmt| {
303303
match stmt.node {
304304
ast::stmt_expr(_, _) | ast::stmt_semi(_, _) |
@@ -317,7 +317,7 @@ fn simplify_ast(ii: ast::inlined_item) -> ast::inlined_item {
317317
id: blk.id,
318318
rules: blk.rules
319319
};
320-
fold::noop_fold_block(blk_sans_items, fld)
320+
fold::noop_fold_block(&blk_sans_items, fld)
321321
}
322322
323323
let fld = fold::make_fold(@fold::AstFoldFns {
@@ -336,7 +336,7 @@ fn simplify_ast(ii: ast::inlined_item) -> ast::inlined_item {
336336
ast::ii_foreign(fld.fold_foreign_item(i))
337337
}
338338
ast::ii_dtor(ref dtor, nm, ref tps, parent_id) => {
339-
let dtor_body = fld.fold_block((*dtor).node.body);
339+
let dtor_body = fld.fold_block(&dtor.node.body);
340340
ast::ii_dtor(
341341
codemap::spanned {
342342
node: ast::struct_dtor_ { body: dtor_body,
@@ -372,8 +372,8 @@ fn renumber_ast(xcx: @ExtendedDecodeContext, ii: ast::inlined_item)
372372
ast::ii_foreign(fld.fold_foreign_item(i))
373373
}
374374
ast::ii_dtor(ref dtor, nm, ref generics, parent_id) => {
375-
let dtor_body = fld.fold_block((*dtor).node.body);
376-
let dtor_attrs = fld.fold_attributes(copy dtor.node.attrs);
375+
let dtor_body = fld.fold_block(&dtor.node.body);
376+
let dtor_attrs = fld.fold_attributes(/*bad*/copy (*dtor).node.attrs);
377377
let new_generics = fold::fold_generics(generics, fld);
378378
let dtor_id = fld.new_id((*dtor).node.id);
379379
let new_parent = xcx.tr_def_id(parent_id);

src/librustc/middle/borrowck/check_loans.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -579,9 +579,9 @@ pub impl CheckLoanCtxt {
579579
}
580580
}
581581

582-
fn check_loans_in_fn(fk: visit::fn_kind,
583-
decl: ast::fn_decl,
584-
body: ast::blk,
582+
fn check_loans_in_fn(fk: &visit::fn_kind,
583+
decl: &ast::fn_decl,
584+
body: &ast::blk,
585585
sp: span,
586586
id: ast::node_id,
587587
&&self: @mut CheckLoanCtxt,
@@ -590,7 +590,7 @@ fn check_loans_in_fn(fk: visit::fn_kind,
590590
let fty = ty::node_id_to_type(self.tcx(), id);
591591

592592
let declared_purity;
593-
match fk {
593+
match *fk {
594594
visit::fk_item_fn(*) | visit::fk_method(*) |
595595
visit::fk_dtor(*) => {
596596
declared_purity = ty::ty_fn_purity(fty);
@@ -611,7 +611,7 @@ fn check_loans_in_fn(fk: visit::fn_kind,
611611
do save_and_restore_managed(self.fn_args) {
612612
*self.declared_purity = declared_purity;
613613

614-
match fk {
614+
match *fk {
615615
visit::fk_anon(*) |
616616
visit::fk_fn_block(*) if is_stack_closure => {
617617
// inherits the fn_args from enclosing ctxt
@@ -753,7 +753,7 @@ fn check_loans_in_expr(expr: @ast::expr,
753753
visit::visit_expr(expr, self, vt);
754754
}
755755

756-
fn check_loans_in_block(blk: ast::blk,
756+
fn check_loans_in_block(blk: &ast::blk,
757757
&&self: @mut CheckLoanCtxt,
758758
vt: visit::vt<@mut CheckLoanCtxt>) {
759759
do save_and_restore_managed(self.declared_purity) {

0 commit comments

Comments
 (0)