Update test for equivalency to include region binders in object types, add new tests relating to HRTB, consolidate the unboxed_closures and overloaded_calls feature gates.

This commit is contained in:
Niko Matsakis 2014-11-15 19:10:22 -05:00
parent 7a846b86a8
commit 56ba260749
48 changed files with 531 additions and 81 deletions

View file

@ -2513,11 +2513,6 @@ The currently implemented features of the reference compiler are:
closure as `once` is unlikely to be supported going forward. So
they are hidden behind this feature until they are to be removed.
* `overloaded_calls` - Allow implementing the `Fn*` family of traits on user
types, allowing overloading the call operator (`()`).
This feature may still undergo changes before being
stabilized.
* `phase` - Usage of the `#[phase]` attribute allows loading compiler plugins
for custom lints or syntax extensions. The implementation is
considered unwholesome and in need of overhaul, and it is not clear
@ -2560,7 +2555,8 @@ The currently implemented features of the reference compiler are:
* `trace_macros` - Allows use of the `trace_macros` macro, which is a nasty
hack that will certainly be removed.
* `unboxed_closures` - A work in progress feature with many known bugs.
* `unboxed_closures` - Rust's new closure design, which is currently a work in
progress feature with many known bugs.
* `unsafe_destructor` - Allows use of the `#[unsafe_destructor]` attribute,
which is considered wildly unsafe and will be

View file

