Skip to content

Commit 039affa

Browse files
committed
---
yaml --- r: 4689 b: refs/heads/master c: c48036c h: refs/heads/master i: 4687: f26e5b2 v: v3
1 parent 27ac2cf commit 039affa

File tree

13 files changed

+80
-51
lines changed

13 files changed

+80
-51
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: 87b56b5565993eec4fb137fe53309ec60873e175
2+
refs/heads/master: c48036c0b7d10606dc8c63b87351fb394cf7d4a6

trunk/src/comp/front/attr.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ fn require_unique_names(sess: &session::session,
190190
}
191191

192192
fn span[T](item: &T) -> ast::spanned[T] {
193-
ret {node: item, span: {lo: 0u, hi: 0u}};
193+
ret {node: item, span: ast::mk_sp(0u, 0u)};
194194
}
195195

196196
fn mk_name_value_item_str(name: ast::ident, value: str) -> @ast::meta_item {

trunk/src/comp/front/test.rs

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -160,15 +160,15 @@ fn mk_test_module(cx: &test_ctxt) -> @ast::item {
160160
attrs: ~[],
161161
id: cx.next_node_id(),
162162
node: item_,
163-
span: {lo: 0u, hi: 0u}};
163+
span: ast::dummy_sp()};
164164

165165
log #fmt("Synthetic test module:\n%s\n", pprust::item_to_str(@item));
166166

167167
ret @item;
168168
}
169169

170170
fn nospan[T](t: &T) -> ast::spanned[T] {
171-
ret {node: t, span: {lo: 0u, hi: 0u}};
171+
ret {node: t, span: ast::dummy_sp()};
172172
}
173173

174174
fn mk_tests(cx: &test_ctxt) -> @ast::item {
@@ -198,7 +198,7 @@ fn mk_tests(cx: &test_ctxt) -> @ast::item {
198198
attrs: ~[],
199199
id: cx.next_node_id(),
200200
node: item_,
201-
span: {lo: 0u, hi: 0u}};
201+
span: ast::dummy_sp()};
202202
ret @item;
203203
}
204204

@@ -236,7 +236,7 @@ fn mk_test_desc_vec(cx: &test_ctxt) -> @ast::expr {
236236

237237
ret @{id: cx.next_node_id(),
238238
node: ast::expr_vec(descs, ast::imm, ast::sk_unique),
239-
span: {lo: 0u, hi: 0u}};
239+
span: ast::dummy_sp()};
240240
}
241241

242242
fn mk_test_desc_rec(cx: &test_ctxt, test: test) -> @ast::expr {
@@ -249,7 +249,7 @@ fn mk_test_desc_rec(cx: &test_ctxt, test: test) -> @ast::expr {
249249
let name_expr: ast::expr =
250250
{id: cx.next_node_id(),
251251
node: ast::expr_lit(@name_lit),
252-
span: {lo: 0u, hi: 0u}};
252+
span: ast::dummy_sp()};
253253

254254
let name_field: ast::field =
255255
nospan({mut: ast::imm, ident: "name", expr: @name_expr});
@@ -260,7 +260,7 @@ fn mk_test_desc_rec(cx: &test_ctxt, test: test) -> @ast::expr {
260260
let fn_expr: ast::expr =
261261
{id: cx.next_node_id(),
262262
node: ast::expr_path(fn_path),
263-
span: {lo: 0u, hi: 0u}};
263+
span: ast::dummy_sp()};
264264

265265
let fn_field: ast::field =
266266
nospan({mut: ast::imm, ident: "fn", expr: @fn_expr});
@@ -270,15 +270,15 @@ fn mk_test_desc_rec(cx: &test_ctxt, test: test) -> @ast::expr {
270270
let ignore_expr: ast::expr =
271271
{id: cx.next_node_id(),
272272
node: ast::expr_lit(@ignore_lit),
273-
span: {lo: 0u, hi: 0u}};
273+
span: ast::dummy_sp()};
274274

275275
let ignore_field: ast::field =
276276
nospan({mut: ast::imm, ident: "ignore", expr: @ignore_expr});
277277

278278
let desc_rec_: ast::expr_ =
279279
ast::expr_rec(~[name_field, fn_field, ignore_field], option::none);
280280
let desc_rec: ast::expr =
281-
{id: cx.next_node_id(), node: desc_rec_, span: {lo: 0u, hi: 0u}};
281+
{id: cx.next_node_id(), node: desc_rec_, span: ast::dummy_sp()};
282282
ret @desc_rec;
283283
}
284284

