Skip to content

Commit b597207

Browse files
committed
libsyntax: De-@mut TtReader::cur_span
1 parent c233c2e commit b597207

File tree

2 files changed

+13
-12
lines changed

2 files changed

+13
-12
lines changed

src/libsyntax/ext/tt/transcribe.rs

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ pub struct TtReader {
4040
priv repeat_len: RefCell<~[uint]>,
4141
/* cached: */
4242
cur_tok: RefCell<Token>,
43-
cur_span: Span
43+
cur_span: RefCell<Span>,
4444
}
4545

4646
/** This can do Macro-By-Example transcription. On the other hand, if
@@ -67,7 +67,7 @@ pub fn new_tt_reader(sp_diag: @mut SpanHandler,
6767
repeat_len: RefCell::new(~[]),
6868
/* dummy values, never read: */
6969
cur_tok: RefCell::new(EOF),
70-
cur_span: DUMMY_SP
70+
cur_span: RefCell::new(DUMMY_SP),
7171
};
7272
tt_next_token(r); /* get cur_tok and cur_span set up */
7373
return r;
@@ -93,7 +93,7 @@ pub fn dup_tt_reader(r: @mut TtReader) -> @mut TtReader {
9393
repeat_idx: r.repeat_idx.clone(),
9494
repeat_len: r.repeat_len.clone(),
9595
cur_tok: r.cur_tok.clone(),
96-
cur_span: r.cur_span,
96+
cur_span: r.cur_span.clone(),
9797
interpolations: r.interpolations.clone(),
9898
}
9999
}
@@ -123,8 +123,9 @@ fn lookup_cur_matched(r: &mut TtReader, name: Ident) -> @named_match {
123123
match matched_opt {
124124
Some(s) => lookup_cur_matched_by_matched(r, s),
125125
None => {
126-
r.sp_diag.span_fatal(r.cur_span, format!("unknown macro variable `{}`",
127-
ident_to_str(&name)));
126+
r.sp_diag.span_fatal(r.cur_span.get(),
127+
format!("unknown macro variable `{}`",
128+
ident_to_str(&name)));
128129
}
129130
}
130131
}
@@ -176,7 +177,7 @@ pub fn tt_next_token(r: &mut TtReader) -> TokenAndSpan {
176177
// XXX(pcwalton): Bad copy?
177178
let ret_val = TokenAndSpan {
178179
tok: r.cur_tok.get(),
179-
sp: r.cur_span,
180+
sp: r.cur_span.get(),
180181
};
181182
loop {
182183
{
@@ -243,7 +244,7 @@ pub fn tt_next_token(r: &mut TtReader) -> TokenAndSpan {
243244
// if this could be 0-length, we'd need to potentially recur here
244245
}
245246
tt_tok(sp, tok) => {
246-
r.cur_span = sp;
247+
r.cur_span.set(sp);
247248
r.cur_tok.set(tok);
248249
r.stack.idx += 1u;
249250
return ret_val;
@@ -299,21 +300,21 @@ pub fn tt_next_token(r: &mut TtReader) -> TokenAndSpan {
299300
(a) idents can be in lots of places, so it'd be a pain
300301
(b) we actually can, since it's a token. */
301302
matched_nonterminal(nt_ident(~sn,b)) => {
302-
r.cur_span = sp;
303+
r.cur_span.set(sp);
303304
r.cur_tok.set(IDENT(sn,b));
304305
r.stack.idx += 1u;
305306
return ret_val;
306307
}
307308
matched_nonterminal(ref other_whole_nt) => {
308309
// XXX(pcwalton): Bad copy.
309-
r.cur_span = sp;
310+
r.cur_span.set(sp);
310311
r.cur_tok.set(INTERPOLATED((*other_whole_nt).clone()));
311312
r.stack.idx += 1u;
312313
return ret_val;
313314
}
314315
matched_seq(..) => {
315316
r.sp_diag.span_fatal(
316-
r.cur_span, /* blame the macro writer */
317+
r.cur_span.get(), /* blame the macro writer */
317318
format!("variable '{}' is still repeating at this depth",
318319
ident_to_str(&ident)));
319320
}

src/libsyntax/parse/lexer.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,13 +143,13 @@ impl reader for TtReader {
143143
return r;
144144
}
145145
fn fatal(@mut self, m: ~str) -> ! {
146-
self.sp_diag.span_fatal(self.cur_span, m);
146+
self.sp_diag.span_fatal(self.cur_span.get(), m);
147147
}
148148
fn span_diag(@mut self) -> @mut SpanHandler { self.sp_diag }
149149
fn peek(@mut self) -> TokenAndSpan {
150150
TokenAndSpan {
151151
tok: self.cur_tok.get(),
152-
sp: self.cur_span,
152+
sp: self.cur_span.get(),
153153
}
154154
}
155155
fn dup(@mut self) -> @mut reader { dup_tt_reader(self) as @mut reader }

0 commit comments

Comments
 (0)