@ -2264,11 +2264,11 @@ fn try_overloaded_call<'a>(fcx: &FnCtxt,
fcx.inh.method_map.borrow_mut().insert(method_call, method_callee);
write_call(fcx, call_expression, output_type);
if !fcx.tcx().sess.features.borrow().overloaded_calls {
if !fcx.tcx().sess.features.borrow().unboxed_closures {
span_err!(fcx.tcx().sess, call_expression.span, E0056,
"overloaded calls are experimental");
span_help!(fcx.tcx().sess, call_expression.span,
"add `#![feature(overloaded_calls)]` to \
"add `#![feature(unboxed_closures)]` to \
the crate attributes to enable");
}

View file

@ -58,7 +58,6 @@ static KNOWN_FEATURES: &'static [(&'static str, Status)] = &[
("quote", Active),
("linkage", Active),
("struct_inherit", Removed),
("overloaded_calls", Active),
("quad_precision_float", Removed),
@ -101,7 +100,7 @@ enum Status {
/// A set of features to be used by later passes.
pub struct Features {
pub default_type_params: bool,
pub overloaded_calls: bool,
pub unboxed_closures: bool,
pub rustc_diagnostic_macros: bool,
pub import_shadowing: bool,
pub visible_private_types: bool,
@ -112,7 +111,7 @@ impl Features {
pub fn new() -> Features {
Features {
default_type_params: false,
overloaded_calls: false,
unboxed_closures: false,
rustc_diagnostic_macros: false,
import_shadowing: false,
visible_private_types: false,
@ -458,7 +457,7 @@ pub fn check_crate(span_handler: &SpanHandler, krate: &ast::Crate) -> (Features,
(Features {
default_type_params: cx.has_feature("default_type_params"),
overloaded_calls: cx.has_feature("overloaded_calls"),
unboxed_closures: cx.has_feature("unboxed_closures"),
rustc_diagnostic_macros: cx.has_feature("rustc_diagnostic_macros"),
import_shadowing: cx.has_feature("import_shadowing"),
visible_private_types: cx.has_feature("visible_private_types"),

View file

@ -8,7 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![feature(unboxed_closures, overloaded_calls)]
#![feature(unboxed_closures)]
#![crate_type = "rlib"]
pub fn inner<F>(f: F) -> F {

View file

@ -8,7 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![feature(unboxed_closures, overloaded_calls)]
#![feature(unboxed_closures)]
#[inline]
pub fn has_closures() -> uint {

View file

@ -40,7 +40,7 @@
// ignore-android see #10393 #13206
#![feature(slicing_syntax, unboxed_closures, overloaded_calls)]
#![feature(slicing_syntax, unboxed_closures)]
extern crate libc;

View file

@ -41,7 +41,7 @@
// no-pretty-expanded FIXME #15189
#![allow(non_snake_case)]
#![feature(unboxed_closures, overloaded_calls)]
#![feature(unboxed_closures)]
use std::iter::AdditiveIterator;
use std::mem;

View file

@ -8,7 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![feature(overloaded_calls)]
#![feature(unboxed_closures)]
use std::ops::{Fn, FnMut, FnOnce};

View file

@ -0,0 +1,60 @@
// 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 HRTB supertraits with several levels of expansion required.
trait Foo<'tcx>
{
fn foo(&'tcx self) -> &'tcx int;
}
trait Bar<'ccx>
: for<'tcx> Foo<'tcx>
{
fn bar(&'ccx self) -> &'ccx int;
}
trait Baz
: for<'ccx> Bar<'ccx>
{
fn dummy(&self);
}
trait Qux
: Bar<'static>
{
fn dummy(&self);
}
fn want_foo_for_any_tcx<F>(f: &F)
where F : for<'tcx> Foo<'tcx>
{
}
fn want_bar_for_any_ccx<B>(b: &B)
where B : for<'ccx> Bar<'ccx>
{
}
fn want_baz<B>(b: &B)
where B : Baz
{
want_foo_for_any_tcx(b);
want_bar_for_any_ccx(b);
}
fn want_qux<B>(b: &B)
where B : Qux
{
want_foo_for_any_tcx(b);
want_bar_for_any_ccx(b); //~ ERROR not implemented
}
fn main() {}

View file

@ -0,0 +1,58 @@
// 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 a trait (`Bar`) with a higher-ranked supertrait.
trait Foo<'tcx>
{
fn foo(&'tcx self) -> &'tcx int;
}
trait Bar<'ccx>
: for<'tcx> Foo<'tcx>
{
fn bar(&'ccx self) -> &'ccx int;
}
fn want_foo_for_some_tcx<'x,F>(f: &'x F)
where F : Foo<'x>
{
want_foo_for_some_tcx(f);
want_foo_for_any_tcx(f); //~ ERROR not implemented
}
fn want_foo_for_any_tcx<F>(f: &F)
where F : for<'tcx> Foo<'tcx>
{
want_foo_for_some_tcx(f);
want_foo_for_any_tcx(f);
}
fn want_bar_for_some_ccx<'x,B>(b: &B)
where B : Bar<'x>
{
want_foo_for_some_tcx(b);
want_foo_for_any_tcx(b);
want_bar_for_some_ccx(b);
want_bar_for_any_ccx(b); //~ ERROR not implemented
}
fn want_bar_for_any_ccx<B>(b: &B)
where B : for<'ccx> Bar<'ccx>
{
want_foo_for_some_tcx(b);
want_foo_for_any_tcx(b);
want_bar_for_some_ccx(b);
want_bar_for_any_ccx(b);
}
fn main() {}

View file

@ -0,0 +1,35 @@
// 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 `'a` in the where clause correctly links the region
// of the output to the region of the input.
trait FnLike<A,R> {
fn call(&self, arg: A) -> R;
}
fn call_repeatedly<F>(f: F)
where F : for<'a> FnLike<&'a int, &'a int>
{
// Result is stored: cannot re-assign `x`
let mut x = 3;
let y = f.call(&x);
x = 5; //~ ERROR cannot assign
// Result is not stored: can re-assign `x`
let mut x = 3;
f.call(&x);
f.call(&x);
f.call(&x);
x = 5;
}
fn main() {
}

View file

@ -8,7 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![feature(overloaded_calls)]
#![feature(unboxed_closures)]
use std::{fmt, ops};

View file

@ -12,7 +12,7 @@
// when a type error or unconstrained type variable propagates
// into it.
#![feature(overloaded_calls)]
#![feature(unboxed_closures)]
fn main() {
(return)((),());

View file

@ -8,7 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![feature(overloaded_calls)]
#![feature(unboxed_closures)]
use std::ops::FnMut;

View file

@ -8,7 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![feature(overloaded_calls)]
#![feature(unboxed_closures)]
use std::ops::FnMut;

View file

@ -0,0 +1,43 @@
// 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.
// A zero-dependency test that covers some basic traits, default
// methods, etc. When mucking about with basic type system stuff I
// often encounter problems in the iterator trait, so it's useful to
// have hanging around. -nmatsakis
// error-pattern: requires `start` lang_item
#![no_std]
#![feature(lang_items)]
#[lang = "sized"]
pub trait Sized for Sized? {
// Empty.
}
pub mod std {
pub mod clone {
pub trait Clone {
fn clone(&self) -> Self;
}
}
}
pub struct ContravariantLifetime<'a>;
impl <'a> ::std::clone::Clone for ContravariantLifetime<'a> {
#[inline]
fn clone(&self) -> ContravariantLifetime<'a> {
match *self { ContravariantLifetime => ContravariantLifetime, }
}
}
fn main() { }

View file

@ -0,0 +1,40 @@
// 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.
// A zero-dependency test that covers some basic traits, default
// methods, etc. When mucking about with basic type system stuff I
// often encounter problems in the iterator trait, so it's useful to
// have hanging around. -nmatsakis
// error-pattern: requires `start` lang_item
#![no_std]
#![feature(lang_items)]
#[lang = "sized"]
pub trait Sized for Sized? {
// Empty.
}
#[unstable = "Definition may change slightly after trait reform"]
pub trait PartialEq for Sized? {
/// This method tests for `self` and `other` values to be equal, and is used by `==`.
fn eq(&self, other: &Self) -> bool;
}
#[cfg(not(stage0))] // NOTE(stage0): remove cfg after a snapshot
#[unstable = "Trait is unstable."]
impl<'a, Sized? T: PartialEq> PartialEq for &'a T {
#[inline]
fn eq(&self, other: & &'a T) -> bool { PartialEq::eq(*self, *other) }
}
fn main() { }

View file

@ -16,13 +16,13 @@
#![feature(unboxed_closures)]
#![allow(dead_code)]
struct Foo<T,U> {
t: T, u: U
trait Foo<T,U> {
fn dummy(&self, t: T, u: U);
}
trait Eq<X> { }
impl<X> Eq<X> for X { }
fn eq<A,B:Eq<A>>() { }
trait Eq<Sized? X> for Sized? { }
impl<Sized? X> Eq<X> for X { }
fn eq<Sized? A,Sized? B:Eq<A>>() { }
fn test<'a,'b>() {
// No errors expected:
@ -32,6 +32,22 @@ fn test<'a,'b>() {
eq::< Foo<(int,uint),uint>, Foo(int,uint) -> uint >();
eq::< Foo<(&'a int,&'b uint),uint>, Foo(&'a int,&'b uint) -> uint >();
// Test that anonymous regions in `()` form are equivalent
// to fresh bound regions, and that we can intermingle
// named and anonymous as we choose:
eq::< for<'a,'b> Foo<(&'a int,&'b uint),uint>,
for<'a,'b> Foo(&'a int,&'b uint) -> uint >();
eq::< for<'a,'b> Foo<(&'a int,&'b uint),uint>,
for<'a> Foo(&'a int,&uint) -> uint >();
eq::< for<'a,'b> Foo<(&'a int,&'b uint),uint>,
for<'b> Foo(&int,&'b uint) -> uint >();
eq::< for<'a,'b> Foo<(&'a int,&'b uint),uint>,
Foo(&int,&uint) -> uint >();
// FIXME(#18992) Test lifetime elision in `()` form:
// eq::< for<'a,'b> Foo<(&'a int,), &'a int>,
// Foo(&int) -> &int >();
// Errors expected:
eq::< Foo<(),()>, Foo(char) >();
//~^ ERROR not implemented

View file

@ -8,7 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![feature(overloaded_calls)]
#![feature(unboxed_closures)]
use std::ops::FnMut;

View file

@ -8,7 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![feature(overloaded_calls, unboxed_closures)]
#![feature(unboxed_closures)]
fn each<'a,T,F:FnMut(&'a T)>(x: &'a [T], mut f: F) {
for val in x.iter() {

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 we handle binder levels in object types correctly.
// Initially, the reference to `'tcx` in the object type
// `&Typer<'tcx>` was getting an incorrect binder level, yielding
// weird compilation ICEs and so forth.
trait Typer<'tcx> {
fn method(&self, data: &'tcx int) -> &'tcx int { data }
}
struct Tcx<'tcx> {
fields: &'tcx int
}
impl<'tcx> Typer<'tcx> for Tcx<'tcx> {
}
fn g<'tcx>(typer: &Typer<'tcx>) {
}
fn check_static_type<'x>(tcx: &Tcx<'x>) {
g(tcx)
}
fn main() { }

View file

@ -0,0 +1,23 @@
// 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 Typer<'tcx> {
fn method(&self, data: &'tcx int) -> &'tcx int { data }
fn dummy(&self) { }
}
fn g(_: |&Typer|) {
}
fn h() {
g(|typer| typer.dummy())
}
fn main() { }

View file

@ -0,0 +1,35 @@
// 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.
// A basic test of using a higher-ranked trait bound.
trait FnLike<A,R> {
fn call(&self, arg: A) -> R;
}
type FnObject<'b> = for<'a> FnLike<&'a int, &'a int> + 'b;
struct Identity;
impl<'a, T> FnLike<&'a T, &'a T> for Identity {
fn call(&self, arg: &'a T) -> &'a T {
arg
}
}
fn call_repeatedly(f: &FnObject) {
let x = 3;
let y = f.call(&x);
assert_eq!(3, *y);
}
fn main() {
call_repeatedly(&Identity);
}

View file

@ -0,0 +1,35 @@
// 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.
// A basic test of using a higher-ranked trait bound.
trait FnLike<A,R> {
fn call(&self, arg: A) -> R;
}
struct Identity;
impl<'a, T> FnLike<&'a T, &'a T> for Identity {
fn call(&self, arg: &'a T) -> &'a T {
arg
}
}
fn call_repeatedly<F>(f: F)
where F : for<'a> FnLike<&'a int, &'a int>
{
let x = 3;
let y = f.call(&x);
assert_eq!(3, *y);
}
fn main() {
call_repeatedly(Identity);
}

View file

@ -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.
// A basic test of using a higher-ranked trait bound.
trait FnLike<A,R> {
fn call(&self, arg: A) -> R;
}
type FnObject<'b> = for<'a> FnLike<&'a int, &'a int> + 'b;
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.
#![feature(unboxed_closures)]
// A basic test of using a higher-ranked trait bound.
trait FnLike<A,R> {
fn call(&self, arg: A) -> R;
}
type FnObject<'b> = for<'a> FnLike(&'a int) -> (&'a int) + 'b;
struct Identity;
impl<'a, T> FnLike<(&'a T,), &'a T> for Identity {
fn call(&self, (arg,): (&'a T,)) -> &'a T {
arg
}
}
fn call_repeatedly(f: &FnObject) {
let x = 3;
let y = f.call((&x,));
assert_eq!(3, *y);
}
fn main() {
call_repeatedly(&Identity);
}

View file

@ -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.
// Test that `&PrinterSupport`, which is really short for `&'a
// PrinterSupport<'b>`, gets properly expanded when it appears in a
// closure type. This used to result in messed up De Bruijn indices.
trait PrinterSupport<'ast> {
fn ast_map(&self) -> Option<&'ast uint> { None }
}
struct NoAnn<'ast> {
f: Option<&'ast uint>
}
impl<'ast> PrinterSupport<'ast> for NoAnn<'ast> {
}
fn foo<'ast> (f: Option<&'ast uint>, g: |&PrinterSupport|) {
let annotation = NoAnn { f: f };
g(&annotation)
}
fn main() {}

View file

@ -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.
// Test HRTB used with the `Fn` trait.
#![feature(unboxed_closures)]
fn foo<F:Fn(&int)>(f: F) {
let x = 22;
f(&x);
}
fn main() {
foo(|&: x: &int| println!("{}", *x));
}

View file

@ -8,7 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![feature(overloaded_calls)]
#![feature(unboxed_closures)]
trait Foo {}

View file

@ -8,7 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![feature(overloaded_calls)]
#![feature(unboxed_closures)]
use std::ops::Fn;

View file

@ -8,7 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![feature(overloaded_calls, unboxed_closures)]
#![feature(unboxed_closures)]
struct X(Box<int>);

View file

@ -12,7 +12,7 @@
// once closure as an optimization by trans. This used to hit an
// incorrect assert.
#![feature(unboxed_closures, overloaded_calls)]
#![feature(unboxed_closures)]
fn main() {
let x = 2u8;

View file

@ -11,7 +11,7 @@
// Test that param substitutions from the correct environment are
// used when translating unboxed closure calls.
#![feature(unboxed_closures, unboxed_closures)]
#![feature(unboxed_closures)]
pub fn inside<F: Fn()>(c: F) {
c.call(());

View file

@ -11,7 +11,7 @@
// Test that the self param space is not used in a conflicting
// manner by unboxed closures within a default method on a trait
#![feature(unboxed_closures, overloaded_calls)]
#![feature(unboxed_closures)]
trait Tr {
fn foo(&self);

View file

@ -11,7 +11,7 @@
// Test that we don't panic on a RefCell borrow conflict in certain
// code paths involving unboxed closures.
#![feature(unboxed_closures, overloaded_calls)]
#![feature(unboxed_closures)]
// aux-build:issue-18711.rs
extern crate "issue-18711" as issue;

View file

@ -10,7 +10,7 @@
// Tests that nested vtables work with overloaded calls.
#![feature(overloaded_calls)]
#![feature(unboxed_closures)]
use std::ops::Fn;

View file

@ -8,7 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![feature(lang_items, overloaded_calls)]
#![feature(lang_items, unboxed_closures)]
use std::ops::{Fn, FnMut, FnOnce};

View file

@ -8,7 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![feature(overloaded_calls)]
#![feature(unboxed_closures)]
use std::ops::{FnMut};

View file

@ -8,7 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![feature(lang_items, overloaded_calls, unboxed_closures, unboxed_closures)]
#![feature(lang_items, unboxed_closures)]
fn a<F:Fn(int, int) -> int>(f: F) -> int {
f(1, 2)

View file

@ -8,7 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![feature(overloaded_calls, unboxed_closures)]
#![feature(unboxed_closures)]
// Test by-ref capture of environment in unboxed closure types

View file

@ -8,7 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![feature(unboxed_closures, overloaded_calls)]
#![feature(unboxed_closures)]
fn main() {
let mut unboxed = |&mut:| {};

View file

@ -11,7 +11,7 @@
// A battery of tests to ensure destructors of unboxed closure environments
// run at the right times.
#![feature(overloaded_calls, unboxed_closures)]
#![feature(unboxed_closures)]
static mut DROP_COUNT: uint = 0;

View file

@ -11,7 +11,7 @@
// Checks that extern fn points implement the full range of Fn traits.
#![feature(unboxed_closures)]
#![feature(overloaded_calls)]
#![feature(unboxed_closures)]
use std::ops::{Fn,FnMut,FnOnce};

View file

@ -12,7 +12,7 @@
// any Fn trait to be used where Fn is implemented.
#![feature(unboxed_closures)]
#![feature(overloaded_calls)]
#![feature(unboxed_closures)]
use std::ops::{Fn,FnMut,FnOnce};

View file

@ -12,7 +12,7 @@
// FnMut or FnOnce to be used where FnMut is implemented.
#![feature(unboxed_closures)]
#![feature(overloaded_calls)]
#![feature(unboxed_closures)]
use std::ops::{FnMut,FnOnce};

View file

@ -11,7 +11,7 @@
// Ensures that single-word environments work right in unboxed closures.
// These take a different path in codegen.
#![feature(overloaded_calls, unboxed_closures)]
#![feature(unboxed_closures)]
fn a<F:Fn(int, int) -> int>(f: F) -> int {
f(1, 2)

View file

@ -1,34 +0,0 @@
// 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)]
trait Foo<T,U> {
fn dummy(&self) -> (T,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

@ -19,7 +19,7 @@
//
// compile-flags: -g
#![feature(unboxed_closures, overloaded_calls)]
#![feature(unboxed_closures)]
use std::ptr;