]> git.lizzy.rs Git - rust.git/commitdiff
borrowck: classify expressions as assignees, uses or both
authorEdward Wang <edward.yu.wang@gmail.com>
Thu, 6 Mar 2014 14:58:34 +0000 (22:58 +0800)
committerEdward Wang <edward.yu.wang@gmail.com>
Sun, 9 Mar 2014 15:23:28 +0000 (23:23 +0800)
- 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.

46 files changed:
src/librustc/middle/borrowck/gather_loans/gather_moves.rs
src/librustc/middle/borrowck/gather_loans/mod.rs
src/librustc/middle/borrowck/mod.rs
src/librustc/middle/borrowck/move_data.rs
src/librustc/middle/liveness.rs
src/test/compile-fail/asm-out-read-uninit.rs
src/test/compile-fail/borrowck-and-init.rs [new file with mode: 0644]
src/test/compile-fail/borrowck-block-unint.rs [new file with mode: 0644]
src/test/compile-fail/borrowck-break-uninit-2.rs [new file with mode: 0644]
src/test/compile-fail/borrowck-break-uninit.rs [new file with mode: 0644]
src/test/compile-fail/borrowck-if-no-else.rs [new file with mode: 0644]
src/test/compile-fail/borrowck-if-with-else.rs [new file with mode: 0644]
src/test/compile-fail/borrowck-init-in-called-fn-expr.rs [new file with mode: 0644]
src/test/compile-fail/borrowck-init-in-fn-expr.rs [new file with mode: 0644]
src/test/compile-fail/borrowck-init-in-fru.rs [new file with mode: 0644]
src/test/compile-fail/borrowck-init-op-equal.rs [new file with mode: 0644]
src/test/compile-fail/borrowck-init-plus-equal.rs [new file with mode: 0644]
src/test/compile-fail/borrowck-or-init.rs [new file with mode: 0644]
src/test/compile-fail/borrowck-return.rs [new file with mode: 0644]
src/test/compile-fail/borrowck-uninit-after-item.rs [new file with mode: 0644]
src/test/compile-fail/borrowck-uninit-in-assignop.rs [new file with mode: 0644]
src/test/compile-fail/borrowck-uninit.rs [new file with mode: 0644]
src/test/compile-fail/borrowck-use-in-index-lvalue.rs [new file with mode: 0644]
src/test/compile-fail/borrowck-while-break.rs [new file with mode: 0644]
src/test/compile-fail/borrowck-while-cond.rs [new file with mode: 0644]
src/test/compile-fail/borrowck-while.rs [new file with mode: 0644]
src/test/compile-fail/liveness-and-init.rs [deleted file]
src/test/compile-fail/liveness-block-unint.rs [deleted file]
src/test/compile-fail/liveness-break-uninit-2.rs [deleted file]
src/test/compile-fail/liveness-break-uninit.rs [deleted file]
src/test/compile-fail/liveness-if-no-else.rs [deleted file]
src/test/compile-fail/liveness-if-with-else.rs [deleted file]
src/test/compile-fail/liveness-init-in-called-fn-expr.rs [deleted file]
src/test/compile-fail/liveness-init-in-fn-expr.rs [deleted file]
src/test/compile-fail/liveness-init-in-fru.rs [deleted file]
src/test/compile-fail/liveness-init-op-equal.rs [deleted file]
src/test/compile-fail/liveness-init-plus-equal.rs [deleted file]
src/test/compile-fail/liveness-or-init.rs [deleted file]
src/test/compile-fail/liveness-return.rs [deleted file]
src/test/compile-fail/liveness-uninit-after-item.rs [deleted file]
src/test/compile-fail/liveness-uninit.rs [deleted file]
src/test/compile-fail/liveness-unused.rs
src/test/compile-fail/liveness-use-in-index-lvalue.rs [deleted file]
src/test/compile-fail/liveness-while-break.rs [deleted file]
src/test/compile-fail/liveness-while-cond.rs [deleted file]
src/test/compile-fail/liveness-while.rs [deleted file]

