]> git.lizzy.rs Git - rust.git/commitdiff
testsuite: Two tests for fixed bugs
authorTim Chevalier <chevalier@alum.wellesley.edu>
Sun, 29 Sep 2013 21:46:23 +0000 (14:46 -0700)
committerTim Chevalier <chevalier@alum.wellesley.edu>
Sun, 6 Oct 2013 00:36:14 +0000 (20:36 -0400)
Closes #7246
Closes #7573

src/librustc/middle/typeck/check/mod.rs
src/test/compile-fail/issue-2149.rs
src/test/compile-fail/issue-7246.rs [new file with mode: 0644]
src/test/compile-fail/issue-7573.rs [new file with mode: 0644]

index 54de7fc1bab9996628bfa7743aab94bf9d80026c..1fc04c7a0f67ad844ed203e2883f3a4a98d2a72d 100644 (file)
@@ -3054,7 +3054,8 @@ pub fn check_block_with_expected(fcx: @mut FnCtxt,
             },
           Some(e) => {
             if any_bot && !warned {
-                fcx.ccx.tcx.sess.span_warn(e.span, "unreachable expression");
+                fcx.ccx.tcx.sess.add_lint(unreachable_code, e.id, e.span,
+                                          ~"unreachable expression");
             }
             check_expr_with_opt_hint(fcx, e, expected);
               let ety = fcx.expr_ty(e);
index 3f393621fd9088f300971c66d9023f6978e64540..1e427ceb4b73dc857c04dda73826450325f716c6 100644 (file)
@@ -16,8 +16,7 @@ impl<A> vec_monad<A> for ~[A] {
     fn bind<B>(&self, f: &fn(A) -> ~[B]) {
         let mut r = fail2!();
         for elt in self.iter() { r = r + f(*elt); }
-        //~^ WARNING unreachable expression
-        //~^^ ERROR the type of this value must be known
+        //~^ ERROR the type of this value must be known
    }
 }
 fn main() {
diff --git a/src/test/compile-fail/issue-7246.rs b/src/test/compile-fail/issue-7246.rs
new file mode 100644 (file)
index 0000000..dacc31a
--- /dev/null
@@ -0,0 +1,18 @@
+// Copyright 2013 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.
+
+#[deny(unreachable_code)];
+use std::ptr;
+pub unsafe fn g() {
+    return; 
+    if *ptr::null() {}; //~ ERROR unreachable
+}
+
+pub fn main() {}
diff --git a/src/test/compile-fail/issue-7573.rs b/src/test/compile-fail/issue-7573.rs
new file mode 100644 (file)
index 0000000..2be763e
--- /dev/null
@@ -0,0 +1,50 @@
+// Copyright 2013 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.
+
+use std::io;
+
+pub struct PkgId {
+    local_path: ~str,
+    junk: ~str
+}
+
+impl PkgId {
+    fn new(s: &str) -> PkgId {
+        PkgId {
+            local_path: s.to_owned(),
+            junk: ~"wutevs"
+        }
+    }
+}
+
+pub fn remove_package_from_database() {
+    let mut lines_to_use: ~[&PkgId] = ~[]; //~ ERROR cannot infer an appropriate lifetime
+    let push_id = |installed_id: &PkgId| {
+        lines_to_use.push(installed_id);
+    };
+    list_database(push_id);
+
+    for l in lines_to_use.iter() {
+        io::stdout().write_line(l.local_path);
+    }
+
+}
+
+pub fn list_database(f: &fn(&PkgId)) {
+    let stuff = ["foo", "bar"];
+
+    for l in stuff.iter() {
+        f(&PkgId::new(*l));
+    }
+}
+
+pub fn main() {
+    remove_package_from_database();
+}