Skip to content

Commit

Permalink
testsuite: Two tests for fixed bugs
Browse files Browse the repository at this point in the history
Closes #7246
Closes #7573
  • Loading branch information
catamorphism committed Oct 6, 2013
1 parent bf416e7 commit 310c0e3
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/librustc/middle/typeck/check/mod.rs
Expand Up @@ -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);
Expand Down
3 changes: 1 addition & 2 deletions src/test/compile-fail/issue-2149.rs
Expand Up @@ -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() {
Expand Down
18 changes: 18 additions & 0 deletions 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() {}
50 changes: 50 additions & 0 deletions 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();
}

5 comments on commit 310c0e3

@bors
Copy link
Contributor

@bors bors commented on 310c0e3 Oct 6, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

saw approval from alexcrichton
at catamorphism@310c0e3

@bors
Copy link
Contributor

@bors bors commented on 310c0e3 Oct 6, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

merging catamorphism/rust/issues-7246-and-7573 = 310c0e3 into auto

@bors
Copy link
Contributor

@bors bors commented on 310c0e3 Oct 6, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

catamorphism/rust/issues-7246-and-7573 = 310c0e3 merged ok, testing candidate = acf9783

@bors
Copy link
Contributor

@bors bors commented on 310c0e3 Oct 6, 2013

@bors
Copy link
Contributor

@bors bors commented on 310c0e3 Oct 6, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fast-forwarding master to auto = acf9783

Please sign in to comment.