1
Fork 0

Put slicing syntax behind a feature gate.

[breaking-change]

If you are using slicing syntax you will need to add #![feature(slicing_syntax)] to your crate.
This commit is contained in:
Nick Cameron 2014-09-26 17:48:16 +12:00
parent 59976942ea
commit 2d3823441f
41 changed files with 101 additions and 39 deletions

View file

@ -9,7 +9,7 @@
// except according to those terms. // except according to those terms.
#![crate_type = "bin"] #![crate_type = "bin"]
#![feature(phase)] #![feature(phase, slicing_syntax)]
#![deny(warnings)] #![deny(warnings)]

View file

@ -3837,7 +3837,7 @@ type signature of `print`, and the cast expression in `main`.
Within the body of an item that has type parameter declarations, the names of Within the body of an item that has type parameter declarations, the names of
its type parameters are types: its type parameters are types:
``` ```ignore
fn map<A: Clone, B: Clone>(f: |A| -> B, xs: &[A]) -> Vec<B> { fn map<A: Clone, B: Clone>(f: |A| -> B, xs: &[A]) -> Vec<B> {
if xs.len() == 0 { if xs.len() == 0 {
return vec![]; return vec![];

View file

@ -19,8 +19,9 @@
html_root_url = "http://doc.rust-lang.org/master/", html_root_url = "http://doc.rust-lang.org/master/",
html_playground_url = "http://play.rust-lang.org/")] html_playground_url = "http://play.rust-lang.org/")]
#![allow(unknown_features)]
#![feature(macro_rules, default_type_params, phase, globs)] #![feature(macro_rules, default_type_params, phase, globs)]
#![feature(unsafe_destructor, import_shadowing)] #![feature(unsafe_destructor, import_shadowing, slicing_syntax)]
#![no_std] #![no_std]
#[phase(plugin, link)] extern crate core; #[phase(plugin, link)] extern crate core;

View file

@ -52,9 +52,12 @@
//! interval `[a, b)`: //! interval `[a, b)`:
//! //!
//! ```rust //! ```rust
//! let numbers = [0i, 1i, 2i]; //! #![feature(slicing_syntax)]
//! let last_numbers = numbers[1..3]; //! fn main() {
//! // last_numbers is now &[1i, 2i] //! let numbers = [0i, 1i, 2i];
//! let last_numbers = numbers[1..3];
//! // last_numbers is now &[1i, 2i]
//! }
//! ``` //! ```
//! //!
//! ## Implementations of other traits //! ## Implementations of other traits

View file

@ -57,8 +57,9 @@
html_playground_url = "http://play.rust-lang.org/")] html_playground_url = "http://play.rust-lang.org/")]
#![no_std] #![no_std]
#![allow(unknown_features)]
#![feature(globs, intrinsics, lang_items, macro_rules, phase)] #![feature(globs, intrinsics, lang_items, macro_rules, phase)]
#![feature(simd, unsafe_destructor)] #![feature(simd, unsafe_destructor, slicing_syntax)]
#![deny(missing_doc)] #![deny(missing_doc)]
mod macros; mod macros;

View file

