about summary refs log tree commit diff
path: root/src/libsyntax
diff options
context:
space:
mode:
authorAlex Crichton <alex@alexcrichton.com>2014-12-22 09:04:23 -0800
committerAlex Crichton <alex@alexcrichton.com>2015-01-02 08:54:06 -0800
commit56290a004493a5d2e211f056601533253497df60 (patch)
treeab0e7c227f9ba155ea5bfd0390cada43062924c1 /src/libsyntax
parent71b46b18a274edc7f7fb60b490e5ebbb9c911462 (diff)
downloadrust-56290a004493a5d2e211f056601533253497df60.tar.gz
rust-56290a004493a5d2e211f056601533253497df60.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.rs19
-rw-r--r--src/libsyntax/ext/bytes.rs1
-rw-r--r--src/libsyntax/ext/quote.rs3
-rw-r--r--src/libsyntax/owned_slice.rs4
-rw-r--r--src/libsyntax/parse/lexer/mod.rs3
-rw-r--r--src/libsyntax/parse/parser.rs3
-rw-r--r--src/libsyntax/parse/token.rs2
-rw-r--r--src/libsyntax/ptr.rs20
-rw-r--r--src/libsyntax/std_inject.rs9
-rw-r--r--src/libsyntax/util/interner.rs4
-rw-r--r--src/libsyntax/util/small_vector.rs2
11 files changed, 45 insertions, 25 deletions
diff --git a/src/libsyntax/codemap.rs b/src/libsyntax/codemap.rs
index e61afb8b193..5eac6546c6b 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..9f225d55b44 100644
--- a/src/libsyntax/ext/bytes.rs
+++ b/src/libsyntax/ext/bytes.rs
@@ -17,7 +17,6 @@ use ext::base;
 use ext::build::AstBuilder;
 use std::ascii::AsciiExt;
 
-
 pub fn expand_syntax_ext<'cx>(cx: &'cx mut ExtCtxt,
                               sp: Span,
                               tts: &[ast::TokenTree])
diff --git a/src/libsyntax/ext/quote.rs b/src/libsyntax/ext/quote.rs
index d87960ebdb8..e46bd7ac4bc 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/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 457085f5cc8..832b112921e 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 f22a4b5c6ed..9c6644c5204 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 c1823231e24..5a4d0cc3bd8 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): (Vec<_>, _) = view_items.iter().cloned().partition(|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;