From abfde39b0e904cf39d3fbf392d747f4f168017ec Mon Sep 17 00:00:00 2001 From: Edward Wang Date: Thu, 6 Mar 2014 22:58:34 +0800 Subject: borrowck: classify expressions as assignees, uses or both - Repurposes `MoveData.assignee_ids` to mean only `=` but not `+=`, so that borrowck effectively classifies all expressions into assignees, uses or both. - Removes two `span_err` in liveness analysis, which are now borrowck's responsibilities. Closes #12527. --- src/test/compile-fail/asm-out-read-uninit.rs | 2 +- src/test/compile-fail/borrowck-and-init.rs | 16 ++++++++ src/test/compile-fail/borrowck-block-unint.rs | 17 +++++++++ src/test/compile-fail/borrowck-break-uninit-2.rs | 24 ++++++++++++ src/test/compile-fail/borrowck-break-uninit.rs | 24 ++++++++++++ src/test/compile-fail/borrowck-if-no-else.rs | 16 ++++++++ src/test/compile-fail/borrowck-if-with-else.rs | 21 +++++++++++ .../borrowck-init-in-called-fn-expr.rs | 17 +++++++++ src/test/compile-fail/borrowck-init-in-fn-expr.rs | 17 +++++++++ src/test/compile-fail/borrowck-init-in-fru.rs | 21 +++++++++++ src/test/compile-fail/borrowck-init-op-equal.rs | 18 +++++++++ src/test/compile-fail/borrowck-init-plus-equal.rs | 18 +++++++++ src/test/compile-fail/borrowck-or-init.rs | 16 ++++++++ src/test/compile-fail/borrowck-return.rs | 16 ++++++++ .../compile-fail/borrowck-uninit-after-item.rs | 15 ++++++++ .../compile-fail/borrowck-uninit-in-assignop.rs | 44 ++++++++++++++++++++++ src/test/compile-fail/borrowck-uninit.rs | 16 ++++++++ .../compile-fail/borrowck-use-in-index-lvalue.rs | 20 ++++++++++ src/test/compile-fail/borrowck-while-break.rs | 22 +++++++++++ src/test/compile-fail/borrowck-while-cond.rs | 14 +++++++ src/test/compile-fail/borrowck-while.rs | 17 +++++++++ src/test/compile-fail/liveness-and-init.rs | 16 -------- src/test/compile-fail/liveness-block-unint.rs | 17 --------- src/test/compile-fail/liveness-break-uninit-2.rs | 24 ------------ src/test/compile-fail/liveness-break-uninit.rs | 24 ------------ src/test/compile-fail/liveness-if-no-else.rs | 16 -------- src/test/compile-fail/liveness-if-with-else.rs | 21 ----------- .../liveness-init-in-called-fn-expr.rs | 17 --------- src/test/compile-fail/liveness-init-in-fn-expr.rs | 17 --------- src/test/compile-fail/liveness-init-in-fru.rs | 21 ----------- src/test/compile-fail/liveness-init-op-equal.rs | 18 --------- src/test/compile-fail/liveness-init-plus-equal.rs | 18 --------- src/test/compile-fail/liveness-or-init.rs | 16 -------- src/test/compile-fail/liveness-return.rs | 16 -------- .../compile-fail/liveness-uninit-after-item.rs | 15 -------- src/test/compile-fail/liveness-uninit.rs | 16 -------- src/test/compile-fail/liveness-unused.rs | 5 +++ .../compile-fail/liveness-use-in-index-lvalue.rs | 16 -------- src/test/compile-fail/liveness-while-break.rs | 22 ----------- src/test/compile-fail/liveness-while-cond.rs | 14 ------- src/test/compile-fail/liveness-while.rs | 17 --------- 41 files changed, 395 insertions(+), 342 deletions(-) create mode 100644 src/test/compile-fail/borrowck-and-init.rs create mode 100644 src/test/compile-fail/borrowck-block-unint.rs create mode 100644 src/test/compile-fail/borrowck-break-uninit-2.rs create mode 100644 src/test/compile-fail/borrowck-break-uninit.rs create mode 100644 src/test/compile-fail/borrowck-if-no-else.rs create mode 100644 src/test/compile-fail/borrowck-if-with-else.rs create mode 100644 src/test/compile-fail/borrowck-init-in-called-fn-expr.rs create mode 100644 src/test/compile-fail/borrowck-init-in-fn-expr.rs create mode 100644 src/test/compile-fail/borrowck-init-in-fru.rs create mode 100644 src/test/compile-fail/borrowck-init-op-equal.rs create mode 100644 src/test/compile-fail/borrowck-init-plus-equal.rs create mode 100644 src/test/compile-fail/borrowck-or-init.rs create mode 100644 src/test/compile-fail/borrowck-return.rs create mode 100644 src/test/compile-fail/borrowck-uninit-after-item.rs create mode 100644 src/test/compile-fail/borrowck-uninit-in-assignop.rs create mode 100644 src/test/compile-fail/borrowck-uninit.rs create mode 100644 src/test/compile-fail/borrowck-use-in-index-lvalue.rs create mode 100644 src/test/compile-fail/borrowck-while-break.rs create mode 100644 src/test/compile-fail/borrowck-while-cond.rs create mode 100644 src/test/compile-fail/borrowck-while.rs delete mode 100644 src/test/compile-fail/liveness-and-init.rs delete mode 100644 src/test/compile-fail/liveness-block-unint.rs delete mode 100644 src/test/compile-fail/liveness-break-uninit-2.rs delete mode 100644 src/test/compile-fail/liveness-break-uninit.rs delete mode 100644 src/test/compile-fail/liveness-if-no-else.rs delete mode 100644 src/test/compile-fail/liveness-if-with-else.rs delete mode 100644 src/test/compile-fail/liveness-init-in-called-fn-expr.rs delete mode 100644 src/test/compile-fail/liveness-init-in-fn-expr.rs delete mode 100644 src/test/compile-fail/liveness-init-in-fru.rs delete mode 100644 src/test/compile-fail/liveness-init-op-equal.rs delete mode 100644 src/test/compile-fail/liveness-init-plus-equal.rs delete mode 100644 src/test/compile-fail/liveness-or-init.rs delete mode 100644 src/test/compile-fail/liveness-return.rs delete mode 100644 src/test/compile-fail/liveness-uninit-after-item.rs delete mode 100644 src/test/compile-fail/liveness-uninit.rs delete mode 100644 src/test/compile-fail/liveness-use-in-index-lvalue.rs delete mode 100644 src/test/compile-fail/liveness-while-break.rs delete mode 100644 src/test/compile-fail/liveness-while-cond.rs delete mode 100644 src/test/compile-fail/liveness-while.rs (limited to 'src/test') diff --git a/src/test/compile-fail/asm-out-read-uninit.rs b/src/test/compile-fail/asm-out-read-uninit.rs index b63865921c6..65750eb926b 100644 --- a/src/test/compile-fail/asm-out-read-uninit.rs +++ b/src/test/compile-fail/asm-out-read-uninit.rs @@ -19,7 +19,7 @@ fn foo(x: int) { info!("{}", x); } pub fn main() { let x: int; unsafe { - asm!("mov $1, $0" : "=r"(x) : "r"(x)); //~ ERROR use of possibly uninitialized value: `x` + asm!("mov $1, $0" : "=r"(x) : "r"(x)); //~ ERROR use of possibly uninitialized variable: `x` } foo(x); } diff --git a/src/test/compile-fail/borrowck-and-init.rs b/src/test/compile-fail/borrowck-and-init.rs new file mode 100644 index 00000000000..134390d0b59 --- /dev/null +++ b/src/test/compile-fail/borrowck-and-init.rs @@ -0,0 +1,16 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn main() { + let i: int; + + info!("{}", false && { i = 5; true }); + info!("{}", i); //~ ERROR use of possibly uninitialized variable: `i` +} diff --git a/src/test/compile-fail/borrowck-block-unint.rs b/src/test/compile-fail/borrowck-block-unint.rs new file mode 100644 index 00000000000..fc865e271e3 --- /dev/null +++ b/src/test/compile-fail/borrowck-block-unint.rs @@ -0,0 +1,17 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn force(f: ||) { f(); } +fn main() { + let x: int; + force(|| { //~ ERROR capture of possibly uninitialized variable: `x` + info!("{}", x); + }); +} diff --git a/src/test/compile-fail/borrowck-break-uninit-2.rs b/src/test/compile-fail/borrowck-break-uninit-2.rs new file mode 100644 index 00000000000..accb9076974 --- /dev/null +++ b/src/test/compile-fail/borrowck-break-uninit-2.rs @@ -0,0 +1,24 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn foo() -> int { + let x: int; + + while 1 != 2 { + break; + x = 0; + } + + info!("{}", x); //~ ERROR use of possibly uninitialized variable: `x` + + return 17; +} + +fn main() { info!("{}", foo()); } diff --git a/src/test/compile-fail/borrowck-break-uninit.rs b/src/test/compile-fail/borrowck-break-uninit.rs new file mode 100644 index 00000000000..d49e79d2c64 --- /dev/null +++ b/src/test/compile-fail/borrowck-break-uninit.rs @@ -0,0 +1,24 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn foo() -> int { + let x: int; + + loop { + break; + x = 0; + } + + info!("{}", x); //~ ERROR use of possibly uninitialized variable: `x` + + return 17; +} + +fn main() { info!("{}", foo()); } diff --git a/src/test/compile-fail/borrowck-if-no-else.rs b/src/test/compile-fail/borrowck-if-no-else.rs new file mode 100644 index 00000000000..8dc590b47f0 --- /dev/null +++ b/src/test/compile-fail/borrowck-if-no-else.rs @@ -0,0 +1,16 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn foo(x: int) { info!("{}", x); } + +fn main() { + let x: int; if 1 > 2 { x = 10; } + foo(x); //~ ERROR use of possibly uninitialized variable: `x` +} diff --git a/src/test/compile-fail/borrowck-if-with-else.rs b/src/test/compile-fail/borrowck-if-with-else.rs new file mode 100644 index 00000000000..55fb8222634 --- /dev/null +++ b/src/test/compile-fail/borrowck-if-with-else.rs @@ -0,0 +1,21 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn foo(x: int) { info!("{:?}", x); } + +fn main() { + let x: int; + if 1 > 2 { + info!("whoops"); + } else { + x = 10; + } + foo(x); //~ ERROR use of possibly uninitialized variable: `x` +} diff --git a/src/test/compile-fail/borrowck-init-in-called-fn-expr.rs b/src/test/compile-fail/borrowck-init-in-called-fn-expr.rs new file mode 100644 index 00000000000..d759a5738bd --- /dev/null +++ b/src/test/compile-fail/borrowck-init-in-called-fn-expr.rs @@ -0,0 +1,17 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn main() { + let j: || -> int = || { + let i: int; + i //~ ERROR use of possibly uninitialized variable: `i` + }; + j(); +} diff --git a/src/test/compile-fail/borrowck-init-in-fn-expr.rs b/src/test/compile-fail/borrowck-init-in-fn-expr.rs new file mode 100644 index 00000000000..f6bb2f54283 --- /dev/null +++ b/src/test/compile-fail/borrowck-init-in-fn-expr.rs @@ -0,0 +1,17 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn main() { + let f: || -> int = || { + let i: int; + i //~ ERROR use of possibly uninitialized variable: `i` + }; + error!("{:?}", f()); +} diff --git a/src/test/compile-fail/borrowck-init-in-fru.rs b/src/test/compile-fail/borrowck-init-in-fru.rs new file mode 100644 index 00000000000..97fc2b4d44c --- /dev/null +++ b/src/test/compile-fail/borrowck-init-in-fru.rs @@ -0,0 +1,21 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#[deriving(Clone)] +struct point { + x: int, + y: int, +} + +fn main() { + let mut origin: point; + origin = point {x: 10,.. origin}; //~ ERROR use of possibly uninitialized variable: `origin` + origin.clone(); +} diff --git a/src/test/compile-fail/borrowck-init-op-equal.rs b/src/test/compile-fail/borrowck-init-op-equal.rs new file mode 100644 index 00000000000..cbe805551c2 --- /dev/null +++ b/src/test/compile-fail/borrowck-init-op-equal.rs @@ -0,0 +1,18 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn test() { + let v: int; + v += 1; //~ ERROR use of possibly uninitialized variable: `v` + v.clone(); +} + +fn main() { +} diff --git a/src/test/compile-fail/borrowck-init-plus-equal.rs b/src/test/compile-fail/borrowck-init-plus-equal.rs new file mode 100644 index 00000000000..6e813809f03 --- /dev/null +++ b/src/test/compile-fail/borrowck-init-plus-equal.rs @@ -0,0 +1,18 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn test() { + let mut v: int; + v = v + 1; //~ ERROR use of possibly uninitialized variable: `v` + v.clone(); +} + +fn main() { +} diff --git a/src/test/compile-fail/borrowck-or-init.rs b/src/test/compile-fail/borrowck-or-init.rs new file mode 100644 index 00000000000..f878afce969 --- /dev/null +++ b/src/test/compile-fail/borrowck-or-init.rs @@ -0,0 +1,16 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn main() { + let i: int; + + info!("{}", false || { i = 5; true }); + info!("{}", i); //~ ERROR use of possibly uninitialized variable: `i` +} diff --git a/src/test/compile-fail/borrowck-return.rs b/src/test/compile-fail/borrowck-return.rs new file mode 100644 index 00000000000..6558bc57968 --- /dev/null +++ b/src/test/compile-fail/borrowck-return.rs @@ -0,0 +1,16 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn f() -> int { + let x: int; + return x; //~ ERROR use of possibly uninitialized variable: `x` +} + +fn main() { f(); } diff --git a/src/test/compile-fail/borrowck-uninit-after-item.rs b/src/test/compile-fail/borrowck-uninit-after-item.rs new file mode 100644 index 00000000000..a828b1d6b9f --- /dev/null +++ b/src/test/compile-fail/borrowck-uninit-after-item.rs @@ -0,0 +1,15 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn main() { + let bar; + fn baz(_x: int) { } + baz(bar); //~ ERROR use of possibly uninitialized variable: `bar` +} diff --git a/src/test/compile-fail/borrowck-uninit-in-assignop.rs b/src/test/compile-fail/borrowck-uninit-in-assignop.rs new file mode 100644 index 00000000000..b5e462e592a --- /dev/null +++ b/src/test/compile-fail/borrowck-uninit-in-assignop.rs @@ -0,0 +1,44 @@ +// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Tests that the use of uninitialized variable in assignment operator +// expression is detected. + +pub fn main() { + let x: int; + x += 1; //~ ERROR use of possibly uninitialized variable: `x` + + let x: int; + x -= 1; //~ ERROR use of possibly uninitialized variable: `x` + + let x: int; + x *= 1; //~ ERROR use of possibly uninitialized variable: `x` + + let x: int; + x /= 1; //~ ERROR use of possibly uninitialized variable: `x` + + let x: int; + x %= 1; //~ ERROR use of possibly uninitialized variable: `x` + + let x: int; + x ^= 1; //~ ERROR use of possibly uninitialized variable: `x` + + let x: int; + x &= 1; //~ ERROR use of possibly uninitialized variable: `x` + + let x: int; + x |= 1; //~ ERROR use of possibly uninitialized variable: `x` + + let x: int; + x <<= 1; //~ ERROR use of possibly uninitialized variable: `x` + + let x: int; + x >>= 1; //~ ERROR use of possibly uninitialized variable: `x` +} diff --git a/src/test/compile-fail/borrowck-uninit.rs b/src/test/compile-fail/borrowck-uninit.rs new file mode 100644 index 00000000000..a6ce736c89b --- /dev/null +++ b/src/test/compile-fail/borrowck-uninit.rs @@ -0,0 +1,16 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn foo(x: int) { info!("{}", x); } + +fn main() { + let x: int; + foo(x); //~ ERROR use of possibly uninitialized variable: `x` +} diff --git a/src/test/compile-fail/borrowck-use-in-index-lvalue.rs b/src/test/compile-fail/borrowck-use-in-index-lvalue.rs new file mode 100644 index 00000000000..3ced9859240 --- /dev/null +++ b/src/test/compile-fail/borrowck-use-in-index-lvalue.rs @@ -0,0 +1,20 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn test() { + let w: ~[int]; + w[5] = 0; //~ ERROR use of possibly uninitialized variable: `w` + //~^ ERROR cannot assign to immutable vec content `w[..]` + + let mut w: ~[int]; + w[5] = 0; //~ ERROR use of possibly uninitialized variable: `w` +} + +fn main() { test(); } diff --git a/src/test/compile-fail/borrowck-while-break.rs b/src/test/compile-fail/borrowck-while-break.rs new file mode 100644 index 00000000000..e5d4b6ef48c --- /dev/null +++ b/src/test/compile-fail/borrowck-while-break.rs @@ -0,0 +1,22 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn test(cond: bool) { + let v; + while cond { + v = 3; + break; + } + info!("{}", v); //~ ERROR use of possibly uninitialized variable: `v` +} + +fn main() { + test(true); +} diff --git a/src/test/compile-fail/borrowck-while-cond.rs b/src/test/compile-fail/borrowck-while-cond.rs new file mode 100644 index 00000000000..27d42d666ea --- /dev/null +++ b/src/test/compile-fail/borrowck-while-cond.rs @@ -0,0 +1,14 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn main() { + let x: bool; + while x { } //~ ERROR use of possibly uninitialized variable: `x` +} diff --git a/src/test/compile-fail/borrowck-while.rs b/src/test/compile-fail/borrowck-while.rs new file mode 100644 index 00000000000..b904fd53d72 --- /dev/null +++ b/src/test/compile-fail/borrowck-while.rs @@ -0,0 +1,17 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn f() -> int { + let mut x: int; + while 1 == 1 { x = 10; } + return x; //~ ERROR use of possibly uninitialized variable: `x` +} + +fn main() { f(); } diff --git a/src/test/compile-fail/liveness-and-init.rs b/src/test/compile-fail/liveness-and-init.rs deleted file mode 100644 index 134390d0b59..00000000000 --- a/src/test/compile-fail/liveness-and-init.rs +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn main() { - let i: int; - - info!("{}", false && { i = 5; true }); - info!("{}", i); //~ ERROR use of possibly uninitialized variable: `i` -} diff --git a/src/test/compile-fail/liveness-block-unint.rs b/src/test/compile-fail/liveness-block-unint.rs deleted file mode 100644 index c46b9013a06..00000000000 --- a/src/test/compile-fail/liveness-block-unint.rs +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn force(f: ||) { f(); } -fn main() { - let x: int; - force(|| { - info!("{}", x); //~ ERROR capture of possibly uninitialized variable: `x` - }); -} diff --git a/src/test/compile-fail/liveness-break-uninit-2.rs b/src/test/compile-fail/liveness-break-uninit-2.rs deleted file mode 100644 index accb9076974..00000000000 --- a/src/test/compile-fail/liveness-break-uninit-2.rs +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn foo() -> int { - let x: int; - - while 1 != 2 { - break; - x = 0; - } - - info!("{}", x); //~ ERROR use of possibly uninitialized variable: `x` - - return 17; -} - -fn main() { info!("{}", foo()); } diff --git a/src/test/compile-fail/liveness-break-uninit.rs b/src/test/compile-fail/liveness-break-uninit.rs deleted file mode 100644 index d49e79d2c64..00000000000 --- a/src/test/compile-fail/liveness-break-uninit.rs +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn foo() -> int { - let x: int; - - loop { - break; - x = 0; - } - - info!("{}", x); //~ ERROR use of possibly uninitialized variable: `x` - - return 17; -} - -fn main() { info!("{}", foo()); } diff --git a/src/test/compile-fail/liveness-if-no-else.rs b/src/test/compile-fail/liveness-if-no-else.rs deleted file mode 100644 index 8dc590b47f0..00000000000 --- a/src/test/compile-fail/liveness-if-no-else.rs +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn foo(x: int) { info!("{}", x); } - -fn main() { - let x: int; if 1 > 2 { x = 10; } - foo(x); //~ ERROR use of possibly uninitialized variable: `x` -} diff --git a/src/test/compile-fail/liveness-if-with-else.rs b/src/test/compile-fail/liveness-if-with-else.rs deleted file mode 100644 index 55fb8222634..00000000000 --- a/src/test/compile-fail/liveness-if-with-else.rs +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn foo(x: int) { info!("{:?}", x); } - -fn main() { - let x: int; - if 1 > 2 { - info!("whoops"); - } else { - x = 10; - } - foo(x); //~ ERROR use of possibly uninitialized variable: `x` -} diff --git a/src/test/compile-fail/liveness-init-in-called-fn-expr.rs b/src/test/compile-fail/liveness-init-in-called-fn-expr.rs deleted file mode 100644 index d759a5738bd..00000000000 --- a/src/test/compile-fail/liveness-init-in-called-fn-expr.rs +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn main() { - let j: || -> int = || { - let i: int; - i //~ ERROR use of possibly uninitialized variable: `i` - }; - j(); -} diff --git a/src/test/compile-fail/liveness-init-in-fn-expr.rs b/src/test/compile-fail/liveness-init-in-fn-expr.rs deleted file mode 100644 index f6bb2f54283..00000000000 --- a/src/test/compile-fail/liveness-init-in-fn-expr.rs +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn main() { - let f: || -> int = || { - let i: int; - i //~ ERROR use of possibly uninitialized variable: `i` - }; - error!("{:?}", f()); -} diff --git a/src/test/compile-fail/liveness-init-in-fru.rs b/src/test/compile-fail/liveness-init-in-fru.rs deleted file mode 100644 index 97fc2b4d44c..00000000000 --- a/src/test/compile-fail/liveness-init-in-fru.rs +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#[deriving(Clone)] -struct point { - x: int, - y: int, -} - -fn main() { - let mut origin: point; - origin = point {x: 10,.. origin}; //~ ERROR use of possibly uninitialized variable: `origin` - origin.clone(); -} diff --git a/src/test/compile-fail/liveness-init-op-equal.rs b/src/test/compile-fail/liveness-init-op-equal.rs deleted file mode 100644 index cbe805551c2..00000000000 --- a/src/test/compile-fail/liveness-init-op-equal.rs +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn test() { - let v: int; - v += 1; //~ ERROR use of possibly uninitialized variable: `v` - v.clone(); -} - -fn main() { -} diff --git a/src/test/compile-fail/liveness-init-plus-equal.rs b/src/test/compile-fail/liveness-init-plus-equal.rs deleted file mode 100644 index 6e813809f03..00000000000 --- a/src/test/compile-fail/liveness-init-plus-equal.rs +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn test() { - let mut v: int; - v = v + 1; //~ ERROR use of possibly uninitialized variable: `v` - v.clone(); -} - -fn main() { -} diff --git a/src/test/compile-fail/liveness-or-init.rs b/src/test/compile-fail/liveness-or-init.rs deleted file mode 100644 index f878afce969..00000000000 --- a/src/test/compile-fail/liveness-or-init.rs +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn main() { - let i: int; - - info!("{}", false || { i = 5; true }); - info!("{}", i); //~ ERROR use of possibly uninitialized variable: `i` -} diff --git a/src/test/compile-fail/liveness-return.rs b/src/test/compile-fail/liveness-return.rs deleted file mode 100644 index 6558bc57968..00000000000 --- a/src/test/compile-fail/liveness-return.rs +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn f() -> int { - let x: int; - return x; //~ ERROR use of possibly uninitialized variable: `x` -} - -fn main() { f(); } diff --git a/src/test/compile-fail/liveness-uninit-after-item.rs b/src/test/compile-fail/liveness-uninit-after-item.rs deleted file mode 100644 index a828b1d6b9f..00000000000 --- a/src/test/compile-fail/liveness-uninit-after-item.rs +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn main() { - let bar; - fn baz(_x: int) { } - baz(bar); //~ ERROR use of possibly uninitialized variable: `bar` -} diff --git a/src/test/compile-fail/liveness-uninit.rs b/src/test/compile-fail/liveness-uninit.rs deleted file mode 100644 index a6ce736c89b..00000000000 --- a/src/test/compile-fail/liveness-uninit.rs +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn foo(x: int) { info!("{}", x); } - -fn main() { - let x: int; - foo(x); //~ ERROR use of possibly uninitialized variable: `x` -} diff --git a/src/test/compile-fail/liveness-unused.rs b/src/test/compile-fail/liveness-unused.rs index 83c911d916e..33fc094abbe 100644 --- a/src/test/compile-fail/liveness-unused.rs +++ b/src/test/compile-fail/liveness-unused.rs @@ -23,6 +23,11 @@ fn f1b(x: &mut int) { #[allow(unused_variable)] fn f1c(x: int) {} +fn f1d() { + let x: int; + //~^ ERROR unused variable: `x` +} + fn f2() { let x = 3; //~^ ERROR unused variable: `x` diff --git a/src/test/compile-fail/liveness-use-in-index-lvalue.rs b/src/test/compile-fail/liveness-use-in-index-lvalue.rs deleted file mode 100644 index 7ec0607fc97..00000000000 --- a/src/test/compile-fail/liveness-use-in-index-lvalue.rs +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn test() { - let w: ~[int]; - w[5] = 0; //~ ERROR use of possibly uninitialized variable: `w` -} - -fn main() { test(); } diff --git a/src/test/compile-fail/liveness-while-break.rs b/src/test/compile-fail/liveness-while-break.rs deleted file mode 100644 index e5d4b6ef48c..00000000000 --- a/src/test/compile-fail/liveness-while-break.rs +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn test(cond: bool) { - let v; - while cond { - v = 3; - break; - } - info!("{}", v); //~ ERROR use of possibly uninitialized variable: `v` -} - -fn main() { - test(true); -} diff --git a/src/test/compile-fail/liveness-while-cond.rs b/src/test/compile-fail/liveness-while-cond.rs deleted file mode 100644 index 27d42d666ea..00000000000 --- a/src/test/compile-fail/liveness-while-cond.rs +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn main() { - let x: bool; - while x { } //~ ERROR use of possibly uninitialized variable: `x` -} diff --git a/src/test/compile-fail/liveness-while.rs b/src/test/compile-fail/liveness-while.rs deleted file mode 100644 index b904fd53d72..00000000000 --- a/src/test/compile-fail/liveness-while.rs +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn f() -> int { - let mut x: int; - while 1 == 1 { x = 10; } - return x; //~ ERROR use of possibly uninitialized variable: `x` -} - -fn main() { f(); } -- cgit 1.4.1-3-g733a5