about summary refs log tree commit diff
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2013-10-05 18:41:34 -0700
committerbors <bors@rust-lang.org>2013-10-05 18:41:34 -0700
commitacf9783879dca0db0721c10ac79c9078f2dec425 (patch)
treea1bcbfb8dbb2fc09c5b97869dff9c5e675571172
parent549f70989e3423642bacc41bb6c58ed81d591c03 (diff)
parent310c0e3d4bdb9e9bf24015ab3a93603f6993c888 (diff)
downloadrust-acf9783879dca0db0721c10ac79c9078f2dec425.tar.gz
rust-acf9783879dca0db0721c10ac79c9078f2dec425.zip
auto merge of #9733 : catamorphism/rust/issues-7246-and-7573, r=alexcrichton
r? anybody Closes #7246
Closes #7573
-rw-r--r--src/librustc/middle/typeck/check/mod.rs3
-rw-r--r--src/test/compile-fail/issue-2149.rs3
-rw-r--r--src/test/compile-fail/issue-7246.rs18
-rw-r--r--src/test/compile-fail/issue-7573.rs50
4 files changed, 71 insertions, 3 deletions
diff --git a/src/librustc/middle/typeck/check/mod.rs b/src/librustc/middle/typeck/check/mod.rs
index 54de7fc1bab..1fc04c7a0f6 100644
--- a/src/librustc/middle/typeck/check/mod.rs
+++ b/src/librustc/middle/typeck/check/mod.rs
@@ -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);
diff --git a/src/test/compile-fail/issue-2149.rs b/src/test/compile-fail/issue-2149.rs
index 3f393621fd9..1e427ceb4b7 100644
--- a/src/test/compile-fail/issue-2149.rs
+++ b/src/test/compile-fail/issue-2149.rs
@@ -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
index 00000000000..dacc31a573a
--- /dev/null
+++ b/src/test/compile-fail/issue-7246.rs
@@ -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
index 00000000000..2be763ee768
--- /dev/null
+++ b/src/test/compile-fail/issue-7573.rs
@@ -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();
+}