Skip to content

Commit

Permalink
auto merge of #5143 : erickt/rust/incoming, r=pcwalton
Browse files Browse the repository at this point in the history
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!
  • Loading branch information
bors committed Mar 2, 2013
2 parents 2304fe6 + 5515fd5 commit afdd0b8
Show file tree
Hide file tree
Showing 77 changed files with 2,868 additions and 2,257 deletions.
18 changes: 9 additions & 9 deletions src/libfuzzer/fuzzer.rc
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ pub pure fn safe_to_use_expr(e: ast::expr, tm: test_mode) -> bool {

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

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


pub fn safe_to_replace_expr(e: ast::expr_, _tm: test_mode) -> bool {
match e {
pub fn safe_to_replace_expr(e: &ast::expr_, _tm: test_mode) -> bool {
match *e {
// https://github.com/mozilla/rust/issues/652
ast::expr_if(*) => { false }
ast::expr_block(_) => { false }
Expand All @@ -188,8 +188,8 @@ pub fn safe_to_replace_expr(e: ast::expr_, _tm: test_mode) -> bool {
}
}

pub fn safe_to_replace_ty(t: ast::ty_, _tm: test_mode) -> bool {
match t {
pub fn safe_to_replace_ty(t: &ast::ty_, _tm: test_mode) -> bool {
match *t {
ast::ty_infer => { false } // always implicit, always top level
ast::ty_bot => { false } // in source, can only appear
// as the out type of a function
Expand All @@ -204,7 +204,7 @@ pub fn replace_expr_in_crate(crate: ast::crate, i: uint,
ast::crate {
let j: @mut uint = @mut 0u;
fn fold_expr_rep(j_: @mut uint, i_: uint, newexpr_: ast::expr_,
original: ast::expr_, fld: fold::ast_fold,
original: &ast::expr_, fld: fold::ast_fold,
tm_: test_mode) ->
ast::expr_ {
*j_ += 1u;
Expand All @@ -221,7 +221,7 @@ pub fn replace_expr_in_crate(crate: ast::crate, i: uint,
.. *fold::default_ast_fold()
};
let af = fold::make_fold(afp);
let crate2: @ast::crate = @af.fold_crate(crate);
let crate2: @ast::crate = @af.fold_crate(&crate);
*crate2
}

Expand All @@ -231,7 +231,7 @@ pub fn replace_ty_in_crate(crate: ast::crate, i: uint, newty: ast::Ty,
tm: test_mode) -> ast::crate {
let j: @mut uint = @mut 0u;
fn fold_ty_rep(j_: @mut uint, i_: uint, newty_: ast::ty_,
original: ast::ty_, fld: fold::ast_fold,
original: &ast::ty_, fld: fold::ast_fold,
tm_: test_mode) ->
ast::ty_ {
*j_ += 1u;
Expand All @@ -244,7 +244,7 @@ pub fn replace_ty_in_crate(crate: ast::crate, i: uint, newty: ast::Ty,
.. *fold::default_ast_fold()
};
let af = fold::make_fold(afp);
let crate2: @ast::crate = @af.fold_crate(crate);
let crate2: @ast::crate = @af.fold_crate(&crate);
*crate2
}

Expand Down
2 changes: 1 addition & 1 deletion src/librustc/driver/driver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@ pub fn pretty_print_input(sess: Session, +cfg: ast::crate_cfg, input: input,
pprust::node_block(s, ref blk) => {
pp::space(s.s);
pprust::synth_comment(
s, ~"block " + int::to_str((*blk).node.id));
s, ~"block " + int::to_str(blk.node.id));
}
pprust::node_expr(s, expr) => {
pp::space(s.s);
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/driver/session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@ pub mod test {
pub fn make_crate_type_attr(+t: ~str) -> ast::attribute {
codemap::respan(codemap::dummy_sp(), ast::attribute_ {
style: ast::attr_outer,
value: codemap::respan(codemap::dummy_sp(),
value: @codemap::respan(codemap::dummy_sp(),
ast::meta_name_value(
@~"crate_type",
codemap::respan(codemap::dummy_sp(),
Expand Down
20 changes: 10 additions & 10 deletions src/librustc/front/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ pub fn strip_items(crate: @ast::crate, in_cfg: in_cfg_pred)
.. *fold::default_ast_fold()};

let fold = fold::make_fold(precursor);
let res = @fold.fold_crate(*crate);
let res = @fold.fold_crate(&*crate);
return res;
}

Expand All @@ -63,7 +63,7 @@ fn filter_view_item(cx: @Context, &&view_item: @ast::view_item
}
}

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

fn fold_foreign_mod(
cx: @Context,
nm: ast::foreign_mod,
nm: &ast::foreign_mod,
fld: fold::ast_fold
) -> ast::foreign_mod {
let filtered_items =
Expand All @@ -98,21 +98,21 @@ fn fold_foreign_mod(
}
}

fn fold_item_underscore(cx: @Context, +item: ast::item_,
fn fold_item_underscore(cx: @Context, item: &ast::item_,
fld: fold::ast_fold) -> ast::item_ {
let item = match item {
ast::item_impl(a, b, c, methods) => {
let item = match *item {
ast::item_impl(ref a, b, c, ref methods) => {
let methods = methods.filtered(|m| method_in_cfg(cx, *m) );
ast::item_impl(a, b, c, methods)
ast::item_impl(/*bad*/ copy *a, b, c, methods)
}
ast::item_trait(ref a, ref b, ref methods) => {
let methods = methods.filtered(|m| trait_method_in_cfg(cx, m) );
ast::item_trait(/*bad*/copy *a, /*bad*/copy *b, methods)
}
item => item
ref item => /*bad*/ copy *item
};

fold::noop_fold_item_underscore(item, fld)
fold::noop_fold_item_underscore(&item, fld)
}

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

fn fold_block(
cx: @Context,
b: ast::blk_,
b: &ast::blk_,
fld: fold::ast_fold
) -> ast::blk_ {
let filtered_stmts =
Expand Down
18 changes: 12 additions & 6 deletions src/librustc/front/core_inject.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ fn inject_libcore_ref(sess: Session,
attrs: ~[
spanned(ast::attribute_ {
style: ast::attr_inner,
value: spanned(ast::meta_name_value(
value: @spanned(ast::meta_name_value(
@~"vers",
spanned(ast::lit_str(@CORE_VERSION.to_str()))
)),
Expand All @@ -66,10 +66,13 @@ fn inject_libcore_ref(sess: Session,
view_items: vis,
../*bad*/copy crate.module
};
new_module = fld.fold_mod(new_module);
new_module = fld.fold_mod(&new_module);

// FIXME #2543: Bad copy.
let new_crate = ast::crate_ { module: new_module, ..copy crate };
let new_crate = ast::crate_ {
module: new_module,
..copy *crate
};
(new_crate, span)
},
fold_mod: |module, fld| {
Expand All @@ -95,12 +98,15 @@ fn inject_libcore_ref(sess: Session,
let vis = vec::append(~[vi2], module.view_items);

// FIXME #2543: Bad copy.
let new_module = ast::_mod { view_items: vis, ..copy module };
fold::noop_fold_mod(new_module, fld)
let new_module = ast::_mod {
view_items: vis,
..copy *module
};
fold::noop_fold_mod(&new_module, fld)
},
..*fold::default_ast_fold()
};

let fold = fold::make_fold(precursor);
@fold.fold_crate(*crate)
@fold.fold_crate(crate)
}
18 changes: 10 additions & 8 deletions src/librustc/front/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ fn generate_test_harness(sess: session::Session,
fold_mod: |a,b| fold_mod(cx, a, b),.. *fold::default_ast_fold()};

let fold = fold::make_fold(precursor);
let res = @fold.fold_crate(*crate);
let res = @fold.fold_crate(&*crate);
cx.ext_cx.bt_pop();
return res;
}
Expand All @@ -106,7 +106,7 @@ fn strip_test_functions(crate: @ast::crate) -> @ast::crate {
}

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

fold::noop_fold_mod(mod_nomain, fld)
fold::noop_fold_mod(&mod_nomain, fld)
}

fn fold_crate(cx: @mut TestCtxt,
c: ast::crate_,
c: &ast::crate_,
fld: fold::ast_fold)
-> ast::crate_ {
let folded = fold::noop_fold_crate(c, fld);

// Add a special __test module to the crate that will contain code
// generated for the test harness
ast::crate_ { module: add_test_module(cx, /*bad*/copy folded.module),
.. folded }
ast::crate_ {
module: add_test_module(cx, &folded.module),
.. folded
}
}


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

fn add_test_module(cx: &TestCtxt, +m: ast::_mod) -> ast::_mod {
fn add_test_module(cx: &TestCtxt, m: &ast::_mod) -> ast::_mod {
let testmod = mk_test_module(cx);
ast::_mod {
items: vec::append_one(/*bad*/copy m.items, testmod),
.. m
.. /*bad*/ copy *m
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/librustc/metadata/decoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1009,7 +1009,7 @@ fn get_attributes(md: ebml::Doc) -> ~[ast::attribute] {
codemap::spanned {
node: ast::attribute_ {
style: ast::attr_outer,
value: /*bad*/copy *meta_item,
value: meta_item,
is_sugared_doc: false,
},
span: codemap::dummy_sp()
Expand Down
14 changes: 7 additions & 7 deletions src/librustc/metadata/encoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ fn encode_path(ecx: @EncodeContext, ebml_w: writer::Encoder,
}

fn encode_info_for_mod(ecx: @EncodeContext, ebml_w: writer::Encoder,
md: _mod, id: node_id, path: &[ast_map::path_elt],
md: &_mod, id: node_id, path: &[ast_map::path_elt],
name: ident) {
ebml_w.start_tag(tag_items_data_item);
encode_def_id(ebml_w, local_def(id));
Expand Down Expand Up @@ -659,7 +659,7 @@ fn encode_info_for_item(ecx: @EncodeContext, ebml_w: writer::Encoder,
}
ebml_w.end_tag();
}
item_mod(m) => {
item_mod(ref m) => {
add_to_index();
encode_info_for_mod(ecx, ebml_w, m, item.id, path, item.ident);
}
Expand Down Expand Up @@ -912,8 +912,8 @@ fn encode_info_for_item(ecx: @EncodeContext, ebml_w: writer::Encoder,
// method info, we output static methods with type signatures as
// written. Here, we output the *real* type signatures. I feel like
// maybe we should only ever handle the real type signatures.
for vec::each((*ms)) |m| {
let ty_m = ast_util::trait_method_to_ty_method(*m);
for ms.each |m| {
let ty_m = ast_util::trait_method_to_ty_method(m);
if ty_m.self_ty.node != ast::sty_static { loop; }

index.push(entry { val: ty_m.id, pos: ebml_w.writer.tell() });
Expand Down Expand Up @@ -995,7 +995,7 @@ fn encode_info_for_items(ecx: @EncodeContext, ebml_w: writer::Encoder,
let index = @mut ~[];
ebml_w.start_tag(tag_items_data);
index.push(entry { val: crate_node_id, pos: ebml_w.writer.tell() });
encode_info_for_mod(ecx, ebml_w, crate.node.module,
encode_info_for_mod(ecx, ebml_w, &crate.node.module,
crate_node_id, ~[],
syntax::parse::token::special_idents::invalid);
visit::visit_crate(*crate, (), visit::mk_vt(@visit::Visitor {
Expand Down Expand Up @@ -1088,7 +1088,7 @@ fn write_int(writer: io::Writer, &&n: int) {
writer.write_be_u32(n as u32);
}

fn encode_meta_item(ebml_w: writer::Encoder, mi: meta_item) {
fn encode_meta_item(ebml_w: writer::Encoder, mi: @meta_item) {
match mi.node {
meta_word(name) => {
ebml_w.start_tag(tag_meta_item_word);
Expand Down Expand Up @@ -1118,7 +1118,7 @@ fn encode_meta_item(ebml_w: writer::Encoder, mi: meta_item) {
ebml_w.writer.write(str::to_bytes(*name));
ebml_w.end_tag();
for items.each |inner_item| {
encode_meta_item(ebml_w, **inner_item);
encode_meta_item(ebml_w, *inner_item);
}
ebml_w.end_tag();
}
Expand Down
10 changes: 5 additions & 5 deletions src/librustc/middle/astencode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ fn encode_ast(ebml_w: writer::Encoder, item: ast::inlined_item) {
// nested items, as otherwise it would get confused when translating
// inlined items.
fn simplify_ast(ii: ast::inlined_item) -> ast::inlined_item {
fn drop_nested_items(blk: ast::blk_, fld: fold::ast_fold) -> ast::blk_ {
fn drop_nested_items(blk: &ast::blk_, fld: fold::ast_fold) -> ast::blk_ {
let stmts_sans_items = do blk.stmts.filtered |stmt| {
match stmt.node {
ast::stmt_expr(_, _) | ast::stmt_semi(_, _) |
Expand All @@ -317,7 +317,7 @@ fn simplify_ast(ii: ast::inlined_item) -> ast::inlined_item {
id: blk.id,
rules: blk.rules
};
fold::noop_fold_block(blk_sans_items, fld)
fold::noop_fold_block(&blk_sans_items, fld)
}

let fld = fold::make_fold(@fold::AstFoldFns {
Expand All @@ -336,7 +336,7 @@ fn simplify_ast(ii: ast::inlined_item) -> ast::inlined_item {
ast::ii_foreign(fld.fold_foreign_item(i))
}
ast::ii_dtor(ref dtor, nm, ref tps, parent_id) => {
let dtor_body = fld.fold_block((*dtor).node.body);
let dtor_body = fld.fold_block(&dtor.node.body);
ast::ii_dtor(
codemap::spanned {
node: ast::struct_dtor_ { body: dtor_body,
Expand Down Expand Up @@ -372,8 +372,8 @@ fn renumber_ast(xcx: @ExtendedDecodeContext, ii: ast::inlined_item)
ast::ii_foreign(fld.fold_foreign_item(i))
}
ast::ii_dtor(ref dtor, nm, ref generics, parent_id) => {
let dtor_body = fld.fold_block((*dtor).node.body);
let dtor_attrs = fld.fold_attributes(copy dtor.node.attrs);
let dtor_body = fld.fold_block(&dtor.node.body);
let dtor_attrs = fld.fold_attributes(/*bad*/copy (*dtor).node.attrs);
let new_generics = fold::fold_generics(generics, fld);
let dtor_id = fld.new_id((*dtor).node.id);
let new_parent = xcx.tr_def_id(parent_id);
Expand Down
12 changes: 6 additions & 6 deletions src/librustc/middle/borrowck/check_loans.rs
Original file line number Diff line number Diff line change
Expand Up @@ -579,9 +579,9 @@ pub impl CheckLoanCtxt {
}
}

fn check_loans_in_fn(fk: visit::fn_kind,
decl: ast::fn_decl,
body: ast::blk,
fn check_loans_in_fn(fk: &visit::fn_kind,
decl: &ast::fn_decl,
body: &ast::blk,
sp: span,
id: ast::node_id,
&&self: @mut CheckLoanCtxt,
Expand All @@ -590,7 +590,7 @@ fn check_loans_in_fn(fk: visit::fn_kind,
let fty = ty::node_id_to_type(self.tcx(), id);

let declared_purity;
match fk {
match *fk {
visit::fk_item_fn(*) | visit::fk_method(*) |
visit::fk_dtor(*) => {
declared_purity = ty::ty_fn_purity(fty);
Expand All @@ -611,7 +611,7 @@ fn check_loans_in_fn(fk: visit::fn_kind,
do save_and_restore_managed(self.fn_args) {
*self.declared_purity = declared_purity;

match fk {
match *fk {
visit::fk_anon(*) |
visit::fk_fn_block(*) if is_stack_closure => {
// inherits the fn_args from enclosing ctxt
Expand Down Expand Up @@ -753,7 +753,7 @@ fn check_loans_in_expr(expr: @ast::expr,
visit::visit_expr(expr, self, vt);
}

fn check_loans_in_block(blk: ast::blk,
fn check_loans_in_block(blk: &ast::blk,
&&self: @mut CheckLoanCtxt,
vt: visit::vt<@mut CheckLoanCtxt>) {
do save_and_restore_managed(self.declared_purity) {
Expand Down
Loading

0 comments on commit afdd0b8

Please sign in to comment.