@ -684,7 +684,7 @@ pub trait IndexMut<Index, Result> {
* A trivial implementation of `Slice`. When `Foo[..Foo]` happens, it ends up * A trivial implementation of `Slice`. When `Foo[..Foo]` happens, it ends up
* calling `slice_to`, and therefore, `main` prints `Slicing!`. * calling `slice_to`, and therefore, `main` prints `Slicing!`.
* *
* ``` * ```ignore
* struct Foo; * struct Foo;
* *
* impl ::core::ops::Slice<Foo, Foo> for Foo { * impl ::core::ops::Slice<Foo, Foo> for Foo {
@ -734,7 +734,7 @@ pub trait Slice<Idx, Sized? Result> for Sized? {
* A trivial implementation of `SliceMut`. When `Foo[Foo..]` happens, it ends up * A trivial implementation of `SliceMut`. When `Foo[Foo..]` happens, it ends up
* calling `slice_from_mut`, and therefore, `main` prints `Slicing!`. * calling `slice_from_mut`, and therefore, `main` prints `Slicing!`.
* *
* ``` * ```ignore
* struct Foo; * struct Foo;
* *
* impl ::core::ops::SliceMut<Foo, Foo> for Foo { * impl ::core::ops::SliceMut<Foo, Foo> for Foo {
@ -756,7 +756,7 @@ pub trait Slice<Idx, Sized? Result> for Sized? {
* } * }
* } * }
* *
* fn main() { * pub fn main() {
* Foo[mut Foo..]; * Foo[mut Foo..];
* } * }
* ``` * ```

View file

@ -7,7 +7,7 @@
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed // option. This file may not be copied, modified, or distributed
// except according to those terms. // except according to those terms.
#![feature(globs, unsafe_destructor, macro_rules)] #![feature(globs, unsafe_destructor, macro_rules, slicing_syntax)]
extern crate core; extern crate core;
extern crate test; extern crate test;

View file

@ -57,7 +57,8 @@
#![deny(unused_result, unused_must_use)] #![deny(unused_result, unused_must_use)]
#![allow(non_camel_case_types, deprecated)] #![allow(non_camel_case_types, deprecated)]
#![feature(default_type_params, lang_items)] #![allow(unknown_features)]
#![feature(default_type_params, lang_items, slicing_syntax)]
// NB this crate explicitly does *not* allow glob imports, please seriously // NB this crate explicitly does *not* allow glob imports, please seriously
// consider whether they're needed before adding that feature here (the // consider whether they're needed before adding that feature here (the

View file

@ -43,7 +43,8 @@
//! //!
//! [newt]: https://en.wikipedia.org/wiki/Methods_of_computing_square_roots#Babylonian_method //! [newt]: https://en.wikipedia.org/wiki/Methods_of_computing_square_roots#Babylonian_method
#![feature(macro_rules)] #![allow(unknown_features)]
#![feature(macro_rules, slicing_syntax)]
#![feature(default_type_params)] #![feature(default_type_params)]
#![crate_name = "num"] #![crate_name = "num"]

View file

@ -24,7 +24,8 @@
html_favicon_url = "http://www.rust-lang.org/favicon.ico", html_favicon_url = "http://www.rust-lang.org/favicon.ico",
html_root_url = "http://doc.rust-lang.org/master/", html_root_url = "http://doc.rust-lang.org/master/",
html_playground_url = "http://play.rust-lang.org/")] html_playground_url = "http://play.rust-lang.org/")]
#![feature(macro_rules, phase)] #![allow(unknown_features)]
#![feature(macro_rules, phase, slicing_syntax)]
#![allow(missing_doc)] #![allow(missing_doc)]
extern crate serialize; extern crate serialize;

View file

@ -368,7 +368,8 @@
html_root_url = "http://doc.rust-lang.org/master/", html_root_url = "http://doc.rust-lang.org/master/",
html_playground_url = "http://play.rust-lang.org/")] html_playground_url = "http://play.rust-lang.org/")]
#![feature(macro_rules, phase)] #![allow(unknown_features)]
#![feature(macro_rules, phase, slicing_syntax)]
#![deny(missing_doc)] #![deny(missing_doc)]
#[cfg(test)] #[cfg(test)]

View file

@ -29,8 +29,9 @@ This API is completely unstable and subject to change.
html_root_url = "http://doc.rust-lang.org/master/")] html_root_url = "http://doc.rust-lang.org/master/")]
#![allow(deprecated)] #![allow(deprecated)]
#![allow(unknown_features)]
#![feature(macro_rules, globs, struct_variant, quote)] #![feature(macro_rules, globs, struct_variant, quote)]
#![feature(default_type_params, phase, unsafe_destructor)] #![feature(default_type_params, phase, unsafe_destructor, slicing_syntax)]
#![feature(rustc_diagnostic_macros)] #![feature(rustc_diagnostic_macros)]
#![feature(import_shadowing)] #![feature(import_shadowing)]

View file

@ -31,7 +31,8 @@
html_favicon_url = "http://www.rust-lang.org/favicon.ico", html_favicon_url = "http://www.rust-lang.org/favicon.ico",
html_root_url = "http://doc.rust-lang.org/")] html_root_url = "http://doc.rust-lang.org/")]
#![feature(globs, phase, macro_rules)] #![allow(unknown_features)]
#![feature(globs, phase, macro_rules, slicing_syntax)]
#[phase(plugin, link)] #[phase(plugin, link)]
extern crate log; extern crate log;

View file

@ -15,7 +15,8 @@
#![crate_type = "dylib"] #![crate_type = "dylib"]
#![crate_type = "rlib"] #![crate_type = "rlib"]
#![feature(globs, struct_variant, macro_rules, phase)] #![allow(unknown_features)]
#![feature(globs, struct_variant, macro_rules, phase, slicing_syntax)]
extern crate arena; extern crate arena;
extern crate debug; extern crate debug;

