Skip to content

Commit 310c0e3

Browse files
committed
testsuite: Two tests for fixed bugs
Closes #7246 Closes #7573
1 parent bf416e7 commit 310c0e3

File tree

4 files changed

+71
-3
lines changed

4 files changed

+71
-3
lines changed

src/librustc/middle/typeck/check/mod.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -3054,7 +3054,8 @@ pub fn check_block_with_expected(fcx: @mut FnCtxt,
30543054
},
30553055
Some(e) => {
30563056
if any_bot && !warned {
3057-
fcx.ccx.tcx.sess.span_warn(e.span, "unreachable expression");
3057+
fcx.ccx.tcx.sess.add_lint(unreachable_code, e.id, e.span,
3058+
~"unreachable expression");
30583059
}
30593060
check_expr_with_opt_hint(fcx, e, expected);
30603061
let ety = fcx.expr_ty(e);

src/test/compile-fail/issue-2149.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,7 @@ impl<A> vec_monad<A> for ~[A] {
1616
fn bind<B>(&self, f: &fn(A) -> ~[B]) {
1717
let mut r = fail2!();
1818
for elt in self.iter() { r = r + f(*elt); }
19-
//~^ WARNING unreachable expression
20-
//~^^ ERROR the type of this value must be known
19+
//~^ ERROR the type of this value must be known
2120
}
2221
}
2322
fn main() {

src/test/compile-fail/issue-7246.rs

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
#[deny(unreachable_code)];
12+
use std::ptr;
13+
pub unsafe fn g() {
14+
return;
15+
if *ptr::null() {}; //~ ERROR unreachable
16+
}
17+
18+
pub fn main() {}

src/test/compile-fail/issue-7573.rs

+50
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
use std::io;
12+
13+
pub struct PkgId {
14+
local_path: ~str,
15+
junk: ~str
16+
}
17+
18+
impl PkgId {
19+
fn new(s: &str) -> PkgId {
20+
PkgId {
21+
local_path: s.to_owned(),
22+
junk: ~"wutevs"
23+
}
24+
}
25+
}
26+
27+
pub fn remove_package_from_database() {
28+
let mut lines_to_use: ~[&PkgId] = ~[]; //~ ERROR cannot infer an appropriate lifetime
29+
let push_id = |installed_id: &PkgId| {
30+
lines_to_use.push(installed_id);
31+
};
32+
list_database(push_id);
33+
34+
for l in lines_to_use.iter() {
35+
io::stdout().write_line(l.local_path);
36+
}
37+
38+
}
39+
40+
pub fn list_database(f: &fn(&PkgId)) {
41+
let stuff = ["foo", "bar"];
42+
43+
for l in stuff.iter() {
44+
f(&PkgId::new(*l));
45+
}
46+
}
47+
48+
pub fn main() {
49+
remove_package_from_database();
50+
}

0 commit comments

Comments
 (0)