rollup merge of #20723: pnkfelix/feature-gate-box-syntax
Conflicts: src/compiletest/compiletest.rs src/libcollections/lib.rs src/libserialize/lib.rs src/libsyntax/feature_gate.rs
This commit is contained in:
commit
373cbab5b0
@ -9,7 +9,9 @@
|
||||
// except according to those terms.
|
||||
|
||||
#![crate_type = "bin"]
|
||||
#![feature(slicing_syntax)]
|
||||
#![allow(unknown_features)]
|
||||
#![feature(slicing_syntax, unboxed_closures)]
|
||||
#![feature(box_syntax)]
|
||||
|
||||
#![deny(warnings)]
|
||||
|
||||
|
@ -49,6 +49,15 @@ pub static HEAP: () = ();
|
||||
#[stable]
|
||||
pub struct Box<T>(Unique<T>);
|
||||
|
||||
#[unstable]
|
||||
impl<T> Box<T> {
|
||||
/// Moves `x` into a freshly allocated box on the global exchange heap.
|
||||
#[unstable]
|
||||
pub fn new(x: T) -> Box<T> {
|
||||
box x
|
||||
}
|
||||
}
|
||||
|
||||
#[stable]
|
||||
impl<T: Default> Default for Box<T> {
|
||||
#[stable]
|
||||
@ -186,27 +195,27 @@ impl<T: ?Sized> DerefMut for Box<T> {
|
||||
mod test {
|
||||
#[test]
|
||||
fn test_owned_clone() {
|
||||
let a = box 5i;
|
||||
let a = Box::new(5i);
|
||||
let b: Box<int> = a.clone();
|
||||
assert!(a == b);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn any_move() {
|
||||
let a = box 8u as Box<Any>;
|
||||
let b = box Test as Box<Any>;
|
||||
let a = Box::new(8u) as Box<Any>;
|
||||
let b = Box::new(Test) as Box<Any>;
|
||||
|
||||
match a.downcast::<uint>() {
|
||||
Ok(a) => { assert!(a == box 8u); }
|
||||
Ok(a) => { assert!(a == Box::new(8u)); }
|
||||
Err(..) => panic!()
|
||||
}
|
||||
match b.downcast::<Test>() {
|
||||
Ok(a) => { assert!(a == box Test); }
|
||||
Ok(a) => { assert!(a == Box::new(Test)); }
|
||||
Err(..) => panic!()
|
||||
}
|
||||
|
||||
let a = box 8u as Box<Any>;
|
||||
let b = box Test as Box<Any>;
|
||||
let a = Box::new(8u) as Box<Any>;
|
||||
let b = Box::new(Test) as Box<Any>;
|
||||
|
||||
assert!(a.downcast::<Box<Test>>().is_err());
|
||||
assert!(b.downcast::<Box<uint>>().is_err());
|
||||
@ -214,8 +223,8 @@ mod test {
|
||||
|
||||
#[test]
|
||||
fn test_show() {
|
||||
let a = box 8u as Box<Any>;
|
||||
let b = box Test as Box<Any>;
|
||||
let a = Box::new(8u) as Box<Any>;
|
||||
let b = Box::new(Test) as Box<Any>;
|
||||
let a_str = a.to_str();
|
||||
let b_str = b.to_str();
|
||||
assert_eq!(a_str, "Box<Any>");
|
||||
@ -232,6 +241,6 @@ mod test {
|
||||
#[test]
|
||||
fn deref() {
|
||||
fn homura<T: Deref<Target=i32>>(_: T) { }
|
||||
homura(box 765i32);
|
||||
homura(Box::new(765i32));
|
||||
}
|
||||
}
|
||||
|
@ -67,6 +67,7 @@
|
||||
#![no_std]
|
||||
#![allow(unknown_features)]
|
||||
#![feature(lang_items, unsafe_destructor)]
|
||||
#![feature(box_syntax)]
|
||||
|
||||
#[macro_use]
|
||||
extern crate core;
|
||||
|
@ -24,6 +24,7 @@
|
||||
|
||||
#![allow(unknown_features)]
|
||||
#![feature(unsafe_destructor, slicing_syntax)]
|
||||
#![feature(box_syntax)]
|
||||
#![feature(unboxed_closures)]
|
||||
#![feature(old_impl_check)]
|
||||
#![no_std]
|
||||
|
@ -164,7 +164,10 @@
|
||||
html_favicon_url = "http://www.rust-lang.org/favicon.ico",
|
||||
html_root_url = "http://doc.rust-lang.org/nightly/",
|
||||
html_playground_url = "http://play.rust-lang.org/")]
|
||||
|
||||
#![allow(unknown_features)]
|
||||
#![feature(slicing_syntax)]
|
||||
#![feature(box_syntax)]
|
||||
#![deny(missing_docs)]
|
||||
|
||||
extern crate regex;
|
||||
|
@ -25,6 +25,7 @@
|
||||
|
||||
#![allow(unknown_features)]
|
||||
#![feature(slicing_syntax)]
|
||||
#![feature(box_syntax)]
|
||||
#![deny(missing_docs)]
|
||||
|
||||
#[cfg(test)]
|
||||
|
@ -26,6 +26,7 @@
|
||||
#![allow(unknown_features)]
|
||||
#![feature(quote)]
|
||||
#![feature(slicing_syntax, unsafe_destructor)]
|
||||
#![feature(box_syntax)]
|
||||
#![feature(rustc_diagnostic_macros)]
|
||||
#![feature(old_impl_check)]
|
||||
|
||||
|
@ -23,8 +23,10 @@
|
||||
html_favicon_url = "http://www.rust-lang.org/favicon.ico",
|
||||
html_root_url = "http://doc.rust-lang.org/nightly/")]
|
||||
|
||||
#![allow(unknown_features)]
|
||||
#![feature(quote)]
|
||||
#![feature(slicing_syntax, unsafe_destructor)]
|
||||
#![feature(box_syntax)]
|
||||
#![feature(rustc_diagnostic_macros)]
|
||||
|
||||
extern crate arena;
|
||||
|
@ -22,7 +22,9 @@
|
||||
html_favicon_url = "http://www.rust-lang.org/favicon.ico",
|
||||
html_root_url = "http://doc.rust-lang.org/nightly/")]
|
||||
|
||||
#![allow(unknown_features)]
|
||||
#![feature(link_args)]
|
||||
#![feature(box_syntax)]
|
||||
|
||||
extern crate libc;
|
||||
|
||||
|
@ -23,8 +23,10 @@
|
||||
html_favicon_url = "http://www.rust-lang.org/favicon.ico",
|
||||
html_root_url = "http://doc.rust-lang.org/nightly/")]
|
||||
|
||||
#![allow(unknown_features)]
|
||||
#![feature(quote)]
|
||||
#![feature(slicing_syntax, unsafe_destructor)]
|
||||
#![feature(box_syntax)]
|
||||
#![feature(rustc_diagnostic_macros)]
|
||||
|
||||
extern crate arena;
|
||||
|
@ -72,8 +72,10 @@ This API is completely unstable and subject to change.
|
||||
html_favicon_url = "http://www.rust-lang.org/favicon.ico",
|
||||
html_root_url = "http://doc.rust-lang.org/nightly/")]
|
||||
|
||||
#![allow(unknown_features)]
|
||||
#![feature(quote)]
|
||||
#![feature(slicing_syntax, unsafe_destructor)]
|
||||
#![feature(box_syntax)]
|
||||
#![feature(rustc_diagnostic_macros)]
|
||||
#![allow(non_camel_case_types)]
|
||||
|
||||
|
@ -18,6 +18,7 @@
|
||||
html_root_url = "http://doc.rust-lang.org/nightly/",
|
||||
html_playground_url = "http://play.rust-lang.org/")]
|
||||
#![feature(slicing_syntax)]
|
||||
#![feature(box_syntax)]
|
||||
|
||||
extern crate arena;
|
||||
extern crate getopts;
|
||||
|
@ -25,6 +25,7 @@ Core encoding and decoding interfaces.
|
||||
html_playground_url = "http://play.rust-lang.org/")]
|
||||
#![allow(unknown_features)]
|
||||
#![cfg_attr(stage0, allow(unused_attributes))]
|
||||
#![feature(box_syntax)]
|
||||
#![feature(old_impl_check)]
|
||||
#![feature(slicing_syntax)]
|
||||
|
||||
|
@ -108,6 +108,7 @@
|
||||
#![feature(linkage, thread_local, asm)]
|
||||
#![feature(lang_items, unsafe_destructor)]
|
||||
#![feature(slicing_syntax, unboxed_closures)]
|
||||
#![feature(box_syntax)]
|
||||
#![feature(old_impl_check)]
|
||||
|
||||
// Don't link to std. We are std.
|
||||
|
@ -69,7 +69,8 @@ static KNOWN_FEATURES: &'static [(&'static str, Status)] = &[
|
||||
("tuple_indexing", Accepted),
|
||||
("associated_types", Accepted),
|
||||
("visible_private_types", Active),
|
||||
("slicing_syntax", Accepted),
|
||||
("slicing_syntax", Active),
|
||||
("box_syntax", Active),
|
||||
|
||||
("if_let", Accepted),
|
||||
("while_let", Accepted),
|
||||
@ -337,6 +338,15 @@ impl<'a, 'v> Visitor<'v> for PostExpansionVisitor<'a> {
|
||||
}
|
||||
|
||||
fn visit_expr(&mut self, e: &ast::Expr) {
|
||||
match e.node {
|
||||
ast::ExprBox(..) | ast::ExprUnary(ast::UnOp::UnUniq, _) => {
|
||||
self.gate_feature("box_syntax",
|
||||
e.span,
|
||||
"box expression syntax is experimental in alpha release; \
|
||||
you can call `Box::new` instead.");
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
visit::walk_expr(self, e);
|
||||
}
|
||||
|
||||
@ -357,6 +367,11 @@ impl<'a, 'v> Visitor<'v> for PostExpansionVisitor<'a> {
|
||||
but at the end of a slice (e.g. \
|
||||
`[0, ..xs, 0]` are experimental")
|
||||
}
|
||||
ast::PatBox(..) => {
|
||||
self.gate_feature("box_syntax",
|
||||
pattern.span,
|
||||
"box pattern syntax is experimental in alpha release");
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
visit::walk_pat(self, pattern)
|
||||
|
@ -25,6 +25,7 @@
|
||||
|
||||
#![allow(unknown_features)]
|
||||
#![feature(slicing_syntax)]
|
||||
#![feature(box_syntax)]
|
||||
#![feature(quote, unsafe_destructor)]
|
||||
|
||||
extern crate arena;
|
||||
|
@ -50,6 +50,7 @@
|
||||
|
||||
#![allow(unknown_features)]
|
||||
#![feature(slicing_syntax)]
|
||||
#![feature(box_syntax)]
|
||||
#![deny(missing_docs)]
|
||||
|
||||
#[macro_use] extern crate log;
|
||||
|
@ -31,7 +31,9 @@
|
||||
#![doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
|
||||
html_favicon_url = "http://www.rust-lang.org/favicon.ico",
|
||||
html_root_url = "http://doc.rust-lang.org/nightly/")]
|
||||
#![allow(unknown_features)]
|
||||
#![feature(asm, slicing_syntax)]
|
||||
#![feature(box_syntax)]
|
||||
|
||||
extern crate getopts;
|
||||
extern crate regex;
|
||||
|
@ -8,6 +8,8 @@
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
#![allow(unknown_features)]
|
||||
#![feature(box_syntax)]
|
||||
|
||||
use std::cell::RefCell;
|
||||
|
||||
|
@ -11,6 +11,8 @@
|
||||
#![crate_name="a"]
|
||||
#![crate_type = "lib"]
|
||||
|
||||
#![allow(unknown_features)]
|
||||
#![feature(box_syntax)]
|
||||
|
||||
pub trait i<T> { }
|
||||
|
||||
|
@ -10,6 +10,9 @@
|
||||
|
||||
#![crate_type = "lib"]
|
||||
|
||||
#![allow(unknown_features)]
|
||||
#![feature(box_syntax)]
|
||||
|
||||
static mut COUNT: u64 = 1;
|
||||
|
||||
pub fn get_count() -> u64 { unsafe { COUNT } }
|
||||
|
@ -10,6 +10,9 @@
|
||||
|
||||
#![crate_type = "lib"]
|
||||
|
||||
#![allow(unknown_features)]
|
||||
#![feature(box_syntax)]
|
||||
|
||||
static mut COUNT: u64 = 1;
|
||||
|
||||
pub fn get_count() -> u64 { unsafe { COUNT } }
|
||||
|
@ -8,6 +8,9 @@
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
#![allow(unknown_features)]
|
||||
#![feature(box_syntax)]
|
||||
|
||||
struct clam {
|
||||
x: Box<isize>,
|
||||
y: Box<isize>,
|
||||
|
@ -8,6 +8,9 @@
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
#![allow(unknown_features)]
|
||||
#![feature(box_syntax)]
|
||||
|
||||
struct Foo(Box<int>, int);
|
||||
|
||||
struct Bar(int, int);
|
||||
|
@ -8,6 +8,9 @@
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
#![allow(unknown_features)]
|
||||
#![feature(box_syntax)]
|
||||
|
||||
fn f() {
|
||||
let mut a = [box 0i, box 1i];
|
||||
drop(a[0]);
|
||||
|
@ -8,6 +8,8 @@
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
#![feature(box_syntax)]
|
||||
|
||||
use std::ops::Add;
|
||||
|
||||
#[derive(Clone)]
|
||||
|
@ -9,6 +9,7 @@
|
||||
// except according to those terms.
|
||||
|
||||
#![feature(advanced_slice_patterns)]
|
||||
#![feature(box_syntax)]
|
||||
|
||||
fn a() {
|
||||
let mut vec = [box 1i, box 2, box 3];
|
||||
|
@ -11,6 +11,8 @@
|
||||
// The regression test for #15031 to make sure destructuring trait
|
||||
// reference work properly.
|
||||
|
||||
#![feature(box_syntax)]
|
||||
|
||||
trait T {}
|
||||
impl T for int {}
|
||||
|
||||
|
23
src/test/compile-fail/feature-gate-box-expr.rs
Normal file
23
src/test/compile-fail/feature-gate-box-expr.rs
Normal file
@ -0,0 +1,23 @@
|
||||
// Copyright 2015 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() {
|
||||
use std::boxed::HEAP;
|
||||
|
||||
let x = box 'c'; //~ ERROR box expression syntax is experimental in alpha release
|
||||
println!("x: {}", x);
|
||||
|
||||
let x = box () 'c'; //~ ERROR box expression syntax is experimental in alpha release
|
||||
println!("x: {}", x);
|
||||
|
||||
let x = box (HEAP) 'c'; //~ ERROR box expression syntax is experimental in alpha release
|
||||
println!("x: {}", x);
|
||||
}
|
||||
|
14
src/test/compile-fail/feature-gate-box-pat.rs
Normal file
14
src/test/compile-fail/feature-gate-box-pat.rs
Normal file
@ -0,0 +1,14 @@
|
||||
// Copyright 2015 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 box x = Box::new('c'); //~ ERROR box pattern syntax is experimental in alpha release
|
||||
println!("x: {}", x);
|
||||
}
|
@ -8,6 +8,8 @@
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
#![feature(box_syntax)]
|
||||
|
||||
enum IntList {
|
||||
Cons(int, Box<IntList>),
|
||||
Nil
|
||||
|
@ -8,6 +8,8 @@
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
#![feature(box_syntax)]
|
||||
|
||||
fn main() {
|
||||
box ( () ) 0;
|
||||
//~^ ERROR: only the managed heap and exchange heap are currently supported
|
||||
|
@ -8,6 +8,7 @@
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
#![feature(box_syntax)]
|
||||
|
||||
struct HTMLImageData {
|
||||
image: Option<String>
|
||||
|
@ -8,6 +8,7 @@
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
#![feature(box_syntax)]
|
||||
|
||||
trait MyTrait { }
|
||||
|
||||
|
@ -8,6 +8,8 @@
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
#![feature(box_syntax)]
|
||||
|
||||
enum A { B, C }
|
||||
|
||||
fn main() {
|
||||
|
@ -10,6 +10,8 @@
|
||||
|
||||
// ignore-tidy-linelength
|
||||
|
||||
#![feature(box_syntax)]
|
||||
|
||||
struct S {
|
||||
x: Box<E>
|
||||
}
|
||||
|
@ -8,6 +8,7 @@
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
#![feature(box_syntax)]
|
||||
|
||||
fn arg_item(box ref x: Box<int>) -> &'static int {
|
||||
x //~^ ERROR borrowed value does not live long enough
|
||||
|
@ -10,6 +10,7 @@
|
||||
|
||||
// error-pattern:unreachable pattern
|
||||
|
||||
#![feature(box_syntax)]
|
||||
|
||||
enum foo { a(Box<foo>, int), b(uint), }
|
||||
|
||||
|
@ -11,6 +11,9 @@
|
||||
|
||||
// error-pattern:meep
|
||||
|
||||
#![allow(unknown_features)]
|
||||
#![feature(box_syntax)]
|
||||
|
||||
fn f(_a: int, _b: int, _c: Box<int>) { panic!("moop"); }
|
||||
|
||||
fn main() { f(1, panic!("meep"), box 42); }
|
||||
|
@ -10,6 +10,9 @@
|
||||
|
||||
// error-pattern:panicked at 'Box<Any>'
|
||||
|
||||
#![allow(unknown_features)]
|
||||
#![feature(box_syntax)]
|
||||
|
||||
fn main() {
|
||||
panic!(box 612_i64);
|
||||
}
|
||||
|
@ -10,6 +10,9 @@
|
||||
|
||||
// error-pattern:panicked at 'Box<Any>'
|
||||
|
||||
#![allow(unknown_features)]
|
||||
#![feature(box_syntax)]
|
||||
|
||||
fn main() {
|
||||
panic!(box 413i as Box<::std::any::Any+Send>);
|
||||
}
|
||||
|
@ -9,4 +9,8 @@
|
||||
// except according to those terms.
|
||||
|
||||
// error-pattern: panic
|
||||
|
||||
#![allow(unknown_features)]
|
||||
#![feature(box_syntax)]
|
||||
|
||||
fn main() { box panic!(); }
|
||||
|
@ -10,6 +10,8 @@
|
||||
|
||||
// error-pattern:fail
|
||||
|
||||
#![allow(unknown_features)]
|
||||
#![feature(box_syntax)]
|
||||
|
||||
fn failfn() {
|
||||
panic!();
|
||||
|
@ -8,6 +8,9 @@
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
#![allow(unknown_features)]
|
||||
#![feature(box_syntax)]
|
||||
|
||||
struct pair<A,B> {
|
||||
a: A, b: B
|
||||
}
|
||||
|
@ -8,6 +8,8 @@
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
#![allow(unknown_features)]
|
||||
#![feature(box_syntax)]
|
||||
|
||||
#[derive(PartialEq, Show)]
|
||||
struct Point { x : int }
|
||||
|
@ -8,6 +8,9 @@
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
#![allow(unknown_features)]
|
||||
#![feature(box_syntax)]
|
||||
|
||||
fn pairwise_sub(mut t: Box<DoubleEndedIterator<Item=int>>) -> int {
|
||||
let mut result = 0;
|
||||
loop {
|
||||
|
@ -8,6 +8,8 @@
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
#![allow(unknown_features)]
|
||||
#![feature(box_syntax)]
|
||||
|
||||
trait double {
|
||||
fn double(self: Box<Self>) -> uint;
|
||||
|
@ -8,6 +8,8 @@
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
#![allow(unknown_features)]
|
||||
#![feature(box_syntax)]
|
||||
|
||||
trait double {
|
||||
fn double(self) -> uint;
|
||||
|
@ -8,6 +8,8 @@
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
#![allow(unknown_features)]
|
||||
#![feature(box_syntax)]
|
||||
|
||||
trait double {
|
||||
fn double(self: Box<Self>) -> uint;
|
||||
|
@ -8,6 +8,9 @@
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
#![allow(unknown_features)]
|
||||
#![feature(box_syntax)]
|
||||
|
||||
trait double {
|
||||
fn double(self: Box<Self>) -> uint;
|
||||
}
|
||||
|
@ -8,6 +8,9 @@
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
#![allow(unknown_features)]
|
||||
#![feature(box_syntax)]
|
||||
|
||||
trait double {
|
||||
fn double(self: Box<Self>) -> uint;
|
||||
}
|
||||
|
@ -9,6 +9,9 @@
|
||||
// except according to those terms.
|
||||
|
||||
|
||||
#![allow(unknown_features)]
|
||||
#![feature(box_syntax)]
|
||||
|
||||
trait Foo {
|
||||
fn foo(&self) -> String;
|
||||
}
|
||||
|
@ -9,6 +9,9 @@
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
#![allow(unknown_features)]
|
||||
#![feature(box_syntax)]
|
||||
|
||||
extern crate collections;
|
||||
use std::collections::Bitv;
|
||||
|
||||
|
@ -8,6 +8,8 @@
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
#![allow(unknown_features)]
|
||||
#![feature(box_syntax)]
|
||||
|
||||
fn borrow<F>(x: &int, f: F) where F: FnOnce(&int) {
|
||||
f(x)
|
||||
|
@ -8,6 +8,9 @@
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
#![allow(unknown_features)]
|
||||
#![feature(box_syntax)]
|
||||
|
||||
struct A { a: int, b: Box<int> }
|
||||
struct B { a: Box<int>, b: Box<int> }
|
||||
|
||||
|
@ -11,6 +11,7 @@
|
||||
// Check that we do not ICE when compiling this
|
||||
// macro, which reuses the expression `$id`
|
||||
|
||||
#![feature(box_syntax)]
|
||||
|
||||
struct Foo {
|
||||
a: int
|
||||
|
@ -8,6 +8,8 @@
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
#![allow(unknown_features)]
|
||||
#![feature(box_syntax)]
|
||||
#![feature(unboxed_closures)]
|
||||
|
||||
pub fn main() {
|
||||
|
@ -8,6 +8,9 @@
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
#![allow(unknown_features)]
|
||||
#![feature(box_syntax)]
|
||||
|
||||
use std::mem::swap;
|
||||
|
||||
#[derive(Show)]
|
||||
|
@ -8,6 +8,9 @@
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
#![allow(unknown_features)]
|
||||
#![feature(box_syntax)]
|
||||
|
||||
struct A { a: int, b: Box<int> }
|
||||
|
||||
fn field_copy_after_field_borrow() {
|
||||
|
@ -8,6 +8,8 @@
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
#![allow(unknown_features)]
|
||||
#![feature(box_syntax)]
|
||||
|
||||
fn foo(x: &mut Box<u8>) {
|
||||
*x = box 5;
|
||||
|
@ -11,6 +11,9 @@
|
||||
// ignore-android (FIXME #11419)
|
||||
// exec-env:RUST_LOG=info
|
||||
|
||||
#![allow(unknown_features)]
|
||||
#![feature(box_syntax)]
|
||||
|
||||
#[macro_use]
|
||||
extern crate log;
|
||||
|
||||
|
@ -10,6 +10,8 @@
|
||||
|
||||
// aux-build:cci_borrow_lib.rs
|
||||
|
||||
#![allow(unknown_features)]
|
||||
#![feature(box_syntax)]
|
||||
|
||||
extern crate cci_borrow_lib;
|
||||
use cci_borrow_lib::foo;
|
||||
|
@ -9,6 +9,10 @@
|
||||
// except according to those terms.
|
||||
|
||||
// aux-build:cci_class_cast.rs
|
||||
|
||||
#![allow(unknown_features)]
|
||||
#![feature(box_syntax)]
|
||||
|
||||
extern crate cci_class_cast;
|
||||
|
||||
use std::string::ToString;
|
||||
|
@ -8,6 +8,9 @@
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
#![allow(unknown_features)]
|
||||
#![feature(box_syntax)]
|
||||
|
||||
use std::fmt;
|
||||
|
||||
struct cat {
|
||||
|
@ -21,6 +21,9 @@
|
||||
// Test that cleanup scope for temporaries created in a match
|
||||
// arm is confined to the match arm itself.
|
||||
|
||||
#![allow(unknown_features)]
|
||||
#![feature(box_syntax)]
|
||||
|
||||
use std::os;
|
||||
|
||||
struct Test { x: int }
|
||||
|
@ -12,6 +12,8 @@
|
||||
// This test verifies that temporaries created for `while`'s and `if`
|
||||
// conditions are dropped after the condition is evaluated.
|
||||
|
||||
#![allow(unknown_features)]
|
||||
#![feature(box_syntax)]
|
||||
|
||||
struct Temporary;
|
||||
|
||||
|
@ -12,6 +12,8 @@
|
||||
// statement or end of block, as appropriate given the temporary
|
||||
// lifetime rules.
|
||||
|
||||
#![feature(box_syntax)]
|
||||
|
||||
use std::ops::Drop;
|
||||
|
||||
static mut FLAGS: u64 = 0;
|
||||
|
@ -24,6 +24,9 @@
|
||||
// It's unclear how likely such a bug is to recur, but it seems like a
|
||||
// scenario worth testing.
|
||||
|
||||
#![allow(unknown_features)]
|
||||
#![feature(box_syntax)]
|
||||
|
||||
use std::thread::Thread;
|
||||
|
||||
enum Conzabble {
|
||||
|
@ -8,6 +8,9 @@
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
#![allow(unknown_features)]
|
||||
#![feature(box_syntax)]
|
||||
|
||||
use std::thread::Thread;
|
||||
|
||||
struct Pair {
|
||||
|
@ -12,6 +12,9 @@
|
||||
// storing closure data (as we used to do), the u64 would
|
||||
// overwrite the u16.
|
||||
|
||||
#![allow(unknown_features)]
|
||||
#![feature(box_syntax)]
|
||||
|
||||
struct Pair<A,B> {
|
||||
a: A, b: B
|
||||
}
|
||||
|
@ -8,6 +8,9 @@
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
#![allow(unknown_features)]
|
||||
#![feature(box_syntax)]
|
||||
|
||||
use std::fmt::Show;
|
||||
|
||||
// Check that coercions apply at the pointer level and don't cause
|
||||
|
23
src/test/run-pass/coerce-match-calls.rs
Normal file
23
src/test/run-pass/coerce-match-calls.rs
Normal 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.
|
||||
|
||||
// Check that coercions are propagated through match and if expressions.
|
||||
|
||||
use std::boxed::Box;
|
||||
|
||||
pub fn main() {
|
||||
let _: Box<[int]> = if true { Box::new([1i, 2, 3]) } else { Box::new([1i]) };
|
||||
|
||||
let _: Box<[int]> = match true { true => Box::new([1i, 2, 3]), false => Box::new([1i]) };
|
||||
|
||||
// Check we don't get over-keen at propagating coercions in the case of casts.
|
||||
let x = if true { 42 } else { 42u8 } as u16;
|
||||
let x = match true { true => 42, false => 42u8 } as u16;
|
||||
}
|
@ -10,6 +10,9 @@
|
||||
|
||||
// Check that coercions are propagated through match and if expressions.
|
||||
|
||||
#![allow(unknown_features)]
|
||||
#![feature(box_syntax)]
|
||||
|
||||
pub fn main() {
|
||||
let _: Box<[int]> = if true { box [1i, 2, 3] } else { box [1i] };
|
||||
|
||||
|
@ -11,6 +11,8 @@
|
||||
// Make sure const bounds work on things, and test that a few types
|
||||
// are const.
|
||||
|
||||
#![allow(unknown_features)]
|
||||
#![feature(box_syntax)]
|
||||
|
||||
fn foo<T: Sync>(x: T) -> T { x }
|
||||
|
||||
|
@ -8,6 +8,8 @@
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
#![allow(unknown_features)]
|
||||
#![feature(box_syntax)]
|
||||
|
||||
// This is a regression test that the metadata for the
|
||||
// name_pool::methods impl in the other crate is reachable from this
|
||||
|
@ -8,6 +8,8 @@
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
#![allow(unknown_features)]
|
||||
#![feature(box_syntax)]
|
||||
|
||||
use std::cell::Cell;
|
||||
|
||||
|
@ -8,6 +8,8 @@
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
#![allow(unknown_features)]
|
||||
#![feature(box_syntax)]
|
||||
|
||||
pub fn main() {
|
||||
let x: Box<int> = box 10;
|
||||
|
@ -8,6 +8,9 @@
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
#![allow(unknown_features)]
|
||||
#![feature(box_syntax)]
|
||||
|
||||
use std::default::Default;
|
||||
|
||||
#[derive(Default)]
|
||||
|
@ -8,6 +8,8 @@
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
#![allow(unknown_features)]
|
||||
#![feature(box_syntax)]
|
||||
#![feature(old_orphan_check)]
|
||||
|
||||
extern crate serialize;
|
||||
|
@ -8,6 +8,9 @@
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
#![allow(unknown_features)]
|
||||
#![feature(box_syntax)]
|
||||
|
||||
#[derive(PartialEq, PartialOrd, Eq, Ord)]
|
||||
struct Foo(Box<[u8]>);
|
||||
|
||||
|
@ -8,6 +8,8 @@
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
#![allow(unknown_features)]
|
||||
#![feature(box_syntax)]
|
||||
|
||||
enum t { foo(Box<int>), }
|
||||
|
||||
|
@ -11,6 +11,9 @@
|
||||
// Test that destructor on a struct runs successfully after the struct
|
||||
// is boxed and converted to an object.
|
||||
|
||||
#![allow(unknown_features)]
|
||||
#![feature(box_syntax)]
|
||||
|
||||
static mut value: uint = 0;
|
||||
|
||||
struct Cat {
|
||||
|
@ -8,6 +8,9 @@
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
#![allow(unknown_features)]
|
||||
#![feature(box_syntax)]
|
||||
|
||||
use std::thread::Thread;
|
||||
use std::sync::mpsc::{channel, Sender};
|
||||
|
||||
|
@ -10,6 +10,9 @@
|
||||
|
||||
// Test that a custom deref with a fat pointer return type does not ICE
|
||||
|
||||
#![allow(unknown_features)]
|
||||
#![feature(box_syntax)]
|
||||
|
||||
use std::ops::{Deref, DerefMut};
|
||||
|
||||
pub struct Arr {
|
||||
|
@ -10,6 +10,9 @@
|
||||
|
||||
// Test that a custom deref with a fat pointer return type does not ICE
|
||||
|
||||
#![allow(unknown_features)]
|
||||
#![feature(box_syntax)]
|
||||
|
||||
use std::ops::Deref;
|
||||
|
||||
pub struct Arr {
|
||||
|
@ -8,6 +8,9 @@
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
#![allow(unknown_features)]
|
||||
#![feature(box_syntax)]
|
||||
|
||||
struct Fat<T: ?Sized> {
|
||||
f1: int,
|
||||
f2: &'static str,
|
||||
|
@ -8,6 +8,9 @@
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
#![allow(unknown_features)]
|
||||
#![feature(box_syntax)]
|
||||
|
||||
struct Fat<T: ?Sized> {
|
||||
f1: int,
|
||||
f2: &'static str,
|
||||
|
@ -8,6 +8,9 @@
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
#![allow(unknown_features)]
|
||||
#![feature(box_syntax)]
|
||||
|
||||
pub fn main() {
|
||||
assert!(Some(box() ()).is_some());
|
||||
|
||||
|
@ -8,6 +8,9 @@
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
#![allow(unknown_features)]
|
||||
#![feature(box_syntax)]
|
||||
|
||||
pub fn main() {
|
||||
let x = *box() ();
|
||||
}
|
||||
|
@ -8,6 +8,8 @@
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
#![allow(unknown_features)]
|
||||
#![feature(box_syntax)]
|
||||
|
||||
/*!
|
||||
* This is a regression test for a bug in LLVM, fixed in upstream r179587,
|
||||
|
@ -8,6 +8,9 @@
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
#![allow(unknown_features)]
|
||||
#![feature(box_syntax)]
|
||||
|
||||
struct LM { resize_at: uint, size: uint }
|
||||
|
||||
impl Copy for LM {}
|
||||
|
@ -8,6 +8,8 @@
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
#![allow(unknown_features)]
|
||||
#![feature(box_syntax)]
|
||||
|
||||
trait Foo {
|
||||
fn f(self: Box<Self>);
|
||||
|
@ -8,6 +8,9 @@
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
#![allow(unknown_features)]
|
||||
#![feature(box_syntax)]
|
||||
|
||||
static tau: f64 = 2.0*3.14159265358979323;
|
||||
|
||||
struct Point {x: f64, y: f64}
|
||||
|
@ -8,6 +8,9 @@
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
#![allow(unknown_features)]
|
||||
#![feature(box_syntax)]
|
||||
|
||||
fn test_generic<T, F>(expected: Box<T>, eq: F) where T: Clone, F: FnOnce(Box<T>, Box<T>) -> bool {
|
||||
let actual: Box<T> = { expected.clone() };
|
||||
assert!(eq(expected, actual));
|
||||
|
@ -8,6 +8,9 @@
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
#![allow(unknown_features)]
|
||||
#![feature(box_syntax)]
|
||||
|
||||
fn test_generic<T, F>(expected: T, eq: F) where T: Clone, F: FnOnce(T, T) -> bool {
|
||||
let actual: T = { expected.clone() };
|
||||
assert!(eq(expected, actual));
|
||||
|
@ -9,6 +9,7 @@
|
||||
// except according to those terms.
|
||||
|
||||
|
||||
|
||||
#![allow(unknown_features)]
|
||||
#![feature(box_syntax)]
|
||||
|
||||
pub fn main() { let x = { box 100i }; assert!((*x == 100)); }
|
||||
|
@ -9,7 +9,8 @@
|
||||
// except according to those terms.
|
||||
|
||||
|
||||
|
||||
#![allow(unknown_features)]
|
||||
#![feature(box_syntax)]
|
||||
|
||||
|
||||
// Tests for if as expressions returning boxed types
|
||||
|
@ -8,6 +8,9 @@
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
#![allow(unknown_features)]
|
||||
#![feature(box_syntax)]
|
||||
|
||||
fn test_generic<T: Clone, F>(expected: Box<T>, eq: F) where F: FnOnce(Box<T>, Box<T>) -> bool {
|
||||
let actual: Box<T> = match true {
|
||||
true => { expected.clone() },
|
||||
|
@ -8,6 +8,9 @@
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
#![allow(unknown_features)]
|
||||
#![feature(box_syntax)]
|
||||
|
||||
fn test_generic<T: Clone, F>(expected: T, eq: F) where F: FnOnce(T, T) -> bool {
|
||||
let actual: T = match true {
|
||||
true => expected.clone(),
|
||||
|
@ -8,6 +8,8 @@
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
#![allow(unknown_features)]
|
||||
#![feature(box_syntax)]
|
||||
|
||||
// Tests for match as expressions resulting in boxed types
|
||||
fn test_box() {
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user