Skip to content

Commit 2046bf4

Browse files
committed
---
yaml --- r: 147909 b: refs/heads/try2 c: 3810bea h: refs/heads/master i: 147907: 324633d v: v3
1 parent 9a62688 commit 2046bf4

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ refs/heads/snap-stage3: 78a7676898d9f80ab540c6df5d4c9ce35bb50463
55
refs/heads/try: 519addf6277dbafccbb4159db4b710c37eaa2ec5
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
8-
refs/heads/try2: 185608754d9418c226ca1a8c8889042046c25c63
8+
refs/heads/try2: 3810bea0da90b49c23f004e0b08277bb88404d85
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/src/libsyntax/ext/tt/transcribe.rs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ use parse::token::{EOF, INTERPOLATED, IDENT, Token, nt_ident};
1717
use parse::token::{ident_to_str};
1818
use parse::lexer::TokenAndSpan;
1919

20+
use std::cell::RefCell;
2021
use std::hashmap::HashMap;
2122
use std::option;
2223

@@ -34,7 +35,7 @@ pub struct TtReader {
3435
// the unzipped tree:
3536
stack: @mut TtFrame,
3637
/* for MBE-style macro transcription */
37-
interpolations: HashMap<Ident, @named_match>,
38+
priv interpolations: RefCell<HashMap<Ident, @named_match>>,
3839
repeat_idx: ~[uint],
3940
repeat_len: ~[uint],
4041
/* cached: */
@@ -59,8 +60,8 @@ pub fn new_tt_reader(sp_diag: @mut SpanHandler,
5960
up: option::None
6061
},
6162
interpolations: match interp { /* just a convienience */
62-
None => HashMap::new(),
63-
Some(x) => x
63+
None => RefCell::new(HashMap::new()),
64+
Some(x) => RefCell::new(x),
6465
},
6566
repeat_idx: ~[],
6667
repeat_len: ~[],
@@ -114,7 +115,11 @@ fn lookup_cur_matched_by_matched(r: &mut TtReader,
114115
}
115116

116117
fn lookup_cur_matched(r: &mut TtReader, name: Ident) -> @named_match {
117-
match r.interpolations.find_copy(&name) {
118+
let matched_opt = {
119+
let interpolations = r.interpolations.borrow();
120+
interpolations.get().find_copy(&name)
121+
};
122+
match matched_opt {
118123
Some(s) => lookup_cur_matched_by_matched(r, s),
119124
None => {
120125
r.sp_diag.span_fatal(r.cur_span, format!("unknown macro variable `{}`",

0 commit comments

Comments
 (0)