diff options
| -rw-r--r-- | src/libcollections/lib.rs | 1 | ||||
| -rw-r--r-- | src/libcollections/str.rs | 6 | ||||
| -rw-r--r-- | src/libcore/intrinsics.rs | 17 | ||||
| -rw-r--r-- | src/libcore/slice.rs | 10 | ||||
| -rw-r--r-- | src/librustc/lib.rs | 1 | ||||
| -rw-r--r-- | src/librustc/middle/mem_categorization.rs | 6 | ||||
| -rw-r--r-- | src/librustc_typeck/check/mod.rs | 2 | ||||
| -rw-r--r-- | src/librustc_typeck/collect.rs | 2 | ||||
| -rw-r--r-- | src/libserialize/lib.rs | 1 | ||||
| -rw-r--r-- | src/libserialize/serialize.rs | 4 | ||||
| -rw-r--r-- | src/libstd/io/mem.rs | 2 | ||||
| -rw-r--r-- | src/libstd/lib.rs | 1 | ||||
| -rw-r--r-- | src/libstd/path/mod.rs | 2 | ||||
| -rw-r--r-- | src/libstd/path/windows.rs | 2 | ||||
| -rw-r--r-- | src/libstd/prelude/v1.rs | 5 | ||||
| -rw-r--r-- | src/libsyntax/ext/tt/macro_rules.rs | 33 | ||||
| -rw-r--r-- | src/libsyntax/feature_gate.rs | 2 | ||||
| -rw-r--r-- | src/libsyntax/parse/parser.rs | 4 |
18 files changed, 67 insertions, 34 deletions
diff --git a/src/libcollections/lib.rs b/src/libcollections/lib.rs index d2eaaade7b6..30451022860 100644 --- a/src/libcollections/lib.rs +++ b/src/libcollections/lib.rs @@ -21,6 +21,7 @@ html_root_url = "http://doc.rust-lang.org/nightly/", html_playground_url = "http://play.rust-lang.org/")] +#![allow(unknown_features)] #![feature(unsafe_destructor, slicing_syntax)] #![feature(old_impl_check)] #![no_std] diff --git a/src/libcollections/str.rs b/src/libcollections/str.rs index aacb6d90d6f..09d140067f4 100644 --- a/src/libcollections/str.rs +++ b/src/libcollections/str.rs @@ -1339,6 +1339,12 @@ pub trait StrExt: Index<FullRange, Output = str> { fn trim_left(&self) -> &str { UnicodeStr::trim_left(self.index(&FullRange)) } + + /// Returns a string with trailing whitespace removed. + #[stable] + fn trim_right(&self) -> &str { + UnicodeStr::trim_right(self.index(&FullRange)) + } } #[stable] diff --git a/src/libcore/intrinsics.rs b/src/libcore/intrinsics.rs index fe9100e8a5c..24ebd1ac21a 100644 --- a/src/libcore/intrinsics.rs +++ b/src/libcore/intrinsics.rs @@ -42,6 +42,9 @@ #![experimental] #![allow(missing_docs)] +#[cfg(not(stage0))] +use marker::Sized; + pub type GlueFn = extern "Rust" fn(*const i8); #[lang="ty_desc"] @@ -200,7 +203,10 @@ extern "rust-intrinsic" { /// Gets an identifier which is globally unique to the specified type. This /// function will return the same value for a type regardless of whichever /// crate it is invoked in. + #[cfg(not(stage0))] pub fn type_id<T: ?Sized + 'static>() -> TypeId; + #[cfg(stage0)] + pub fn type_id<T: 'static>() -> TypeId; /// Create a value initialized to zero. /// @@ -550,7 +556,16 @@ pub struct TypeId { } impl TypeId { - /// Returns the `TypeId` of the type this generic function has been instantiated with + /// Returns the `TypeId` of the type this generic function has been + /// instantiated with + #[cfg(stage0)] + pub fn of<T: 'static>() -> TypeId { + unsafe { type_id::<T>() } + } + + /// Returns the `TypeId` of the type this generic function has been + /// instantiated with + #[cfg(not(stage0))] pub fn of<T: ?Sized + 'static>() -> TypeId { unsafe { type_id::<T>() } } diff --git a/src/libcore/slice.rs b/src/libcore/slice.rs index 7fb08ceb610..bf2df465370 100644 --- a/src/libcore/slice.rs +++ b/src/libcore/slice.rs @@ -733,7 +733,7 @@ macro_rules! iterator { } macro_rules! make_slice { - ($t: ty -> $result: ty: $start: expr, $end: expr) => {{ + ($t: ty => $result: ty: $start: expr, $end: expr) => {{ let diff = $end as uint - $start as uint; let len = if mem::size_of::<T>() == 0 { diff @@ -797,7 +797,7 @@ impl<'a, T> Iter<'a, T> { /// iterator can continue to be used while this exists. #[experimental] pub fn as_slice(&self) -> &'a [T] { - make_slice!(T -> &'a [T]: self.ptr, self.end) + make_slice!(T => &'a [T]: self.ptr, self.end) } } @@ -876,7 +876,7 @@ impl<'a, T> ops::Index<ops::FullRange> for IterMut<'a, T> { type Output = [T]; #[inline] fn index(&self, _index: &ops::FullRange) -> &[T] { - make_slice!(T -> &[T]: self.ptr, self.end) + make_slice!(T => &[T]: self.ptr, self.end) } } @@ -909,7 +909,7 @@ impl<'a, T> ops::IndexMut<ops::FullRange> for IterMut<'a, T> { type Output = [T]; #[inline] fn index_mut(&mut self, _index: &ops::FullRange) -> &mut [T] { - make_slice!(T -> &mut [T]: self.ptr, self.end) + make_slice!(T => &mut [T]: self.ptr, self.end) } } @@ -923,7 +923,7 @@ impl<'a, T> IterMut<'a, T> { /// restricted lifetimes that do not consume the iterator. #[experimental] pub fn into_slice(self) -> &'a mut [T] { - make_slice!(T -> &'a mut [T]: self.ptr, self.end) + make_slice!(T => &'a mut [T]: self.ptr, self.end) } } diff --git a/src/librustc/lib.rs b/src/librustc/lib.rs index 1a5746e8e12..a3a041c2497 100644 --- a/src/librustc/lib.rs +++ b/src/librustc/lib.rs @@ -22,6 +22,7 @@ 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(rustc_diagnostic_macros)] diff --git a/src/librustc/middle/mem_categorization.rs b/src/librustc/middle/mem_categorization.rs index b1afd30a13a..b29c24c5861 100644 --- a/src/librustc/middle/mem_categorization.rs +++ b/src/librustc/middle/mem_categorization.rs @@ -486,9 +486,9 @@ impl<'t,'tcx,TYPER:Typer<'tcx>> MemCategorizationContext<'t,TYPER> { let method_call = ty::MethodCall::expr(expr.id()); match self.typer.node_method_ty(method_call) { Some(method_ty) => { - // If this is an index implemented by a method call, then it will - // include an implicit deref of the result. - let ret_ty = ty::ty_fn_ret(method_ty).unwrap(); + // If this is an index implemented by a method call, then it + // will include an implicit deref of the result. + let ret_ty = self.overloaded_method_return_ty(method_ty); self.cat_deref(expr, self.cat_rvalue_node(expr.id(), expr.span(), diff --git a/src/librustc_typeck/check/mod.rs b/src/librustc_typeck/check/mod.rs index 05906c03328..9563dd45ca2 100644 --- a/src/librustc_typeck/check/mod.rs +++ b/src/librustc_typeck/check/mod.rs @@ -2405,7 +2405,7 @@ fn try_index_step<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>, // First, try built-in indexing. match (ty::index(adjusted_ty), &index_ty.sty) { - (Some(ty), &ty::ty_uint(ast::TyU)) | (Some(ty), &ty::ty_infer(ty::IntVar(_))) => { + (Some(ty), &ty::ty_uint(ast::TyUs)) | (Some(ty), &ty::ty_infer(ty::IntVar(_))) => { debug!("try_index_step: success, using built-in indexing"); fcx.write_adjustment(base_expr.id, base_expr.span, ty::AdjustDerefRef(adjustment)); return Some((tcx.types.uint, ty)); diff --git a/src/librustc_typeck/collect.rs b/src/librustc_typeck/collect.rs index d106a380222..79e98f15a2d 100644 --- a/src/librustc_typeck/collect.rs +++ b/src/librustc_typeck/collect.rs @@ -171,7 +171,7 @@ impl<'a, 'tcx> AstConv<'tcx> for CollectCtxt<'a, 'tcx> { x => { self.tcx.sess.bug(format!("unexpected sort of node \ in get_item_type_scheme(): {:?}", - x)[]); + x).as_slice()); } } } diff --git a/src/libserialize/lib.rs b/src/libserialize/lib.rs index f0a51fcea18..139170fc012 100644 --- a/src/libserialize/lib.rs +++ b/src/libserialize/lib.rs @@ -25,6 +25,7 @@ Core encoding and decoding interfaces. #![allow(unknown_features)] #![feature(slicing_syntax)] #![feature(old_impl_check)] +#![cfg_attr(stage0, allow(unused_attributes))] // test harness access #[cfg(test)] extern crate test; diff --git a/src/libserialize/serialize.rs b/src/libserialize/serialize.rs index 6a04565312d..7b6ca10669d 100644 --- a/src/libserialize/serialize.rs +++ b/src/libserialize/serialize.rs @@ -499,7 +499,7 @@ macro_rules! peel { /// Evaluates to the number of identifiers passed to it, for example: `count_idents!(a, b, c) == 3 macro_rules! count_idents { () => { 0u }; - ($_i:ident, $($rest:ident),*) => { 1 + count_idents!($($rest),*) } + ($_i:ident, $($rest:ident,)*) => { 1 + count_idents!($($rest,)*) } } macro_rules! tuple { @@ -508,7 +508,7 @@ macro_rules! tuple { impl<$($name:Decodable),*> Decodable for ($($name,)*) { #[allow(non_snake_case)] fn decode<D: Decoder>(d: &mut D) -> Result<($($name,)*), D::Error> { - let len: uint = count_idents!($($name),*); + let len: uint = count_idents!($($name,)*); d.read_tuple(len, |d| { let mut i = 0; let ret = ($(try!(d.read_tuple_arg({ i+=1; i-1 }, diff --git a/src/libstd/io/mem.rs b/src/libstd/io/mem.rs index 9e6af86925b..9a6ad04fdbc 100644 --- a/src/libstd/io/mem.rs +++ b/src/libstd/io/mem.rs @@ -13,7 +13,7 @@ //! Readers and Writers for in-memory buffers use cmp::min; -use prelude::v1::Index; +use ops::Index; use option::Option::None; use result::Result::{Err, Ok}; use io; diff --git a/src/libstd/lib.rs b/src/libstd/lib.rs index e3c5fcf7552..32b28c0c2c9 100644 --- a/src/libstd/lib.rs +++ b/src/libstd/lib.rs @@ -108,6 +108,7 @@ #![feature(phase, lang_items, unsafe_destructor)] #![feature(slicing_syntax, unboxed_closures)] #![feature(old_impl_check)] +#![cfg_attr(stage0, allow(unused_attributes))] // Don't link to std. We are std. #![no_std] diff --git a/src/libstd/path/mod.rs b/src/libstd/path/mod.rs index cc418cb510b..581969e98fb 100644 --- a/src/libstd/path/mod.rs +++ b/src/libstd/path/mod.rs @@ -68,7 +68,7 @@ use fmt; use iter::IteratorExt; use option::Option; use option::Option::{None, Some}; -use prelude::v1::{FullRange, Index}; +use ops::{FullRange, Index}; use str; use str::StrExt; use string::{String, CowString}; diff --git a/src/libstd/path/windows.rs b/src/libstd/path/windows.rs index bd3382b4288..bd4b0407bf5 100644 --- a/src/libstd/path/windows.rs +++ b/src/libstd/path/windows.rs @@ -25,7 +25,7 @@ use iter::{AdditiveIterator, Extend}; use iter::{Iterator, IteratorExt, Map, repeat}; use mem; use option::Option::{self, Some, None}; -use prelude::v1::{FullRange, Index}; +use ops::{FullRange, Index}; use slice::{SliceExt, SliceConcatExt}; use str::{SplitTerminator, FromStr, StrExt}; use string::{String, ToString}; diff --git a/src/libstd/prelude/v1.rs b/src/libstd/prelude/v1.rs index 06a9303e0d7..dcb342b9ca2 100644 --- a/src/libstd/prelude/v1.rs +++ b/src/libstd/prelude/v1.rs @@ -14,7 +14,10 @@ // Reexported core operators #[stable] #[doc(no_inline)] pub use marker::{Copy, Send, Sized, Sync}; -#[stable] #[doc(no_inline)] pub use ops::{Drop, Fn, FnMut, FnOnce, FullRange}; +#[stable] #[doc(no_inline)] pub use ops::{Drop, Fn, FnMut, FnOnce}; + +// TEMPORARY +#[unstable] #[doc(no_inline)] pub use ops::{Index, IndexMut, FullRange}; // Reexported functions #[stable] #[doc(no_inline)] pub use mem::drop; diff --git a/src/libsyntax/ext/tt/macro_rules.rs b/src/libsyntax/ext/tt/macro_rules.rs index 95240cd7a87..64c53e298ef 100644 --- a/src/libsyntax/ext/tt/macro_rules.rs +++ b/src/libsyntax/ext/tt/macro_rules.rs @@ -287,7 +287,7 @@ fn check_lhs_nt_follows(cx: &mut ExtCtxt, lhs: &NamedMatch, sp: Span) { // &MatchedNonterminal(NtTT(box TtDelimited(...))) = lhs` let matcher = match lhs { &MatchedNonterminal(NtTT(ref inner)) => match &**inner { - &TtDelimited(_, ref tts) => tts.tts[], + &TtDelimited(_, ref tts) => tts.tts.as_slice(), _ => cx.span_bug(sp, "wrong-structured lhs for follow check") }, _ => cx.span_bug(sp, "wrong-structured lhs for follow check") @@ -317,9 +317,12 @@ fn check_matcher<'a, I>(cx: &mut ExtCtxt, matcher: I, follow: &Token) Some(&&TtToken(_, CloseDelim(_))) => follow.clone(), Some(&&TtToken(_, ref tok)) => tok.clone(), Some(&&TtSequence(sp, _)) => { - cx.span_err(sp, format!("`${0}:{1}` is followed by a sequence \ - repetition, which is not allowed for `{1}` \ - fragments", name.as_str(), frag_spec.as_str())[]); + cx.span_err(sp, + format!("`${0}:{1}` is followed by a \ + sequence repetition, which is not \ + allowed for `{1}` fragments", + name.as_str(), frag_spec.as_str()) + .as_slice()); Eof }, // die next iteration @@ -337,7 +340,7 @@ fn check_matcher<'a, I>(cx: &mut ExtCtxt, matcher: I, follow: &Token) cx.span_err(sp, format!("`${0}:{1}` is followed by `{2}`, which \ is not allowed for `{1}` fragments", name.as_str(), frag_spec.as_str(), - token_to_string(next))[]); + token_to_string(next)).as_slice()); continue }, } @@ -351,11 +354,12 @@ fn check_matcher<'a, I>(cx: &mut ExtCtxt, matcher: I, follow: &Token) Some(ref u) => { let last = check_matcher(cx, seq.tts.iter(), u); match last { - // Since the delimiter isn't required after the last repetition, make - // sure that the *next* token is sane. This doesn't actually compute - // the FIRST of the rest of the matcher yet, it only considers single - // tokens and simple NTs. This is imprecise, but conservatively - // correct. + // Since the delimiter isn't required after the last + // repetition, make sure that the *next* token is + // sane. This doesn't actually compute the FIRST of + // the rest of the matcher yet, it only considers + // single tokens and simple NTs. This is imprecise, + // but conservatively correct. Some((span, tok)) => { let fol = match tokens.peek() { Some(&&TtToken(_, ref tok)) => tok.clone(), @@ -373,9 +377,9 @@ fn check_matcher<'a, I>(cx: &mut ExtCtxt, matcher: I, follow: &Token) None => last, } }, - // If T has the form $(...)+ or $(...)*, run the algorithm on the contents with - // F set to the token following the sequence. If it accepts, continue, else, - // reject. + // If T has the form $(...)+ or $(...)*, run the algorithm + // on the contents with F set to the token following the + // sequence. If it accepts, continue, else, reject. None => { let fol = match tokens.peek() { Some(&&TtToken(_, ref tok)) => tok.clone(), @@ -449,6 +453,7 @@ fn is_in_follow(cx: &ExtCtxt, tok: &Token, frag: &str) -> bool { // harmless true }, - _ => cx.bug(format!("unrecognized builtin nonterminal {}", frag)[]), + _ => cx.bug(format!("unrecognized builtin nonterminal {}", + frag).as_slice()), } } diff --git a/src/libsyntax/feature_gate.rs b/src/libsyntax/feature_gate.rs index 75d231d68b5..f10113254de 100644 --- a/src/libsyntax/feature_gate.rs +++ b/src/libsyntax/feature_gate.rs @@ -298,7 +298,7 @@ impl<'a, 'v> Visitor<'v> for PostExpansionVisitor<'a> { "the new orphan check rules will eventually be strictly enforced"); } - if attr::contains_name(i.attrs[], + if attr::contains_name(i.attrs.index(&FullRange), "old_impl_check") { self.gate_feature("old_impl_check", i.span, diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 0ba9f23fc11..92e0395eca4 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -2613,7 +2613,7 @@ impl<'a> Parser<'a> { |p| p.parse_token_tree() ); let (sep, repeat) = self.parse_sep_and_kleene_op(); - let name_num = macro_parser::count_names(seq[]); + let name_num = macro_parser::count_names(seq.as_slice()); return TtSequence(mk_sp(sp.lo, seq_span.hi), Rc::new(SequenceRepetition { tts: seq, @@ -2656,7 +2656,7 @@ impl<'a> Parser<'a> { match self.token { token::SubstNt(name, _) => self.fatal(format!("unknown macro variable `{}`", - token::get_ident(name))[]), + token::get_ident(name)).index(&FullRange)), _ => {} } } |
