Skip to content

Commit 3fc9886

Browse files
committed
---
yaml --- r: 4690 b: refs/heads/master c: ebb16e6 h: refs/heads/master v: v3
1 parent 604237b commit 3fc9886

File tree

9 files changed

+64
-38
lines changed

9 files changed

+64
-38
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: c48036c0b7d10606dc8c63b87351fb394cf7d4a6
2+
refs/heads/master: ebb16e6a25da9694dabe19ecea24baeb7007ba1f

trunk/src/comp/metadata/tydecode.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ fn parse_ty_constr_arg(st: @pstate, sd: str_def) ->
153153
fn parse_constr[@T](st: @pstate, sd: str_def, pser: arg_parser[T]) ->
154154
@ty::constr_general[T] {
155155
let sp = ast::dummy_sp(); // FIXME: use a real span
156-
let args: [@sp_constr_arg[T]][] = ~[];
156+
let args: [@sp_constr_arg[T]] = ~[];
157157
let pth: path = parse_path(st, sd);
158158
let ignore: char = next(st) as char;
159159
assert (ignore as char == '(');

trunk/src/comp/middle/ast_map.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ fn node_span(node: &ast_node) -> codemap::span {
127127
mod test {
128128
#[test]
129129
fn test_node_span_item() {
130-
let expected: codemap::span = {lo: 20u, hi: 30u};
130+
let expected: codemap::span = mk_sp(20u, 30u);
131131
let node = node_item(@{ident: "test",
132132
attrs: ~[],
133133
id: 0,
@@ -139,7 +139,7 @@ mod test {
139139

140140
#[test]
141141
fn test_node_span_obj_ctor() {
142-
let expected: codemap::span = {lo: 20u, hi: 30u};
142+
let expected: codemap::span = mk_sp(20u, 30u);
143143
let node = node_obj_ctor(@{ident: "test",
144144
attrs: ~[],
145145
id: 0,
@@ -151,7 +151,7 @@ mod test {
151151

152152
#[test]
153153
fn test_node_span_native_item() {
154-
let expected: codemap::span = {lo: 20u, hi: 30u};
154+
let expected: codemap::span = mk_sp(20u, 30u);
155155
let node = node_native_item(@{ident: "test",
156156
attrs: ~[],
157157
node: native_item_ty,
@@ -162,7 +162,7 @@ mod test {
162162

163163
#[test]
164164
fn test_node_span_expr() {
165-
let expected: codemap::span = {lo: 20u, hi: 30u};
165+
let expected: codemap::span = mk_sp(20u, 30u);
166166
let node = node_expr(@{id: 0,
167167
node: expr_break,
168168
span: expected});

trunk/src/comp/middle/check_alt.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ fn pattern_supersedes(tcx: &ty::ctxt, a: &@pat, b: &@pat) -> bool {
4949
}
5050
fn field_patterns_supersede(tcx: &ty::ctxt, fas: &[field_pat],
5151
fbs: &[field_pat]) -> bool {
52-
let wild = @{id: 0, node: pat_wild, span: dummy_sp();
52+
let wild = @{id: 0, node: pat_wild, span: dummy_sp()};
5353
for fa: field_pat in fas {
5454
let pb = wild;
5555
for fb: field_pat in fbs {

trunk/src/comp/middle/trans_alt.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ fn enter_opt(ccx: &@crate_ctxt, m: &match, opt: &opt, col: uint,
126126

127127
fn enter_rec(m: &match, col: uint, fields: &[ast::ident], val: ValueRef) ->
128128
match {
129-
let dummy = @{id: 0, node: ast::pat_wild, span: dummy_sp();
129+
let dummy = @{id: 0, node: ast::pat_wild, span: dummy_sp()};
130130
fn e(dummy: &@ast::pat, fields: &[ast::ident], p: &@ast::pat) ->
131131
option::t[[@ast::pat]] {
132132
alt p.node {
@@ -148,7 +148,7 @@ fn enter_rec(m: &match, col: uint, fields: &[ast::ident], val: ValueRef) ->
148148
}
149149

150150
fn enter_tup(m: &match, col: uint, val: ValueRef, n_elts: uint) -> match {
151-
let dummy = @{id: 0, node: ast::pat_wild, span: {lo: 0u, hi: 0u}};
151+
let dummy = @{id: 0, node: ast::pat_wild, span: dummy_sp()};
152152
fn e(dummy: &@ast::pat, n_elts: uint, p: &@ast::pat)
153153
-> option::t[[@ast::pat]] {
154154
alt p.node {

trunk/src/comp/syntax/ext/base.rs

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,19 +35,29 @@ fn syntax_expander_table() -> hashmap[str, syntax_extension] {
3535
}
3636

3737
obj ext_ctxt(sess: @session, crate_file_name_hack: str,
38-
mutable backtrace: span[]) {
38+
mutable backtrace: codemap::opt_span) {
3939
fn crate_file_name() -> str { ret crate_file_name_hack; }
4040

4141
fn session() -> @session { ret sess; }
4242

4343
fn print_backtrace() {
44-
for sp: span in backtrace {
45-
sess.span_note(sp, "(while expanding this)")
46-
}
4744
}
4845

49-
fn bt_push(sp: span) { backtrace += ~[sp]; }
50-
fn bt_pop() { ivec::pop(backtrace); }
46+
fn backtrace() -> codemap::opt_span { ret backtrace; }
47+
48+
fn bt_push(sp: span) {
49+
backtrace = codemap::os_some(@{lo: sp.lo, hi: sp.hi,
50+
expanded_from: backtrace});
51+
}
52+
fn bt_pop() {
53+
alt backtrace {
54+
codemap::os_some(@{expanded_from: pre, _}) {
55+
let tmp = pre;
56+
backtrace = tmp;
57+
}
58+
_ { self.bug("tried to pop without a push"); }
59+
}
60+
}
5161

5262
fn span_fatal(sp: span, msg: str) -> ! {
5363
self.print_backtrace();
@@ -85,7 +95,7 @@ fn mk_ctxt(sess: &session) -> ext_ctxt {
8595
// super-ugly and needs a better solution.
8696
let crate_file_name_hack = sess.get_codemap().files.(0).name;
8797

88-
ret ext_ctxt(@sess, crate_file_name_hack, ~[]);
98+
ret ext_ctxt(@sess, crate_file_name_hack, codemap::os_none);
8999
}
90100

91101
fn expr_to_str(cx: &ext_ctxt, expr: @ast::expr, error: str) -> str {

trunk/src/comp/syntax/ext/simplext.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,10 @@ fn use_selectors_to_bind(b: &binders, e: @expr) -> option::t[bindings] {
205205
fn transcribe(cx: &ext_ctxt, b: &bindings, body: @expr) -> @expr {
206206
let idx_path: @mutable [uint] = @mutable ~[];
207207
fn new_id(old: node_id, cx: &ext_ctxt) -> node_id { ret cx.next_id(); }
208+
fn new_span(cx: &ext_ctxt, sp: &span) -> span {
209+
/* this discards information in the case of macro-defining macros */
210+
ret {lo: sp.lo, hi: sp.hi, expanded_from: cx.backtrace()};
211+
}
208212
let afp = default_ast_fold();
209213
let f_pre =
210214
{fold_ident: bind transcribe_ident(cx, b, idx_path, _, _),
@@ -215,7 +219,8 @@ fn transcribe(cx: &ext_ctxt, b: &bindings, body: @expr) -> @expr {
215219
fold_block:
216220
bind transcribe_block(cx, b, idx_path, _, _, afp.fold_block),
217221
map_exprs: bind transcribe_exprs(cx, b, idx_path, _, _),
218-
new_id: bind new_id(_, cx) with *afp};
222+
new_id: bind new_id(_, cx),
223+
new_span: bind new_span(cx, _) with *afp};
219224
let f = make_fold(f_pre);
220225
let result = f.fold_expr(body);
221226
dummy_out(f); //temporary: kill circular reference

trunk/src/comp/syntax/fold.rs

Lines changed: 30 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,8 @@ type ast_fold_precursor =
4444
fold_path: fn(&path_, ast_fold) -> path_ ,
4545
fold_local: fn(&local_, ast_fold) -> local_ ,
4646
map_exprs: fn(fn(&@expr) -> @expr , [@expr]) -> [@expr],
47-
new_id: fn(node_id) -> node_id};
47+
new_id: fn(node_id) -> node_id,
48+
new_span: fn(&span) -> span};
4849

4950
type a_f =
5051
{fold_crate: fn(&crate) -> crate ,
@@ -70,7 +71,8 @@ type a_f =
7071
fold_path: fn(&path) -> path ,
7172
fold_local: fn(&@local) -> @local ,
7273
map_exprs: fn(fn(&@expr) -> @expr , [@expr]) -> [@expr],
73-
new_id: fn(node_id) -> node_id};
74+
new_id: fn(node_id) -> node_id,
75+
new_span: fn(&span) -> span};
7476

7577

7678
//fn nf_dummy[T](&T node) -> T { fail; }
@@ -514,6 +516,8 @@ fn noop_map_exprs(f: fn(&@expr) -> @expr , es: [@expr]) -> [@expr] {
514516

515517
fn noop_id(i: node_id) -> node_id { ret i; }
516518

519+
fn noop_span(sp: &span) -> span { ret sp; }
520+
517521

518522
fn default_ast_fold() -> @ast_fold_precursor {
519523
ret @{fold_crate: noop_fold_crate,
@@ -539,7 +543,8 @@ fn default_ast_fold() -> @ast_fold_precursor {
539543
fold_path: noop_fold_path,
540544
fold_local: noop_fold_local,
541545
map_exprs: noop_map_exprs,
542-
new_id: noop_id};
546+
new_id: noop_id,
547+
new_span: noop_span};
543548
}
544549

545550
fn dummy_out(a: ast_fold) {
@@ -567,7 +572,8 @@ fn dummy_out(a: ast_fold) {
567572
fold_path: nf_path_dummy,
568573
fold_local: nf_local_dummy,
569574
map_exprs: noop_map_exprs,
570-
new_id: noop_id};
575+
new_id: noop_id,
576+
new_span: noop_span};
571577
}
572578

573579

@@ -596,19 +602,22 @@ fn make_fold(afp: &ast_fold_precursor) -> ast_fold {
596602
fold_path: nf_path_dummy,
597603
fold_local: nf_local_dummy,
598604
map_exprs: noop_map_exprs,
599-
new_id: noop_id};
605+
new_id: noop_id,
606+
new_span: noop_span};
600607

601608
/* naturally, a macro to write these would be nice */
602609
fn f_crate(afp: &ast_fold_precursor, f: ast_fold, c: &crate) -> crate {
603-
ret {node: afp.fold_crate(c.node, f), span: c.span};
610+
ret {node: afp.fold_crate(c.node, f), span: afp.new_span(c.span)};
604611
}
605612
fn f_crate_directive(afp: &ast_fold_precursor, f: ast_fold,
606613
c: &@crate_directive) -> @crate_directive {
607-
ret @{node: afp.fold_crate_directive(c.node, f), span: c.span};
614+
ret @{node: afp.fold_crate_directive(c.node, f),
615+
span: afp.new_span(c.span)};
608616
}
609617
fn f_view_item(afp: &ast_fold_precursor, f: ast_fold, x: &@view_item) ->
610618
@view_item {
611-
ret @{node: afp.fold_view_item(x.node, f), span: x.span};
619+
ret @{node: afp.fold_view_item(x.node, f),
620+
span: afp.new_span(x.span)};
612621
}
613622
fn f_native_item(afp: &ast_fold_precursor, f: ast_fold, x: &@native_item)
614623
-> @native_item {
@@ -623,34 +632,34 @@ fn make_fold(afp: &ast_fold_precursor) -> ast_fold {
623632
}
624633
fn f_method(afp: &ast_fold_precursor, f: ast_fold, x: &@method) ->
625634
@method {
626-
ret @{node: afp.fold_method(x.node, f), span: x.span};
635+
ret @{node: afp.fold_method(x.node, f), span: afp.new_span(x.span)};
627636
}
628637
fn f_block(afp: &ast_fold_precursor, f: ast_fold, x: &blk) -> blk {
629-
ret {node: afp.fold_block(x.node, f), span: x.span};
638+
ret {node: afp.fold_block(x.node, f), span: afp.new_span(x.span)};
630639
}
631640
fn f_stmt(afp: &ast_fold_precursor, f: ast_fold, x: &@stmt) -> @stmt {
632-
ret @{node: afp.fold_stmt(x.node, f), span: x.span};
641+
ret @{node: afp.fold_stmt(x.node, f), span: afp.new_span(x.span)};
633642
}
634643
fn f_arm(afp: &ast_fold_precursor, f: ast_fold, x: &arm) -> arm {
635644
ret afp.fold_arm(x, f);
636645
}
637646
fn f_pat(afp: &ast_fold_precursor, f: ast_fold, x: &@pat) -> @pat {
638647
ret @{id: afp.new_id(x.id),
639-
node: afp.fold_pat(x.node, f), span: x.span};
648+
node: afp.fold_pat(x.node, f), span: afp.new_span(x.span)};
640649
}
641650
fn f_decl(afp: &ast_fold_precursor, f: ast_fold, x: &@decl) -> @decl {
642-
ret @{node: afp.fold_decl(x.node, f), span: x.span};
651+
ret @{node: afp.fold_decl(x.node, f), span: afp.new_span(x.span)};
643652
}
644653
fn f_expr(afp: &ast_fold_precursor, f: ast_fold, x: &@expr) -> @expr {
645654
ret @{id: afp.new_id(x.id),
646-
node: afp.fold_expr(x.node, f), span: x.span};
655+
node: afp.fold_expr(x.node, f), span: afp.new_span(x.span)};
647656
}
648657
fn f_ty(afp: &ast_fold_precursor, f: ast_fold, x: &@ty) -> @ty {
649-
ret @{node: afp.fold_ty(x.node, f), span: x.span};
658+
ret @{node: afp.fold_ty(x.node, f), span: afp.new_span(x.span)};
650659
}
651660
fn f_constr(afp: &ast_fold_precursor, f: ast_fold, x: &@ast::constr) ->
652661
@ast::constr {
653-
ret @{node: afp.fold_constr(x.node, f), span: x.span};
662+
ret @{node: afp.fold_constr(x.node, f), span: afp.new_span(x.span)};
654663
}
655664
fn f_fn(afp: &ast_fold_precursor, f: ast_fold, x: &_fn) -> _fn {
656665
ret afp.fold_fn(x, f);
@@ -664,16 +673,16 @@ fn make_fold(afp: &ast_fold_precursor) -> ast_fold {
664673
}
665674
fn f_variant(afp: &ast_fold_precursor, f: ast_fold, x: &variant) ->
666675
variant {
667-
ret {node: afp.fold_variant(x.node, f), span: x.span};
676+
ret {node: afp.fold_variant(x.node, f), span: afp.new_span(x.span)};
668677
}
669678
fn f_ident(afp: &ast_fold_precursor, f: ast_fold, x: &ident) -> ident {
670679
ret afp.fold_ident(x, f);
671680
}
672681
fn f_path(afp: &ast_fold_precursor, f: ast_fold, x: &path) -> path {
673-
ret {node: afp.fold_path(x.node, f), span: x.span};
682+
ret {node: afp.fold_path(x.node, f), span: afp.new_span(x.span)};
674683
}
675684
fn f_local(afp: &ast_fold_precursor, f: ast_fold, x: &@local) -> @local {
676-
ret @{node: afp.fold_local(x.node, f), span: x.span};
685+
ret @{node: afp.fold_local(x.node, f), span: afp.new_span(x.span)};
677686
}
678687

679688
*result =
@@ -700,7 +709,8 @@ fn make_fold(afp: &ast_fold_precursor) -> ast_fold {
700709
fold_path: bind f_path(afp, result, _),
701710
fold_local: bind f_local(afp, result, _),
702711
map_exprs: afp.map_exprs,
703-
new_id: afp.new_id};
712+
new_id: afp.new_id,
713+
new_span: afp.new_span};
704714
ret result;
705715
}
706716

trunk/src/comp/syntax/parse/parser.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1478,7 +1478,8 @@ fn parse_pat(p: &parser) -> @ast::pat {
14781478
if p.peek() == token::RPAREN {
14791479
hi = p.get_hi_pos();
14801480
p.bump();
1481-
pat = ast::pat_lit(@{node: ast::lit_nil, span: {lo: lo, hi: hi}});
1481+
pat = ast::pat_lit(@{node: ast::lit_nil,
1482+
span: ast::mk_sp(lo,hi)});
14821483
} else {
14831484
let fields = ~[parse_pat(p)];
14841485
while p.peek() == token::COMMA {

0 commit comments

Comments
 (0)