From 3810bea0da90b49c23f004e0b08277bb88404d85 Mon Sep 17 00:00:00 2001 From: Patrick Walton Date: Fri, 27 Dec 2013 13:14:21 -0800 Subject: [PATCH] libsyntax: De-`@mut` `TtReader::interpolations` --- src/libsyntax/ext/tt/transcribe.rs | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/libsyntax/ext/tt/transcribe.rs b/src/libsyntax/ext/tt/transcribe.rs index cbce5fb16cbb..bcede5a7dc57 100644 --- a/src/libsyntax/ext/tt/transcribe.rs +++ b/src/libsyntax/ext/tt/transcribe.rs @@ -17,6 +17,7 @@ use parse::token::{EOF, INTERPOLATED, IDENT, Token, nt_ident}; use parse::token::{ident_to_str}; use parse::lexer::TokenAndSpan; +use std::cell::RefCell; use std::hashmap::HashMap; use std::option; @@ -34,7 +35,7 @@ pub struct TtReader { // the unzipped tree: stack: @mut TtFrame, /* for MBE-style macro transcription */ - interpolations: HashMap, + priv interpolations: RefCell>, repeat_idx: ~[uint], repeat_len: ~[uint], /* cached: */ @@ -59,8 +60,8 @@ pub fn new_tt_reader(sp_diag: @mut SpanHandler, up: option::None }, interpolations: match interp { /* just a convienience */ - None => HashMap::new(), - Some(x) => x + None => RefCell::new(HashMap::new()), + Some(x) => RefCell::new(x), }, repeat_idx: ~[], repeat_len: ~[], @@ -114,7 +115,11 @@ fn lookup_cur_matched_by_matched(r: &mut TtReader, } fn lookup_cur_matched(r: &mut TtReader, name: Ident) -> @named_match { - match r.interpolations.find_copy(&name) { + let matched_opt = { + let interpolations = r.interpolations.borrow(); + interpolations.get().find_copy(&name) + }; + match matched_opt { Some(s) => lookup_cur_matched_by_matched(r, s), None => { r.sp_diag.span_fatal(r.cur_span, format!("unknown macro variable `{}`",