Skip to content

Commit

Permalink
rollup merge of rust-lang#19780: jakub-/e-needstest
Browse files Browse the repository at this point in the history
  • Loading branch information
brson committed Dec 13, 2014
2 parents 6508ed9 + e62dc6b commit c59b9b7
Show file tree
Hide file tree
Showing 35 changed files with 923 additions and 0 deletions.
30 changes: 30 additions & 0 deletions src/test/auxiliary/issue-16822.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// 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.

#![crate_type="lib"]

use std::cell::RefCell;

pub struct Window<Data>{
pub data: RefCell<Data>
}

impl<Data: Update> Window<Data> {
pub fn update(&self, e: i32) {
match e {
1 => self.data.borrow_mut().update(),
_ => {}
}
}
}

pub trait Update {
fn update(&mut self);
}
31 changes: 31 additions & 0 deletions src/test/auxiliary/issue-18502.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.

#![crate_type="lib"]

struct Foo;
// This is the ICE trigger
struct Formatter;

trait Show {
fn fmt(&self);
}

impl Show for Foo {
fn fmt(&self) {}
}

fn bar<T>(f: extern "Rust" fn(&T), t: &T) { }

// ICE requirement: this has to be marked as inline
#[inline]
pub fn baz() {
bar(Show::fmt, &Foo);
}
16 changes: 16 additions & 0 deletions src/test/compile-fail/issue-10176.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// 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 f() -> int {
(return 1, return 2)
//~^ ERROR mismatched types: expected `int`, found `(_, _)` (expected int, found tuple)
}

fn main() {}
25 changes: 25 additions & 0 deletions src/test/compile-fail/issue-14182.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.

struct Foo {
f: for <'b> |&'b int|:
'b -> &'b int //~ ERROR use of undeclared lifetime name `'b`
}

fn main() {
let mut x: Vec< for <'a> ||
:'a //~ ERROR use of undeclared lifetime name `'a`
> = Vec::new();
x.push(|| {});

let foo = Foo {
f: |x| x
};
}
20 changes: 20 additions & 0 deletions src/test/compile-fail/issue-15381.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.

fn main() {
let values: Vec<u8> = vec![1,2,3,4,5,6,7,8];

for
[x,y,z]
//~^ ERROR refutable pattern in `for` loop binding: `[]` not covered
in values.as_slice().chunks(3).filter(|&xs| xs.len() == 3) {
println!("y={}", y);
}
}
20 changes: 20 additions & 0 deletions src/test/compile-fail/issue-15480.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.

fn main() {
let v = vec![
&3i
//~^ ERROR borrowed value does not live long enough
];

for &&x in v.iter() {
println!("{}", x + 3);
}
}
24 changes: 24 additions & 0 deletions src/test/compile-fail/issue-15756.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// 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::slice::Chunks;
use std::slice::MutChunks;

fn dft_iter<'a, T>(arg1: Chunks<'a,T>, arg2: MutChunks<'a,T>)
{
for
&something
//~^ ERROR the trait `core::kinds::Sized` is not implemented for the type `[T]`
in arg2
{
}
}

fn main() {}
15 changes: 15 additions & 0 deletions src/test/compile-fail/issue-16966.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() {
panic!(
1.2 //~ ERROR cannot determine a type for this expression
);
}
18 changes: 18 additions & 0 deletions src/test/compile-fail/issue-17545.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.

#![feature(unboxed_closures)]

pub fn foo<'a, F: Fn<(&'a (),), ()>>(bar: F) {
bar.call((
&(), //~ ERROR borrowed value does not live long enough
));
}
fn main() {}
27 changes: 27 additions & 0 deletions src/test/compile-fail/issue-17905.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.

#[deriving(Show)]
struct Pair<T, V> (T, V);

impl Pair<
&str, //~ ERROR missing lifetime specifier
int
> {
fn say(self: &Pair<&str, int>) {
//~^ ERROR mismatched types: expected `Pair<&'static str, int>`, found `Pair<&str, int>`
println!("{}", self);
}
}

fn main() {
let result = &Pair("shane", 1i);
result.say();
}
19 changes: 19 additions & 0 deletions src/test/compile-fail/issue-18345.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.

type Step<'s, R, T> = |R, T|: 's -> R;
type Transducer<'t, R, T, U> = |Step<'t, R, U>|: 't -> Step<'t, R, T>;

fn mapping<'f, R, T, U>(f: |T|: 'f -> U) -> &'f Transducer<'f, R, T, U> {
|step| |r, x|
step(r, f(x)) //~ ERROR the type of this value must be known in this context
}

fn main() {}
34 changes: 34 additions & 0 deletions src/test/compile-fail/issue-18389.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// 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(unboxed_closures)]
#![feature(associated_types)]

use std::any::Any;
use std::intrinsics::TypeId;

pub trait Pt {}
pub trait Rt {}

trait Private<P: Pt, R: Rt> {
fn call(&self, p: P, r: R);
}
pub trait Public: Private<
<Self as Public>::P,
//~^ ERROR illegal recursive type; insert an enum or struct in the cycle, if this is desired
<Self as Public>::R
> {
type P;
type R;

fn call_inner(&self);
}

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

trait Set<T> {
fn contains(&self, T) -> bool;
fn set(&mut self, T);
}

impl<'a, T, S> Set<&'a [T]> for S where
T: Copy,
S: Set<T>,
{
fn contains(&self, bits: &[T]) -> bool {
bits.iter().all(|&bit| self.contains(bit))
}

fn set(&mut self, bits: &[T]) {
for &bit in bits.iter() {
self.set(bit)
}
}
}

fn main() {
let bits: &[_] = &[0, 1];

0.contains(bits);
//~^ ERROR the trait `Set<_>` is not implemented for the type `_`
}
22 changes: 22 additions & 0 deletions src/test/compile-fail/issue-18611.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// 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(associated_types)]

fn add_state(op:
<int as HasState>::State
//~^ ERROR it is currently unsupported to access associated types except through a type parameter
) {}

trait HasState {
type State;
}

fn main() {}
37 changes: 37 additions & 0 deletions src/test/compile-fail/issue-18783.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::cell::RefCell;

fn main() {
let c = RefCell::new(vec![]);
let mut y = 1u;
c.push(|| y = 0);
c.push(|| y = 0);
//~^ ERROR cannot borrow `y` as mutable more than once at a time
}

fn ufcs() {
let c = RefCell::new(vec![]);
let mut y = 1u;

Push::push(&c, || y = 0);
Push::push(&c, || y = 0);
}

trait Push<'c> {
fn push<'f: 'c>(&self, push: ||:'f -> ());
}

impl<'c> Push<'c> for RefCell<Vec<||:'c>> {
fn push<'f: 'c>(&self, fun: ||:'f -> ()) {
self.borrow_mut().push(fun)
}
}
Loading

2 comments on commit c59b9b7

@sfackler
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

r+ p=1

@brson
Copy link
Owner Author

@brson brson commented on c59b9b7 Dec 14, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bors: retry

Please sign in to comment.