Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RFC on long series to free libsyntax of vecs_implicitly_copyable #5143

Merged
merged 37 commits into from
Mar 2, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
5b9e110
libsyntax: Convert ast::attribute_ to store a @meta_item
erickt Feb 25, 2013
44f5537
libsyntax: add explicit modes where required to copy strs/vecs
erickt Feb 17, 2013
297c6e1
libsyntax: minor cleanup
erickt Feb 17, 2013
9ac5262
libsyntax: convert visit to pass ty_params by reference
erickt Feb 19, 2013
f14409c
libsyntax: progress on making syntax::visit vecs_implicitly_copyable-…
erickt Feb 18, 2013
d204386
libsyntax: make lexer vecs_implicitly_copyable-free
erickt Feb 24, 2013
8b94ef0
libsyntax: fix the span in parse_bottom_expr's INTERPOLATED handler
erickt Feb 21, 2013
1deb858
libsyntax: is_keyword should take a &~str
erickt Feb 24, 2013
4650da5
libsyntax: change eat to take a &token
erickt Feb 24, 2013
f396582
libsyntax: change flip_delimiter to take a &token::Token
erickt Feb 24, 2013
3635480
libsyntax: change expect to take &token::Token
erickt Feb 24, 2013
272c25e
libsyntax: minor cleanup
erickt Feb 24, 2013
752befe
libsyntax: change token_is_{word,keyword} to take &Token
erickt Feb 24, 2013
bff22cf
libsyntax: add some explicit copies
erickt Feb 25, 2013
3180d22
libsyntax: change parse_trait_ref_list to take a &Token
erickt Feb 25, 2013
cf6e21a
libsyntax: change attr::parse_seq_* to take &Token
erickt Feb 25, 2013
380597e
libsyntax: change parse_matcher_subseq to take &Token
erickt Feb 25, 2013
194f29c
libsyntax: minor cleanup
erickt Feb 25, 2013
d346b51
libsyntax: change token::to_str to take &Token
erickt Feb 25, 2013
ff36986
libsyntax: change token fns to take &Token
erickt Feb 25, 2013
28691a0
libsyntax: more minor cleanup
erickt Feb 25, 2013
34c02a6
libsyntax: change Parser::unexpected_last to take &Token
erickt Feb 25, 2013
de6d9f6
libsyntax: change token_is_word to take &Token
erickt Feb 25, 2013
375c298
libsyntax: change binop_to_str to be pure
erickt Feb 25, 2013
8d239a2
libsyntax: change closures to take fn(&Parser)
erickt Feb 26, 2013
4ae91e2
libsyntax: add explicit copies
erickt Feb 26, 2013
5f1652f
libsyntax: remove vecs_implicitly_copyable from the printer
erickt Feb 26, 2013
5271464
libsyntax: remove vecs_implicitly_copyable from the syntax extensions
erickt Feb 25, 2013
da7aedc
libsyntax: add some explicit refs
erickt Feb 25, 2013
ea36a0d
libsyntax: add some more explicit copies
erickt Feb 27, 2013
7d0ec86
Merge remote-tracking branch 'remotes/origin/incoming' into incoming
erickt Feb 27, 2013
7f5d4cb
Merge remote-tracking branch 'remotes/origin/incoming' into incoming
erickt Feb 27, 2013
3953bdd
Merge remote-tracking branch 'remotes/origin/incoming' into incoming
erickt Feb 28, 2013
d2c4b64
Merge remote-tracking branch 'remotes/origin/incoming' into incoming
erickt Feb 28, 2013
85fecd0
Merge remote-tracking branch 'remotes/origin/incoming' into incoming
erickt Mar 1, 2013
aa3505d
Merge remote-tracking branch 'remotes/origin/incoming' into incoming
erickt Mar 2, 2013
5515fd5
Merge remote-tracking branch 'remotes/origin/incoming' into incoming
erickt Mar 2, 2013
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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