View file

@ -16,9 +16,10 @@
html_favicon_url = "http://www.rust-lang.org/favicon.ico", html_favicon_url = "http://www.rust-lang.org/favicon.ico",
html_root_url = "http://doc.rust-lang.org/master/")] html_root_url = "http://doc.rust-lang.org/master/")]
#![allow(unknown_features)]
#![feature(macro_rules, phase, globs, thread_local, asm)] #![feature(macro_rules, phase, globs, thread_local, asm)]
#![feature(linkage, lang_items, unsafe_destructor, default_type_params)] #![feature(linkage, lang_items, unsafe_destructor, default_type_params)]
#![feature(import_shadowing)] #![feature(import_shadowing, slicing_syntax)]
#![no_std] #![no_std]
#![experimental] #![experimental]

View file

@ -23,7 +23,8 @@ Core encoding and decoding interfaces.
html_favicon_url = "http://www.rust-lang.org/favicon.ico", html_favicon_url = "http://www.rust-lang.org/favicon.ico",
html_root_url = "http://doc.rust-lang.org/master/", html_root_url = "http://doc.rust-lang.org/master/",
html_playground_url = "http://play.rust-lang.org/")] html_playground_url = "http://play.rust-lang.org/")]
#![feature(macro_rules, default_type_params, phase)] #![allow(unknown_features)]
#![feature(macro_rules, default_type_params, phase, slicing_syntax)]
// test harness access // test harness access
#[cfg(test)] #[cfg(test)]

View file

@ -35,26 +35,29 @@ use rt::rtio;
/// ///
/// ```rust,no_run /// ```rust,no_run
/// # #![allow(unused_must_use)] /// # #![allow(unused_must_use)]
/// #![feature(slicing_syntax)]
///
/// use std::io::net::udp::UdpSocket; /// use std::io::net::udp::UdpSocket;
/// use std::io::net::ip::{Ipv4Addr, SocketAddr}; /// use std::io::net::ip::{Ipv4Addr, SocketAddr};
/// fn main() {
/// let addr = SocketAddr { ip: Ipv4Addr(127, 0, 0, 1), port: 34254 };
/// let mut socket = match UdpSocket::bind(addr) {
/// Ok(s) => s,
/// Err(e) => fail!("couldn't bind socket: {}", e),
/// };
/// ///
/// let addr = SocketAddr { ip: Ipv4Addr(127, 0, 0, 1), port: 34254 }; /// let mut buf = [0, ..10];
/// let mut socket = match UdpSocket::bind(addr) { /// match socket.recv_from(buf) {
/// Ok(s) => s, /// Ok((amt, src)) => {
/// Err(e) => fail!("couldn't bind socket: {}", e), /// // Send a reply to the socket we received data from
/// }; /// let buf = buf[mut ..amt];
/// /// buf.reverse();
/// let mut buf = [0, ..10]; /// socket.send_to(buf, src);
/// match socket.recv_from(buf) { /// }
/// Ok((amt, src)) => { /// Err(e) => println!("couldn't receive a datagram: {}", e)
/// // Send a reply to the socket we received data from
/// let buf = buf[mut ..amt];
/// buf.reverse();
/// socket.send_to(buf, src);
/// } /// }
/// Err(e) => println!("couldn't receive a datagram: {}", e) /// drop(socket); // close the socket
/// } /// }
/// drop(socket); // close the socket
/// ``` /// ```
pub struct UdpSocket { pub struct UdpSocket {
obj: Box<RtioUdpSocket + Send>, obj: Box<RtioUdpSocket + Send>,

View file

@ -105,9 +105,10 @@
html_root_url = "http://doc.rust-lang.org/master/", html_root_url = "http://doc.rust-lang.org/master/",
html_playground_url = "http://play.rust-lang.org/")] html_playground_url = "http://play.rust-lang.org/")]
#![allow(unknown_features)]
#![feature(macro_rules, globs, linkage)] #![feature(macro_rules, globs, linkage)]
#![feature(default_type_params, phase, lang_items, unsafe_destructor)] #![feature(default_type_params, phase, lang_items, unsafe_destructor)]
#![feature(import_shadowing)] #![feature(import_shadowing, slicing_syntax)]
// Don't link to std. We are std. // Don't link to std. We are std.
#![no_std] #![no_std]

View file

