Skip to content

Commit aba93c6

Browse files
committed
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.
2 parents a6dd7dc + c389d0b commit aba93c6

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+265
-120
lines changed

src/libcore/cell.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ fn test_with_ref() {
121121
#[test]
122122
fn test_with_mut_ref() {
123123
let good = ~[1, 2, 3];
124-
let mut v = ~[1, 2];
124+
let v = ~[1, 2];
125125
let c = Cell(v);
126126
do c.with_mut_ref() |v| { v.push(3); }
127127
let v = c.take();

src/libcore/flate.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ pub fn deflate_bytes(bytes: &const [u8]) -> ~[u8] {
6767
pub fn inflate_bytes(bytes: &const [u8]) -> ~[u8] {
6868
do vec::as_const_buf(bytes) |b, len| {
6969
unsafe {
70-
let mut outsz : size_t = 0;
70+
let outsz : size_t = 0;
7171
let res =
7272
rustrt::tinfl_decompress_mem_to_heap(b as *c_void,
7373
len as size_t,

src/libcore/path.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -854,7 +854,7 @@ pub mod windows {
854854
while i < s.len() {
855855
if is_sep(s[i]) {
856856
let pre = s.slice(2, i).to_owned();
857-
let mut rest = s.slice(i, s.len()).to_owned();
857+
let rest = s.slice(i, s.len()).to_owned();
858858
return Some((pre, rest));
859859
}
860860
i += 1;

src/libcore/rand.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -742,7 +742,7 @@ struct XorShiftState {
742742
impl Rng for XorShiftState {
743743
fn next(&self) -> u32 {
744744
let x = self.x;
745-
let mut t = x ^ (x << 11);
745+
let t = x ^ (x << 11);
746746
self.x = self.y;
747747
self.y = self.z;
748748
self.z = self.w;

src/libcore/repr.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ pub impl ReprVisitor {
210210
#[inline(always)]
211211
fn visit_ptr_inner(&self, ptr: *c_void, inner: *TyDesc) -> bool {
212212
unsafe {
213-
let mut u = ReprVisitor(ptr, self.writer);
213+
let u = ReprVisitor(ptr, self.writer);
214214
let v = reflect::MovePtrAdaptor(u);
215215
visit_tydesc(inner, @v as @TyVisitor);
216216
true
@@ -667,7 +667,7 @@ pub fn write_repr<T>(writer: @Writer, object: &T) {
667667
unsafe {
668668
let ptr = ptr::to_unsafe_ptr(object) as *c_void;
669669
let tydesc = intrinsic::get_tydesc::<T>();
670-
let mut u = ReprVisitor(ptr, writer);
670+
let u = ReprVisitor(ptr, writer);
671671
let v = reflect::MovePtrAdaptor(u);
672672
visit_tydesc(tydesc, @v as @TyVisitor)
673673
}

src/libcore/rt/uv/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -402,7 +402,7 @@ fn loop_smoke_test() {
402402
fn idle_new_then_close() {
403403
do run_in_bare_thread {
404404
let mut loop_ = Loop::new();
405-
let mut idle_watcher = { IdleWatcher::new(&mut loop_) };
405+
let idle_watcher = { IdleWatcher::new(&mut loop_) };
406406
idle_watcher.close();
407407
}
408408
}

src/libcore/rt/uv/net.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,7 @@ fn connect_read() {
393393
let buf = vec_from_uv_buf(buf);
394394
rtdebug!("read cb!");
395395
if status.is_none() {
396-
let bytes = buf.unwrap();
396+
let _bytes = buf.unwrap();
397397
rtdebug!("%s", bytes.slice(0, nread as uint).to_str());
398398
} else {
399399
rtdebug!("status after read: %s", status.get().to_str());

src/libcore/rt/uvio.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ impl TcpListener for UvTcpListener {
206206
let mut server_stream_watcher = server_stream_watcher;
207207
let mut loop_ = loop_from_watcher(&server_stream_watcher);
208208
let mut client_tcp_watcher = TcpWatcher::new(&mut loop_);
209-
let mut client_tcp_watcher = client_tcp_watcher.as_stream();
209+
let client_tcp_watcher = client_tcp_watcher.as_stream();
210210
// XXX: Need's to be surfaced in interface
211211
server_stream_watcher.accept(client_tcp_watcher);
212212
Some(~UvStream::new(client_tcp_watcher))

src/libcore/run.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,7 @@ pub fn start_program(prog: &str, args: &[~str]) -> @Program {
343343
fn force_destroy(&mut self) { destroy_repr(&mut self.r, true); }
344344
}
345345

346-
let mut repr = ProgRepr {
346+
let repr = ProgRepr {
347347
pid: pid,
348348
in_fd: pipe_input.out,
349349
out_file: os::fdopen(pipe_output.in),

src/libcore/str.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -673,7 +673,7 @@ pub fn levdistance(s: &str, t: &str) -> uint {
673673

674674
for t.each_chari |j, tc| {
675675

676-
let mut next = dcol[j + 1];
676+
let next = dcol[j + 1];
677677

678678
if sc == tc {
679679
dcol[j + 1] = current;
@@ -909,7 +909,7 @@ impl TotalOrd for @str {
909909
/// Bytewise slice less than
910910
fn lt(a: &str, b: &str) -> bool {
911911
let (a_len, b_len) = (a.len(), b.len());
912-
let mut end = uint::min(a_len, b_len);
912+
let end = uint::min(a_len, b_len);
913913

914914
let mut i = 0;
915915
while i < end {
@@ -1715,7 +1715,7 @@ pub fn utf16_chars(v: &[u16], f: &fn(char)) {
17151715
let len = vec::len(v);
17161716
let mut i = 0u;
17171717
while (i < len && v[i] != 0u16) {
1718-
let mut u = v[i];
1718+
let u = v[i];
17191719

17201720
if u <= 0xD7FF_u16 || u >= 0xE000_u16 {
17211721
f(u as char);

0 commit comments

Comments
 (0)