diff options
| author | Alex Crichton <alex@alexcrichton.com> | 2014-12-22 09:04:23 -0800 |
|---|---|---|
| committer | Alex Crichton <alex@alexcrichton.com> | 2014-12-29 08:58:21 -0800 |
| commit | c32d03f4172580e3f33e4844ed3c01234dca2d53 (patch) | |
| tree | 70c57ebe6a3b5f6e8cb4609c918f9455671926be /src/libsyntax | |
| parent | 3dcc409fac18a258ba2a8af4345d9566ec8eebad (diff) | |
| download | rust-c32d03f4172580e3f33e4844ed3c01234dca2d53.tar.gz rust-c32d03f4172580e3f33e4844ed3c01234dca2d53.zip | |
std: Stabilize the prelude module
This commit is an implementation of [RFC 503][rfc] which is a stabilization story for the prelude. Most of the RFC was directly applied, removing reexports. Some reexports are kept around, however: * `range` remains until range syntax has landed to reduce churn. * `Path` and `GenericPath` remain until path reform lands. This is done to prevent many imports of `GenericPath` which will soon be removed. * All `io` traits remain until I/O reform lands so imports can be rewritten all at once to `std::io::prelude::*`. This is a breaking change because many prelude reexports have been removed, and the RFC can be consulted for the exact list of removed reexports, as well as to find the locations of where to import them. [rfc]: https://github.com/rust-lang/rfcs/blob/master/text/0503-prelude-stabilization.md [breaking-change] Closes #20068
Diffstat (limited to 'src/libsyntax')
| -rw-r--r-- | src/libsyntax/codemap.rs | 19 | ||||
| -rw-r--r-- | src/libsyntax/ext/bytes.rs | 1 | ||||
| -rw-r--r-- | src/libsyntax/ext/quote.rs | 3 | ||||
| -rw-r--r-- | src/libsyntax/feature_gate.rs | 1 | ||||
| -rw-r--r-- | src/libsyntax/owned_slice.rs | 4 | ||||
| -rw-r--r-- | src/libsyntax/parse/lexer/mod.rs | 3 | ||||
| -rw-r--r-- | src/libsyntax/parse/parser.rs | 3 | ||||
| -rw-r--r-- | src/libsyntax/parse/token.rs | 2 | ||||
| -rw-r--r-- | src/libsyntax/ptr.rs | 20 | ||||
| -rw-r--r-- | src/libsyntax/std_inject.rs | 9 | ||||
| -rw-r--r-- | src/libsyntax/util/interner.rs | 4 | ||||
| -rw-r--r-- | src/libsyntax/util/small_vector.rs | 2 |
12 files changed, 47 insertions, 24 deletions
diff --git a/src/libsyntax/codemap.rs b/src/libsyntax/codemap.rs index 6b9af29c604..042a1bd0781 100644 --- a/src/libsyntax/codemap.rs +++ b/src/libsyntax/codemap.rs @@ -10,19 +10,24 @@ // // ignore-lexer-test FIXME #15679 -//! The CodeMap tracks all the source code used within a single crate, mapping from integer byte -//! positions to the original source code location. Each bit of source parsed during crate parsing -//! (typically files, in-memory strings, or various bits of macro expansion) cover a continuous -//! range of bytes in the CodeMap and are represented by FileMaps. Byte positions are stored in -//! `spans` and used pervasively in the compiler. They are absolute positions within the CodeMap, -//! which upon request can be converted to line and column information, source code snippets, etc. +//! The CodeMap tracks all the source code used within a single crate, mapping +//! from integer byte positions to the original source code location. Each bit +//! of source parsed during crate parsing (typically files, in-memory strings, +//! or various bits of macro expansion) cover a continuous range of bytes in the +//! CodeMap and are represented by FileMaps. Byte positions are stored in +//! `spans` and used pervasively in the compiler. They are absolute positions +//! within the CodeMap, which upon request can be converted to line and column +//! information, source code snippets, etc. pub use self::MacroFormat::*; -use serialize::{Encodable, Decodable, Encoder, Decoder}; use std::cell::RefCell; +use std::num::ToPrimitive; +use std::ops::{Add, Sub}; use std::rc::Rc; + use libc::c_uint; +use serialize::{Encodable, Decodable, Encoder, Decoder}; pub trait Pos { fn from_uint(n: uint) -> Self; diff --git a/src/libsyntax/ext/bytes.rs b/src/libsyntax/ext/bytes.rs index 2844c0b523e..cafd1d60700 100644 --- a/src/libsyntax/ext/bytes.rs +++ b/src/libsyntax/ext/bytes.rs @@ -17,6 +17,7 @@ use ext::base; use ext::build::AstBuilder; use std::ascii::AsciiExt; +use std::ascii::AsciiCast; pub fn expand_syntax_ext<'cx>(cx: &'cx mut ExtCtxt, sp: Span, diff --git a/src/libsyntax/ext/quote.rs b/src/libsyntax/ext/quote.rs index 368d4fa8447..4aadc78babd 100644 --- a/src/libsyntax/ext/quote.rs +++ b/src/libsyntax/ext/quote.rs @@ -50,8 +50,7 @@ pub mod rt { impl<T: ToTokens> ToTokens for Vec<T> { fn to_tokens(&self, cx: &ExtCtxt) -> Vec<TokenTree> { - let a = self.iter().flat_map(|t| t.to_tokens(cx).into_iter()); - FromIterator::from_iter(a) + self.iter().flat_map(|t| t.to_tokens(cx).into_iter()).collect() } } diff --git a/src/libsyntax/feature_gate.rs b/src/libsyntax/feature_gate.rs index 28f7a78ddd0..45bd28371b5 100644 --- a/src/libsyntax/feature_gate.rs +++ b/src/libsyntax/feature_gate.rs @@ -30,6 +30,7 @@ use visit; use visit::Visitor; use parse::token; +use std::ascii::AsciiCast; use std::slice; use std::ascii::AsciiExt; diff --git a/src/libsyntax/owned_slice.rs b/src/libsyntax/owned_slice.rs index 3023c547fb0..f7d2331c9ec 100644 --- a/src/libsyntax/owned_slice.rs +++ b/src/libsyntax/owned_slice.rs @@ -8,8 +8,10 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use std::fmt; use std::default::Default; +use std::fmt; +use std::iter::FromIterator; +use std::ops::Deref; use std::vec; use serialize::{Encodable, Decodable, Encoder, Decoder}; diff --git a/src/libsyntax/parse/lexer/mod.rs b/src/libsyntax/parse/lexer/mod.rs index 13d020f6ae3..0f5ff33021c 100644 --- a/src/libsyntax/parse/lexer/mod.rs +++ b/src/libsyntax/parse/lexer/mod.rs @@ -16,6 +16,7 @@ use ext::tt::transcribe::tt_next_token; use parse::token; use parse::token::{str_to_ident}; +use std::borrow::IntoCow; use std::char; use std::fmt; use std::mem::replace; @@ -358,7 +359,7 @@ impl<'a> StringReader<'a> { pub fn nextnextch(&self) -> Option<char> { let offset = self.byte_offset(self.pos).to_uint(); - let s = self.filemap.deref().src[]; + let s = self.filemap.src.as_slice(); if offset >= s.len() { return None } let str::CharRange { next, .. } = s.char_range_at(offset); if next < s.len() { diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index a2e2abab03e..7b40ae85c7d 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -84,11 +84,12 @@ use owned_slice::OwnedSlice; use std::collections::HashSet; use std::io::fs::PathExtensions; +use std::iter; use std::mem; use std::num::Float; use std::rc::Rc; -use std::iter; use std::slice; +use std::str::from_str; bitflags! { flags Restrictions: u8 { diff --git a/src/libsyntax/parse/token.rs b/src/libsyntax/parse/token.rs index f575d3d6c67..dbc0cef8340 100644 --- a/src/libsyntax/parse/token.rs +++ b/src/libsyntax/parse/token.rs @@ -22,8 +22,10 @@ use util::interner::{RcStr, StrInterner}; use util::interner; use serialize::{Decodable, Decoder, Encodable, Encoder}; +use std::cmp::Equiv; use std::fmt; use std::mem; +use std::ops::Deref; use std::path::BytesContainer; use std::rc::Rc; diff --git a/src/libsyntax/ptr.rs b/src/libsyntax/ptr.rs index 1b3ebde2461..8b1aed483c3 100644 --- a/src/libsyntax/ptr.rs +++ b/src/libsyntax/ptr.rs @@ -10,16 +10,18 @@ //! The AST pointer //! -//! Provides `P<T>`, a frozen owned smart pointer, as a replacement for `@T` in the AST. +//! Provides `P<T>`, a frozen owned smart pointer, as a replacement for `@T` in +//! the AST. //! //! # Motivations and benefits //! -//! * **Identity**: sharing AST nodes is problematic for the various analysis passes -//! (e.g. one may be able to bypass the borrow checker with a shared `ExprAddrOf` -//! node taking a mutable borrow). The only reason `@T` in the AST hasn't caused -//! issues is because of inefficient folding passes which would always deduplicate -//! any such shared nodes. Even if the AST were to switch to an arena, this would -//! still hold, i.e. it couldn't use `&'a T`, but rather a wrapper like `P<'a, T>`. +//! * **Identity**: sharing AST nodes is problematic for the various analysis +//! passes (e.g. one may be able to bypass the borrow checker with a shared +//! `ExprAddrOf` node taking a mutable borrow). The only reason `@T` in the +//! AST hasn't caused issues is because of inefficient folding passes which +//! would always deduplicate any such shared nodes. Even if the AST were to +//! switch to an arena, this would still hold, i.e. it couldn't use `&'a T`, +//! but rather a wrapper like `P<'a, T>`. //! //! * **Immutability**: `P<T>` disallows mutating its inner `T`, unlike `Box<T>` //! (unless it contains an `Unsafe` interior, but that may be denied later). @@ -34,9 +36,9 @@ //! implementation changes (using a special thread-local heap, for example). //! Moreover, a switch to, e.g. `P<'a, T>` would be easy and mostly automated. -use std::fmt; -use std::fmt::Show; +use std::fmt::{mod, Show}; use std::hash::Hash; +use std::ops::Deref; use std::ptr; use serialize::{Encodable, Decodable, Encoder, Decoder}; diff --git a/src/libsyntax/std_inject.rs b/src/libsyntax/std_inject.rs index e1c8ff5011b..0d89403ab6c 100644 --- a/src/libsyntax/std_inject.rs +++ b/src/libsyntax/std_inject.rs @@ -152,7 +152,7 @@ impl<'a> fold::Folder for PreludeInjector<'a> { let prelude_path = ast::Path { span: DUMMY_SP, global: false, - segments: vec!( + segments: vec![ ast::PathSegment { identifier: token::str_to_ident("std"), parameters: ast::PathParameters::none(), @@ -160,7 +160,12 @@ impl<'a> fold::Folder for PreludeInjector<'a> { ast::PathSegment { identifier: token::str_to_ident("prelude"), parameters: ast::PathParameters::none(), - }), + }, + ast::PathSegment { + identifier: token::str_to_ident("v1"), + parameters: ast::PathParameters::none(), + }, + ], }; let (crates, uses) = view_items.partitioned(|x| { diff --git a/src/libsyntax/util/interner.rs b/src/libsyntax/util/interner.rs index 97eb4316583..d25161a12a7 100644 --- a/src/libsyntax/util/interner.rs +++ b/src/libsyntax/util/interner.rs @@ -15,10 +15,12 @@ use ast::Name; use std::borrow::BorrowFrom; -use std::collections::HashMap; use std::cell::RefCell; +use std::cmp::Ordering; +use std::collections::HashMap; use std::fmt; use std::hash::Hash; +use std::ops::Deref; use std::rc::Rc; pub struct Interner<T> { diff --git a/src/libsyntax/util/small_vector.rs b/src/libsyntax/util/small_vector.rs index 946181770c8..953a7ae960e 100644 --- a/src/libsyntax/util/small_vector.rs +++ b/src/libsyntax/util/small_vector.rs @@ -7,9 +7,11 @@ // <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. + use self::SmallVectorRepr::*; use self::IntoIterRepr::*; +use std::iter::FromIterator; use std::mem; use std::slice; use std::vec; |
