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 vec_monad for ~[A] { fn bind(&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 or the MIT license +// , 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 or the MIT license +// , 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(); +}