auto merge of #17199 : jakub-/rust/issues-that-need-tests, r=alexcrichton
Closes #7813. Closes #10902. Closes #11374. Closes #11714. Closes #12920. Closes #13202. Closes #13624. Closes #14039. Closes #15730. Closes #15783.
This commit is contained in:
commit
382fc45759
37
src/test/compile-fail/issue-11374.rs
Normal file
37
src/test/compile-fail/issue-11374.rs
Normal file
@ -0,0 +1,37 @@
|
||||
// Copyright 2014 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;
|
||||
use std::vec;
|
||||
|
||||
pub struct Container<'a> {
|
||||
reader: &'a mut Reader //~ ERROR explicit lifetime bound required
|
||||
}
|
||||
|
||||
impl<'a> Container<'a> {
|
||||
pub fn wrap<'s>(reader: &'s mut Reader) -> Container<'s> {
|
||||
Container { reader: reader }
|
||||
}
|
||||
|
||||
pub fn read_to(&mut self, vec: &mut [u8]) {
|
||||
self.reader.read(vec);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn for_stdin<'a>() -> Container<'a> {
|
||||
let mut r = io::stdin();
|
||||
Container::wrap(&mut r as &mut Reader)
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let mut c = for_stdin();
|
||||
let mut v = vec::Vec::from_elem(10, 0u8);
|
||||
c.read_to(v.as_mut_slice());
|
||||
}
|
17
src/test/compile-fail/issue-11714.rs
Normal file
17
src/test/compile-fail/issue-11714.rs
Normal file
@ -0,0 +1,17 @@
|
||||
// Copyright 2014 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.
|
||||
|
||||
fn blah() -> int { //~ ERROR not all control paths return a value
|
||||
1i
|
||||
|
||||
; //~ NOTE consider removing this semicolon:
|
||||
}
|
||||
|
||||
fn main() { }
|
39
src/test/compile-fail/issue-13624.rs
Normal file
39
src/test/compile-fail/issue-13624.rs
Normal file
@ -0,0 +1,39 @@
|
||||
// Copyright 2014 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.
|
||||
|
||||
#![feature(struct_variant)]
|
||||
|
||||
mod a {
|
||||
pub enum Enum {
|
||||
EnumStructVariant { x: u8, y: u8, z: u8 }
|
||||
}
|
||||
|
||||
pub fn get_enum_struct_variant() -> () {
|
||||
EnumStructVariant { x: 1, y: 2, z: 3 }
|
||||
//~^ ERROR mismatched types: expected `()`, found `a::Enum` (expected (), found enum a::Enum)
|
||||
}
|
||||
}
|
||||
|
||||
mod b {
|
||||
mod test {
|
||||
use a;
|
||||
|
||||
fn test_enum_struct_variant() {
|
||||
let enum_struct_variant = ::a::get_enum_struct_variant();
|
||||
match enum_struct_variant {
|
||||
a::EnumStructVariant { x, y, z } => {
|
||||
//~^ ERROR error: mismatched types: expected `()`, found a structure pattern
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {}
|
15
src/test/compile-fail/issue-15730.rs
Normal file
15
src/test/compile-fail/issue-15730.rs
Normal file
@ -0,0 +1,15 @@
|
||||
// Copyright 2014 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.
|
||||
|
||||
fn main() {
|
||||
let mut array = [1, 2, 3];
|
||||
//~^ ERROR cannot determine a type for this local variable: cannot determine the type of this integ
|
||||
let pie_slice = array.slice(1, 2);
|
||||
}
|
20
src/test/compile-fail/issue-15783.rs
Normal file
20
src/test/compile-fail/issue-15783.rs
Normal file
@ -0,0 +1,20 @@
|
||||
// Copyright 2014 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.
|
||||
|
||||
pub fn foo(params: Option<&[&str]>) -> uint {
|
||||
params.unwrap().head().unwrap().len()
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let name = "Foo";
|
||||
let msg = foo(Some(&[name.as_slice()]));
|
||||
//~^ ERROR mismatched types: expected `core::option::Option<&[&str]>`
|
||||
assert_eq!(msg, 3);
|
||||
}
|
14
src/test/compile-fail/issue-7813.rs
Normal file
14
src/test/compile-fail/issue-7813.rs
Normal file
@ -0,0 +1,14 @@
|
||||
// Copyright 2014 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.
|
||||
|
||||
fn main() {
|
||||
let v = &[]; //~ ERROR cannot determine a type for this local variable: unconstrained type
|
||||
let it = v.iter();
|
||||
}
|
15
src/test/run-fail/issue-12920.rs
Normal file
15
src/test/run-fail/issue-12920.rs
Normal file
@ -0,0 +1,15 @@
|
||||
// Copyright 2014 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.
|
||||
|
||||
// error-pattern:explicit failure
|
||||
|
||||
pub fn main() {
|
||||
fail!(); println!("{}", 1i);
|
||||
}
|
15
src/test/run-fail/issue-13202.rs
Normal file
15
src/test/run-fail/issue-13202.rs
Normal file
@ -0,0 +1,15 @@
|
||||
// Copyright 2014 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.
|
||||
|
||||
// error-pattern:bad input
|
||||
|
||||
fn main() {
|
||||
Some("foo").unwrap_or(fail!("bad input")).to_string();
|
||||
}
|
27
src/test/run-pass/issue-10902.rs
Normal file
27
src/test/run-pass/issue-10902.rs
Normal file
@ -0,0 +1,27 @@
|
||||
// Copyright 2014 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.
|
||||
|
||||
pub mod two_tuple {
|
||||
trait T {}
|
||||
struct P<'a>(&'a T + 'a, &'a T + 'a);
|
||||
pub fn f<'a>(car: &'a T, cdr: &'a T) -> P<'a> {
|
||||
P(car, cdr)
|
||||
}
|
||||
}
|
||||
|
||||
pub mod two_fields {
|
||||
trait T {}
|
||||
struct P<'a> { car: &'a T + 'a, cdr: &'a T + 'a }
|
||||
pub fn f<'a>(car: &'a T, cdr: &'a T) -> P<'a> {
|
||||
P{ car: car, cdr: cdr }
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {}
|
17
src/test/run-pass/issue-14039.rs
Normal file
17
src/test/run-pass/issue-14039.rs
Normal file
@ -0,0 +1,17 @@
|
||||
// Copyright 2014 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.
|
||||
|
||||
fn main() {
|
||||
if true {
|
||||
proc(_) {}
|
||||
} else {
|
||||
proc(_: &mut ()) {}
|
||||
};
|
||||
}
|
Loading…
Reference in New Issue
Block a user