diff options
| author | bors <bors@rust-lang.org> | 2013-04-22 15:36:51 -0700 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2013-04-22 15:36:51 -0700 |
| commit | aba93c6b60a91fc4b6b60408e51b23dbee5f44c9 (patch) | |
| tree | 91d5ca30a8d1809161972cffa0b69b89a22750f2 /src/libsyntax/ext | |
| parent | a6dd7dc1f2e1057719179e861a5a5ae55d6a8335 (diff) | |
| parent | c389d0b0dd2273c9f7d16917a1738509f5522491 (diff) | |
| download | rust-aba93c6b60a91fc4b6b60408e51b23dbee5f44c9.tar.gz rust-aba93c6b60a91fc4b6b60408e51b23dbee5f44c9.zip | |
auto merge of #5966 : alexcrichton/rust/issue-3083, r=graydon
Closes #3083. This takes a similar approach to #5797 where a set is present on the `tcx` of used mutable definitions. Everything is by default warned about, and analyses must explicitly add mutable definitions to this set so they're not warned about. Most of this was pretty straightforward, although there was one caveat that I ran into when implementing it. Apparently when the old modes are used (or maybe `legacy_modes`, I'm not sure) some different code paths are taken to cause spurious warnings to be issued which shouldn't be issued. I'm not really sure how modes even worked, so I was having a lot of trouble tracking this down. I figured that because they're a legacy thing that I'd just de-mode the compiler so that the warnings wouldn't be a problem anymore (or at least for the compiler). Other than that, the entire compiler compiles without warnings of unused mutable variables. To prevent bad warnings, #5965 should be landed (which in turn is waiting on #5963) before landing this. I figured I'd stick it out for review anyway though.
Diffstat (limited to 'src/libsyntax/ext')
| -rw-r--r-- | src/libsyntax/ext/fmt.rs | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/src/libsyntax/ext/fmt.rs b/src/libsyntax/ext/fmt.rs index 3ebe844950a..6a877040f48 100644 --- a/src/libsyntax/ext/fmt.rs +++ b/src/libsyntax/ext/fmt.rs @@ -96,7 +96,7 @@ fn pieces_to_expr(cx: @ext_ctxt, sp: span, } } fn make_ty(cx: @ext_ctxt, sp: span, t: Ty) -> @ast::expr { - let mut rt_type; + let rt_type; match t { TyHex(c) => match c { CaseUpper => rt_type = ~"TyHexUpper", @@ -272,6 +272,7 @@ fn pieces_to_expr(cx: @ext_ctxt, sp: span, /* Translate each piece (portion of the fmt expression) by invoking the corresponding function in core::unstable::extfmt. Each function takes a buffer to insert data into along with the data being formatted. */ + let npieces = pieces.len(); do vec::consume(pieces) |i, pc| { match pc { /* Raw strings get appended via str::push_str */ @@ -279,9 +280,10 @@ fn pieces_to_expr(cx: @ext_ctxt, sp: span, let portion = mk_uniq_str(cx, fmt_sp, s); /* If this is the first portion, then initialize the local - buffer with it directly */ + buffer with it directly. If it's actually the only piece, + then there's no need for it to be mutable */ if i == 0 { - stms.push(mk_local(cx, fmt_sp, true, ident, portion)); + stms.push(mk_local(cx, fmt_sp, npieces > 1, ident, portion)); } else { let args = ~[mk_mut_addr_of(cx, fmt_sp, buf()), portion]; let call = mk_call_global(cx, |