@@ -307,7 +307,7 @@ fn mk_main(cx: &test_ctxt) -> @ast::item {
307307
{stmts: ~[],
308308
expr: option::some(test_main_call_expr),
309309
id: cx.next_node_id()};
310-
let body = {node: body_, span: {lo: 0u, hi: 0u}};
310+
let body = {node: body_, span: ast::dummy_sp()};
311311

312312
let fn_ = {decl: decl, proto: proto, body: body};
313313

@@ -317,7 +317,7 @@ fn mk_main(cx: &test_ctxt) -> @ast::item {
317317
attrs: ~[],
318318
id: cx.next_node_id(),
319319
node: item_,
320-
span: {lo: 0u, hi: 0u}};
320+
span: ast::dummy_sp()};
321321
ret @item;
322322
}
323323

@@ -332,7 +332,7 @@ fn mk_test_main_call(cx: &test_ctxt) -> @ast::expr {
332332
let args_path_expr: ast::expr =
333333
{id: cx.next_node_id(),
334334
node: args_path_expr_,
335-
span: {lo: 0u, hi: 0u}};
335+
span: ast::dummy_sp()};
336336

337337
// Call __test::test to generate the vector of test_descs
338338
let test_path: ast::path =
@@ -343,14 +343,14 @@ fn mk_test_main_call(cx: &test_ctxt) -> @ast::expr {
343343
let test_path_expr: ast::expr =
344344
{id: cx.next_node_id(),
345345
node: test_path_expr_,
346-
span: {lo: 0u, hi: 0u}};
346+
span: ast::dummy_sp()};
347347

348348
let test_call_expr_: ast::expr_ = ast::expr_call(@test_path_expr, ~[]);
349349

350350
let test_call_expr: ast::expr =
351351
{id: cx.next_node_id(),
352352
node: test_call_expr_,
353-
span: {lo: 0u, hi: 0u}};
353+
span: ast::dummy_sp()};
354354

355355
// Call std::test::test_main
356356
let test_main_path: ast::path =
@@ -363,7 +363,7 @@ fn mk_test_main_call(cx: &test_ctxt) -> @ast::expr {
363363
let test_main_path_expr: ast::expr =
364364
{id: cx.next_node_id(),
365365
node: test_main_path_expr_,
366-
span: {lo: 0u, hi: 0u}};
366+
span: ast::dummy_sp()};
367367

368368
let test_main_call_expr_: ast::expr_ =
369369
ast::expr_call(@test_main_path_expr,
@@ -372,7 +372,7 @@ fn mk_test_main_call(cx: &test_ctxt) -> @ast::expr {
372372
let test_main_call_expr: ast::expr =
373373
{id: cx.next_node_id(),
374374
node: test_main_call_expr_,
375-
span: {lo: 0u, hi: 0u}};
375+
span: ast::dummy_sp()};
376376

377377
ret @test_main_call_expr;
378378
}

trunk/src/comp/metadata/creader.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ fn resolve_crate_deps(e: env, cdata: &@[u8]) -> cstore::cnum_map {
263263
log "need to load it";
264264
// This is a new one so we've got to load it
265265
// FIXME: Need better error reporting than just a bogus span
266-
let fake_span = {lo: 0u, hi: 0u};
266+
let fake_span = ast::dummy_sp();
267267
let local_cnum = resolve_crate(e, cname, ~[], fake_span);
268268
cnum_map.insert(extrn_cnum, local_cnum);
269269
}

trunk/src/comp/metadata/decoder.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ fn get_attributes(md: &ebml::doc) -> [ast::attribute] {
335335
let meta_item = meta_items.(0);
336336
attrs +=
337337
~[{node: {style: ast::attr_outer, value: *meta_item},
338-
span: {lo: 0u, hi: 0u}}];
338+
span: ast::dummy_sp()}];
339339
}
340340
}
341341
option::none. { }

