Skip to content

Commit 05d5fca

Browse files
committedMay 7, 2015
Auto merge of #25161 - jooert:moretests, r=alexcrichton
The last one (at least for the moment 😃). r? @alexcrichton
2 parents acb3aa0 + 1a8ccd7 commit 05d5fca

File tree

8 files changed

+177
-0
lines changed

8 files changed

+177
-0
lines changed
 

‎src/test/compile-fail/issue-21177.rs

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// Copyright 2015 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+
trait Trait {
12+
type A;
13+
type B;
14+
}
15+
16+
fn foo<T: Trait<A = T::B>>() { }
17+
//~^ ERROR: unsupported cyclic reference between types/traits detected
18+
19+
fn main() { }

‎src/test/compile-fail/issue-21701.rs

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// Copyright 2015 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 foo<U>(t: U) {
12+
let y = t();
13+
//~^ ERROR: expected function, found `U`
14+
}
15+
16+
struct Bar;
17+
18+
pub fn some_func() {
19+
let f = Bar();
20+
//~^ ERROR: expected function, found `Bar`
21+
}
22+
23+
fn main() {
24+
foo(|| { 1 });
25+
}

‎src/test/compile-fail/issue-22037.rs

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// Copyright 2015 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+
trait A {
12+
type Output;
13+
fn a(&self) -> <Self as A>::X;
14+
//~^ ERROR: use of undeclared associated type `A::X`
15+
}
16+
17+
impl A for u32 {
18+
type Output = u32;
19+
fn a(&self) -> u32 {
20+
0
21+
}
22+
}
23+
24+
fn main() {
25+
let a: u32 = 0;
26+
let b: u32 = a.a();
27+
}
+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
-include ../tools.mk
2+
3+
# Test output to be four
4+
# The original error only occurred when printing, not when comparing using assert!
5+
6+
all:
7+
$(RUSTC) foo.rs -O
8+
[ `$(call RUN,foo)` = "4" ]

‎src/test/run-make/issue-20626/foo.rs

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// Copyright 2015 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 identity(a: &u32) -> &u32 { a }
12+
13+
fn print_foo(f: &fn(&u32) -> &u32, x: &u32) {
14+
print!("{}", (*f)(x));
15+
}
16+
17+
fn main() {
18+
let x = &4;
19+
let f: fn(&u32) -> &u32 = identity;
20+
21+
// Didn't print 4 on optimized builds
22+
print_foo(&f, x);
23+
}

‎src/test/run-pass/issue-21562.rs

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// Copyright 2015 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(core)]
12+
13+
extern crate core;
14+
use core::marker::Sync;
15+
16+
static SARRAY: [i32; 1] = [11];
17+
18+
struct MyStruct {
19+
pub arr: *const [i32],
20+
}
21+
unsafe impl Sync for MyStruct {}
22+
23+
static mystruct: MyStruct = MyStruct {
24+
arr: &SARRAY
25+
};
26+
27+
fn main() {}

‎src/test/run-pass/issue-22258.rs

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// Copyright 2015 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::ops::Add;
12+
13+
fn f<T: Add>(a: T, b: T) -> <T as Add>::Output {
14+
a + b
15+
}
16+
17+
fn main() {
18+
println!("a + b is {}", f::<f32>(100f32, 200f32));
19+
}

‎src/test/run-pass/issue-22463.rs

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
// Copyright 2015 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+
macro_rules! items {
12+
() => {
13+
type A = ();
14+
fn a() {}
15+
}
16+
}
17+
18+
trait Foo {
19+
type A;
20+
fn a();
21+
}
22+
23+
impl Foo for () {
24+
items!();
25+
}
26+
27+
fn main() {
28+
29+
}

0 commit comments

Comments
 (0)
Please sign in to comment.