diff options
Diffstat (limited to 'src/test')
| -rw-r--r-- | src/test/compile-fail/asm-out-read-uninit.rs | 2 | ||||
| -rw-r--r-- | src/test/compile-fail/borrowck-and-init.rs (renamed from src/test/compile-fail/liveness-and-init.rs) | 0 | ||||
| -rw-r--r-- | src/test/compile-fail/borrowck-block-unint.rs (renamed from src/test/compile-fail/liveness-block-unint.rs) | 4 | ||||
| -rw-r--r-- | src/test/compile-fail/borrowck-break-uninit-2.rs (renamed from src/test/compile-fail/liveness-break-uninit-2.rs) | 0 | ||||
| -rw-r--r-- | src/test/compile-fail/borrowck-break-uninit.rs (renamed from src/test/compile-fail/liveness-break-uninit.rs) | 0 | ||||
| -rw-r--r-- | src/test/compile-fail/borrowck-if-no-else.rs (renamed from src/test/compile-fail/liveness-if-no-else.rs) | 0 | ||||
| -rw-r--r-- | src/test/compile-fail/borrowck-if-with-else.rs (renamed from src/test/compile-fail/liveness-if-with-else.rs) | 0 | ||||
| -rw-r--r-- | src/test/compile-fail/borrowck-init-in-called-fn-expr.rs (renamed from src/test/compile-fail/liveness-init-in-called-fn-expr.rs) | 0 | ||||
| -rw-r--r-- | src/test/compile-fail/borrowck-init-in-fn-expr.rs (renamed from src/test/compile-fail/liveness-init-in-fn-expr.rs) | 0 | ||||
| -rw-r--r-- | src/test/compile-fail/borrowck-init-in-fru.rs (renamed from src/test/compile-fail/liveness-init-in-fru.rs) | 0 | ||||
| -rw-r--r-- | src/test/compile-fail/borrowck-init-op-equal.rs (renamed from src/test/compile-fail/liveness-init-op-equal.rs) | 0 | ||||
| -rw-r--r-- | src/test/compile-fail/borrowck-init-plus-equal.rs (renamed from src/test/compile-fail/liveness-init-plus-equal.rs) | 0 | ||||
| -rw-r--r-- | src/test/compile-fail/borrowck-or-init.rs (renamed from src/test/compile-fail/liveness-or-init.rs) | 0 | ||||
| -rw-r--r-- | src/test/compile-fail/borrowck-return.rs (renamed from src/test/compile-fail/liveness-return.rs) | 0 | ||||
| -rw-r--r-- | src/test/compile-fail/borrowck-uninit-after-item.rs (renamed from src/test/compile-fail/liveness-uninit-after-item.rs) | 0 | ||||
| -rw-r--r-- | src/test/compile-fail/borrowck-uninit-in-assignop.rs | 44 | ||||
| -rw-r--r-- | src/test/compile-fail/borrowck-uninit.rs (renamed from src/test/compile-fail/liveness-uninit.rs) | 0 | ||||
| -rw-r--r-- | src/test/compile-fail/borrowck-use-in-index-lvalue.rs (renamed from src/test/compile-fail/liveness-use-in-index-lvalue.rs) | 4 | ||||
| -rw-r--r-- | src/test/compile-fail/borrowck-while-break.rs (renamed from src/test/compile-fail/liveness-while-break.rs) | 0 | ||||
| -rw-r--r-- | src/test/compile-fail/borrowck-while-cond.rs (renamed from src/test/compile-fail/liveness-while-cond.rs) | 0 | ||||
| -rw-r--r-- | src/test/compile-fail/borrowck-while.rs (renamed from src/test/compile-fail/liveness-while.rs) | 0 | ||||
| -rw-r--r-- | src/test/compile-fail/liveness-unused.rs | 5 |
22 files changed, 56 insertions, 3 deletions
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/liveness-and-init.rs b/src/test/compile-fail/borrowck-and-init.rs index 134390d0b59..134390d0b59 100644 --- a/src/test/compile-fail/liveness-and-init.rs +++ b/src/test/compile-fail/borrowck-and-init.rs diff --git a/src/test/compile-fail/liveness-block-unint.rs b/src/test/compile-fail/borrowck-block-unint.rs index c46b9013a06..fc865e271e3 100644 --- a/src/test/compile-fail/liveness-block-unint.rs +++ b/src/test/compile-fail/borrowck-block-unint.rs @@ -11,7 +11,7 @@ fn force(f: ||) { f(); } fn main() { let x: int; - force(|| { - info!("{}", x); //~ ERROR capture of possibly uninitialized variable: `x` + force(|| { //~ ERROR capture of possibly uninitialized variable: `x` + info!("{}", x); }); } diff --git a/src/test/compile-fail/liveness-break-uninit-2.rs b/src/test/compile-fail/borrowck-break-uninit-2.rs index accb9076974..accb9076974 100644 --- a/src/test/compile-fail/liveness-break-uninit-2.rs +++ b/src/test/compile-fail/borrowck-break-uninit-2.rs diff --git a/src/test/compile-fail/liveness-break-uninit.rs b/src/test/compile-fail/borrowck-break-uninit.rs index d49e79d2c64..d49e79d2c64 100644 --- a/src/test/compile-fail/liveness-break-uninit.rs +++ b/src/test/compile-fail/borrowck-break-uninit.rs diff --git a/src/test/compile-fail/liveness-if-no-else.rs b/src/test/compile-fail/borrowck-if-no-else.rs index 8dc590b47f0..8dc590b47f0 100644 --- a/src/test/compile-fail/liveness-if-no-else.rs +++ b/src/test/compile-fail/borrowck-if-no-else.rs diff --git a/src/test/compile-fail/liveness-if-with-else.rs b/src/test/compile-fail/borrowck-if-with-else.rs index 55fb8222634..55fb8222634 100644 --- a/src/test/compile-fail/liveness-if-with-else.rs +++ b/src/test/compile-fail/borrowck-if-with-else.rs diff --git a/src/test/compile-fail/liveness-init-in-called-fn-expr.rs b/src/test/compile-fail/borrowck-init-in-called-fn-expr.rs index d759a5738bd..d759a5738bd 100644 --- a/src/test/compile-fail/liveness-init-in-called-fn-expr.rs +++ b/src/test/compile-fail/borrowck-init-in-called-fn-expr.rs diff --git a/src/test/compile-fail/liveness-init-in-fn-expr.rs b/src/test/compile-fail/borrowck-init-in-fn-expr.rs index f6bb2f54283..f6bb2f54283 100644 --- a/src/test/compile-fail/liveness-init-in-fn-expr.rs +++ b/src/test/compile-fail/borrowck-init-in-fn-expr.rs diff --git a/src/test/compile-fail/liveness-init-in-fru.rs b/src/test/compile-fail/borrowck-init-in-fru.rs index 97fc2b4d44c..97fc2b4d44c 100644 --- a/src/test/compile-fail/liveness-init-in-fru.rs +++ b/src/test/compile-fail/borrowck-init-in-fru.rs diff --git a/src/test/compile-fail/liveness-init-op-equal.rs b/src/test/compile-fail/borrowck-init-op-equal.rs index cbe805551c2..cbe805551c2 100644 --- a/src/test/compile-fail/liveness-init-op-equal.rs +++ b/src/test/compile-fail/borrowck-init-op-equal.rs diff --git a/src/test/compile-fail/liveness-init-plus-equal.rs b/src/test/compile-fail/borrowck-init-plus-equal.rs index 6e813809f03..6e813809f03 100644 --- a/src/test/compile-fail/liveness-init-plus-equal.rs +++ b/src/test/compile-fail/borrowck-init-plus-equal.rs diff --git a/src/test/compile-fail/liveness-or-init.rs b/src/test/compile-fail/borrowck-or-init.rs index f878afce969..f878afce969 100644 --- a/src/test/compile-fail/liveness-or-init.rs +++ b/src/test/compile-fail/borrowck-or-init.rs diff --git a/src/test/compile-fail/liveness-return.rs b/src/test/compile-fail/borrowck-return.rs index 6558bc57968..6558bc57968 100644 --- a/src/test/compile-fail/liveness-return.rs +++ b/src/test/compile-fail/borrowck-return.rs diff --git a/src/test/compile-fail/liveness-uninit-after-item.rs b/src/test/compile-fail/borrowck-uninit-after-item.rs index a828b1d6b9f..a828b1d6b9f 100644 --- a/src/test/compile-fail/liveness-uninit-after-item.rs +++ b/src/test/compile-fail/borrowck-uninit-after-item.rs 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 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, 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/liveness-uninit.rs b/src/test/compile-fail/borrowck-uninit.rs index a6ce736c89b..a6ce736c89b 100644 --- a/src/test/compile-fail/liveness-uninit.rs +++ b/src/test/compile-fail/borrowck-uninit.rs diff --git a/src/test/compile-fail/liveness-use-in-index-lvalue.rs b/src/test/compile-fail/borrowck-use-in-index-lvalue.rs index 7ec0607fc97..3ced9859240 100644 --- a/src/test/compile-fail/liveness-use-in-index-lvalue.rs +++ b/src/test/compile-fail/borrowck-use-in-index-lvalue.rs @@ -11,6 +11,10 @@ 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/liveness-while-break.rs b/src/test/compile-fail/borrowck-while-break.rs index e5d4b6ef48c..e5d4b6ef48c 100644 --- a/src/test/compile-fail/liveness-while-break.rs +++ b/src/test/compile-fail/borrowck-while-break.rs diff --git a/src/test/compile-fail/liveness-while-cond.rs b/src/test/compile-fail/borrowck-while-cond.rs index 27d42d666ea..27d42d666ea 100644 --- a/src/test/compile-fail/liveness-while-cond.rs +++ b/src/test/compile-fail/borrowck-while-cond.rs diff --git a/src/test/compile-fail/liveness-while.rs b/src/test/compile-fail/borrowck-while.rs index b904fd53d72..b904fd53d72 100644 --- a/src/test/compile-fail/liveness-while.rs +++ b/src/test/compile-fail/borrowck-while.rs 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` |
