Skip to content
2 changes: 1 addition & 1 deletion src/librustc/driver/session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ mod test {
use syntax::ast_util;

fn make_crate_type_attr(+t: ~str) -> ast::attribute {
ast_util::respan(ast_util::dummy_sp(), {
ast_util::respan(ast_util::dummy_sp(), ast::attribute_ {
style: ast::attr_outer,
value: ast_util::respan(ast_util::dummy_sp(),
ast::meta_name_value(
Expand Down
41 changes: 20 additions & 21 deletions src/librustc/front/core_inject.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,22 +45,21 @@ fn inject_libcore_ref(sess: Session,
let precursor = @fold::AstFoldFns {
fold_crate: |crate, span, fld| {
let n1 = sess.next_node_id();
let vi1 = @{node: ast::view_item_use(sess.ident_of(~"core"),
~[],
n1),
attrs: ~[
spanned({
style: ast::attr_inner,
value: spanned(ast::meta_name_value(
~"vers",
spanned(ast::lit_str(
@CORE_VERSION.to_str()))
)),
is_sugared_doc: false
})
],
vis: ast::private,
span: dummy_sp()};
let vi1 = @ast::view_item {
node: ast::view_item_use(sess.ident_of(~"core"), ~[], n1),
attrs: ~[
spanned(ast::attribute_ {
style: ast::attr_inner,
value: spanned(ast::meta_name_value(
~"vers",
spanned(ast::lit_str(@CORE_VERSION.to_str()))
)),
is_sugared_doc: false
})
],
vis: ast::private,
span: dummy_sp()
};

let vis = vec::append(~[vi1], crate.module.view_items);
let mut new_module = {
Expand All @@ -76,7 +75,7 @@ fn inject_libcore_ref(sess: Session,
fold_mod: |module, fld| {
let n2 = sess.next_node_id();

let prelude_path = @{
let prelude_path = @ast::path {
span: dummy_sp(),
global: false,
idents: ~[
Expand All @@ -88,10 +87,10 @@ fn inject_libcore_ref(sess: Session,
};

let vp = @spanned(ast::view_path_glob(prelude_path, n2));
let vi2 = @{node: ast::view_item_import(~[vp]),
attrs: ~[],
vis: ast::private,
span: dummy_sp()};
let vi2 = @ast::view_item { node: ast::view_item_import(~[vp]),
attrs: ~[],
vis: ast::private,
span: dummy_sp() };

let vis = vec::append(~[vi2], module.view_items);

Expand Down
59 changes: 35 additions & 24 deletions src/librustc/front/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -226,13 +226,14 @@ fn mk_test_module(cx: test_ctxt) -> @ast::item {
// This attribute tells resolve to let us call unexported functions
let resolve_unexported_attr =
attr::mk_attr(attr::mk_word_item(~"!resolve_unexported"));
let item: ast::item =
{ident: cx.sess.ident_of(~"__test"),
attrs: ~[resolve_unexported_attr],
id: cx.sess.next_node_id(),
node: item_,
vis: ast::public,
span: dummy_sp()};
let item = ast::item {
ident: cx.sess.ident_of(~"__test"),
attrs: ~[resolve_unexported_attr],
id: cx.sess.next_node_id(),
node: item_,
vis: ast::public,
span: dummy_sp(),
};

debug!("Synthetic test module:\n%s\n",
pprust::item_to_str(@copy item, cx.sess.intr()));
Expand All @@ -245,11 +246,19 @@ fn nospan<T: Copy>(t: T) -> ast::spanned<T> {
}

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

fn path_node_global(+ids: ~[ast::ident]) -> @ast::path {
@{span: dummy_sp(), global: true, idents: ids, rp: None, types: ~[]}
@ast::path { span: dummy_sp(),
global: true,
idents: ids,
rp: None,
types: ~[] }
}

fn mk_std(cx: test_ctxt) -> @ast::view_item {
Expand All @@ -260,7 +269,7 @@ fn mk_std(cx: test_ctxt) -> @ast::view_item {
let vi = ast::view_item_use(cx.sess.ident_of(~"std"),
~[@mi],
cx.sess.next_node_id());
let vi = {
let vi = ast::view_item {
node: vi,
attrs: ~[],
vis: ast::private,
Expand All @@ -286,13 +295,14 @@ fn mk_tests(cx: test_ctxt) -> @ast::item {
let body = nospan(body_);

let item_ = ast::item_fn(decl, ast::impure_fn, ~[], body);
let item: ast::item =
{ident: cx.sess.ident_of(~"tests"),
attrs: ~[],
id: cx.sess.next_node_id(),
node: item_,
vis: ast::public,
span: dummy_sp()};
let item = ast::item {
ident: cx.sess.ident_of(~"tests"),
attrs: ~[],
id: cx.sess.next_node_id(),
node: item_,
vis: ast::public,
span: dummy_sp(),
};
return @item;
}

Expand Down Expand Up @@ -496,13 +506,14 @@ fn mk_main(cx: test_ctxt) -> @ast::item {
let body = ast::spanned { node: body_, span: dummy_sp() };

let item_ = ast::item_fn(decl, ast::impure_fn, ~[], body);
let item: ast::item =
{ident: cx.sess.ident_of(~"main"),
attrs: ~[],
id: cx.sess.next_node_id(),
node: item_,
vis: ast::public,
span: dummy_sp()};
let item = ast::item {
ident: cx.sess.ident_of(~"main"),
attrs: ~[],
id: cx.sess.next_node_id(),
node: item_,
vis: ast::public,
span: dummy_sp(),
};
return @item;
}

Expand Down
33 changes: 20 additions & 13 deletions src/librustc/metadata/decoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -218,13 +218,15 @@ fn item_parent_item(d: ebml::Doc) -> Option<ast::def_id> {
fn translated_parent_item_opt(cnum: ast::crate_num, d: ebml::Doc) ->
Option<ast::def_id> {
let trait_did_opt = item_parent_item(d);
trait_did_opt.map(|trait_did| {crate: cnum, node: trait_did.node})
do trait_did_opt.map |trait_did| {
ast::def_id { crate: cnum, node: trait_did.node }
}
}

fn item_reqd_and_translated_parent_item(cnum: ast::crate_num,
d: ebml::Doc) -> ast::def_id {
let trait_did = item_parent_item(d).expect(~"item without parent");
{crate: cnum, node: trait_did.node}
ast::def_id { crate: cnum, node: trait_did.node }
}

fn item_def_id(d: ebml::Doc, cdata: cmd) -> ast::def_id {
Expand Down Expand Up @@ -313,7 +315,7 @@ fn enum_variant_ids(item: ebml::Doc, cdata: cmd) -> ~[ast::def_id] {
let v = tag_items_data_item_variant;
for reader::tagged_docs(item, v) |p| {
let ext = reader::with_doc_data(p, |d| parse_def_id(d));
ids.push({crate: cdata.cnum, node: ext.node});
ids.push(ast::def_id { crate: cdata.cnum, node: ext.node });
};
return ids;
}
Expand Down Expand Up @@ -384,7 +386,7 @@ fn item_to_def_like(item: ebml::Doc, did: ast::def_id, cnum: ast::crate_num)
fn lookup_def(cnum: ast::crate_num, data: @~[u8], did_: ast::def_id) ->
ast::def {
let item = lookup_item(did_.node, data);
let did = {crate: cnum, node: did_.node};
let did = ast::def_id { crate: cnum, node: did_.node };
// We treat references to enums as references to types.
return def_like_to_def(item_to_def_like(item, did, cnum));
}
Expand All @@ -393,7 +395,8 @@ fn get_type(cdata: cmd, id: ast::node_id, tcx: ty::ctxt)
-> ty::ty_param_bounds_and_ty {

let item = lookup_item(id, cdata.data);
let t = item_type({crate: cdata.cnum, node: id}, item, tcx, cdata);
let t = item_type(ast::def_id { crate: cdata.cnum, node: id }, item, tcx,
cdata);
let tp_bounds = if family_has_type_params(item_family(item)) {
item_ty_param_bounds(item, tcx, cdata)
} else { @~[] };
Expand Down Expand Up @@ -640,8 +643,8 @@ fn get_enum_variants(intr: @ident_interner, cdata: cmd, id: ast::node_id,
let mut disr_val = 0;
for variant_ids.each |did| {
let item = find_item(did.node, items);
let ctor_ty = item_type({crate: cdata.cnum, node: id}, item,
tcx, cdata);
let ctor_ty = item_type(ast::def_id { crate: cdata.cnum, node: id},
item, tcx, cdata);
let name = item_name(intr, item);
let arg_tys = match ty::get(ctor_ty).sty {
ty::ty_fn(ref f) => (*f).sig.inputs.map(|a| a.ty),
Expand Down Expand Up @@ -1031,10 +1034,14 @@ fn get_attributes(md: ebml::Doc) -> ~[ast::attribute] {
assert (vec::len(meta_items) == 1u);
let meta_item = meta_items[0];
attrs.push(
ast::spanned { node: { style: ast::attr_outer,
value: /*bad*/copy *meta_item,
is_sugared_doc: false },
span: ast_util::dummy_sp()});
ast::spanned {
node: ast::attribute_ {
style: ast::attr_outer,
value: /*bad*/copy *meta_item,
is_sugared_doc: false,
},
span: ast_util::dummy_sp()
});
};
}
option::None => ()
Expand Down Expand Up @@ -1141,11 +1148,11 @@ fn list_crate_metadata(intr: @ident_interner, bytes: @~[u8],
// crate to the correct local crate number.
fn translate_def_id(cdata: cmd, did: ast::def_id) -> ast::def_id {
if did.crate == ast::local_crate {
return {crate: cdata.cnum, node: did.node};
return ast::def_id { crate: cdata.cnum, node: did.node };
}

match cdata.cnum_map.find(did.crate) {
option::Some(n) => return {crate: n, node: did.node},
option::Some(n) => ast::def_id { crate: n, node: did.node },
option::None => fail ~"didn't find a crate in the cnum_map"
}
}
Expand Down
3 changes: 2 additions & 1 deletion src/librustc/metadata/encoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,8 @@ fn encode_enum_variant_info(ecx: @encode_ctxt, ebml_w: writer::Encoder,
ty_params: ~[ty_param]) {
let mut disr_val = 0;
let mut i = 0;
let vi = ty::enum_variants(ecx.tcx, {crate: local_crate, node: id});
let vi = ty::enum_variants(ecx.tcx,
ast::def_id { crate: local_crate, node: id });
for variants.each |variant| {
index.push({val: variant.node.id, pos: ebml_w.writer.tell()});
ebml_w.start_tag(tag_items_data_item);
Expand Down
10 changes: 6 additions & 4 deletions src/librustc/metadata/tydecode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,11 @@ fn parse_path(st: @pstate) -> @ast::path {
':' => { next(st); next(st); }
c => {
if c == '(' {
return @{span: ast_util::dummy_sp(),
global: false, idents: idents,
rp: None, types: ~[]};
return @ast::path { span: ast_util::dummy_sp(),
global: false,
idents: idents,
rp: None,
types: ~[] };
} else { idents.push(parse_ident_(st, is_last)); }
}
}
Expand Down Expand Up @@ -468,7 +470,7 @@ fn parse_def_id(buf: &[u8]) -> ast::def_id {
None => fail (fmt!("internal error: parse_def_id: id expected, but \
found %?", def_part))
};
return {crate: crate_num, node: def_num};
ast::def_id { crate: crate_num, node: def_num }
}

fn parse_bounds_data(data: @~[u8], start: uint,
Expand Down
31 changes: 18 additions & 13 deletions src/librustc/middle/astencode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ impl extended_decode_ctxt {
}
fn tr_intern_def_id(did: ast::def_id) -> ast::def_id {
assert did.crate == ast::local_crate;
{crate: ast::local_crate, node: self.tr_id(did.node)}
ast::def_id { crate: ast::local_crate, node: self.tr_id(did.node) }
}
fn tr_span(_span: span) -> span {
ast_util::dummy_sp() // FIXME (#1972): handle span properly
Expand Down Expand Up @@ -288,10 +288,12 @@ fn simplify_ast(ii: ast::inlined_item) -> ast::inlined_item {
}
ast::ii_dtor(ref dtor, nm, ref tps, parent_id) => {
let dtor_body = fld.fold_block((*dtor).node.body);
ast::ii_dtor(ast::spanned { node: { body: dtor_body,
.. /*bad*/copy (*dtor).node },
.. (/*bad*/copy *dtor) },
nm, /*bad*/copy *tps, parent_id)
ast::ii_dtor(
ast::spanned {
node: ast::struct_dtor_ { body: dtor_body,
.. /*bad*/copy (*dtor).node },
.. (/*bad*/copy *dtor) },
nm, /*bad*/copy *tps, parent_id)
}
}
}
Expand Down Expand Up @@ -327,12 +329,15 @@ fn renumber_ast(xcx: extended_decode_ctxt, ii: ast::inlined_item)
let dtor_id = fld.new_id((*dtor).node.id);
let new_parent = xcx.tr_def_id(parent_id);
let new_self = fld.new_id((*dtor).node.self_id);
ast::ii_dtor(ast::spanned { node: { id: dtor_id,
attrs: dtor_attrs,
self_id: new_self,
body: dtor_body },
.. (/*bad*/copy *dtor)},
nm, new_params, new_parent)
ast::ii_dtor(
ast::spanned {
node: ast::struct_dtor_ { id: dtor_id,
attrs: dtor_attrs,
self_id: new_self,
body: dtor_body },
.. (/*bad*/copy *dtor)
},
nm, new_params, new_parent)
}
}
}
Expand Down Expand Up @@ -785,7 +790,7 @@ fn encode_side_tables_for_id(ecx: @e::encode_ctxt,
}
}

let lid = {crate: ast::local_crate, node: id};
let lid = ast::def_id { crate: ast::local_crate, node: id };
do option::iter(&tcx.tcache.find(lid)) |tpbt| {
do ebml_w.tag(c::tag_table_tcache) {
ebml_w.id(id);
Expand Down Expand Up @@ -988,7 +993,7 @@ fn decode_side_tables(xcx: extended_decode_ctxt,
dcx.tcx.freevars.insert(id, fv_info);
} else if tag == (c::tag_table_tcache as uint) {
let tpbt = val_dsr.read_ty_param_bounds_and_ty(xcx);
let lid = {crate: ast::local_crate, node: id};
let lid = ast::def_id { crate: ast::local_crate, node: id };
dcx.tcx.tcache.insert(lid, tpbt);
} else if tag == (c::tag_table_param_bounds as uint) {
let bounds = val_dsr.read_bounds(xcx);
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/middle/lang_items.rs
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@ impl LanguageItemCollector {
do iter_crate_data(crate_store) |crate_number, _crate_metadata| {
for each_lang_item(crate_store, crate_number)
|node_id, item_index| {
let def_id = { crate: crate_number, node: node_id };
let def_id = def_id { crate: crate_number, node: node_id };
self.collect_item(item_index, def_id);
}
}
Expand Down
Loading