Skip to content

Commit 4795e19

Browse files
kevinabrson
authored andcommitted
When replacing a pattern variable in macro expansion use the span of
the replacement and not the span of the pattern variable. Fixes issue #1448, and #1387.
1 parent 20ab47f commit 4795e19

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/comp/syntax/ext/simplext.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -338,9 +338,9 @@ fn transcribe_path(cx: ext_ctxt, b: bindings, idx_path: @mutable [uint],
338338
if vec::len(p.types) > 0u || vec::len(p.idents) != 1u { ret (p, s); }
339339
ret alt follow_for_trans(cx, b.find(p.idents[0]), idx_path) {
340340
some(match_ident(id)) {
341-
({global: false, idents: [id.node], types: []}, s)
341+
({global: false, idents: [id.node], types: []}, id.span)
342342
}
343-
some(match_path(a_pth)) { (a_pth.node, s) }
343+
some(match_path(a_pth)) { (a_pth.node, a_pth.span) }
344344
some(m) { match_error(cx, m, "a path") }
345345
none { (p, s) }
346346
}
@@ -363,10 +363,10 @@ fn transcribe_expr(cx: ext_ctxt, b: bindings, idx_path: @mutable [uint],
363363
(expr_path(@respan(id.span,
364364
{global: false,
365365
idents: [id.node],
366-
types: []})), s)
366+
types: []})), id.span)
367367
}
368368
some(match_path(a_pth)) { (expr_path(a_pth), s) }
369-
some(match_expr(a_exp)) { (a_exp.node, s) }
369+
some(match_expr(a_exp)) { (a_exp.node, a_exp.span) }
370370
some(m) { match_error(cx, m, "an expression") }
371371
none { orig(e, s, fld) }
372372
}
@@ -385,7 +385,7 @@ fn transcribe_type(cx: ext_ctxt, b: bindings, idx_path: @mutable [uint],
385385
alt path_to_ident(pth) {
386386
some(id) {
387387
alt follow_for_trans(cx, b.find(id), idx_path) {
388-
some(match_ty(ty)) { (ty.node, s) }
388+
some(match_ty(ty)) { (ty.node, ty.span) }
389389
some(m) { match_error(cx, m, "a type") }
390390
none { orig(t, s, fld) }
391391
}
@@ -409,7 +409,7 @@ fn transcribe_block(cx: ext_ctxt, b: bindings, idx_path: @mutable [uint],
409409
ret alt block_to_ident(blk) {
410410
some(id) {
411411
alt follow_for_trans(cx, b.find(id), idx_path) {
412-
some(match_block(new_blk)) { (new_blk.node, s) }
412+
some(match_block(new_blk)) { (new_blk.node, new_blk.span) }
413413

414414

415415

0 commit comments

Comments
 (0)