From 7c3ed86e5a57b6cfa0872e15a478079a1871122f Mon Sep 17 00:00:00 2001 From: Edward Wang Date: Sun, 23 Mar 2014 02:53:35 +0800 Subject: [PATCH] Get rid of @Cell --- src/librustc/middle/trans/_match.rs | 4 ++-- src/libsyntax/parse/parser.rs | 17 ++++++++--------- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/src/librustc/middle/trans/_match.rs b/src/librustc/middle/trans/_match.rs index 39a0597a5da..ebb813f6d24 100644 --- a/src/librustc/middle/trans/_match.rs +++ b/src/librustc/middle/trans/_match.rs @@ -1185,7 +1185,7 @@ struct DynamicFailureHandler<'a> { bcx: &'a Block<'a>, sp: Span, msg: InternedString, - finished: @Cell>, + finished: Cell>, } impl<'a> DynamicFailureHandler<'a> { @@ -1927,7 +1927,7 @@ fn trans_match_inner<'a>(scope_cx: &'a Block<'a>, let chk = { if ty::type_is_empty(tcx, t) { // Special case for empty types - let fail_cx = @Cell::new(None); + let fail_cx = Cell::new(None); let fail_handler = ~DynamicFailureHandler { bcx: scope_cx, sp: discr_expr.span, diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 1313225e22b..adf3ac0e17d 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -77,7 +77,6 @@ use parse::token; use parse::{new_sub_parser_from_file, ParseSess}; use owned_slice::OwnedSlice; -use std::cell::Cell; use collections::HashSet; use std::kinds::marker; use std::mem::replace; @@ -2202,12 +2201,12 @@ impl<'a> Parser<'a> { // unification of Matcher's and TokenTree's would vastly improve // the interpolation of Matcher's maybe_whole!(self, NtMatchers); - let name_idx = @Cell::new(0u); + let mut name_idx = 0u; match self.token { token::LBRACE | token::LPAREN | token::LBRACKET => { let other_delimiter = token::flip_delimiter(&self.token); self.bump(); - self.parse_matcher_subseq_upto(name_idx, &other_delimiter) + self.parse_matcher_subseq_upto(&mut name_idx, &other_delimiter) } _ => self.fatal("expected open delimiter") } @@ -2217,7 +2216,7 @@ impl<'a> Parser<'a> { // Otherwise, `$( ( )` would be a valid Matcher, and `$( () )` would be // invalid. It's similar to common::parse_seq. pub fn parse_matcher_subseq_upto(&mut self, - name_idx: @Cell, + name_idx: &mut uint, ket: &token::Token) -> Vec { let mut ret_val = Vec::new(); @@ -2234,13 +2233,13 @@ impl<'a> Parser<'a> { return ret_val; } - pub fn parse_matcher(&mut self, name_idx: @Cell) -> Matcher { + pub fn parse_matcher(&mut self, name_idx: &mut uint) -> Matcher { let lo = self.span.lo; let m = if self.token == token::DOLLAR { self.bump(); if self.token == token::LPAREN { - let name_idx_lo = name_idx.get(); + let name_idx_lo = *name_idx; self.bump(); let ms = self.parse_matcher_subseq_upto(name_idx, &token::RPAREN); @@ -2248,13 +2247,13 @@ impl<'a> Parser<'a> { self.fatal("repetition body must be nonempty"); } let (sep, zerok) = self.parse_sep_and_zerok(); - MatchSeq(ms, sep, zerok, name_idx_lo, name_idx.get()) + MatchSeq(ms, sep, zerok, name_idx_lo, *name_idx) } else { let bound_to = self.parse_ident(); self.expect(&token::COLON); let nt_name = self.parse_ident(); - let m = MatchNonterminal(bound_to, nt_name, name_idx.get()); - name_idx.set(name_idx.get() + 1u); + let m = MatchNonterminal(bound_to, nt_name, *name_idx); + *name_idx += 1; m } } else {