Skip to content

Commit c59b9b7

Browse files
committed
2 parents 6508ed9 + e62dc6b commit c59b9b7

35 files changed

+923
-0
lines changed

src/test/auxiliary/issue-16822.rs

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
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+
#![crate_type="lib"]
12+
13+
use std::cell::RefCell;
14+
15+
pub struct Window<Data>{
16+
pub data: RefCell<Data>
17+
}
18+
19+
impl<Data: Update> Window<Data> {
20+
pub fn update(&self, e: i32) {
21+
match e {
22+
1 => self.data.borrow_mut().update(),
23+
_ => {}
24+
}
25+
}
26+
}
27+
28+
pub trait Update {
29+
fn update(&mut self);
30+
}

src/test/auxiliary/issue-18502.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+
#![crate_type="lib"]
12+
13+
struct Foo;
14+
// This is the ICE trigger
15+
struct Formatter;
16+
17+
trait Show {
18+
fn fmt(&self);
19+
}
20+
21+
impl Show for Foo {
22+
fn fmt(&self) {}
23+
}
24+
25+
fn bar<T>(f: extern "Rust" fn(&T), t: &T) { }
26+
27+
// ICE requirement: this has to be marked as inline
28+
#[inline]
29+
pub fn baz() {
30+
bar(Show::fmt, &Foo);
31+
}

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

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
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 f() -> int {
12+
(return 1, return 2)
13+
//~^ ERROR mismatched types: expected `int`, found `(_, _)` (expected int, found tuple)
14+
}
15+
16+
fn main() {}

src/test/compile-fail/issue-14182.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+
struct Foo {
12+
f: for <'b> |&'b int|:
13+
'b -> &'b int //~ ERROR use of undeclared lifetime name `'b`
14+
}
15+
16+
fn main() {
17+
let mut x: Vec< for <'a> ||
18+
:'a //~ ERROR use of undeclared lifetime name `'a`
19+
> = Vec::new();
20+
x.push(|| {});
21+
22+
let foo = Foo {
23+
f: |x| x
24+
};
25+
}

src/test/compile-fail/issue-15381.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+
fn main() {
12+
let values: Vec<u8> = vec![1,2,3,4,5,6,7,8];
13+
14+
for
15+
[x,y,z]
16+
//~^ ERROR refutable pattern in `for` loop binding: `[]` not covered
17+
in values.as_slice().chunks(3).filter(|&xs| xs.len() == 3) {
18+
println!("y={}", y);
19+
}
20+
}

src/test/compile-fail/issue-15480.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+
fn main() {
12+
let v = vec![
13+
&3i
14+
//~^ ERROR borrowed value does not live long enough
15+
];
16+
17+
for &&x in v.iter() {
18+
println!("{}", x + 3);
19+
}
20+
}

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

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
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+
use std::slice::Chunks;
12+
use std::slice::MutChunks;
13+
14+
fn dft_iter<'a, T>(arg1: Chunks<'a,T>, arg2: MutChunks<'a,T>)
15+
{
16+
for
17+
&something
18+
//~^ ERROR the trait `core::kinds::Sized` is not implemented for the type `[T]`
19+
in arg2
20+
{
21+
}
22+
}
23+
24+
fn main() {}

src/test/compile-fail/issue-16966.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+
panic!(
13+
1.2 //~ ERROR cannot determine a type for this expression
14+
);
15+
}

src/test/compile-fail/issue-17545.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+
#![feature(unboxed_closures)]
12+
13+
pub fn foo<'a, F: Fn<(&'a (),), ()>>(bar: F) {
14+
bar.call((
15+
&(), //~ ERROR borrowed value does not live long enough
16+
));
17+
}
18+
fn main() {}

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

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
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+
#[deriving(Show)]
12+
struct Pair<T, V> (T, V);
13+
14+
impl Pair<
15+
&str, //~ ERROR missing lifetime specifier
16+
int
17+
> {
18+
fn say(self: &Pair<&str, int>) {
19+
//~^ ERROR mismatched types: expected `Pair<&'static str, int>`, found `Pair<&str, int>`
20+
println!("{}", self);
21+
}
22+
}
23+
24+
fn main() {
25+
let result = &Pair("shane", 1i);
26+
result.say();
27+
}

src/test/compile-fail/issue-18345.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+
type Step<'s, R, T> = |R, T|: 's -> R;
12+
type Transducer<'t, R, T, U> = |Step<'t, R, U>|: 't -> Step<'t, R, T>;
13+
14+
fn mapping<'f, R, T, U>(f: |T|: 'f -> U) -> &'f Transducer<'f, R, T, U> {
15+
|step| |r, x|
16+
step(r, f(x)) //~ ERROR the type of this value must be known in this context
17+
}
18+
19+
fn main() {}

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

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
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(unboxed_closures)]
12+
#![feature(associated_types)]
13+
14+
use std::any::Any;
15+
use std::intrinsics::TypeId;
16+
17+
pub trait Pt {}
18+
pub trait Rt {}
19+
20+
trait Private<P: Pt, R: Rt> {
21+
fn call(&self, p: P, r: R);
22+
}
23+
pub trait Public: Private<
24+
<Self as Public>::P,
25+
//~^ ERROR illegal recursive type; insert an enum or struct in the cycle, if this is desired
26+
<Self as Public>::R
27+
> {
28+
type P;
29+
type R;
30+
31+
fn call_inner(&self);
32+
}
33+
34+
fn main() {}

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

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
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+
trait Set<T> {
12+
fn contains(&self, T) -> bool;
13+
fn set(&mut self, T);
14+
}
15+
16+
impl<'a, T, S> Set<&'a [T]> for S where
17+
T: Copy,
18+
S: Set<T>,
19+
{
20+
fn contains(&self, bits: &[T]) -> bool {
21+
bits.iter().all(|&bit| self.contains(bit))
22+
}
23+
24+
fn set(&mut self, bits: &[T]) {
25+
for &bit in bits.iter() {
26+
self.set(bit)
27+
}
28+
}
29+
}
30+
31+
fn main() {
32+
let bits: &[_] = &[0, 1];
33+
34+
0.contains(bits);
35+
//~^ ERROR the trait `Set<_>` is not implemented for the type `_`
36+
}

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

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
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(associated_types)]
12+
13+
fn add_state(op:
14+
<int as HasState>::State
15+
//~^ ERROR it is currently unsupported to access associated types except through a type parameter
16+
) {}
17+
18+
trait HasState {
19+
type State;
20+
}
21+
22+
fn main() {}

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

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
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+
use std::cell::RefCell;
12+
13+
fn main() {
14+
let c = RefCell::new(vec![]);
15+
let mut y = 1u;
16+
c.push(|| y = 0);
17+
c.push(|| y = 0);
18+
//~^ ERROR cannot borrow `y` as mutable more than once at a time
19+
}
20+
21+
fn ufcs() {
22+
let c = RefCell::new(vec![]);
23+
let mut y = 1u;
24+
25+
Push::push(&c, || y = 0);
26+
Push::push(&c, || y = 0);
27+
}
28+
29+
trait Push<'c> {
30+
fn push<'f: 'c>(&self, push: ||:'f -> ());
31+
}
32+
33+
impl<'c> Push<'c> for RefCell<Vec<||:'c>> {
34+
fn push<'f: 'c>(&self, fun: ||:'f -> ()) {
35+
self.borrow_mut().push(fun)
36+
}
37+
}

0 commit comments

Comments
 (0)