Skip to content

Remove some of the @ from the AST #7615

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

Merged
merged 10 commits into from
Jul 7, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
19 changes: 9 additions & 10 deletions src/librustc/front/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
use std::option;
use syntax::{ast, fold, attr};

type in_cfg_pred = @fn(attrs: ~[ast::attribute]) -> bool;
type in_cfg_pred = @fn(attrs: &[ast::attribute]) -> bool;

struct Context {
in_cfg: in_cfg_pred
Expand Down Expand Up @@ -50,8 +50,7 @@ fn filter_item(cx: @Context, item: @ast::item) ->
if item_in_cfg(cx, item) { option::Some(item) } else { option::None }
}

fn filter_view_item(cx: @Context, view_item: @ast::view_item
)-> Option<@ast::view_item> {
fn filter_view_item<'r>(cx: @Context, view_item: &'r ast::view_item)-> Option<&'r ast::view_item> {
if view_item_in_cfg(cx, view_item) {
option::Some(view_item)
} else {
Expand All @@ -64,7 +63,7 @@ fn fold_mod(cx: @Context, m: &ast::_mod, fld: @fold::ast_fold) -> ast::_mod {
filter_item(cx, *a).chain(|x| fld.fold_item(x))
}.collect();
let filtered_view_items = do m.view_items.iter().filter_map |a| {
filter_view_item(cx, *a).map(|x| fld.fold_view_item(*x))
filter_view_item(cx, a).map(|&x| fld.fold_view_item(x))
}.collect();
ast::_mod {
view_items: filtered_view_items,
Expand All @@ -86,7 +85,7 @@ fn fold_foreign_mod(
) -> ast::foreign_mod {
let filtered_items = nm.items.iter().filter_map(|a| filter_foreign_item(cx, *a)).collect();
let filtered_view_items = do nm.view_items.iter().filter_map |a| {
filter_view_item(cx, *a).map(|x| fld.fold_view_item(*x))
filter_view_item(cx, a).map(|&x| fld.fold_view_item(x))
}.collect();
ast::foreign_mod {
sort: nm.sort,
Expand All @@ -99,10 +98,10 @@ fn fold_foreign_mod(
fn fold_item_underscore(cx: @Context, item: &ast::item_,
fld: @fold::ast_fold) -> ast::item_ {
let item = match *item {
ast::item_impl(ref a, b, c, ref methods) => {
ast::item_impl(ref a, ref b, ref c, ref methods) => {
let methods = methods.iter().filter(|m| method_in_cfg(cx, **m))
.transform(|x| *x).collect();
ast::item_impl(/*bad*/ copy *a, b, c, methods)
ast::item_impl(/*bad*/ copy *a, /*bad*/ copy *b, /*bad*/ copy *c, methods)
}
ast::item_trait(ref a, ref b, ref methods) => {
let methods = methods.iter().filter(|m| trait_method_in_cfg(cx, *m) )
Expand Down Expand Up @@ -141,7 +140,7 @@ fn fold_block(
filter_stmt(cx, *a).chain(|stmt| fld.fold_stmt(stmt))
}.collect();
let filtered_view_items = do b.view_items.iter().filter_map |a| {
filter_view_item(cx, *a).map(|x| fld.fold_view_item(*x))
filter_view_item(cx, a).map(|&x| fld.fold_view_item(x))
}.collect();
ast::blk_ {
view_items: filtered_view_items,
Expand All @@ -160,8 +159,8 @@ fn foreign_item_in_cfg(cx: @Context, item: @ast::foreign_item) -> bool {
return (cx.in_cfg)(/*bad*/copy item.attrs);
}

fn view_item_in_cfg(cx: @Context, item: @ast::view_item) -> bool {
return (cx.in_cfg)(/*bad*/copy item.attrs);
fn view_item_in_cfg(cx: @Context, item: &ast::view_item) -> bool {
return (cx.in_cfg)(item.attrs);
}

fn method_in_cfg(cx: @Context, meth: @ast::method) -> bool {
Expand Down
6 changes: 3 additions & 3 deletions src/librustc/front/std_inject.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ fn inject_libstd_ref(sess: Session, crate: &ast::crate) -> @ast::crate {
let precursor = @fold::AstFoldFns {
fold_crate: |crate, span, fld| {
let n1 = sess.next_node_id();
let vi1 = @ast::view_item {
let vi1 = ast::view_item {
node: ast::view_item_extern_mod(
sess.ident_of("std"), ~[], n1),
attrs: ~[
Expand Down Expand Up @@ -75,7 +75,7 @@ fn inject_libstd_ref(sess: Session, crate: &ast::crate) -> @ast::crate {
fold_mod: |module, fld| {
let n2 = sess.next_node_id();

let prelude_path = @ast::Path {
let prelude_path = ast::Path {
span: dummy_sp(),
global: false,
idents: ~[
Expand All @@ -87,7 +87,7 @@ fn inject_libstd_ref(sess: Session, crate: &ast::crate) -> @ast::crate {
};

let vp = @spanned(ast::view_path_glob(prelude_path, n2));
let vi2 = @ast::view_item { node: ast::view_item_use(~[vp]),
let vi2 = ast::view_item { node: ast::view_item_use(~[vp]),
attrs: ~[],
vis: ast::private,
span: dummy_sp() };
Expand Down
15 changes: 7 additions & 8 deletions src/librustc/front/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ mod __test {

*/

fn mk_std(cx: &TestCtxt) -> @ast::view_item {
fn mk_std(cx: &TestCtxt) -> ast::view_item {
let vers = ast::lit_str(@"0.7");
let vers = nospan(vers);
let mi = ast::meta_name_value(@"vers", vers);
Expand All @@ -287,13 +287,12 @@ fn mk_std(cx: &TestCtxt) -> @ast::view_item {
ast::view_item_extern_mod(id_std, ~[@mi],
cx.sess.next_node_id())
};
let vi = ast::view_item {
ast::view_item {
node: vi,
attrs: ~[],
vis: ast::public,
span: dummy_sp()
};
return @vi;
}
}

fn mk_test_module(cx: &TestCtxt) -> @ast::item {
Expand Down Expand Up @@ -343,16 +342,16 @@ fn nospan<T:Copy>(t: T) -> codemap::spanned<T> {
codemap::spanned { node: t, span: dummy_sp() }
}

fn path_node(ids: ~[ast::ident]) -> @ast::Path {
@ast::Path { span: dummy_sp(),
fn path_node(ids: ~[ast::ident]) -> ast::Path {
ast::Path { span: dummy_sp(),
global: false,
idents: ids,
rp: None,
types: ~[] }
}

fn path_node_global(ids: ~[ast::ident]) -> @ast::Path {
@ast::Path { span: dummy_sp(),
fn path_node_global(ids: ~[ast::ident]) -> ast::Path {
ast::Path { span: dummy_sp(),
global: true,
idents: ids,
rp: None,
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/metadata/creader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ fn visit_crate(e: &Env, c: &ast::crate) {
}
}

fn visit_view_item(e: @mut Env, i: @ast::view_item) {
fn visit_view_item(e: @mut Env, i: &ast::view_item) {
match i.node {
ast::view_item_extern_mod(ident, ref meta_items, id) => {
debug!("resolving extern mod stmt. ident: %?, meta: %?",
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 @@ -1141,7 +1141,7 @@ fn list_crate_attributes(intr: @ident_interner, md: ebml::Doc, hash: &str,

let r = get_attributes(md);
for r.iter().advance |attr| {
out.write_str(fmt!("%s\n", pprust::attribute_to_str(*attr, intr)));
out.write_str(fmt!("%s\n", pprust::attribute_to_str(attr, intr)));
}

out.write_str("\n\n");
Expand Down
4 changes: 2 additions & 2 deletions src/librustc/metadata/encoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1003,7 +1003,7 @@ fn encode_info_for_item(ecx: &EncodeContext,
index);
}
}
item_impl(ref generics, opt_trait, ty, ref methods) => {
item_impl(ref generics, ref opt_trait, ref ty, ref methods) => {
add_to_index();
ebml_w.start_tag(tag_items_data_item);
encode_def_id(ebml_w, local_def(item.id));
Expand All @@ -1014,7 +1014,7 @@ fn encode_info_for_item(ecx: &EncodeContext,
encode_name(ecx, ebml_w, item.ident);
encode_attributes(ebml_w, item.attrs);
match ty.node {
ast::ty_path(path, bounds, _) if path.idents.len() == 1 => {
ast::ty_path(ref path, ref bounds, _) if path.idents.len() == 1 => {
assert!(bounds.is_none());
encode_impl_type_basename(ecx, ebml_w,
ast_util::path_to_ident(path));
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/middle/check_const.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ pub fn check_expr(sess: Session,
"` in a constant expression");
}
}
expr_path(pth) => {
expr_path(ref pth) => {
// NB: In the future you might wish to relax this slightly
// to handle on-demand instantiation of functions via
// foo::<bar> in a const. Currently that is only done on
Expand Down
6 changes: 3 additions & 3 deletions src/librustc/middle/kind.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,15 +117,15 @@ fn check_item(item: @item, (cx, visitor): (Context, visit::vt<Context>)) {
// If this is a destructor, check kinds.
if !attrs_contains_name(item.attrs, "unsafe_destructor") {
match item.node {
item_impl(_, Some(trait_ref), self_type, _) => {
item_impl(_, Some(ref trait_ref), ref self_type, _) => {
match cx.tcx.def_map.find(&trait_ref.ref_id) {
None => cx.tcx.sess.bug("trait ref not in def map!"),
Some(&trait_def) => {
let trait_def_id = ast_util::def_id_of_def(trait_def);
if cx.tcx.lang_items.drop_trait() == trait_def_id {
// Yes, it's a destructor.
match self_type.node {
ty_path(_, bounds, path_node_id) => {
ty_path(_, ref bounds, path_node_id) => {
assert!(bounds.is_none());
let struct_def = cx.tcx.def_map.get_copy(
&path_node_id);
Expand Down Expand Up @@ -321,7 +321,7 @@ pub fn check_expr(e: @expr, (cx, v): (Context, visit::vt<Context>)) {
visit::visit_expr(e, (cx, v));
}

fn check_ty(aty: @Ty, (cx, v): (Context, visit::vt<Context>)) {
fn check_ty(aty: &Ty, (cx, v): (Context, visit::vt<Context>)) {
match aty.node {
ty_path(_, _, id) => {
let r = cx.tcx.node_type_substs.find(&id);
Expand Down
6 changes: 3 additions & 3 deletions src/librustc/middle/lint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -747,9 +747,9 @@ fn check_item_ctypes(cx: &Context, it: &ast::item) {

fn check_foreign_fn(cx: &Context, decl: &ast::fn_decl) {
for decl.inputs.iter().advance |in| {
check_ty(cx, in.ty);
check_ty(cx, &in.ty);
}
check_ty(cx, decl.output)
check_ty(cx, &decl.output)
}

match it.node {
Expand All @@ -759,7 +759,7 @@ fn check_item_ctypes(cx: &Context, it: &ast::item) {
ast::foreign_item_fn(ref decl, _, _) => {
check_foreign_fn(cx, decl);
}
ast::foreign_item_static(t, _) => { check_ty(cx, t); }
ast::foreign_item_static(ref t, _) => { check_ty(cx, t); }
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/librustc/middle/pat_util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,10 @@ pub fn pat_is_binding_or_wild(dm: resolve::DefMap, pat: @pat) -> bool {
}

pub fn pat_bindings(dm: resolve::DefMap, pat: @pat,
it: &fn(binding_mode, node_id, span, @Path)) {
it: &fn(binding_mode, node_id, span, &Path)) {
for walk_pat(pat) |p| {
match p.node {
pat_ident(binding_mode, pth, _) if pat_is_binding(dm, p) => {
pat_ident(binding_mode, ref pth, _) if pat_is_binding(dm, p) => {
it(binding_mode, p.id, p.span, pth);
}
_ => {}
Expand Down
4 changes: 2 additions & 2 deletions src/librustc/middle/privacy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ pub fn check_crate<'mm>(tcx: ty::ctxt,
};

// Checks that a private path is in scope.
let check_path: @fn(span: span, def: def, path: @Path) =
let check_path: @fn(span: span, def: def, path: &Path) =
|span, def, path| {
debug!("checking path");
match def {
Expand Down Expand Up @@ -449,7 +449,7 @@ pub fn check_crate<'mm>(tcx: ty::ctxt,
_ => {}
}
}
expr_path(path) => {
expr_path(ref path) => {
check_path(expr.span, tcx.def_map.get_copy(&expr.id), path);
}
expr_struct(_, ref fields, _) => {
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/middle/reachable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ impl ReachableContext {
}
}
}
item_impl(ref generics, trait_ref, _, ref methods) => {
item_impl(ref generics, ref trait_ref, _, ref methods) => {
// XXX(pcwalton): We conservatively assume any methods
// on a trait implementation are reachable, when this
// is not the case. We could be more precise by only
Expand Down
Loading