trunk/src/comp/metadata/tydecode.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ fn parse_path(st: @pstate, sd: str_def) -> ast::path {
106106
':' { next(st); next(st); }
107107
c {
108108
if c == '(' {
109-
ret respan({lo: 0u, hi: 0u},
109+
ret respan(ast::dummy_sp(),
110110
{global: false, idents: idents, types: ~[]});
111111
} else { idents += ~[parse_ident_(st, sd, is_last)]; }
112112
}
@@ -152,8 +152,8 @@ fn parse_ty_constr_arg(st: @pstate, sd: str_def) ->
152152

153153
fn parse_constr[@T](st: @pstate, sd: str_def, pser: arg_parser[T]) ->
154154
@ty::constr_general[T] {
155-
let sp = {lo: 0u, hi: 0u}; // FIXME: use a real span
156-
let args: [@sp_constr_arg[T]] = ~[];
155+
let sp = ast::dummy_sp(); // FIXME: use a real span
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/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: {lo: 0u, hi: 0u}};
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/shape.rs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import middle::ty;
2121
import middle::ty::field;
2222
import middle::ty::mt;
2323
import syntax::ast;
24+
import syntax::ast::dummy_sp;
2425
import syntax::codemap::span;
2526
import syntax::util::interner;
2627
import util::common;
@@ -72,8 +73,6 @@ const shape_uniq : u8 = 22u8;
7273
// FIXME: This is a bad API in trans_common.
7374
fn C_u8(n : u8) -> ValueRef { ret trans_common::C_u8(n as uint); }
7475

75-
fn fake_span() -> span { ret { lo: 0u, hi: 0u }; }
76-
7776
fn hash_res_info(ri : &res_info) -> uint {
7877
let h = 5381u;
7978
h *= 33u; h += (ri.did.crate as uint);
@@ -121,7 +120,7 @@ fn largest_variants(ccx : &@crate_ctxt, tag_id : &ast::def_id) -> [uint] {
121120
// when in fact it has minimum size sizeof(int).
122121
bounded = false;
123122
} else {
124-
let llty = trans::type_of(ccx, fake_span(), elem_t);
123+
let llty = trans::type_of(ccx, dummy_sp(), elem_t);
125124
min_size += trans::llsize_of_real(ccx, llty);
126125
min_align += trans::llalign_of_real(ccx, llty);
127126
}
@@ -195,7 +194,7 @@ fn compute_static_tag_size(ccx : &@crate_ctxt, largest_variants : &[uint],
195194
// We increment a "virtual data pointer" to compute the size.
196195
let lltys = ~[];
197196
for typ : ty::t in variants.(vid).args {
198-
lltys += ~[trans::type_of(ccx, fake_span(), typ)];
197+
lltys += ~[trans::type_of(ccx, dummy_sp(), typ)];
199198
}
200199

201200
let llty = trans_common::T_struct(lltys);
@@ -412,7 +411,7 @@ fn add_size_hint(ccx : &@crate_ctxt, s : &mutable [u8], typ : ty::t) {
412411
ret;
413412
}
414413

415-
let llty = trans::type_of(ccx, fake_span(), typ);
414+
let llty = trans::type_of(ccx, dummy_sp(), typ);
416415
add_u16(s, trans::llsize_of_real(ccx, llty) as u16);
417416
s += ~[ trans::llalign_of_real(ccx, llty) as u8 ];
418417
}
@@ -523,8 +522,7 @@ fn gen_resource_shapes(ccx : &@crate_ctxt) -> ValueRef {
523522
let len = interner::len(ccx.shape_cx.resources);
524523
while i < len {
525524
let ri = interner::get(ccx.shape_cx.resources, i);
526-
dtors += ~[trans_common::get_res_dtor(ccx, fake_span(), ri.did,
527-
ri.t)];
525+
dtors += ~[trans_common::get_res_dtor(ccx, dummy_sp(), ri.did, ri.t)];
528526
i += 1u;
529527
}
530528

trunk/src/comp/middle/trans_alt.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import trans::new_scope_block_ctxt;
1414
import trans::load_if_immediate;
1515
import ty::pat_ty;
1616
import syntax::ast;
17+
import syntax::ast::dummy_sp;
1718
import syntax::ast::def_id;
1819
import syntax::codemap::span;
1920
import util::common::lit_eq;
@@ -105,7 +106,7 @@ fn enter_default(m: &match, col: uint, val: ValueRef) -> match {
105106

106107
fn enter_opt(ccx: &@crate_ctxt, m: &match, opt: &opt, col: uint,
107108
tag_size: uint, val: ValueRef) -> match {
108-
let dummy = @{id: 0, node: ast::pat_wild, span: {lo: 0u, hi: 0u}};
109+
let dummy = @{id: 0, node: ast::pat_wild, span: dummy_sp()};
109110
fn e(ccx: &@crate_ctxt, dummy: &@ast::pat, opt: &opt, size: uint,
110111
p: &@ast::pat) -> option::t[[@ast::pat]] {
111112
alt p.node {
@@ -125,7 +126,7 @@ fn enter_opt(ccx: &@crate_ctxt, m: &match, opt: &opt, col: uint,
125126

126127
fn enter_rec(m: &match, col: uint, fields: &[ast::ident], val: ValueRef) ->
127128
match {
128-
let dummy = @{id: 0, node: ast::pat_wild, span: {lo: 0u, hi: 0u}};
129+
let dummy = @{id: 0, node: ast::pat_wild, span: dummy_sp();
129130
fn e(dummy: &@ast::pat, fields: &[ast::ident], p: &@ast::pat) ->
130131
option::t[[@ast::pat]] {
131132
alt p.node {
@@ -159,7 +160,7 @@ fn enter_tup(m: &match, col: uint, val: ValueRef, n_elts: uint) -> match {
159160
}
160161

161162
fn enter_box(m: &match, col: uint, val: ValueRef) -> match {
162-
let dummy = @{id: 0, node: ast::pat_wild, span: {lo: 0u, hi: 0u}};
163+
let dummy = @{id: 0, node: ast::pat_wild, span: dummy_sp()};
163164
fn e(dummy: &@ast::pat, p: &@ast::pat) -> option::t[[@ast::pat]] {
164165
alt p.node {
165166
ast::pat_box(sub) { ret some(~[sub]); }
@@ -310,7 +311,7 @@ fn compile_submatch(bcx: @block_ctxt, m: &match, vals: [ValueRef],
310311
let rec_vals = ~[];
311312
for field_name: ast::ident in rec_fields {
312313
let ix: uint =
313-
ty::field_idx(ccx.sess, {lo: 0u, hi: 0u}, field_name, fields);
314+
ty::field_idx(ccx.sess, dummy_sp(), field_name, fields);
314315
let r = trans::GEP_tup_like(bcx, rec_ty, val, ~[0, ix as int]);
315316
rec_vals += ~[r.val];
316317
bcx = r.bcx;

trunk/src/comp/syntax/ast.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,14 @@ import codemap::filename;
99
type spanned[T] = {node: T, span: span};
1010
fn respan[T](sp: &span, t: &T) -> spanned[T] { ret {node: t, span: sp}; }
1111

12+
/* assuming that we're not in macro expansion */
13+
fn mk_sp(lo: uint, hi: uint) -> span {
14+
ret {lo: lo, hi: hi, expanded_from: codemap::os_none};
15+
}
16+
17+
// make this a const, once the compiler supports it
18+
fn dummy_sp() -> span { ret mk_sp(0u, 0u); }
19+
1220
type ident = str;
1321
// Functions may or may not have names.
1422
type fn_ident = option::t[ident];

trunk/src/comp/syntax/codemap.rs

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,12 +65,34 @@ fn lookup_byte_pos(map: codemap, pos: uint) -> loc {
6565
ret lookup_pos(map, pos, lookup);
6666
}
6767

68-
type span = {lo: uint, hi: uint};
68+
tag opt_span { //hack (as opposed to option::t), to make `span` compile
69+
os_none;
70+
os_some(@span);
71+
}
72+
type span = {lo: uint, hi: uint, expanded_from: opt_span};
6973

7074
fn span_to_str(sp: &span, cm: &codemap) -> str {
71-
let lo = lookup_char_pos(cm, sp.lo);
72-
let hi = lookup_char_pos(cm, sp.hi);
73-
ret #fmt("%s:%u:%u:%u:%u", lo.filename, lo.line, lo.col, hi.line, hi.col);
75+
let cur = sp;
76+
let res = "";
77+
let prev_file = none;
78+
while(true) {
79+
let lo = lookup_char_pos(cm, cur.lo);
80+
let hi = lookup_char_pos(cm, cur.hi);
81+
res += #fmt("%s:%u:%u:%u:%u",
82+
if some(lo.filename) == prev_file { "-" }
83+
else { lo.filename },
84+
lo.line, lo.col, hi.line, hi.col);
85+
alt cur.expanded_from {
86+
os_none. { break; }
87+
os_some(new_sp) {
88+
cur = *new_sp;
89+
prev_file = some(lo.filename);
90+
res += "<<";
91+
}
92+
}
93+
}
94+
95+
ret res;
7496
}
7597

7698
fn emit_diagnostic(sp: &option::t[span], msg: &str, kind: &str, color: u8,

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ fn new_reader(cm: &codemap::codemap, src: str, filemap: codemap::filemap,
7878
fn get_col() -> uint { ret col; }
7979
fn get_filemap() -> codemap::filemap { ret fm; }
8080
fn err(m: str) {
81-
codemap::emit_error(some({lo: chpos, hi: chpos}), m, cm);
81+
codemap::emit_error(some(ast::mk_sp(chpos, chpos)), m, cm);
8282
}
8383
}
8484
let strs: [str] = ~[];

0 commit comments

Comments
 (0)