rollup merge of #18630 : nikomatsakis/purge-the-bars

This commit is contained in:
Alex Crichton 2014-11-06 13:31:18 -08:00
commit 76d2abe0e7
45 changed files with 954 additions and 630 deletions

View file

@ -8,7 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
fn fn1(0: Box) {} //~ ERROR: not enough type parameters supplied to `Box<T>`
fn fn1(0: Box) {} //~ ERROR: wrong number of type arguments: expected 1, found 0
fn main() {}

View 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.
// Test that `Box` cannot be used with a lifetime parameter.
struct Foo<'a> {
x: Box<'a, int> //~ ERROR wrong number of lifetime parameters
}
pub fn main() {
}

View file

@ -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.
// Test interaction between unboxed closure sugar and default type
// parameters (should be exactly as if angle brackets were used).
#![feature(default_type_params)]
#![allow(dead_code)]
struct Foo<T,U,V=T> {
t: T, u: U
}
trait Eq<X> { }
impl<X> Eq<X> for X { }
fn eq<A,B:Eq<A>>() { }
fn test<'a,'b>() {
// Parens are equivalent to omitting default in angle.
eq::< Foo<(int,),()>, Foo(int) >();
// In angle version, we supply something other than the default
eq::< Foo<(int,),(),int>, Foo(int) >();
//~^ ERROR not implemented
// Supply default explicitly.
eq::< Foo<(int,),(),(int,)>, Foo(int) >();
}
fn main() { }

View file

@ -0,0 +1,39 @@
// 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.
// Test that the unboxed closure sugar can be used with an arbitrary
// struct type and that it is equivalent to the same syntax using
// angle brackets. This test covers only simple types and in
// particular doesn't test bound regions.
#![allow(dead_code)]
struct Foo<T,U> {
t: T, u: U
}
trait Eq<X> { }
impl<X> Eq<X> for X { }
fn eq<A,B:Eq<A>>() { }
fn test<'a,'b>() {
// No errors expected:
eq::< Foo<(),()>, Foo() >();
eq::< Foo<(int,),()>, Foo(int) >();
eq::< Foo<(int,uint),()>, Foo(int,uint) >();
eq::< Foo<(int,uint),uint>, Foo(int,uint) -> uint >();
eq::< Foo<(&'a int,&'b uint),uint>, Foo(&'a int,&'b uint) -> uint >();
// Errors expected:
eq::< Foo<(),()>, Foo(char) >();
//~^ ERROR not implemented
}
fn main() { }

View file

@ -8,7 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
fn f<F:Nonexist(int) -> int>(x: F) {} //~ ERROR unresolved trait
fn f<F:Nonexist(int) -> int>(x: F) {} //~ ERROR nonexistent trait `Nonexist`
type Typedef = int;

View file

@ -0,0 +1,45 @@
// 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.
// Test interaction between unboxed closure sugar and region
// parameters (should be exactly as if angle brackets were used
// and regions omitted).
#![feature(default_type_params)]
#![allow(dead_code)]
use std::kinds::marker;
struct Foo<'a,T,U> {
t: T,
u: U,
m: marker::InvariantLifetime<'a>
}
trait Eq<X> { }
impl<X> Eq<X> for X { }
fn eq<A,B:Eq<A>>() { }
fn same_type<A,B:Eq<A>>(a: A, b: B) { }
fn test<'a,'b>() {
// Parens are equivalent to omitting default in angle.
eq::< Foo<(int,),()>, Foo(int) >();
// Here we specify 'static explicitly in angle-bracket version.
// Parenthesized winds up getting inferred.
eq::< Foo<'static, (int,),()>, Foo(int) >();
}
fn test2(x: Foo<(int,),()>, y: Foo(int)) {
// Here, the omitted lifetimes are expanded to distinct things.
same_type(x, y) //~ ERROR cannot infer
}
fn main() { }

View file

@ -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.
struct One<A>;
fn foo(_: One()) //~ ERROR wrong number of type arguments
{}
fn main() { }

View file

@ -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.
struct Three<A,B,C>;
fn foo(_: Three()) //~ ERROR wrong number of type arguments
{}
fn main() { }

View file

@ -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.
struct Zero;
fn foo(_: Zero()) //~ ERROR wrong number of type arguments
{}
fn main() { }

View file

@ -11,7 +11,7 @@
trait Trait {}
fn f<F:Trait(int) -> int>(x: F) {}
//~^ ERROR unboxed function trait must be one of `Fn`, `FnMut`, or `FnOnce`
//~^ ERROR wrong number of type arguments: expected 0, found 2
fn main() {}

View file

@ -25,7 +25,7 @@ fn call_it<F:FnMut(int)->int>(mut f: F, x: int) -> int {
f.call_mut((x,)) + 3
}
fn call_box(f: &mut |&mut: int|->int, x: int) -> int {
fn call_box(f: &mut FnMut(int) -> int, x: int) -> int {
f.call_mut((x,)) + 3
}

View file

@ -13,7 +13,7 @@
#![feature(unboxed_closures, unboxed_closure_sugar)]
fn main() {
let task: Box<|: int| -> int> = box |: x| x;
let task: Box<FnOnce(int) -> int> = box |: x| x;
task.call_once((0i, ));
}

View file

@ -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.
// Test that the unboxed closure sugar can be used with an arbitrary
// struct type and that it is equivalent to the same syntax using
// angle brackets. This test covers only simple types and in
// particular doesn't test bound regions.
#![allow(dead_code)]
struct Foo<T,U> {
t: T, u: U
}
trait Eq<X> { }
impl<X> Eq<X> for X { }
fn eq<A,B:Eq<A>>() { }
fn test<'a,'b>() {
eq::< Foo<(),()>, Foo() >();
eq::< Foo<(int,),()>, Foo(int) >();
eq::< Foo<(int,uint),()>, Foo(int,uint) >();
eq::< Foo<(int,uint),uint>, Foo(int,uint) -> uint >();
eq::< Foo<(&'a int,&'b uint),uint>, Foo(&'a int,&'b uint) -> uint >();
}
fn main() { }

View file

@ -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.
// Test unboxed closure sugar used in object types.
#![allow(dead_code)]
struct Foo<T,U> {
t: T, u: U
}
trait Getter<A,R> {
fn get(&self, arg: A) -> R;
}
struct Identity;
impl<X> Getter<X,X> for Identity {
fn get(&self, arg: X) -> X {
arg
}
}
fn main() {
let x: &Getter(int) -> (int,) = &Identity;
let (y,) = x.get((22,));
assert_eq!(y, 22);
}

View file

@ -13,7 +13,7 @@
use std::ops::FnOnce;
fn main() {
let task: Box<|: int| -> int> = box |: x| x;
let task: Box<FnOnce(int) -> int> = box |: x| x;
assert!(task.call_once((1234i,)) == 1234i);
}