Skip to content

Commit fd97cac

Browse files
committed
syntax: remove unused 'mut' variables
1 parent 7d317fe commit fd97cac

File tree

7 files changed

+29
-27
lines changed

7 files changed

+29
-27
lines changed

src/libsyntax/diagnostic.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,7 @@ fn highlight_lines_internal(cm: @codemap::CodeMap,
342342
while num > 0u { num /= 10u; digits += 1u; }
343343

344344
// indent past |name:## | and the 0-offset column location
345-
let mut left = str::len(fm.name) + digits + lo.col.to_uint() + 3u;
345+
let left = str::len(fm.name) + digits + lo.col.to_uint() + 3u;
346346
let mut s = ~"";
347347
// Skip is the number of characters we need to skip because they are
348348
// part of the 'filename:line ' part of the previous line.

src/libsyntax/ext/fmt.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ fn pieces_to_expr(cx: @ext_ctxt, sp: span,
9696
}
9797
}
9898
fn make_ty(cx: @ext_ctxt, sp: span, t: Ty) -> @ast::expr {
99-
let mut rt_type;
99+
let rt_type;
100100
match t {
101101
TyHex(c) => match c {
102102
CaseUpper => rt_type = ~"TyHexUpper",
@@ -272,16 +272,18 @@ fn pieces_to_expr(cx: @ext_ctxt, sp: span,
272272
/* Translate each piece (portion of the fmt expression) by invoking the
273273
corresponding function in core::unstable::extfmt. Each function takes a
274274
buffer to insert data into along with the data being formatted. */
275+
let npieces = pieces.len();
275276
do vec::consume(pieces) |i, pc| {
276277
match pc {
277278
/* Raw strings get appended via str::push_str */
278279
PieceString(s) => {
279280
let portion = mk_uniq_str(cx, fmt_sp, s);
280281

281282
/* If this is the first portion, then initialize the local
282-
buffer with it directly */
283+
buffer with it directly. If it's actually the only piece,
284+
then there's no need for it to be mutable */
283285
if i == 0 {
284-
stms.push(mk_local(cx, fmt_sp, true, ident, portion));
286+
stms.push(mk_local(cx, fmt_sp, npieces > 1, ident, portion));
285287
} else {
286288
let args = ~[mk_mut_addr_of(cx, fmt_sp, buf()), portion];
287289
let call = mk_call_global(cx,

src/libsyntax/parse/attr.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ impl parser_attr for Parser {
7373
self.expect(&token::LBRACKET);
7474
let meta_item = self.parse_meta_item();
7575
self.expect(&token::RBRACKET);
76-
let mut hi = self.span.hi;
76+
let hi = self.span.hi;
7777
return spanned(lo, hi, ast::attribute_ { style: style,
7878
value: meta_item,
7979
is_sugared_doc: false });
@@ -141,16 +141,16 @@ impl parser_attr for Parser {
141141
token::EQ => {
142142
self.bump();
143143
let lit = self.parse_lit();
144-
let mut hi = self.span.hi;
144+
let hi = self.span.hi;
145145
@spanned(lo, hi, ast::meta_name_value(name, lit))
146146
}
147147
token::LPAREN => {
148148
let inner_items = self.parse_meta_seq();
149-
let mut hi = self.span.hi;
149+
let hi = self.span.hi;
150150
@spanned(lo, hi, ast::meta_list(name, inner_items))
151151
}
152152
_ => {
153-
let mut hi = self.span.hi;
153+
let hi = self.span.hi;
154154
@spanned(lo, hi, ast::meta_word(name))
155155
}
156156
}

src/libsyntax/parse/comments.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ fn read_block_comment(rdr: @mut StringReader,
229229
debug!(">>> block comment");
230230
let p = rdr.last_pos;
231231
let mut lines: ~[~str] = ~[];
232-
let mut col: CharPos = rdr.col;
232+
let col: CharPos = rdr.col;
233233
bump(rdr);
234234
bump(rdr);
235235

src/libsyntax/parse/parser.rs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -810,7 +810,7 @@ pub impl Parser {
810810
// This version of parse arg doesn't necessarily require
811811
// identifier names.
812812
fn parse_arg_general(&self, require_name: bool) -> arg {
813-
let mut m;
813+
let m;
814814
let mut is_mutbl = false;
815815
let pat = if require_name || self.is_named_argument() {
816816
m = self.parse_arg_mode();
@@ -1154,7 +1154,7 @@ pub impl Parser {
11541154
let lo = self.span.lo;
11551155
let mut hi = self.span.hi;
11561156

1157-
let mut ex: expr_;
1157+
let ex: expr_;
11581158

11591159
if *self.token == token::LPAREN {
11601160
self.bump();
@@ -1629,9 +1629,9 @@ pub impl Parser {
16291629
// parse a prefix-operator expr
16301630
fn parse_prefix_expr(&self) -> @expr {
16311631
let lo = self.span.lo;
1632-
let mut hi;
1632+
let hi;
16331633

1634-
let mut ex;
1634+
let ex;
16351635
match *self.token {
16361636
token::NOT => {
16371637
self.bump();
@@ -1781,7 +1781,7 @@ pub impl Parser {
17811781
token::BINOPEQ(op) => {
17821782
self.bump();
17831783
let rhs = self.parse_expr();
1784-
let mut aop;
1784+
let aop;
17851785
match op {
17861786
token::PLUS => aop = add,
17871787
token::MINUS => aop = subtract,
@@ -1956,7 +1956,7 @@ pub impl Parser {
19561956
let lo = self.last_span.lo;
19571957
let cond = self.parse_expr();
19581958
let body = self.parse_block_no_value();
1959-
let mut hi = body.span.hi;
1959+
let hi = body.span.hi;
19601960
return self.mk_expr(lo, hi, expr_while(cond, body));
19611961
}
19621962

@@ -1984,7 +1984,7 @@ pub impl Parser {
19841984

19851985
let lo = self.last_span.lo;
19861986
let body = self.parse_block_no_value();
1987-
let mut hi = body.span.hi;
1987+
let hi = body.span.hi;
19881988
return self.mk_expr(lo, hi, expr_loop(body, opt_ident));
19891989
} else {
19901990
// This is a 'continue' expression
@@ -2043,7 +2043,7 @@ pub impl Parser {
20432043

20442044
arms.push(ast::arm { pats: pats, guard: guard, body: blk });
20452045
}
2046-
let mut hi = self.span.hi;
2046+
let hi = self.span.hi;
20472047
self.bump();
20482048
return self.mk_expr(lo, hi, expr_match(discriminant, arms));
20492049
}
@@ -2162,7 +2162,7 @@ pub impl Parser {
21622162
let hi1 = self.last_span.lo;
21632163
let fieldpath = ast_util::ident_to_path(mk_sp(lo1, hi1),
21642164
fieldname);
2165-
let mut subpat;
2165+
let subpat;
21662166
if *self.token == token::COLON {
21672167
self.bump();
21682168
subpat = self.parse_pat(refutable);
@@ -2183,7 +2183,7 @@ pub impl Parser {
21832183

21842184
let lo = self.span.lo;
21852185
let mut hi = self.span.hi;
2186-
let mut pat;
2186+
let pat;
21872187
match *self.token {
21882188
token::UNDERSCORE => { self.bump(); pat = pat_wild; }
21892189
token::AT => {
@@ -2534,7 +2534,7 @@ pub impl Parser {
25342534
match self.parse_item_or_view_item(/*bad*/ copy item_attrs,
25352535
true, false, false) {
25362536
iovi_item(i) => {
2537-
let mut hi = i.span.hi;
2537+
let hi = i.span.hi;
25382538
let decl = @spanned(lo, hi, decl_item(i));
25392539
return @spanned(lo, hi, stmt_decl(decl, self.get_id()));
25402540
}
@@ -2704,7 +2704,7 @@ pub impl Parser {
27042704
}
27052705
}
27062706
}
2707-
let mut hi = self.span.hi;
2707+
let hi = self.span.hi;
27082708
self.bump();
27092709
let bloc = ast::blk_ {
27102710
view_items: view_items,
@@ -3590,7 +3590,7 @@ pub impl Parser {
35903590
let purity = self.parse_fn_purity();
35913591
let (ident, generics) = self.parse_fn_header();
35923592
let decl = self.parse_fn_decl(|p| p.parse_arg());
3593-
let mut hi = self.span.hi;
3593+
let hi = self.span.hi;
35943594
self.expect(&token::SEMI);
35953595
@ast::foreign_item { ident: ident,
35963596
attrs: attrs,
@@ -3798,7 +3798,7 @@ pub impl Parser {
37983798
}
37993799
}
38003800
self.bump();
3801-
let mut actual_dtor = do the_dtor.map |dtor| {
3801+
let actual_dtor = do the_dtor.map |dtor| {
38023802
let (d_body, d_attrs, d_s) = copy *dtor;
38033803
codemap::spanned { node: ast::struct_dtor_ { id: self.get_id(),
38043804
attrs: d_attrs,

src/libsyntax/print/pp.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -146,9 +146,9 @@ pub fn mk_printer(out: @io::Writer, linewidth: uint) -> @mut Printer {
146146
// fall behind.
147147
let n: uint = 3 * linewidth;
148148
debug!("mk_printer %u", linewidth);
149-
let mut token: ~[token] = vec::from_elem(n, EOF);
150-
let mut size: ~[int] = vec::from_elem(n, 0);
151-
let mut scan_stack: ~[uint] = vec::from_elem(n, 0u);
149+
let token: ~[token] = vec::from_elem(n, EOF);
150+
let size: ~[int] = vec::from_elem(n, 0);
151+
let scan_stack: ~[uint] = vec::from_elem(n, 0u);
152152
@mut Printer {
153153
out: @out,
154154
buf_len: n,

src/libsyntax/print/pprust.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1972,7 +1972,7 @@ pub fn print_ty_fn(s: @ps,
19721972
19731973
pub fn maybe_print_trailing_comment(s: @ps, span: codemap::span,
19741974
next_pos: Option<BytePos>) {
1975-
let mut cm;
1975+
let cm;
19761976
match s.cm { Some(ccm) => cm = ccm, _ => return }
19771977
match next_comment(s) {
19781978
Some(ref cmnt) => {

0 commit comments

Comments
 (0)