diff --git a/src/test/compile-fail/issue-11374.rs b/src/test/compile-fail/issue-11374.rs new file mode 100644 index 00000000000..9705994550b --- /dev/null +++ b/src/test/compile-fail/issue-11374.rs @@ -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 or the MIT license +// , 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()); +} diff --git a/src/test/compile-fail/issue-11714.rs b/src/test/compile-fail/issue-11714.rs new file mode 100644 index 00000000000..d57182e275b --- /dev/null +++ b/src/test/compile-fail/issue-11714.rs @@ -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 or the MIT license +// , 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() { } diff --git a/src/test/compile-fail/issue-13624.rs b/src/test/compile-fail/issue-13624.rs new file mode 100644 index 00000000000..0593b498192 --- /dev/null +++ b/src/test/compile-fail/issue-13624.rs @@ -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 or the MIT license +// , 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() {} diff --git a/src/test/compile-fail/issue-15730.rs b/src/test/compile-fail/issue-15730.rs new file mode 100644 index 00000000000..6cddd8ee939 --- /dev/null +++ b/src/test/compile-fail/issue-15730.rs @@ -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 or the MIT license +// , 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); +} diff --git a/src/test/compile-fail/issue-15783.rs b/src/test/compile-fail/issue-15783.rs new file mode 100644 index 00000000000..32a920baa31 --- /dev/null +++ b/src/test/compile-fail/issue-15783.rs @@ -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 or the MIT license +// , 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); +} diff --git a/src/test/compile-fail/issue-7813.rs b/src/test/compile-fail/issue-7813.rs new file mode 100644 index 00000000000..be8b6715bc0 --- /dev/null +++ b/src/test/compile-fail/issue-7813.rs @@ -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 or the MIT license +// , 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(); +} diff --git a/src/test/run-fail/issue-12920.rs b/src/test/run-fail/issue-12920.rs new file mode 100644 index 00000000000..b5b8d4855ab --- /dev/null +++ b/src/test/run-fail/issue-12920.rs @@ -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 or the MIT license +// , 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); +} diff --git a/src/test/run-fail/issue-13202.rs b/src/test/run-fail/issue-13202.rs new file mode 100644 index 00000000000..80006936f22 --- /dev/null +++ b/src/test/run-fail/issue-13202.rs @@ -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 or the MIT license +// , 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(); +} diff --git a/src/test/run-pass/issue-10902.rs b/src/test/run-pass/issue-10902.rs new file mode 100644 index 00000000000..f8fd96166ea --- /dev/null +++ b/src/test/run-pass/issue-10902.rs @@ -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 or the MIT license +// , 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() {} diff --git a/src/test/run-pass/issue-14039.rs b/src/test/run-pass/issue-14039.rs new file mode 100644 index 00000000000..c017a9dad64 --- /dev/null +++ b/src/test/run-pass/issue-14039.rs @@ -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 or the MIT license +// , 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 ()) {} + }; +}