Skip to content

Commit 95cfc35

Browse files
committed
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.
1 parent df2f1fa commit 95cfc35

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+105
-43
lines changed

src/compiletest/compiletest.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
// except according to those terms.
1010

1111
#![crate_type = "bin"]
12-
#![feature(phase)]
12+
#![feature(phase, slicing_syntax)]
1313

1414
#![deny(warnings)]
1515

src/doc/reference.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -3828,7 +3828,7 @@ type signature of `print`, and the cast expression in `main`.
38283828
Within the body of an item that has type parameter declarations, the names of
38293829
its type parameters are types:
38303830

3831-
```
3831+
```ignore
38323832
fn map<A: Clone, B: Clone>(f: |A| -> B, xs: &[A]) -> Vec<B> {
38333833
if xs.len() == 0 {
38343834
return vec![];

src/libcollections/lib.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,9 @@
1919
html_root_url = "http://doc.rust-lang.org/master/",
2020
html_playground_url = "http://play.rust-lang.org/")]
2121

22+
#![allow(unknown_features)]
2223
#![feature(macro_rules, managed_boxes, default_type_params, phase, globs)]
23-
#![feature(unsafe_destructor, import_shadowing)]
24+
#![feature(unsafe_destructor, import_shadowing, slicing_syntax)]
2425
#![no_std]
2526

2627
#[phase(plugin, link)] extern crate core;

src/libcollections/slice.rs

+6-3
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,12 @@
5151
//! interval `[a, b)`:
5252
//!
5353
//! ```rust
54-
//! let numbers = [0i, 1i, 2i];
55-
//! let last_numbers = numbers[1..3];
56-
//! // last_numbers is now &[1i, 2i]
54+
//! #![feature(slicing_syntax)]
55+
//! fn main() {
56+
//! let numbers = [0i, 1i, 2i];
57+
//! let last_numbers = numbers[1..3];
58+
//! // last_numbers is now &[1i, 2i]
59+
//! }
5760
//! ```
5861
//!
5962
//! ## Implementations of other traits

