Revert "rustc: Add node IDs to AST types so we can associate them with region environments"

This reverts commit 96e1bbd4a0.
This commit is contained in:
Patrick Walton
2012-03-12 16:33:55 -07:00
parent 96e1bbd4a0
commit 59a56ad043
6 changed files with 34 additions and 75 deletions

View File

@@ -254,15 +254,11 @@ fn mk_test_desc_vec_ty(cx: test_ctxt) -> @ast::ty {
types: []}); types: []});
let test_desc_ty: ast::ty = let test_desc_ty: ast::ty =
{id: cx.sess.next_node_id(), nospan(ast::ty_path(test_desc_ty_path, cx.sess.next_node_id()));
node: ast::ty_path(test_desc_ty_path, cx.sess.next_node_id()),
span: dummy_sp()};
let vec_mt: ast::mt = {ty: @test_desc_ty, mutbl: ast::m_imm}; let vec_mt: ast::mt = {ty: @test_desc_ty, mutbl: ast::m_imm};
ret @{id: cx.sess.next_node_id(), ret @nospan(ast::ty_vec(vec_mt));
node: ast::ty_vec(vec_mt),
span: dummy_sp()};
} }
fn mk_test_desc_vec(cx: test_ctxt) -> @ast::expr { fn mk_test_desc_vec(cx: test_ctxt) -> @ast::expr {
@@ -350,7 +346,7 @@ fn mk_test_wrapper(cx: test_ctxt,
let wrapper_decl: ast::fn_decl = { let wrapper_decl: ast::fn_decl = {
inputs: [], inputs: [],
output: @{id: cx.sess.next_node_id(), node: ast::ty_nil, span: span}, output: @nospan(ast::ty_nil),
purity: ast::impure_fn, purity: ast::impure_fn,
cf: ast::return_val, cf: ast::return_val,
constraints: [] constraints: []
@@ -381,13 +377,9 @@ fn mk_test_wrapper(cx: test_ctxt,
fn mk_main(cx: test_ctxt) -> @ast::item { fn mk_main(cx: test_ctxt) -> @ast::item {
let str_pt = @nospan({global: false, idents: ["str"], types: []}); let str_pt = @nospan({global: false, idents: ["str"], types: []});
let str_ty = @{id: cx.sess.next_node_id(), let str_ty = @nospan(ast::ty_path(str_pt, cx.sess.next_node_id()));
node: ast::ty_path(str_pt, cx.sess.next_node_id()),
span: dummy_sp()};
let args_mt: ast::mt = {ty: str_ty, mutbl: ast::m_imm}; let args_mt: ast::mt = {ty: str_ty, mutbl: ast::m_imm};
let args_ty: ast::ty = {id: cx.sess.next_node_id(), let args_ty: ast::ty = nospan(ast::ty_vec(args_mt));
node: ast::ty_vec(args_mt),
span: dummy_sp()};
let args_arg: ast::arg = let args_arg: ast::arg =
{mode: ast::expl(ast::by_val), {mode: ast::expl(ast::by_val),
@@ -395,9 +387,7 @@ fn mk_main(cx: test_ctxt) -> @ast::item {
ident: "args", ident: "args",
id: cx.sess.next_node_id()}; id: cx.sess.next_node_id()};
let ret_ty = {id: cx.sess.next_node_id(), let ret_ty = nospan(ast::ty_nil);
node: ast::ty_nil,
span: dummy_sp()};
let decl: ast::fn_decl = let decl: ast::fn_decl =
{inputs: [args_arg], {inputs: [args_arg],

View File

@@ -3463,15 +3463,12 @@ fn serialize_31<S: std::serialization::serializer>(s: S,
/*syntax::ast::ty*/ /*syntax::ast::ty*/
fn serialize_30<S: std::serialization::serializer>(s: S, v: syntax::ast::ty) { fn serialize_30<S: std::serialization::serializer>(s: S, v: syntax::ast::ty) {
s.emit_rec(/*syntax::ast::node_id*//*syntax::ast::ty_*/ s.emit_rec(/*syntax::ast::ty_*//*syntax::codemap::span*/
/*syntax::codemap::span*/
{|| {||
{ {
s.emit_rec_field("id", 0u, s.emit_rec_field("node", 0u,
{|| serialize_27(s, v.id) });
s.emit_rec_field("node", 1u,
{|| serialize_31(s, v.node) }); {|| serialize_31(s, v.node) });
s.emit_rec_field("span", 2u, s.emit_rec_field("span", 1u,
{|| serialize_19(s, v.span) }) {|| serialize_19(s, v.span) })
} }
}); });
@@ -7328,18 +7325,15 @@ fn deserialize_30<S: std::serialization::deserializer>(s: S) ->
s.read_rec( s.read_rec(
/*syntax::ast::node_id*/
/*syntax::ast::ty_*/ /*syntax::ast::ty_*/
/*syntax::codemap::span*/ /*syntax::codemap::span*/
{|| {||
{id: s.read_rec_field("id", 0u, {|| deserialize_27(s) }), {node:
node: s.read_rec_field("node", 0u, {|| deserialize_31(s) }),
s.read_rec_field("node", 1u, {|| deserialize_31(s) }),
span: span:
s.read_rec_field("span", 2u, s.read_rec_field("span", 1u,
{|| deserialize_19(s) }),} {|| deserialize_19(s) }),}
}) })

View File

@@ -4419,8 +4419,7 @@ fn trans_item(ccx: crate_ctxt, item: ast::item) {
node: ast::pat_ident(rslt_path, none), node: ast::pat_ident(rslt_path, none),
span: ctor.node.body.span}; span: ctor.node.body.span};
// Set up obj's type // Set up obj's type
let rslt_ast_ty : @ast::ty = @{id: ccx.sess.next_node_id(), let rslt_ast_ty : @ast::ty = @{node: ast::ty_infer,
node: ast::ty_infer,
span: ctor.node.body.span}; span: ctor.node.body.span};
// kludgy // kludgy
let ty_args = [], i = 0u; let ty_args = [], i = 0u;

View File

@@ -334,7 +334,7 @@ enum uint_ty { ty_u, ty_u8, ty_u16, ty_u32, ty_u64, }
enum float_ty { ty_f, ty_f32, ty_f64, } enum float_ty { ty_f, ty_f32, ty_f64, }
type ty = {id: node_id, node: ty_, span: span}; type ty = spanned<ty_>;
// Not represented directly in the AST, referred to by name through a ty_path. // Not represented directly in the AST, referred to by name through a ty_path.
enum prim_ty { enum prim_ty {

View File

@@ -699,7 +699,7 @@ fn make_fold(afp: ast_fold_precursor) -> ast_fold {
} }
fn f_ty(afp: ast_fold_precursor, f: ast_fold, &&x: @ty) -> @ty { fn f_ty(afp: ast_fold_precursor, f: ast_fold, &&x: @ty) -> @ty {
let (n, s) = afp.fold_ty(x.node, x.span, f); let (n, s) = afp.fold_ty(x.node, x.span, f);
ret @{id: x.id, node: n, span: afp.new_span(s)}; ret @{node: n, span: afp.new_span(s)};
} }
fn f_constr(afp: ast_fold_precursor, f: ast_fold, &&x: @ast::constr) -> fn f_constr(afp: ast_fold_precursor, f: ast_fold, &&x: @ast::constr) ->
@ast::constr { @ast::constr {

View File

@@ -385,11 +385,7 @@ fn parse_ty_postfix(orig_t: ast::ty_, p: parser, colons_before_params: bool,
expect(p, token::LT); expect(p, token::LT);
} else if !colons_before_params && p.token == token::LT { } else if !colons_before_params && p.token == token::LT {
p.bump(); p.bump();
} else { } else { ret @spanned(lo, p.last_span.hi, orig_t); }
ret @{id: p.get_id(),
node: orig_t,
span: ast_util::mk_sp(lo, p.last_span.hi)};
}
// If we're here, we have explicit type parameter instantiation. // If we're here, we have explicit type parameter instantiation.
let seq = parse_seq_to_gt(some(token::COMMA), {|p| parse_ty(p, false)}, let seq = parse_seq_to_gt(some(token::COMMA), {|p| parse_ty(p, false)},
@@ -397,12 +393,11 @@ fn parse_ty_postfix(orig_t: ast::ty_, p: parser, colons_before_params: bool,
alt orig_t { alt orig_t {
ast::ty_path(pth, ann) { ast::ty_path(pth, ann) {
ret @{id: p.get_id(), ret @spanned(lo, p.last_span.hi,
node: ast::ty_path(@spanned(lo, p.last_span.hi, ast::ty_path(@spanned(lo, p.last_span.hi,
{global: pth.node.global, {global: pth.node.global,
idents: pth.node.idents, idents: pth.node.idents,
types: seq}), ann), types: seq}), ann));
span: ast_util::mk_sp(lo, p.last_span.hi)};
} }
_ { p.fatal("type parameter instantiation only allowed for paths"); } _ { p.fatal("type parameter instantiation only allowed for paths"); }
} }
@@ -412,17 +407,11 @@ fn parse_ret_ty(p: parser) -> (ast::ret_style, @ast::ty) {
ret if eat(p, token::RARROW) { ret if eat(p, token::RARROW) {
let lo = p.span.lo; let lo = p.span.lo;
if eat(p, token::NOT) { if eat(p, token::NOT) {
(ast::noreturn, @{id: p.get_id(), (ast::noreturn, @spanned(lo, p.last_span.hi, ast::ty_bot))
node: ast::ty_bot, } else { (ast::return_val, parse_ty(p, false)) }
span: ast_util::mk_sp(lo, p.last_span.hi)})
} else {
(ast::return_val, parse_ty(p, false))
}
} else { } else {
let pos = p.span.lo; let pos = p.span.lo;
(ast::return_val, @{id: p.get_id(), (ast::return_val, @spanned(pos, pos, ast::ty_nil))
node: ast::ty_nil,
span: ast_util::mk_sp(pos, pos)})
} }
} }
@@ -446,11 +435,8 @@ fn parse_ty(p: parser, colons_before_params: bool) -> @ast::ty {
let lo = p.span.lo; let lo = p.span.lo;
alt have_dollar(p) { alt have_dollar(p) {
some(e) { some(e) {ret @spanned(lo, p.span.hi,
ret @{id: p.get_id(), ast::ty_mac(spanned(lo, p.span.hi, e)))}
node: ast::ty_mac(spanned(lo, p.span.hi, e)),
span: ast_util::mk_sp(lo, p.span.hi)};
}
none {} none {}
} }
@@ -489,10 +475,7 @@ fn parse_ty(p: parser, colons_before_params: bool) -> @ast::ty {
let t = ast::ty_rec(elems.node); let t = ast::ty_rec(elems.node);
if p.token == token::COLON { if p.token == token::COLON {
p.bump(); p.bump();
ast::ty_constr(@{id: p.get_id(), ast::ty_constr(@spanned(lo, hi, t), parse_type_constraints(p))
node: t,
span: ast_util::mk_sp(lo, hi)},
parse_type_constraints(p))
} else { t } } else { t }
} else if p.token == token::LBRACKET { } else if p.token == token::LBRACKET {
expect(p, token::LBRACKET); expect(p, token::LBRACKET);
@@ -551,9 +534,7 @@ fn parse_fn_block_arg(p: parser) -> ast::arg {
let t = if eat(p, token::COLON) { let t = if eat(p, token::COLON) {
parse_ty(p, false) parse_ty(p, false)
} else { } else {
@{id: p.get_id(), @spanned(p.span.lo, p.span.hi, ast::ty_infer)
node: ast::ty_infer,
span: ast_util::mk_sp(p.span.lo, p.span.hi)}
}; };
ret {mode: m, ty: t, ident: i, id: p.get_id()}; ret {mode: m, ty: t, ident: i, id: p.get_id()};
} }
@@ -1625,9 +1606,7 @@ fn parse_local(p: parser, is_mutbl: bool,
allow_init: bool) -> @ast::local { allow_init: bool) -> @ast::local {
let lo = p.span.lo; let lo = p.span.lo;
let pat = parse_pat(p); let pat = parse_pat(p);
let ty = @{id: p.get_id(), let ty = @spanned(lo, lo, ast::ty_infer);
node: ast::ty_infer,
span: ast_util::mk_sp(lo, lo)};
if eat(p, token::COLON) { ty = parse_ty(p, false); } if eat(p, token::COLON) { ty = parse_ty(p, false); }
let init = if allow_init { parse_initializer(p) } else { none }; let init = if allow_init { parse_initializer(p) } else { none };
ret @spanned(lo, p.last_span.hi, ret @spanned(lo, p.last_span.hi,
@@ -1903,7 +1882,7 @@ fn parse_fn_block_decl(p: parser) -> ast::fn_decl {
let output = if eat(p, token::RARROW) { let output = if eat(p, token::RARROW) {
parse_ty(p, false) parse_ty(p, false)
} else { } else {
@{id: p.get_id(), node: ast::ty_infer, span: p.span} @spanned(p.span.lo, p.span.hi, ast::ty_infer)
}; };
ret {inputs: inputs, ret {inputs: inputs,
output: output, output: output,
@@ -1978,7 +1957,7 @@ fn parse_item_iface(p: parser, attrs: [ast::attribute]) -> @ast::item {
fn parse_item_impl(p: parser, attrs: [ast::attribute]) -> @ast::item { fn parse_item_impl(p: parser, attrs: [ast::attribute]) -> @ast::item {
let lo = p.last_span.lo; let lo = p.last_span.lo;
fn wrap_path(p: parser, pt: @ast::path) -> @ast::ty { fn wrap_path(p: parser, pt: @ast::path) -> @ast::ty {
@{id: p.get_id(), node: ast::ty_path(pt, p.get_id()), span: pt.span} @{node: ast::ty_path(pt, p.get_id()), span: pt.span}
} }
let (ident, tps) = if !is_word(p, "of") { let (ident, tps) = if !is_word(p, "of") {
if p.token == token::LT { (none, parse_ty_params(p)) } if p.token == token::LT { (none, parse_ty_params(p)) }
@@ -2017,9 +1996,7 @@ fn parse_item_res(p: parser, attrs: [ast::attribute]) -> @ast::item {
{inputs: {inputs:
[{mode: ast::expl(ast::by_ref), ty: t, [{mode: ast::expl(ast::by_ref), ty: t,
ident: arg_ident, id: p.get_id()}], ident: arg_ident, id: p.get_id()}],
output: @{id: p.get_id(), output: @spanned(lo, lo, ast::ty_nil),
node: ast::ty_nil,
span: ast_util::mk_sp(lo, lo)},
purity: ast::impure_fn, purity: ast::impure_fn,
cf: ast::return_val, cf: ast::return_val,
constraints: []}; constraints: []};
@@ -2089,8 +2066,7 @@ enum class_contents { ctor_decl(ast::fn_decl, ast::blk, codemap::span),
// Can ctors have attrs? // Can ctors have attrs?
// result type is always the type of the class // result type is always the type of the class
let decl_ = parse_fn_decl(p, ast::impure_fn); let decl_ = parse_fn_decl(p, ast::impure_fn);
let decl = {output: @{id: p.get_id(), let decl = {output: @{node: ast::ty_path(class_name, p.get_id()),
node: ast::ty_path(class_name, p.get_id()),
span: decl_.output.span} span: decl_.output.span}
with decl_}; with decl_};
let body = parse_block(p); let body = parse_block(p);