index 7ec9f1f8f47953f986362921c711cc9177fdb6ac..6dd7ae31c9d386166311de26a7ef625fd406bfde 100644 (file)
@@ -94,7 +94,22 @@ pub fn gather_assignment(bccx: &BorrowckCtxt,
                              assignee_loan_path,
                              assignment_id,
                              assignment_span,
-                             assignee_id);
+                             assignee_id,
+                             false);
+}
+
+pub fn gather_move_and_assignment(bccx: &BorrowckCtxt,
+                                  move_data: &MoveData,
+                                  assignment_id: ast::NodeId,
+                                  assignment_span: Span,
+                                  assignee_loan_path: @LoanPath,
+                                  assignee_id: ast::NodeId) {
+    move_data.add_assignment(bccx.tcx,
+                             assignee_loan_path,
+                             assignment_id,
+                             assignment_span,
+                             assignee_id,
+                             true);
 }
 
 fn check_is_legal_to_move_from(bccx: &BorrowckCtxt,
index d6666eb6293102a3149fa5363d680a40cc32a125..e50d6da378af1e81a738b9146b3e7299fd4fbadc 100644 (file)
@@ -214,20 +214,19 @@ fn gather_loans_in_expr(this: &mut GatherLoanCtxt,
         visit::walk_expr(this, ex, ());
       }
 
-      ast::ExprAssign(l, _) | ast::ExprAssignOp(_, l, _) => {
-          let l_cmt = this.bccx.cat_expr(l);
-          match opt_loan_path(l_cmt) {
-              Some(l_lp) => {
-                  gather_moves::gather_assignment(this.bccx, &this.move_data,
-                                                  ex.id, ex.span,
-                                                  l_lp, l.id);
-              }
-              None => {
-                  // This can occur with e.g. `*foo() = 5`.  In such
-                  // cases, there is no need to check for conflicts
-                  // with moves etc, just ignore.
-              }
-          }
+      ast::ExprAssign(l, _) => {
+          with_assignee_loan_path(
+              this.bccx, l,
+              |lp| gather_moves::gather_assignment(this.bccx, &this.move_data,
+                                                   ex.id, ex.span, lp, l.id));
+          visit::walk_expr(this, ex, ());
+      }
+
+      ast::ExprAssignOp(_, l, _) => {
+          with_assignee_loan_path(
+              this.bccx, l,
+              |lp| gather_moves::gather_move_and_assignment(this.bccx, &this.move_data,
+                                                            ex.id, ex.span, lp, l.id));
           visit::walk_expr(this, ex, ());
       }
 
@@ -288,17 +287,10 @@ fn gather_loans_in_expr(this: &mut GatherLoanCtxt,
 
       ast::ExprInlineAsm(ref ia) => {
           for &(_, out) in ia.outputs.iter() {
-              let out_cmt = this.bccx.cat_expr(out);
-              match opt_loan_path(out_cmt) {
-                  Some(out_lp) => {
-                      gather_moves::gather_assignment(this.bccx, &this.move_data,
-                                                      ex.id, ex.span,
-                                                      out_lp, out.id);
-                  }
-                  None => {
-                      // See the comment for ExprAssign.
-                  }
-              }
+              with_assignee_loan_path(
+                  this.bccx, out,
+                  |lp| gather_moves::gather_assignment(this.bccx, &this.move_data,
+                                                       ex.id, ex.span, lp, out.id));
           }
           visit::walk_expr(this, ex, ());
       }
@@ -309,6 +301,18 @@ fn gather_loans_in_expr(this: &mut GatherLoanCtxt,
     }
 }
 
+fn with_assignee_loan_path(bccx: &BorrowckCtxt, expr: &ast::Expr, op: |@LoanPath|) {
+    let cmt = bccx.cat_expr(expr);
+    match opt_loan_path(cmt) {
+        Some(lp) => op(lp),
+        None => {
+            // This can occur with e.g. `*foo() = 5`.  In such
+            // cases, there is no need to check for conflicts
+            // with moves etc, just ignore.
+        }
+    }
+}
+
 impl<'a> GatherLoanCtxt<'a> {
     pub fn tcx(&self) -> ty::ctxt { self.bccx.tcx }
 
index 9767b50ae96031fb7fbba7164183da504593253e..654203bf0776bf0a3e682d81898d6c377aa9d019 100644 (file)
@@ -535,7 +535,7 @@ pub fn report_use_of_moved_value(&self,
             move_data::Declared => {
                 self.tcx.sess.span_err(
                     use_span,
-                    format!("{} of possibly uninitialized value: `{}`",
+                    format!("{} of possibly uninitialized variable: `{}`",
                          verb,
                          self.loan_path_to_str(lp)));
             }
index e1434a8ac4e9758a046f7ca1f1336055f37a1dfa..5f4d5b43231c880c00be50390d7216167a5914b5 100644 (file)
 
 pub struct MoveData {
     /// Move paths. See section "Move paths" in `doc.rs`.
-    paths: RefCell<Vec<MovePath> >,
+    paths: RefCell<Vec<MovePath>>,
 
     /// Cache of loan path to move path index, for easy lookup.
     path_map: RefCell<HashMap<@LoanPath, MovePathIndex>>,
 
     /// Each move or uninitialized variable gets an entry here.
-    moves: RefCell<Vec<Move> >,
+    moves: RefCell<Vec<Move>>,
 
     /// Assignments to a variable, like `x = foo`. These are assigned
     /// bits for dataflow, since we must track them to ensure that
     /// immutable variables are assigned at most once along each path.
-    var_assignments: RefCell<Vec<Assignment> >,
+    var_assignments: RefCell<Vec<Assignment>>,
 
     /// Assignments to a path, like `x.f = foo`. These are not
     /// assigned dataflow bits, but we track them because they still
     /// kill move bits.
-    path_assignments: RefCell<Vec<Assignment> >,
+    path_assignments: RefCell<Vec<Assignment>>,
+
+    /// Assignments to a variable or path, like `x = foo`, but not `x += foo`.
     assignee_ids: RefCell<HashSet<ast::NodeId>>,
 }
 
@@ -392,7 +394,8 @@ pub fn add_assignment(&self,
                           lp: @LoanPath,
                           assign_id: ast::NodeId,
                           span: Span,
-                          assignee_id: ast::NodeId) {
+                          assignee_id: ast::NodeId,
+                          is_also_move: bool) {
         /*!
          * Adds a new record for an assignment to `lp` that occurs at
          * location `id` with the given `span`.
@@ -403,7 +406,7 @@ pub fn add_assignment(&self,
 
         let path_index = self.move_path(tcx, lp);
 
-        {
+        if !is_also_move {
             let mut assignee_ids = self.assignee_ids.borrow_mut();
             assignee_ids.get().insert(assignee_id);
         }
index 04f2b2f28231935aaf3a229c0d5503a93c8be6a0..02a947a0ddc7af8aff406af13d47f9e8e05a95a3 100644 (file)
@@ -1468,28 +1468,14 @@ pub fn with_loop_nodes<R>(
 
 fn check_local(this: &mut Liveness, local: &Local) {
     match local.init {
-      Some(_) => {
-        this.warn_about_unused_or_dead_vars_in_pat(local.pat);
-      }
-      None => {
-
-        // No initializer: the variable might be unused; if not, it
-        // should not be live at this point.
-
-        debug!("check_local() with no initializer");
-        this.pat_bindings(local.pat, |ln, var, sp, id| {
-            if !this.warn_about_unused(sp, id, ln, var) {
-                match this.live_on_exit(ln, var) {
-                  None => { /* not live: good */ }
-                  Some(lnk) => {
-                    this.report_illegal_read(
-                        local.span, lnk, var,
-                        PossiblyUninitializedVariable);
-                  }
-                }
-            }
-        })
-      }
+        Some(_) => {
+            this.warn_about_unused_or_dead_vars_in_pat(local.pat);
+        },
+        None => {
+            this.pat_bindings(local.pat, |ln, var, sp, id| {
+                this.warn_about_unused(sp, id, ln, var);
+            })
+        }
     }
 
     visit::walk_local(this, local, ());
