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

test: Add some tests for closed issues #12738

Merged
merged 1 commit into from
Mar 7, 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
20 changes: 20 additions & 0 deletions src/test/auxiliary/issue-10028.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.

#[unsafe_no_drop_flag]
pub struct ZeroLengthThingWithDestructor;
impl Drop for ZeroLengthThingWithDestructor {
fn drop(&mut self) {}
}
impl ZeroLengthThingWithDestructor {
pub fn new() -> ZeroLengthThingWithDestructor {
ZeroLengthThingWithDestructor
}
}
20 changes: 20 additions & 0 deletions src/test/auxiliary/issue-11508.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 struct Closed01<F>(F);

pub trait Bar { fn new() -> Self; }

impl<T: Bar> Bar for Closed01<T> {
fn new() -> Closed01<T> { Closed01(Bar::new()) }
}
impl Bar for f32 { fn new() -> f32 { 1.0 } }

pub fn random<T: Bar>() -> T { Bar::new() }
11 changes: 11 additions & 0 deletions src/test/auxiliary/issue-11529.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// 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 struct A<'a>(&'a int);
11 changes: 11 additions & 0 deletions src/test/auxiliary/issue-7899.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// 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 struct V2<T>(T, T);
15 changes: 15 additions & 0 deletions src/test/compile-fail/issue-10401.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 a = "a";
a += { "b" };
//~^ ERROR: binary assignment operation `+=` cannot be applied
}
31 changes: 31 additions & 0 deletions src/test/compile-fail/issue-11192.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// 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.

struct Foo {
x: int
}

impl Drop for Foo {
fn drop(&mut self) {
println!("drop {}", self.x);
}
}

fn main() {
let mut ptr = ~Foo { x: 0 };
let test = |foo: &Foo| {
println!("access {}", foo.x);
ptr = ~Foo { x: ptr.x + 1 };
println!("access {}", foo.x);
};
test(ptr);
//~^ ERROR: cannot borrow `*ptr` as immutable
}

19 changes: 19 additions & 0 deletions src/test/compile-fail/issue-11873.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// Copyright 2012-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::vec_ng::Vec;

fn main() {
let mut v = vec!(1);
let f = || v.push(2);
let _w = v; //~ ERROR: cannot move out of `v`

f();
}
19 changes: 19 additions & 0 deletions src/test/compile-fail/issue-11925.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// 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 r = {
let x = ~42;
let f = proc() &x; //~ ERROR: borrowed value does not live long enough
f()
};

drop(r);
}
20 changes: 20 additions & 0 deletions src/test/compile-fail/issue-6738.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.

struct Foo<T> {
x: T,
}
impl<T> Foo<T> {
fn add(&mut self, v: Foo<T>){
self.x += v.x;
//~^ ERROR: binary assignment operation `+=` cannot be applied
}
}
fn main() {}
20 changes: 20 additions & 0 deletions src/test/compile-fail/issue-7061.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.

#[feature(managed_boxes)];

struct BarStruct;

impl<'a> BarStruct {
fn foo(&'a mut self) -> @BarStruct { self }
//~^ ERROR: error: mismatched types: expected `@BarStruct` but found `&'a mut BarStruct
}

fn main() {}
28 changes: 28 additions & 0 deletions src/test/run-pass/issue-10028.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// 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.

// aux-build:issue-10028.rs
// ignore-fast

extern crate issue10028 = "issue-10028";

use issue10028::ZeroLengthThingWithDestructor;

struct Foo {
zero_length_thing: ZeroLengthThingWithDestructor
}

fn make_foo() -> Foo {
Foo { zero_length_thing: ZeroLengthThingWithDestructor::new() }
}

fn main() {
let _f:Foo = make_foo();
}
25 changes: 25 additions & 0 deletions src/test/run-pass/issue-10228.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// 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.

enum StdioContainer {
CreatePipe(bool)
}

struct Test<'a> {
args: &'a [~str],
io: &'a [StdioContainer]
}

pub fn main() {
let test = Test {
args: &[],
io: &[CreatePipe(true)]
};
}
21 changes: 21 additions & 0 deletions src/test/run-pass/issue-11508.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// 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.

// aux-build:issue-11508.rs
// ignore-fast

extern crate rand = "issue-11508";

use rand::{Closed01, random};

fn main() {
let Closed01(val) = random::<Closed01<f32>>();
println!("{}", val);
}
19 changes: 19 additions & 0 deletions src/test/run-pass/issue-11529.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// 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.

// aux-build:issue-11529.rs
// ignore-fast

extern crate a = "issue-11529";

fn main() {
let one = 1;
let _a = a::A(&one);
}
18 changes: 18 additions & 0 deletions src/test/run-pass/issue-7899.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// 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.

// ignore-fast
// aux-build:issue-7899.rs

extern crate testcrate = "issue-7899";

fn main() {
let f = testcrate::V2(1.0f32, 2.0f32);
}
43 changes: 43 additions & 0 deletions src/test/run-pass/issue-9719.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
// 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.

mod a {
pub enum Enum<T> {
A(T),
}

pub trait X {}
impl X for int {}

pub struct Z<'a>(Enum<&'a X>);
fn foo() { let x = 42; let z = Z(A(&x as &X)); let _ = z; }
}

mod b {
trait X {}
impl X for int {}
struct Y<'a>{
x:Option<&'a X>,
}

fn bar() {
let x = 42;
let _y = Y { x: Some(&x as &X) };
}
}

mod c {
pub trait X { fn f(&self); }
impl X for int { fn f(&self) {} }
pub struct Z<'a>(Option<&'a X>);
fn main() { let x = 42; let z = Z(Some(&x as &X)); let _ = z; }
}

pub fn main() {}