Skip to content

Commit bc3bf6e

Browse files
committed
---
yaml --- r: 2926 b: refs/heads/master c: 088ab03 h: refs/heads/master v: v3
1 parent d0ba594 commit bc3bf6e

File tree

6 files changed

+41
-39
lines changed

6 files changed

+41
-39
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
---
2-
refs/heads/master: 8235e76a473f6c650ad6a96dca0b5ef84ebdac4a
2+
refs/heads/master: 088ab03fdbdd2fad29b678f5eeaadde4e15cb205

trunk/src/comp/front/ast.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -300,11 +300,15 @@ tag lit_ {
300300
// type structure in middle/ty.rs as well.
301301
302302
type mt = rec(@ty ty, mutability mut);
303-
type ty_field = rec(ident ident, mt mt);
304-
type ty_arg = rec(mode mode, @ty ty);
305-
type ty_method = rec(proto proto, ident ident,
303+
type ty_field_ = rec(ident ident, mt mt);
304+
type ty_arg_ = rec(mode mode, @ty ty);
305+
type ty_method_ = rec(proto proto, ident ident,
306306
vec[ty_arg] inputs, @ty output,
307307
controlflow cf);
308+
type ty_field = spanned[ty_field_];
309+
type ty_arg = spanned[ty_arg_];
310+
type ty_method = spanned[ty_method_];
311+
308312
type ty = spanned[ty_];
309313
tag ty_ {
310314
ty_nil;

trunk/src/comp/front/parser.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,6 @@ fn eat_word(&parser p, &str word) -> bool {
287287
p.bump();
288288
ret true;
289289
} else { ret false; }
290-
291290
}
292291
case (_) { ret false; }
293292
}
@@ -312,7 +311,8 @@ fn check_bad_word(&parser p) {
312311

313312
fn parse_ty_fn(ast::proto proto, &parser p, uint lo)
314313
-> ast::ty_ {
315-
fn parse_fn_input_ty(&parser p) -> rec(ast::mode mode, @ast::ty ty) {
314+
fn parse_fn_input_ty(&parser p) -> ast::ty_arg {
315+
auto lo = p.get_lo_pos();
316316
auto mode;
317317
if (p.peek() == token::BINOP(token::AND)) {
318318
p.bump();
@@ -332,14 +332,12 @@ fn parse_ty_fn(ast::proto proto, &parser p, uint lo)
332332
case (_) { /* no param name present */ }
333333
}
334334

335-
ret rec(mode=mode, ty=t);
335+
ret spanned(lo, t.span.hi, rec(mode=mode, ty=t));
336336
}
337337

338338
auto lo = p.get_lo_pos();
339-
340-
auto f = parse_fn_input_ty; // FIXME: trans_const_lval bug
341-
auto inputs = parse_seq[rec(ast::mode mode, @ast::ty ty)](token::LPAREN,
342-
token::RPAREN, some(token::COMMA), f, p);
339+
auto inputs = parse_seq(token::LPAREN, token::RPAREN,
340+
some(token::COMMA), parse_fn_input_ty, p);
343341

344342
// FIXME: dropping constrs on the floor at the moment.
345343
// pick them up when they're used by typestate pass.
@@ -383,8 +381,9 @@ fn parse_ty_obj(&parser p, &mutable uint hi) -> ast::ty_ {
383381
expect(p, token::SEMI);
384382
alt (f) {
385383
case (ast::ty_fn(?proto, ?inputs, ?output, ?cf)) {
386-
ret rec(proto=proto, ident=ident,
387-
inputs=inputs, output=output, cf=cf);
384+
ret spanned(flo, output.span.hi,
385+
rec(proto=proto, ident=ident,
386+
inputs=inputs, output=output, cf=cf));
388387
}
389388
}
390389
fail;
@@ -405,9 +404,10 @@ fn parse_mt(&parser p) -> ast::mt {
405404
}
406405

407406
fn parse_ty_field(&parser p) -> ast::ty_field {
407+
auto lo = p.get_lo_pos();
408408
auto mt = parse_mt(p);
409409
auto id = parse_ident(p);
410-
ret rec(ident=id, mt=mt);
410+
ret spanned(lo, mt.ty.span.hi, rec(ident=id, mt=mt));
411411
}
412412

413413
fn parse_constr_arg(&parser p) -> @ast::constr_arg {

trunk/src/comp/middle/typeck.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -229,10 +229,10 @@ fn ast_mode_to_mode(ast::mode mode) -> ty::mode {
229229
fn ast_ty_to_ty(&ty::ctxt tcx, &ty_getter getter, &@ast::ty ast_ty) -> ty::t {
230230
fn ast_arg_to_arg(&ty::ctxt tcx,
231231
&ty_getter getter,
232-
&rec(ast::mode mode, @ast::ty ty) arg)
232+
&ast::ty_arg arg)
233233
-> rec(ty::mode mode, ty::t ty) {
234-
auto ty_mode = ast_mode_to_mode(arg.mode);
235-
ret rec(mode=ty_mode, ty=ast_ty_to_ty(tcx, getter, arg.ty));
234+
auto ty_mode = ast_mode_to_mode(arg.node.mode);
235+
ret rec(mode=ty_mode, ty=ast_ty_to_ty(tcx, getter, arg.node.ty));
236236
}
237237

238238
fn ast_mt_to_mt(&ty::ctxt tcx,
@@ -306,8 +306,8 @@ fn ast_ty_to_ty(&ty::ctxt tcx, &ty_getter getter, &@ast::ty ast_ty) -> ty::t {
306306
case (ast::ty_rec(?fields)) {
307307
let vec[field] flds = [];
308308
for (ast::ty_field f in fields) {
309-
auto tm = ast_mt_to_mt(tcx, getter, f.mt);
310-
vec::push[field](flds, rec(ident=f.ident, mt=tm));
309+
auto tm = ast_mt_to_mt(tcx, getter, f.node.mt);
310+
vec::push[field](flds, rec(ident=f.node.ident, mt=tm));
311311
}
312312
typ = ty::mk_rec(tcx, flds);
313313
}
@@ -342,14 +342,14 @@ fn ast_ty_to_ty(&ty::ctxt tcx, &ty_getter getter, &@ast::ty ast_ty) -> ty::t {
342342
let vec[ty::method] tmeths = [];
343343
auto f = bind ast_arg_to_arg(tcx, getter, _);
344344
for (ast::ty_method m in meths) {
345-
auto ins = vec::map[ast::ty_arg, arg](f, m.inputs);
346-
auto out = ast_ty_to_ty(tcx, getter, m.output);
345+
auto ins = vec::map[ast::ty_arg, arg](f, m.node.inputs);
346+
auto out = ast_ty_to_ty(tcx, getter, m.node.output);
347347
let ty::method new_m =
348-
rec(proto=m.proto,
349-
ident=m.ident,
348+
rec(proto=m.node.proto,
349+
ident=m.node.ident,
350350
inputs=ins,
351351
output=out,
352-
cf=m.cf);
352+
cf=m.node.cf);
353353
vec::push[ty::method](tmeths, new_m);
354354
}
355355

trunk/src/comp/middle/walk.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -167,21 +167,21 @@ fn walk_ty(&ast_visitor v, @ast::ty t) {
167167
}
168168
case (ast::ty_rec(?flds)) {
169169
for (ast::ty_field f in flds) {
170-
walk_ty(v, f.mt.ty);
170+
walk_ty(v, f.node.mt.ty);
171171
}
172172
}
173173
case (ast::ty_fn(_, ?args, ?out, _)) {
174174
for (ast::ty_arg a in args) {
175-
walk_ty(v, a.ty);
175+
walk_ty(v, a.node.ty);
176176
}
177177
walk_ty(v, out);
178178
}
179179
case (ast::ty_obj(?tmeths)) {
180180
for (ast::ty_method m in tmeths) {
181-
for (ast::ty_arg a in m.inputs) {
182-
walk_ty(v, a.ty);
181+
for (ast::ty_arg a in m.node.inputs) {
182+
walk_ty(v, a.node.ty);
183183
}
184-
walk_ty(v, m.output);
184+
walk_ty(v, m.node.output);
185185
}
186186
}
187187
case (ast::ty_path(?p, _)) {

trunk/src/comp/pretty/pprust.rs

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -268,16 +268,13 @@ fn print_type(&ps s, &ast::ty ty) {
268268
popen(s);
269269
fn print_field(&ps s, &ast::ty_field f) {
270270
cbox(s, indent_unit);
271-
print_mt(s, f.mt);
271+
print_mt(s, f.node.mt);
272272
space(s.s);
273-
word(s.s, f.ident);
273+
word(s.s, f.node.ident);
274274
end(s);
275275
}
276276
fn get_span(&ast::ty_field f) -> common::span {
277-
// Try to reconstruct the span for this field
278-
auto sp = f.mt.ty.span;
279-
auto hi = sp.hi + str::char_len(f.ident) + 1u;
280-
ret rec(hi=hi with sp);
277+
ret f.span;
281278
}
282279
auto f = print_field;
283280
auto gs = get_span;
@@ -290,8 +287,9 @@ fn print_type(&ps s, &ast::ty ty) {
290287
for (ast::ty_method m in methods) {
291288
hardbreak(s.s);
292289
cbox(s, indent_unit);
293-
print_ty_fn(s, m.proto, some(m.ident),
294-
m.inputs, m.output, m.cf);
290+
maybe_print_comment(s, m.span.lo);
291+
print_ty_fn(s, m.node.proto, some(m.node.ident),
292+
m.node.inputs, m.node.output, m.node.cf);
295293
word(s.s, ";");
296294
end(s);
297295
}
@@ -1217,8 +1215,8 @@ fn print_ty_fn(&ps s, &ast::proto proto, &option::t[str] id,
12171215
zerobreak(s.s);
12181216
popen(s);
12191217
fn print_arg(&ps s, &ast::ty_arg input) {
1220-
if (input.mode == ast::alias) {word(s.s, "&");}
1221-
print_type(s, *input.ty);
1218+
if (input.node.mode == ast::alias) {word(s.s, "&");}
1219+
print_type(s, *input.node.ty);
12221220
}
12231221
auto f = print_arg;
12241222
commasep[ast::ty_arg](s, inconsistent, inputs, f);

0 commit comments

Comments
 (0)