@@ -1644,38 +1630,6 @@ pub fn check_lvalue(&mut self, expr: @Expr) {
        }
     }
 
-    pub fn report_illegal_read(&self,
-                               chk_span: Span,
-                               lnk: LiveNodeKind,
-                               var: Variable,
-                               rk: ReadKind) {
-        let msg = match rk {
-            PossiblyUninitializedVariable => "possibly uninitialized \
-                                              variable",
-            PossiblyUninitializedField => "possibly uninitialized field",
-            MovedValue => "moved value",
-            PartiallyMovedValue => "partially moved value"
-        };
-        let name = self.ir.variable_name(var);
-        match lnk {
-          FreeVarNode(span) => {
-            self.tcx.sess.span_err(
-                span,
-                format!("capture of {}: `{}`", msg, name));
-          }
-          ExprNode(span) => {
-            self.tcx.sess.span_err(
-                span,
-                format!("use of {}: `{}`", msg, name));
-          }
-          ExitNode | VarDefNode(_) => {
-            self.tcx.sess.span_bug(
-                chk_span,
-                format!("illegal reader: {:?}", lnk));
-          }
-        }
-    }
-
     pub fn should_warn(&self, var: Variable) -> Option<~str> {
         let name = self.ir.variable_name(var);
         if name.len() == 0 || name[0] == ('_' as u8) { None } else { Some(name) }
index b63865921c653c8deddfe9e26443b58ff584b482..65750eb926b450674d8385c03e785d795e787cd8 100644 (file)
@@ -19,7 +19,7 @@
 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 (file)
index 0000000..134390d
--- /dev/null
@@ -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 <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.
+
+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 (file)
index 0000000..fc865e2
--- /dev/null
@@ -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 <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.
+
+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 (file)
index 0000000..accb907
--- /dev/null
@@ -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 <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.
+
+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 (file)
index 0000000..d49e79d
--- /dev/null
@@ -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 <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.
+
+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 (file)
index 0000000..8dc590b
--- /dev/null
@@ -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 <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.
+
+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 (file)
index 0000000..55fb822
--- /dev/null
@@ -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 <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.
+
+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 (file)
index 0000000..d759a57
--- /dev/null
@@ -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 <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.
+
+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 (file)
index 0000000..f6bb2f5
--- /dev/null
@@ -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 <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.
+
+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 (file)
index 0000000..97fc2b4
--- /dev/null
@@ -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 <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.
+
+#[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 (file)
index 0000000..cbe8055
--- /dev/null
@@ -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 <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.
+
+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 (file)
index 0000000..6e81380
--- /dev/null
@@ -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 <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.
+
+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 (file)
index 0000000..f878afc
--- /dev/null
@@ -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 <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.
+
+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 (file)
index 0000000..6558bc5
--- /dev/null
@@ -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 <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.
+
+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 (file)
index 0000000..a828b1d
--- /dev/null
@@ -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 <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.
+
+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 (file)
index 0000000..b5e462e
--- /dev/null
@@ -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/borrowck-uninit.rs b/src/test/compile-fail/borrowck-uninit.rs
new file mode 100644 (file)
index 0000000..a6ce736
--- /dev/null
@@ -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 <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.
+
+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 (file)
index 0000000..3ced985
--- /dev/null
@@ -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 <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.
+
+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 (file)
index 0000000..e5d4b6e
--- /dev/null
@@ -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 <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.
+
+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 (file)
index 0000000..27d42d6
--- /dev/null
@@ -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 <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.
+
+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 (file)
index 0000000..b904fd5
--- /dev/null
@@ -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 <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.
+
+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 (file)
index 134390d..0000000
+++ /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 <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.
-
-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 (file)
index c46b901..0000000
+++ /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 <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.
-
-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 (file)
index accb907..0000000
+++ /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 <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.
-
-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 (file)
index d49e79d..0000000
+++ /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 <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.
-
-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 (file)
index 8dc590b..0000000
+++ /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 <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.
-
-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 (file)
index 55fb822..0000000
+++ /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 <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.
-
-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 (file)
index d759a57..0000000
+++ /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 <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.
-
-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 (file)
index f6bb2f5..0000000
+++ /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 <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.
-
-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 (file)
index 97fc2b4..0000000
+++ /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 <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.
-
-#[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 (file)
index cbe8055..0000000
+++ /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 <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.
-
-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 (file)
index 6e81380..0000000
+++ /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 <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.
-
-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 (file)
index f878afc..0000000
+++ /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 <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.
-
-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 (file)
index 6558bc5..0000000
+++ /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 <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.
-
-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 (file)
index a828b1d..0000000
+++ /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 <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.
-
-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 (file)
index a6ce736..0000000
+++ /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 <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.
-
-fn foo(x: int) { info!("{}", x); }
-
-fn main() {
-    let x: int;
-    foo(x); //~ ERROR use of possibly uninitialized variable: `x`
-}
index 83c911d916e1e8c348101e061a6dee961db3e86c..33fc094abbe75b5586374bf54a1faa31b62d6266 100644 (file)
@@ -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 (file)
index 7ec0607..0000000
+++ /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 <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.
-
-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 (file)
index e5d4b6e..0000000
+++ /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 <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.
-
-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 (file)
index 27d42d6..0000000
+++ /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 <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.
-
-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 (file)
index b904fd5..0000000
+++ /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 <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.
-
-fn f() -> int {
-    let mut x: int;
-    while 1 == 1 { x = 10; }
-    return x; //~ ERROR use of possibly uninitialized variable: `x`
-}
-
-fn main() { f(); }