Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add tests for a few A-needstest issues #17199

Merged
merged 1 commit into from Sep 15, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions src/test/compile-fail/issue-11374.rs
Original file line number Diff line number Diff line change
@@ -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 changes: 17 additions & 0 deletions src/test/compile-fail/issue-11714.rs
Original file line number Diff line number Diff line change
@@ -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 changes: 39 additions & 0 deletions src/test/compile-fail/issue-13624.rs
Original file line number Diff line number Diff line change
@@ -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 changes: 15 additions & 0 deletions src/test/compile-fail/issue-15730.rs
Original file line number Diff line number Diff line change
@@ -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 changes: 20 additions & 0 deletions src/test/compile-fail/issue-15783.rs
Original file line number Diff line number Diff line change
@@ -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 changes: 14 additions & 0 deletions src/test/compile-fail/issue-7813.rs
Original file line number Diff line number Diff line change
@@ -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 changes: 15 additions & 0 deletions src/test/run-fail/issue-12920.rs
Original file line number Diff line number Diff line change
@@ -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 changes: 15 additions & 0 deletions src/test/run-fail/issue-13202.rs
Original file line number Diff line number Diff line change
@@ -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 changes: 27 additions & 0 deletions src/test/run-pass/issue-10902.rs
Original file line number Diff line number Diff line change
@@ -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 changes: 17 additions & 0 deletions src/test/run-pass/issue-14039.rs
Original file line number Diff line number Diff line change
@@ -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 ()) {}
};
}