src/libcollections/string.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ impl String {
160160

161161
if i > 0 {
162162
unsafe {
163-
res.as_mut_vec().push_all(v.[..i])
163+
res.as_mut_vec().push_all(v[..i])
164164
};
165165
}
166166

@@ -177,7 +177,7 @@ impl String {
177177
macro_rules! error(() => ({
178178
unsafe {
179179
if subseqidx != i_ {
180-
res.as_mut_vec().push_all(vv[subseqidx..i_]);
180+
res.as_mut_vec().push_all(v[subseqidx..i_]);
181181
}
182182
subseqidx = i;
183183
res.as_mut_vec().push_all(REPLACEMENT);

src/libcore/lib.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,9 @@
5757
html_playground_url = "http://play.rust-lang.org/")]
5858

5959
#![no_std]
60+
#![allow(unknown_features)]
6061
#![feature(globs, intrinsics, lang_items, macro_rules, managed_boxes, phase)]
61-
#![feature(simd, unsafe_destructor)]
62+
#![feature(simd, unsafe_destructor, slicing_syntax)]
6263
#![deny(missing_doc)]
6364

6465
mod macros;

src/libcore/ops.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -684,7 +684,7 @@ pub trait IndexMut<Index, Result> {
684684
* A trivial implementation of `Slice`. When `Foo[..Foo]` happens, it ends up
685685
* calling `slice_to`, and therefore, `main` prints `Slicing!`.
686686
*
687-
* ```
687+
* ```ignore
688688
* struct Foo;
689689
*
690690
* impl ::core::ops::Slice<Foo, Foo> for Foo {
@@ -749,7 +749,7 @@ pub trait Slice<Idx, Sized? Result> for Sized? {
749749
* A trivial implementation of `SliceMut`. When `Foo[Foo..]` happens, it ends up
750750
* calling `slice_from_mut`, and therefore, `main` prints `Slicing!`.
751751
*
752-
* ```
752+
* ```ignore
753753
* struct Foo;
754754
*
755755
* impl ::core::ops::SliceMut<Foo, Foo> for Foo {
@@ -771,7 +771,7 @@ pub trait Slice<Idx, Sized? Result> for Sized? {
771771
* }
772772
* }
773773
*
774-
* fn main() {
774+
* pub fn main() {
775775
* Foo[mut Foo..];
776776
* }
777777
* ```

src/libcore/slice.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -814,13 +814,13 @@ impl<'a,T> MutableSlice<'a, T> for &'a mut [T] {
814814
#[inline]
815815
fn tail_mut(self) -> &'a mut [T] {
816816
let len = self.len();
817-
self.slice_mut(1, len)
817+
self[mut 1..len]
818818
}
819819

820820
#[inline]
821821
fn init_mut(self) -> &'a mut [T] {
822822
let len = self.len();
823-
self.slice_mut(0, len - 1)
823+
self[mut 0..len - 1]
824824
}
825825

826826
#[inline]

src/libcoretest/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
10-
#![feature(globs, unsafe_destructor, macro_rules)]
10+
#![feature(globs, unsafe_destructor, macro_rules, slicing_syntax)]
1111

1212
extern crate core;
1313
extern crate test;

src/libnative/lib.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,8 @@
5757

5858
#![deny(unused_result, unused_must_use)]
5959
#![allow(non_camel_case_types, deprecated)]
60-
#![feature(default_type_params, lang_items)]
60+
#![allow(unknown_features)]
61+
#![feature(default_type_params, lang_items, slicing_syntax)]
6162

6263
// NB this crate explicitly does *not* allow glob imports, please seriously
6364
// consider whether they're needed before adding that feature here (the

src/libnum/lib.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@
4343
//!
4444
//! [newt]: https://en.wikipedia.org/wiki/Methods_of_computing_square_roots#Babylonian_method
4545
46-
#![feature(macro_rules)]
46+
#![allow(unknown_features)]
47+
#![feature(macro_rules, slicing_syntax)]
4748
#![feature(default_type_params)]
4849

4950
#![crate_name = "num"]

src/librbml/lib.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@
2424
html_favicon_url = "http://www.rust-lang.org/favicon.ico",
2525
html_root_url = "http://doc.rust-lang.org/master/",
2626
html_playground_url = "http://play.rust-lang.org/")]
27-
#![feature(macro_rules, phase)]
27+
#![allow(unknown_features)]
28+
#![feature(macro_rules, phase, slicing_syntax)]
2829
#![allow(missing_doc)]
2930

3031
extern crate serialize;

src/libregex/lib.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,8 @@
368368
html_root_url = "http://doc.rust-lang.org/master/",
369369
html_playground_url = "http://play.rust-lang.org/")]
370370

371-
#![feature(macro_rules, phase)]
371+
#![allow(unknown_features)]
372+
#![feature(macro_rules, phase, slicing_syntax)]
372373
#![deny(missing_doc)]
373374

374375
#[cfg(test)]

src/librustc/lib.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,9 @@ This API is completely unstable and subject to change.
2929
html_root_url = "http://doc.rust-lang.org/master/")]
3030

3131
#![allow(deprecated)]
32+
#![allow(unknown_features)]
3233
#![feature(macro_rules, globs, struct_variant, quote)]
33-
#![feature(default_type_params, phase, unsafe_destructor)]
34+
#![feature(default_type_params, phase, unsafe_destructor, slicing_syntax)]
3435

3536
#![feature(rustc_diagnostic_macros)]
3637
#![feature(import_shadowing)]

src/librustc_back/lib.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@
3131
html_favicon_url = "http://www.rust-lang.org/favicon.ico",
3232
html_root_url = "http://doc.rust-lang.org/")]
3333

34-
#![feature(globs, phase, macro_rules)]
34+
#![allow(unknown_features)]
35+
#![feature(globs, phase, macro_rules, slicing_syntax)]
3536

3637
#[phase(plugin, link)]
3738
extern crate log;

src/librustdoc/lib.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@
1515
#![crate_type = "dylib"]
1616
#![crate_type = "rlib"]
1717

18-
#![feature(globs, struct_variant, managed_boxes, macro_rules, phase)]
18+
#![allow(unknown_features)]
19+
#![feature(globs, struct_variant, managed_boxes, macro_rules, phase, slicing_syntax)]
1920

2021
extern crate arena;
2122
extern crate debug;

src/librustrt/lib.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,10 @@
1616
html_favicon_url = "http://www.rust-lang.org/favicon.ico",
1717
html_root_url = "http://doc.rust-lang.org/master/")]
1818

19+
#![allow(unknown_features)]
1920
#![feature(macro_rules, phase, globs, thread_local, managed_boxes, asm)]
2021
#![feature(linkage, lang_items, unsafe_destructor, default_type_params)]
21-
#![feature(import_shadowing)]
22+
#![feature(import_shadowing, slicing_syntax)]
2223
#![no_std]
2324
#![experimental]
2425

src/libserialize/lib.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ Core encoding and decoding interfaces.
2323
html_favicon_url = "http://www.rust-lang.org/favicon.ico",
2424
html_root_url = "http://doc.rust-lang.org/master/",
2525
html_playground_url = "http://play.rust-lang.org/")]
26-
#![feature(macro_rules, managed_boxes, default_type_params, phase)]
26+
#![allow(unknown_features)]
27+
#![feature(macro_rules, managed_boxes, default_type_params, phase, slicing_syntax)]
2728

2829
// test harness access
2930
#[cfg(test)]

src/libstd/io/net/udp.rs

+18-15
Original file line numberDiff line numberDiff line change
@@ -35,26 +35,29 @@ use rt::rtio;
3535
///
3636
/// ```rust,no_run
3737
/// # #![allow(unused_must_use)]
38+
/// #![feature(slicing_syntax)]
39+
///
3840
/// use std::io::net::udp::UdpSocket;
3941
/// use std::io::net::ip::{Ipv4Addr, SocketAddr};
42+
/// fn main() {
43+
/// let addr = SocketAddr { ip: Ipv4Addr(127, 0, 0, 1), port: 34254 };
44+
/// let mut socket = match UdpSocket::bind(addr) {
45+
/// Ok(s) => s,
46+
/// Err(e) => fail!("couldn't bind socket: {}", e),
47+
/// };
4048
///
41-
/// let addr = SocketAddr { ip: Ipv4Addr(127, 0, 0, 1), port: 34254 };
42-
/// let mut socket = match UdpSocket::bind(addr) {
43-
/// Ok(s) => s,
44-
/// Err(e) => fail!("couldn't bind socket: {}", e),
45-
/// };
46-
///
47-
/// let mut buf = [0, ..10];
48-
/// match socket.recv_from(buf) {
49-
/// Ok((amt, src)) => {
50-
/// // Send a reply to the socket we received data from
51-
/// let buf = buf[mut ..amt];
52-
/// buf.reverse();
53-
/// socket.send_to(buf, src);
49+
/// let mut buf = [0, ..10];
50+
/// match socket.recv_from(buf) {
51+
/// Ok((amt, src)) => {
52+
/// // Send a reply to the socket we received data from
53+
/// let buf = buf[mut ..amt];
54+
/// buf.reverse();
55+
/// socket.send_to(buf, src);
56+
/// }
57+
/// Err(e) => println!("couldn't receive a datagram: {}", e)
5458
/// }
55-
/// Err(e) => println!("couldn't receive a datagram: {}", e)
59+
/// drop(socket); // close the socket
5660
/// }
57-
/// drop(socket); // close the socket
5861
/// ```
5962
pub struct UdpSocket {
6063
obj: Box<RtioUdpSocket + Send>,

src/libstd/lib.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -105,9 +105,10 @@
105105
html_root_url = "http://doc.rust-lang.org/master/",
106106
html_playground_url = "http://play.rust-lang.org/")]
107107

108+
#![allow(unknown_features)]
108109
#![feature(macro_rules, globs, managed_boxes, linkage)]
109110
#![feature(default_type_params, phase, lang_items, unsafe_destructor)]
110-
#![feature(import_shadowing)]
111+
#![feature(import_shadowing, slicing_syntax)]
111112

112113
// Don't link to std. We are std.
113114
#![no_std]

src/libsyntax/feature_gate.rs

+6
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ static KNOWN_FEATURES: &'static [(&'static str, Status)] = &[
7070
("tuple_indexing", Active),
7171
("associated_types", Active),
7272
("visible_private_types", Active),
73+
("slicing_syntax", Active),
7374

7475
("if_let", Active),
7576

@@ -362,6 +363,11 @@ impl<'a, 'v> Visitor<'v> for Context<'a> {
362363
self.gate_feature("if_let", e.span,
363364
"`if let` syntax is experimental");
364365
}
366+
ast::ExprSlice(..) => {
367+
self.gate_feature("slicing_syntax",
368+
e.span,
369+
"slicing syntax is experimental");
370+
}
365371
_ => {}
366372
}
367373
visit::walk_expr(self, e);

src/libsyntax/lib.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@
2323
html_favicon_url = "http://www.rust-lang.org/favicon.ico",
2424
html_root_url = "http://doc.rust-lang.org/master/")]
2525

26-
#![feature(macro_rules, globs, default_type_params, phase)]
26+
#![allow(unknown_features)]
27+
#![feature(macro_rules, globs, default_type_params, phase, slicing_syntax)]
2728
#![feature(quote, struct_variant, unsafe_destructor, import_shadowing)]
2829
#![allow(deprecated)]
2930

src/libterm/lib.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,8 @@
4949
html_root_url = "http://doc.rust-lang.org/master/",
5050
html_playground_url = "http://play.rust-lang.org/")]
5151

52-
#![feature(macro_rules, phase)]
52+
#![allow(unknown_features)]
53+
#![feature(macro_rules, phase, slicing_syntax)]
5354

5455
#![deny(missing_doc)]
5556

src/test/bench/shootout-fannkuch-redux.rs

+2
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@
3838
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
3939
// OF THE POSSIBILITY OF SUCH DAMAGE.
4040

41+
#![feature(slicing_syntax)]
42+
4143
use std::{cmp, iter, mem};
4244
use std::sync::Future;
4345

src/test/bench/shootout-fasta-redux.rs

+2
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@
3838
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
3939
// OF THE POSSIBILITY OF SUCH DAMAGE.
4040

41+
#![feature(slicing_syntax)]
42+
4143
use std::cmp::min;
4244
use std::io::{stdout, IoResult};
4345
use std::os;

src/test/bench/shootout-fasta.rs

+2
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@
3838
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
3939
// OF THE POSSIBILITY OF SUCH DAMAGE.
4040

41+
#![feature(slicing_syntax)]
42+
4143
use std::io;
4244
use std::io::{BufferedWriter, File};
4345
use std::cmp::min;

src/test/bench/shootout-k-nucleotide-pipes.rs

+2
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313

1414
// multi tasking k-nucleotide
1515

16+
#![feature(slicing_syntax)]
17+
1618
extern crate collections;
1719

1820
use std::collections::HashMap;

src/test/bench/shootout-k-nucleotide.rs

+2
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@
4040

4141
// ignore-android see #10393 #13206
4242

43+
#![feature(slicing_syntax)]
44+
4345
use std::string::String;
4446
use std::slice;
4547
use std::sync::{Arc, Future};

src/test/bench/shootout-regex-dna.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
// ignore-stage1
4242
// ignore-cross-compile #12102
4343

44-
#![feature(macro_rules, phase)]
44+
#![feature(macro_rules, phase, slicing_syntax)]
4545

4646
extern crate regex;
4747
#[phase(plugin)]extern crate regex_macros;

src/test/bench/shootout-reverse-complement.rs

+2
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@
4141
// ignore-pretty very bad with line comments
4242
// ignore-android doesn't terminate?
4343

44+
#![feature(slicing_syntax)]
45+
4446
use std::iter::range_step;
4547
use std::io::{stdin, stdout, File};
4648

src/test/compile-fail/issue-15730.rs

+2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11+
#![feature(slicing_syntax)]
12+
1113
fn main() {
1214
let mut array = [1, 2, 3];
1315
//~^ ERROR cannot determine a type for this local variable: cannot determine the type of this integ

src/test/compile-fail/slice-2.rs

+2
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010

1111
// Test that slicing syntax gives errors if we have not implemented the trait.
1212

13+
#![feature(slicing_syntax)]
14+
1315
struct Foo;
1416

1517
fn main() {

0 commit comments

Comments
 (0)