@ -70,6 +70,7 @@ static KNOWN_FEATURES: &'static [(&'static str, Status)] = &[
("tuple_indexing", Active), ("tuple_indexing", Active),
("associated_types", Active), ("associated_types", Active),
("visible_private_types", Active), ("visible_private_types", Active),
("slicing_syntax", Active),
("if_let", Active), ("if_let", Active),
@ -350,6 +351,11 @@ impl<'a, 'v> Visitor<'v> for Context<'a> {
self.gate_feature("if_let", e.span, self.gate_feature("if_let", e.span,
"`if let` syntax is experimental"); "`if let` syntax is experimental");
} }
ast::ExprSlice(..) => {
self.gate_feature("slicing_syntax",
e.span,
"slicing syntax is experimental");
}
_ => {} _ => {}
} }
visit::walk_expr(self, e); visit::walk_expr(self, e);

View file

@ -23,7 +23,8 @@
html_favicon_url = "http://www.rust-lang.org/favicon.ico", html_favicon_url = "http://www.rust-lang.org/favicon.ico",
html_root_url = "http://doc.rust-lang.org/master/")] html_root_url = "http://doc.rust-lang.org/master/")]
#![feature(macro_rules, globs, default_type_params, phase)] #![allow(unknown_features)]
#![feature(macro_rules, globs, default_type_params, phase, slicing_syntax)]
#![feature(quote, struct_variant, unsafe_destructor, import_shadowing)] #![feature(quote, struct_variant, unsafe_destructor, import_shadowing)]
#![allow(deprecated)] #![allow(deprecated)]

View file

@ -49,7 +49,8 @@
html_root_url = "http://doc.rust-lang.org/master/", html_root_url = "http://doc.rust-lang.org/master/",
html_playground_url = "http://play.rust-lang.org/")] html_playground_url = "http://play.rust-lang.org/")]
#![feature(macro_rules, phase)] #![allow(unknown_features)]
#![feature(macro_rules, phase, slicing_syntax)]
#![deny(missing_doc)] #![deny(missing_doc)]

View file

@ -38,6 +38,8 @@
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
// OF THE POSSIBILITY OF SUCH DAMAGE. // OF THE POSSIBILITY OF SUCH DAMAGE.
#![feature(slicing_syntax)]
use std::{cmp, iter, mem}; use std::{cmp, iter, mem};
use std::sync::Future; use std::sync::Future;

View file

@ -38,6 +38,8 @@
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
// OF THE POSSIBILITY OF SUCH DAMAGE. // OF THE POSSIBILITY OF SUCH DAMAGE.
#![feature(slicing_syntax)]
use std::cmp::min; use std::cmp::min;
use std::io::{stdout, IoResult}; use std::io::{stdout, IoResult};
use std::os; use std::os;

View file

@ -38,6 +38,8 @@
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
// OF THE POSSIBILITY OF SUCH DAMAGE. // OF THE POSSIBILITY OF SUCH DAMAGE.
#![feature(slicing_syntax)]
use std::io; use std::io;
use std::io::{BufferedWriter, File}; use std::io::{BufferedWriter, File};
use std::cmp::min; use std::cmp::min;

View file

@ -13,6 +13,8 @@
// multi tasking k-nucleotide // multi tasking k-nucleotide
#![feature(slicing_syntax)]
extern crate collections; extern crate collections;
use std::collections::HashMap; use std::collections::HashMap;

View file

@ -40,6 +40,8 @@
// ignore-android see #10393 #13206 // ignore-android see #10393 #13206
#![feature(slicing_syntax)]
use std::string::String; use std::string::String;
use std::slice; use std::slice;
use std::sync::{Arc, Future}; use std::sync::{Arc, Future};

View file

@ -41,7 +41,7 @@
// ignore-stage1 // ignore-stage1
// ignore-cross-compile #12102 // ignore-cross-compile #12102
#![feature(macro_rules, phase)] #![feature(macro_rules, phase, slicing_syntax)]
extern crate regex; extern crate regex;
#[phase(plugin)]extern crate regex_macros; #[phase(plugin)]extern crate regex_macros;

View file

@ -41,6 +41,8 @@
// ignore-pretty very bad with line comments // ignore-pretty very bad with line comments
// ignore-android doesn't terminate? // ignore-android doesn't terminate?
#![feature(slicing_syntax)]
use std::iter::range_step; use std::iter::range_step;
use std::io::{stdin, stdout, File}; use std::io::{stdin, stdout, File};

View file

