Add test cases for E-needstest issues
This commit is contained in:
parent
80e5fe1a56
commit
2c744c7f32
13 changed files with 278 additions and 0 deletions
17
src/test/compile-fail/issue-12863.rs
Normal file
17
src/test/compile-fail/issue-12863.rs
Normal file
|
@ -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
src/test/compile-fail/issue-14721.rs
Normal file
15
src/test/compile-fail/issue-14721.rs
Normal file
|
@ -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
src/test/compile-fail/issue-16683.rs
Normal file
18
src/test/compile-fail/issue-16683.rs
Normal file
|
@ -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
src/test/compile-fail/issue-17551.rs
Normal file
18
src/test/compile-fail/issue-17551.rs
Normal file
|
@ -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
src/test/compile-fail/issue-18118.rs
Normal file
17
src/test/compile-fail/issue-18118.rs
Normal file
|
@ -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
src/test/compile-fail/issue-18252.rs
Normal file
19
src/test/compile-fail/issue-18252.rs
Normal file
|
@ -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
src/test/compile-fail/issue-6991.rs
Normal file
15
src/test/compile-fail/issue-6991.rs
Normal file
|
@ -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
src/test/compile-fail/issue-7867.rs
Normal file
27
src/test/compile-fail/issue-7867.rs
Normal file
|
@ -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>>`
|
||||||
|
}
|
||||||
|
}
|
|
@ -9,6 +9,9 @@
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
#![allow(dead_code)]
|
#![allow(dead_code)]
|
||||||
|
#![feature(unboxed_closures, unboxed_closure_sugar)]
|
||||||
|
|
||||||
|
// compile-flags:-g
|
||||||
|
|
||||||
fn foo<T>() {}
|
fn foo<T>() {}
|
||||||
|
|
||||||
|
@ -82,6 +85,9 @@ fn bar<'b>() {
|
||||||
// issue #13490
|
// issue #13490
|
||||||
let _ = || -> ! loop {};
|
let _ = || -> ! loop {};
|
||||||
let _ = proc() -> ! loop {};
|
let _ = proc() -> ! loop {};
|
||||||
|
|
||||||
|
// issue #17021
|
||||||
|
let c = box |&:| {};
|
||||||
}
|
}
|
||||||
|
|
||||||
struct B<T>;
|
struct B<T>;
|
||||||
|
|
44
src/test/run-pass/issue-12028.rs
Normal file
44
src/test/run-pass/issue-12028.rs
Normal file
|
@ -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
src/test/run-pass/issue-14901.rs
Normal file
27
src/test/run-pass/issue-14901.rs
Normal file
|
@ -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
src/test/run-pass/issue-16560.rs
Normal file
25
src/test/run-pass/issue-16560.rs
Normal file
|
@ -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
src/test/run-pass/issue-16668.rs
Normal file
30
src/test/run-pass/issue-16668.rs
Normal file
|
@ -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() {}
|
Loading…
Add table
Add a link
Reference in a new issue