Skip to content

Commit 0e95b08

Browse files
committed
auto merge of #12738 : alexcrichton/rust/needstest, r=brson,just
Closes #6738 Closes #7061 Closes #7899 Closes #9719 Closes #10028 Closes #10228 Closes #10401 Closes #11192 Closes #11508 Closes #11529 Closes #11873 Closes #11925
2 parents bd47f67 + 13e10f5 commit 0e95b08

16 files changed

+340
-0
lines changed

src/test/auxiliary/issue-10028.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+
#[unsafe_no_drop_flag]
12+
pub struct ZeroLengthThingWithDestructor;
13+
impl Drop for ZeroLengthThingWithDestructor {
14+
fn drop(&mut self) {}
15+
}
16+
impl ZeroLengthThingWithDestructor {
17+
pub fn new() -> ZeroLengthThingWithDestructor {
18+
ZeroLengthThingWithDestructor
19+
}
20+
}

src/test/auxiliary/issue-11508.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 struct Closed01<F>(F);
12+
13+
pub trait Bar { fn new() -> Self; }
14+
15+
impl<T: Bar> Bar for Closed01<T> {
16+
fn new() -> Closed01<T> { Closed01(Bar::new()) }
17+
}
18+
impl Bar for f32 { fn new() -> f32 { 1.0 } }
19+
20+
pub fn random<T: Bar>() -> T { Bar::new() }

src/test/auxiliary/issue-11529.rs

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
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 struct A<'a>(&'a int);

src/test/auxiliary/issue-7899.rs

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
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 struct V2<T>(T, T);

src/test/compile-fail/issue-10401.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 a = "a";
13+
a += { "b" };
14+
//~^ ERROR: binary assignment operation `+=` cannot be applied
15+
}

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

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
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+
struct Foo {
12+
x: int
13+
}
14+
15+
impl Drop for Foo {
16+
fn drop(&mut self) {
17+
println!("drop {}", self.x);
18+
}
19+
}
20+
21+
fn main() {
22+
let mut ptr = ~Foo { x: 0 };
23+
let test = |foo: &Foo| {
24+
println!("access {}", foo.x);
25+
ptr = ~Foo { x: ptr.x + 1 };
26+
println!("access {}", foo.x);
27+
};
28+
test(ptr);
29+
//~^ ERROR: cannot borrow `*ptr` as immutable
30+
}
31+

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

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// Copyright 2012-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::vec_ng::Vec;
12+
13+
fn main() {
14+
let mut v = vec!(1);
15+
let f = || v.push(2);
16+
let _w = v; //~ ERROR: cannot move out of `v`
17+
18+
f();
19+
}

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

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
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 r = {
13+
let x = ~42;
14+
let f = proc() &x; //~ ERROR: borrowed value does not live long enough
15+
f()
16+
};
17+
18+
drop(r);
19+
}

src/test/compile-fail/issue-6738.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+
struct Foo<T> {
12+
x: T,
13+
}
14+
impl<T> Foo<T> {
15+
fn add(&mut self, v: Foo<T>){
16+
self.x += v.x;
17+
//~^ ERROR: binary assignment operation `+=` cannot be applied
18+
}
19+
}
20+
fn main() {}

src/test/compile-fail/issue-7061.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+
#[feature(managed_boxes)];
12+
13+
struct BarStruct;
14+
15+
impl<'a> BarStruct {
16+
fn foo(&'a mut self) -> @BarStruct { self }
17+
//~^ ERROR: error: mismatched types: expected `@BarStruct` but found `&'a mut BarStruct
18+
}
19+
20+
fn main() {}

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

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
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+
// aux-build:issue-10028.rs
12+
// ignore-fast
13+
14+
extern crate issue10028 = "issue-10028";
15+
16+
use issue10028::ZeroLengthThingWithDestructor;
17+
18+
struct Foo {
19+
zero_length_thing: ZeroLengthThingWithDestructor
20+
}
21+
22+
fn make_foo() -> Foo {
23+
Foo { zero_length_thing: ZeroLengthThingWithDestructor::new() }
24+
}
25+
26+
fn main() {
27+
let _f:Foo = make_foo();
28+
}

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

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
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+
enum StdioContainer {
12+
CreatePipe(bool)
13+
}
14+
15+
struct Test<'a> {
16+
args: &'a [~str],
17+
io: &'a [StdioContainer]
18+
}
19+
20+
pub fn main() {
21+
let test = Test {
22+
args: &[],
23+
io: &[CreatePipe(true)]
24+
};
25+
}

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

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
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+
// aux-build:issue-11508.rs
12+
// ignore-fast
13+
14+
extern crate rand = "issue-11508";
15+
16+
use rand::{Closed01, random};
17+
18+
fn main() {
19+
let Closed01(val) = random::<Closed01<f32>>();
20+
println!("{}", val);
21+
}

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

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
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+
// aux-build:issue-11529.rs
12+
// ignore-fast
13+
14+
extern crate a = "issue-11529";
15+
16+
fn main() {
17+
let one = 1;
18+
let _a = a::A(&one);
19+
}

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

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
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+
// ignore-fast
12+
// aux-build:issue-7899.rs
13+
14+
extern crate testcrate = "issue-7899";
15+
16+
fn main() {
17+
let f = testcrate::V2(1.0f32, 2.0f32);
18+
}

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

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
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+
mod a {
12+
pub enum Enum<T> {
13+
A(T),
14+
}
15+
16+
pub trait X {}
17+
impl X for int {}
18+
19+
pub struct Z<'a>(Enum<&'a X>);
20+
fn foo() { let x = 42; let z = Z(A(&x as &X)); let _ = z; }
21+
}
22+
23+
mod b {
24+
trait X {}
25+
impl X for int {}
26+
struct Y<'a>{
27+
x:Option<&'a X>,
28+
}
29+
30+
fn bar() {
31+
let x = 42;
32+
let _y = Y { x: Some(&x as &X) };
33+
}
34+
}
35+
36+
mod c {
37+
pub trait X { fn f(&self); }
38+
impl X for int { fn f(&self) {} }
39+
pub struct Z<'a>(Option<&'a X>);
40+
fn main() { let x = 42; let z = Z(Some(&x as &X)); let _ = z; }
41+
}
42+
43+
pub fn main() {}

0 commit comments

Comments
 (0)