@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed // option. This file may not be copied, modified, or distributed
// except according to those terms. // except according to those terms.
#![feature(slicing_syntax)]
fn main() { fn main() {
let mut array = [1, 2, 3]; let mut array = [1, 2, 3];
//~^ ERROR cannot determine a type for this local variable: cannot determine the type of this integ //~^ ERROR cannot determine a type for this local variable: cannot determine the type of this integ

View file

@ -10,6 +10,8 @@
// Test that slicing syntax gives errors if we have not implemented the trait. // Test that slicing syntax gives errors if we have not implemented the trait.
#![feature(slicing_syntax)]
struct Foo; struct Foo;
fn main() { fn main() {

View file

@ -10,6 +10,8 @@
// Test slicing expressions doesn't defeat the borrow checker. // Test slicing expressions doesn't defeat the borrow checker.
#![feature(slicing_syntax)]
fn main() { fn main() {
let y; let y;
{ {

View file

@ -10,6 +10,8 @@
// Test mutability and slicing syntax. // Test mutability and slicing syntax.
#![feature(slicing_syntax)]
fn main() { fn main() {
let x: &[int] = &[1, 2, 3, 4, 5]; let x: &[int] = &[1, 2, 3, 4, 5];
// Can't mutably slice an immutable slice // Can't mutably slice an immutable slice

View file

@ -10,6 +10,8 @@
// Test mutability and slicing syntax. // Test mutability and slicing syntax.
#![feature(slicing_syntax)]
fn main() { fn main() {
let x: &[int] = &[1, 2, 3, 4, 5]; let x: &[int] = &[1, 2, 3, 4, 5];
// Immutable slices are not mutable. // Immutable slices are not mutable.

View file

@ -80,6 +80,7 @@
// lldb-check:[...]$5 = &[AStruct { x: 10, y: 11, z: 12 }, AStruct { x: 13, y: 14, z: 15 }] // lldb-check:[...]$5 = &[AStruct { x: 10, y: 11, z: 12 }, AStruct { x: 13, y: 14, z: 15 }]
#![allow(unused_variable)] #![allow(unused_variable)]
#![feature(slicing_syntax)]
struct AStruct { struct AStruct {
x: i16, x: i16,

View file

@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed // option. This file may not be copied, modified, or distributed
// except according to those terms. // except according to those terms.
#![feature(slicing_syntax)]
fn vec_peek<'r, T>(v: &'r [T]) -> &'r [T] { fn vec_peek<'r, T>(v: &'r [T]) -> &'r [T] {
v[1..5] v[1..5]
} }

View file

@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed // option. This file may not be copied, modified, or distributed
// except according to those terms. // except according to those terms.
#![feature(slicing_syntax)]
fn broken(v: &[u8], i: uint, j: uint) -> &[u8] { v[i..j] } fn broken(v: &[u8], i: uint, j: uint) -> &[u8] { v[i..j] }
pub fn main() {} pub fn main() {}

View file

@ -8,6 +8,7 @@
// option. This file may not be copied, modified, or distributed // option. This file may not be copied, modified, or distributed
// except according to those terms. // except according to those terms.
#![feature(slicing_syntax)]
extern crate debug; extern crate debug;

View file

@ -10,6 +10,8 @@
// Test slicing expressions on slices and Vecs. // Test slicing expressions on slices and Vecs.
#![feature(slicing_syntax)]
fn main() { fn main() {
let x: &[int] = &[1, 2, 3, 4, 5]; let x: &[int] = &[1, 2, 3, 4, 5];
let cmp: &[int] = &[1, 2, 3, 4, 5]; let cmp: &[int] = &[1, 2, 3, 4, 5];

View file

@ -10,6 +10,8 @@
// Test that is a slicing expr[..] fails, the correct cleanups happen. // Test that is a slicing expr[..] fails, the correct cleanups happen.
#![feature(slicing_syntax)]
use std::task; use std::task;
struct Foo; struct Foo;

View file

@ -10,6 +10,8 @@
// Test that is a slicing expr[..] fails, the correct cleanups happen. // Test that is a slicing expr[..] fails, the correct cleanups happen.
#![feature(slicing_syntax)]
use std::task; use std::task;
struct Foo; struct Foo;

View file

@ -10,6 +10,8 @@
// Test slicing sugar. // Test slicing sugar.
#![feature(slicing_syntax)]
extern crate core; extern crate core;
use core::ops::{Slice,SliceMut}; use core::ops::{Slice,SliceMut};