Skip to content

Commit 8a4ef62

Browse files
author
Jakub Wieczorek
committed
Add tests for a few A-needstest issues
Closes #7813. Closes #10902. Closes #11374. Closes #11714. Closes #12920. Closes #13202. Closes #13624. Closes #14039. Closes #15730. Closes #15783.
1 parent e73156f commit 8a4ef62

File tree

10 files changed

+216
-0
lines changed

10 files changed

+216
-0
lines changed

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

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
// Copyright 2014 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+
use std::vec;
13+
14+
pub struct Container<'a> {
15+
reader: &'a mut Reader //~ ERROR explicit lifetime bound required
16+
}
17+
18+
impl<'a> Container<'a> {
19+
pub fn wrap<'s>(reader: &'s mut Reader) -> Container<'s> {
20+
Container { reader: reader }
21+
}
22+
23+
pub fn read_to(&mut self, vec: &mut [u8]) {
24+
self.reader.read(vec);
25+
}
26+
}
27+
28+
pub fn for_stdin<'a>() -> Container<'a> {
29+
let mut r = io::stdin();
30+
Container::wrap(&mut r as &mut Reader)
31+
}
32+
33+
fn main() {
34+
let mut c = for_stdin();
35+
let mut v = vec::Vec::from_elem(10, 0u8);
36+
c.read_to(v.as_mut_slice());
37+
}

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

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// Copyright 2014 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+
fn blah() -> int { //~ ERROR not all control paths return a value
12+
1i
13+
14+
; //~ NOTE consider removing this semicolon:
15+
}
16+
17+
fn main() { }

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

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
// Copyright 2014 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+
#![feature(struct_variant)]
12+
13+
mod a {
14+
pub enum Enum {
15+
EnumStructVariant { x: u8, y: u8, z: u8 }
16+
}
17+
18+
pub fn get_enum_struct_variant() -> () {
19+
EnumStructVariant { x: 1, y: 2, z: 3 }
20+
//~^ ERROR mismatched types: expected `()`, found `a::Enum` (expected (), found enum a::Enum)
21+
}
22+
}
23+
24+
mod b {
25+
mod test {
26+
use a;
27+
28+
fn test_enum_struct_variant() {
29+
let enum_struct_variant = ::a::get_enum_struct_variant();
30+
match enum_struct_variant {
31+
a::EnumStructVariant { x, y, z } => {
32+
//~^ ERROR error: mismatched types: expected `()`, found a structure pattern
33+
}
34+
}
35+
}
36+
}
37+
}
38+
39+
fn main() {}

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

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// Copyright 2014 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+
fn main() {
12+
let mut array = [1, 2, 3];
13+
//~^ ERROR cannot determine a type for this local variable: cannot determine the type of this integ
14+
let pie_slice = array.slice(1, 2);
15+
}

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

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// Copyright 2014 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+
pub fn foo(params: Option<&[&str]>) -> uint {
12+
params.unwrap().head().unwrap().len()
13+
}
14+
15+
fn main() {
16+
let name = "Foo";
17+
let msg = foo(Some(&[name.as_slice()]));
18+
//~^ ERROR mismatched types: expected `core::option::Option<&[&str]>`
19+
assert_eq!(msg, 3);
20+
}

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

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// Copyright 2014 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+
fn main() {
12+
let v = &[]; //~ ERROR cannot determine a type for this local variable: unconstrained type
13+
let it = v.iter();
14+
}

src/test/run-fail/issue-12920.rs

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// Copyright 2014 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+
// error-pattern:explicit failure
12+
13+
pub fn main() {
14+
fail!(); println!("{}", 1i);
15+
}

src/test/run-fail/issue-13202.rs

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// Copyright 2014 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+
// error-pattern:bad input
12+
13+
fn main() {
14+
Some("foo").unwrap_or(fail!("bad input")).to_string();
15+
}

src/test/run-pass/issue-10902.rs

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// Copyright 2014 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+
pub mod two_tuple {
12+
trait T {}
13+
struct P<'a>(&'a T + 'a, &'a T + 'a);
14+
pub fn f<'a>(car: &'a T, cdr: &'a T) -> P<'a> {
15+
P(car, cdr)
16+
}
17+
}
18+
19+
pub mod two_fields {
20+
trait T {}
21+
struct P<'a> { car: &'a T + 'a, cdr: &'a T + 'a }
22+
pub fn f<'a>(car: &'a T, cdr: &'a T) -> P<'a> {
23+
P{ car: car, cdr: cdr }
24+
}
25+
}
26+
27+
fn main() {}

src/test/run-pass/issue-14039.rs

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// Copyright 2014 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+
fn main() {
12+
if true {
13+
proc(_) {}
14+
} else {
15+
proc(_: &mut ()) {}
16+
};
17+
}

0 commit comments

Comments
 (0)