Skip to content

Commit

Permalink
rollup merge of rust-lang#18324 : jakub-/eneedstest
Browse files Browse the repository at this point in the history
  • Loading branch information
alexcrichton committed Oct 27, 2014
2 parents dac3234 + 2c744c7 commit f1118cc
Show file tree
Hide file tree
Showing 13 changed files with 278 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/test/compile-fail/issue-12863.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// 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 foo { pub fn bar() {} }

fn main() {
match () {
foo::bar => {} //~ ERROR `bar` is not an enum variant, struct or const
}
}
15 changes: 15 additions & 0 deletions src/test/compile-fail/issue-14721.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 foo = "str";
println!("{}", foo.desc); //~ ERROR attempted access of field `desc` on type `&str`,
// but no field with that name was found
}
18 changes: 18 additions & 0 deletions src/test/compile-fail/issue-16683.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.

trait T<'a> {
fn a(&'a self) -> &'a bool;
fn b(&self) {
self.a(); //~ ERROR mismatched types: expected `&'a Self`, found `&Self` (lifetime mismatch)
}
}

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

struct B<T>;

fn main() {
let foo = B; //~ ERROR unable to infer enough type information to locate the impl of the trait
let closure = |:| foo;
}
17 changes: 17 additions & 0 deletions src/test/compile-fail/issue-18118.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// 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 fn main() {
static z: &'static int = {
let p = 3;
&p
//~^ ERROR cannot borrow a local variable inside a static block, define a separate static instead
};
}
19 changes: 19 additions & 0 deletions src/test/compile-fail/issue-18252.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.

#![feature(struct_variant)]

enum Foo {
Variant { x: uint }
}

fn main() {
let f = Variant(42u); //~ ERROR expected function, found `Foo`
}
15 changes: 15 additions & 0 deletions src/test/compile-fail/issue-6991.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.

static x: &'static uint = &1;
static y: uint = *x;
//~^ ERROR cannot refer to other statics by value,
// use the address-of operator or a constant instead
fn main() {}
27 changes: 27 additions & 0 deletions src/test/compile-fail/issue-7867.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.

enum A { B, C }

mod foo { pub fn bar() {} }

fn main() {
match (true, false) {
B => (), //~ ERROR expected `(bool,bool)`, found `A` (expected tuple, found enum A)
_ => ()
}

match &Some(42i) {
Some(x) => (), //~ ERROR expected `&core::option::Option<int>`,
// found `core::option::Option<<generic #4>>`
None => () //~ ERROR expected `&core::option::Option<int>`,
// found `core::option::Option<<generic #5>>`
}
}
6 changes: 6 additions & 0 deletions src/test/run-pass/closure-syntax.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
// except according to those terms.

#![allow(dead_code)]
#![feature(unboxed_closures, unboxed_closure_sugar)]

// compile-flags:-g

fn foo<T>() {}

Expand Down Expand Up @@ -82,6 +85,9 @@ fn bar<'b>() {
// issue #13490
let _ = || -> ! loop {};
let _ = proc() -> ! loop {};

// issue #17021
let c = box |&:| {};
}

struct B<T>;
Expand Down
44 changes: 44 additions & 0 deletions src/test/run-pass/issue-12028.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
// 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 Hash<H> {
fn hash2(&self, hasher: &H) -> u64;
}

trait Stream {
fn input(&mut self, bytes: &[u8]);
fn result(&self) -> u64;
}

trait StreamHasher<S: Stream> {
fn stream(&self) -> S;
}

//////////////////////////////////////////////////////////////////////////////

trait StreamHash<S: Stream, H: StreamHasher<S>>: Hash<H> {
fn input_stream(&self, stream: &mut S);
}

impl<S: Stream, H: StreamHasher<S>> Hash<H> for u8 {
fn hash2(&self, hasher: &H) -> u64 {
let mut stream = hasher.stream();
self.input_stream(&mut stream);
stream.result()
}
}

impl<S: Stream, H: StreamHasher<S>> StreamHash<S, H> for u8 {
fn input_stream(&self, stream: &mut S) {
stream.input([*self]);
}
}

fn main() {}
27 changes: 27 additions & 0 deletions src/test/run-pass/issue-14901.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.

use std::io::Reader;

enum Wrapper<'a> {
WrapReader(&'a Reader + 'a)
}

trait Wrap<'a> {
fn wrap(self) -> Wrapper<'a>;
}

impl<'a, R: Reader> Wrap<'a> for &'a mut R {
fn wrap(self) -> Wrapper<'a> {
WrapReader(self as &'a mut Reader)
}
}

pub fn main() {}
25 changes: 25 additions & 0 deletions src/test/run-pass/issue-16560.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.

#![feature(unboxed_closures)]

use std::mem;

fn main() {
let y = 0u8;
let closure = move |&: x| y + x;

// Check that both closures are capturing by value
assert_eq!(1, mem::size_of_val(&closure));

spawn(proc() {
let ok = closure;
})
}
30 changes: 30 additions & 0 deletions src/test/run-pass/issue-16668.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.

#![feature(unboxed_closures)]

struct Parser<'a, I, O> {
parse: Box<FnMut<(I,), Result<O, String>> + 'a>
}

impl<'a, I, O: 'a> Parser<'a, I, O> {
fn compose<K: 'a>(mut self, mut rhs: Parser<O, K>) -> Parser<'a, I, K> {
Parser {
parse: box move |&mut: x: I| {
match self.parse.call_mut((x,)) {
Ok(r) => rhs.parse.call_mut((r,)),
Err(e) => Err(e)
}
}
}
}
}

fn main() {}

0 comments on commit f1118cc

Please sign in to comment.