parent
bf416e7daf
commit
310c0e3d4b
src
@ -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);
|
||||
|
@ -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() {
|
||||
|
18
src/test/compile-fail/issue-7246.rs
Normal file
18
src/test/compile-fail/issue-7246.rs
Normal file
@ -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() {}
|
50
src/test/compile-fail/issue-7573.rs
Normal file
50
src/test/compile-fail/issue-7573.rs
Normal file
@ -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();
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user