Skip to content

Use box syntax in vec! macro #31797

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 3, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/libcollections/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
#![cfg_attr(not(stage0), deny(warnings))]

#![feature(alloc)]
#![feature(allow_internal_unstable)]
#![feature(box_patterns)]
#![feature(box_syntax)]
#![feature(core_intrinsics)]
Expand Down
5 changes: 3 additions & 2 deletions src/libcollections/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,13 @@
#[cfg(not(test))]
#[macro_export]
#[stable(feature = "rust1", since = "1.0.0")]
#[allow_internal_unstable]
macro_rules! vec {
($elem:expr; $n:expr) => (
$crate::vec::from_elem($elem, $n)
);
($($x:expr),*) => (
<[_]>::into_vec($crate::boxed::Box::new([$($x),*]))
<[_]>::into_vec(box [$($x),*])
);
($($x:expr,)*) => (vec![$($x),*])
}
Expand All @@ -61,7 +62,7 @@ macro_rules! vec {
$crate::vec::from_elem($elem, $n)
);
($($x:expr),*) => (
$crate::slice::into_vec($crate::boxed::Box::new([$($x),*]))
$crate::slice::into_vec(box [$($x),*])
);
($($x:expr,)*) => (vec![$($x),*])
}
Expand Down
3 changes: 0 additions & 3 deletions src/test/run-pass/borrow-by-val-method-receiver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.


// pretty-expanded FIXME #23616

trait Foo {
fn foo(self);
}
Expand Down
3 changes: 0 additions & 3 deletions src/test/run-pass/borrowck/borrowck-binding-mutbl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.


// pretty-expanded FIXME #23616

struct F { f: Vec<isize> }

fn impure(_v: &[isize]) {
Expand Down
2 changes: 0 additions & 2 deletions src/test/run-pass/generic-ivec-leak.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

// pretty-expanded FIXME #23616

enum wrapper<T> { wrapped(T), }

pub fn main() { let _w = wrapper::wrapped(vec!(1, 2, 3, 4, 5)); }
2 changes: 0 additions & 2 deletions src/test/run-pass/issue-17816.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

// pretty-expanded FIXME #23616

#![feature(unboxed_closures)]

use std::marker::PhantomData;
Expand Down
1 change: 0 additions & 1 deletion src/test/run-pass/issue-18514.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
// impl.

// aux-build:issue-18514.rs
// pretty-expanded FIXME #23616

extern crate issue_18514 as ice;
use ice::{Tr, St};
Expand Down
2 changes: 0 additions & 2 deletions src/test/run-pass/issue-2631-b.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@

// aux-build:issue-2631-a.rs

// pretty-expanded FIXME #23616

extern crate req;

use req::request;
Expand Down
2 changes: 0 additions & 2 deletions src/test/run-pass/issue-2723-b.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@

// aux-build:issue_2723_a.rs

// pretty-expanded FIXME #23616

extern crate issue_2723_a;
use issue_2723_a::f;

Expand Down
23 changes: 23 additions & 0 deletions src/test/run-pass/issue-28950.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// Copyright 2012-2016 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.

// Tests that the `vec!` macro does not overflow the stack when it is
// given data larger than the stack.

const LEN: usize = 1 << 15;

use std::thread::Builder;

fn main() {
assert!(Builder::new().stack_size(LEN / 2).spawn(|| {
let vec = vec![[0; LEN]];
assert_eq!(vec.len(), 1);
}).unwrap().join().is_ok());
}
3 changes: 0 additions & 3 deletions src/test/run-pass/ivec-pass-by-value.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,5 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.


// pretty-expanded FIXME #23616

fn f(_a: Vec<isize> ) { }
pub fn main() { f(vec!(1, 2, 3, 4, 5)); }
1 change: 0 additions & 1 deletion src/test/run-pass/ivec-tag.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

// pretty-expanded FIXME #23616
// ignore-emscripten no threads support

#![feature(std_misc)]
Expand Down
2 changes: 0 additions & 2 deletions src/test/run-pass/macro-delimiter-significance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

// pretty-expanded FIXME #23616

fn main() {
vec![1_usize, 2, 3].len();
}
3 changes: 0 additions & 3 deletions src/test/run-pass/regions-dependent-autoslice.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@
// Test lifetimes are linked properly when we autoslice a vector.
// Issue #3148.


// pretty-expanded FIXME #23616

fn subslice1<'r>(v: &'r [usize]) -> &'r [usize] { v }

fn both<'r>(v: &'r [usize]) -> &'r [usize] {
Expand Down
2 changes: 0 additions & 2 deletions src/test/run-pass/vec-push.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,4 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

// pretty-expanded FIXME #23616

pub fn main() { let mut v = vec!(1, 2, 3); v.push(1); }