Skip to content

Roll-up PRs in the queue #18978

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 38 commits into from Nov 16, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
769d49a
Don't use rust keyword for fake code
IanConnolly Nov 13, 2014
fb954a1
src/etc/snapshot: support triples lacking a vendor
codyps Nov 13, 2014
643edea
Remove BTreeSet from all examples.
jbcrail Nov 14, 2014
93c4942
Rewrite std::sync::TaskPool to be load balancing and panic-resistant
reem Nov 14, 2014
0053fbb
serialize: Add ToJson impl for str
tomjakubowski Nov 14, 2014
9416935
Improve examples for syntax::ext::deriving::encodable
barosl Nov 14, 2014
7eae5b4
impl Default for Cell and RefCell
stepancheg Nov 14, 2014
ccbda28
Hide interactive elements when printing rustdoc
coyotebush Nov 14, 2014
5416901
librustc: use type parameters less vigorously when giving the IR type…
emberian Nov 15, 2014
4caffa8
libs: fix #[stable] inheritance fallout
aturon Nov 15, 2014
60741e0
rustdoc: tweak stability summary counting
aturon Nov 15, 2014
3391ddd
Slightly improved rustc error messages for invalid -C arguments
inrustwetrust Nov 15, 2014
3e0368e
std: Fix a flaky test on OSX 10.10
alexcrichton Nov 15, 2014
e94cd40
Fixed several typos
alex Nov 15, 2014
c523261
doc: small grammar fix
Nov 15, 2014
29bc9c6
Move FromStr to core::str
brendanzab Nov 15, 2014
68bd495
Remove core::num::strconv
brendanzab Nov 15, 2014
8b15672
Remove use of deprecated function
brendanzab Nov 15, 2014
2d8ca04
Rename IntoStr to IntoString
brendanzab Nov 15, 2014
59abf75
Move IntoString to collections::string
brendanzab Nov 15, 2014
d82a7ea
Move ToString to collections::string
brendanzab Nov 16, 2014
ecf765d
rollup merge of #18933: IanConnolly/doc-fake-rust
Nov 16, 2014
0d97b95
rollup merge of #18935: jmesmon/cody/no-vendor-triplle
Nov 16, 2014
c7fc332
rollup merge of #18941: reem/better-task-pool
Nov 16, 2014
b45dbfb
rollup merge of #18942: jbcrail/tree-set-docs
Nov 16, 2014
1214409
rollup merge of #18948: barosl/doc-encodable-fix
Nov 16, 2014
f7be596
rollup merge of #18949: tomjakubowski/tojson-str
Nov 16, 2014
c46b5b5
rollup merge of #18960: stepancheg/cell-default
Nov 16, 2014
c01c6e2
rollup merge of #18964: coyotebush/rustdoc-print
Nov 16, 2014
f3fd09a
rollup merge of #18965: cmr/master
Nov 16, 2014
42c77f4
rollup merge of #18970: aturon/fixup-stable
Nov 16, 2014
4c30cb2
rollup merge of #18976: bjz/rfc369-numerics
Nov 16, 2014
94c8bb4
rollup merge of #18979: inrustwetrust/codegen-options-parsing
Nov 16, 2014
086b297
rollup merge of #18985: alexcrichton/issue-18900
Nov 16, 2014
a9f9e80
rollup merge of #18989: alex/fix-typos
Nov 16, 2014
b22afe9
rollup merge of #18990: alfie/master
Nov 16, 2014
3ee9f0d
Fix warnings
Nov 16, 2014
892d4e2
Fix doctests
Nov 16, 2014
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/compiletest/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

use std::from_str::FromStr;
use std::fmt;
use std::str::FromStr;
use regex::Regex;

#[deriving(Clone, PartialEq)]
Expand Down
2 changes: 1 addition & 1 deletion src/compiletest/compiletest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ extern crate regex;
use std::os;
use std::io;
use std::io::fs;
use std::from_str::FromStr;
use std::str::FromStr;
use getopts::{optopt, optflag, reqopt};
use common::Config;
use common::{Pretty, DebugInfoGdb, DebugInfoLldb, Codegen};
Expand Down
8 changes: 3 additions & 5 deletions src/compiletest/header.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ use common::Config;
use common;
use util;

use std::from_str::FromStr;

pub struct TestProps {
// Lines that should be expected, in order, on standard out
pub error_patterns: Vec<String> ,
Expand Down Expand Up @@ -353,8 +351,8 @@ pub fn gdb_version_to_int(version_string: &str) -> int {
panic!("{}", error_string);
}

let major: int = FromStr::from_str(components[0]).expect(error_string);
let minor: int = FromStr::from_str(components[1]).expect(error_string);
let major: int = from_str(components[0]).expect(error_string);
let minor: int = from_str(components[1]).expect(error_string);

return major * 1000 + minor;
}
Expand All @@ -364,6 +362,6 @@ pub fn lldb_version_to_int(version_string: &str) -> int {
"Encountered LLDB version string with unexpected format: {}",
version_string);
let error_string = error_string.as_slice();
let major: int = FromStr::from_str(version_string).expect(error_string);
let major: int = from_str(version_string).expect(error_string);
return major;
}
2 changes: 1 addition & 1 deletion src/doc/complement-design-faq.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ code should need to run is a stack.
`match` being exhaustive has some useful properties. First, if every
possibility is covered by the `match`, adding further variants to the `enum`
in the future will prompt a compilation failure, rather than runtime panic.
Second, it makes cost explicit. In general, only safe way to have a
Second, it makes cost explicit. In general, the only safe way to have a
non-exhaustive match would be to panic the task if nothing is matched, though
it could fall through if the type of the `match` expression is `()`. This sort
of hidden cost and special casing is against the language's philosophy. It's
Expand Down
16 changes: 8 additions & 8 deletions src/doc/guide-pointers.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,11 +133,11 @@ pass-by-reference. Basically, languages can make two choices (this is made
up syntax, it's not Rust):

```{notrust,ignore}
fn foo(x) {
func foo(x) {
x = 5
}

fn main() {
func main() {
i = 1
foo(i)
// what is the value of i here?
Expand All @@ -153,11 +153,11 @@ So what do pointers have to do with this? Well, since pointers point to a
location in memory...

```{notrust,ignore}
fn foo(&int x) {
func foo(&int x) {
*x = 5
}

fn main() {
func main() {
i = 1
foo(&i)
// what is the value of i here?
Expand Down Expand Up @@ -192,13 +192,13 @@ When you combine pointers and functions, it's easy to accidentally invalidate
the memory the pointer is pointing to. For example:

```{notrust,ignore}
fn make_pointer(): &int {
func make_pointer(): &int {
x = 5;

return &x;
}

fn main() {
func main() {
&int i = make_pointer();
*i = 5; // uh oh!
}
Expand All @@ -214,11 +214,11 @@ issue. Two pointers are said to alias when they point at the same location
in memory. Like this:

```{notrust,ignore}
fn mutate(&int i, int j) {
func mutate(&int i, int j) {
*i = j;
}

fn main() {
func main() {
x = 5;
y = &x;
z = &x; //y and z are aliased
Expand Down
2 changes: 1 addition & 1 deletion src/doc/guide-strings.md
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ println!("{}", s[0]);
This does not compile. This is on purpose. In the world of UTF-8, direct
indexing is basically never what you want to do. The reason is that each
character can be a variable number of bytes. This means that you have to iterate
through the characters anyway, which is a O(n) operation.
through the characters anyway, which is an O(n) operation.

There's 3 basic levels of unicode (and its encodings):

Expand Down
15 changes: 7 additions & 8 deletions src/doc/reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -2526,7 +2526,7 @@ The currently implemented features of the reference compiler are:

* `plugin_registrar` - Indicates that a crate has [compiler plugins][plugin] that it
wants to load. As with `phase`, the implementation is
in need of a overhaul, and it is not clear that plugins
in need of an overhaul, and it is not clear that plugins
defined using this will continue to work.

* `quote` - Allows use of the `quote_*!` family of macros, which are
Expand Down Expand Up @@ -2583,7 +2583,7 @@ there isn't a parser error first). The directive in this case is no longer
necessary, and it's likely that existing code will break if the feature isn't
removed.

If a unknown feature is found in a directive, it results in a compiler error.
If an unknown feature is found in a directive, it results in a compiler error.
An unknown feature is one which has never been recognized by the compiler.

# Statements and expressions
Expand Down Expand Up @@ -2685,7 +2685,7 @@ When an lvalue is evaluated in an _lvalue context_, it denotes a memory
location; when evaluated in an _rvalue context_, it denotes the value held _in_
that memory location.

When an rvalue is used in lvalue context, a temporary un-named lvalue is
When an rvalue is used in an lvalue context, a temporary un-named lvalue is
created and used instead. A temporary's lifetime equals the largest lifetime
of any reference that points to it.

Expand Down Expand Up @@ -2833,7 +2833,7 @@ foo().x;
```

A field access is an [lvalue](#lvalues,-rvalues-and-temporaries) referring to
the value of that field. When the type providing the field inherits mutabilty,
the value of that field. When the type providing the field inherits mutability,
it can be [assigned](#assignment-expressions) to.

Also, if the type of the expression to the left of the dot is a pointer, it is
Expand Down Expand Up @@ -3108,11 +3108,10 @@ then the expression completes.
Some examples of call expressions:

```
# use std::from_str::FromStr;
# fn add(x: int, y: int) -> int { 0 }

let x: int = add(1, 2);
let pi: Option<f32> = FromStr::from_str("3.14");
let pi: Option<f32> = from_str("3.14");
```

### Lambda expressions
Expand Down Expand Up @@ -3321,7 +3320,7 @@ between `_` and `..` is that the pattern `C(_)` is only type-correct if `C` has
exactly one argument, while the pattern `C(..)` is type-correct for any enum
variant `C`, regardless of how many arguments `C` has.

Used inside a array pattern, `..` stands for any number of elements, when the
Used inside an array pattern, `..` stands for any number of elements, when the
`advanced_slice_patterns` feature gate is turned on. This wildcard can be used
at most once for a given array, which implies that it cannot be used to
specifically match elements that are at an unknown distance from both ends of a
Expand Down Expand Up @@ -3584,7 +3583,7 @@ is not a surrogate), represented as a 32-bit unsigned word in the 0x0000 to
0xD7FF or 0xE000 to 0x10FFFF range. A `[char]` array is effectively an UCS-4 /
UTF-32 string.

A value of type `str` is a Unicode string, represented as a array of 8-bit
A value of type `str` is a Unicode string, represented as an array of 8-bit
unsigned bytes holding a sequence of UTF-8 codepoints. Since `str` is of
unknown size, it is not a _first class_ type, but can only be instantiated
through a pointer type, such as `&str` or `String`.
Expand Down
6 changes: 5 additions & 1 deletion src/etc/snapshot.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,11 @@ def full_snapshot_name(date, rev, platform, hsh):


def get_kernel(triple):
os_name = triple.split('-')[2]
t = triple.split('-')
if len(t) == 2:
os_name = t[1]
else:
os_name = t[2]
if os_name == "windows":
return "winnt"
if os_name == "darwin":
Expand Down
2 changes: 1 addition & 1 deletion src/etc/vim/syntax/rust.vim
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ syn keyword rustTrait RawPtr
syn keyword rustTrait Buffer Writer Reader Seek
syn keyword rustTrait Str StrVector StrSlice
syn keyword rustTrait IntoMaybeOwned StrAllocating UnicodeStrSlice
syn keyword rustTrait ToString IntoStr
syn keyword rustTrait ToString IntoString
syn keyword rustTrait Tuple1 Tuple2 Tuple3 Tuple4
syn keyword rustTrait Tuple5 Tuple6 Tuple7 Tuple8
syn keyword rustTrait Tuple9 Tuple10 Tuple11 Tuple12
Expand Down
4 changes: 1 addition & 3 deletions src/liballoc/rc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -179,9 +179,9 @@ pub struct Rc<T> {
_noshare: marker::NoSync
}

#[stable]
impl<T> Rc<T> {
/// Constructs a new reference-counted pointer.
#[stable]
pub fn new(value: T) -> Rc<T> {
unsafe {
Rc {
Expand All @@ -200,9 +200,7 @@ impl<T> Rc<T> {
}
}
}
}

impl<T> Rc<T> {
/// Downgrades the reference-counted pointer to a weak reference.
#[experimental = "Weak pointers may not belong in this module"]
pub fn downgrade(&self) -> Weak<T> {
Expand Down
1 change: 1 addition & 0 deletions src/libcollections/str.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ pub use core::str::{CharSplitsN, AnyLines, MatchIndices, StrSplits};
pub use core::str::{Utf16CodeUnits, eq_slice, is_utf8, is_utf16, Utf16Items};
pub use core::str::{Utf16Item, ScalarValue, LoneSurrogate, utf16_items};
pub use core::str::{truncate_utf16_at_nul, utf8_char_width, CharRange};
pub use core::str::{FromStr, from_str};
pub use core::str::{Str, StrPrelude};
pub use unicode::str::{UnicodeStrPrelude, Words, Graphemes, GraphemeIndices};

Expand Down
53 changes: 51 additions & 2 deletions src/libcollections/string.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ use core::raw::Slice as RawSlice;
use hash;
use slice::CloneSliceAllocPrelude;
use str;
use str::{CharRange, StrAllocating, MaybeOwned, Owned};
use str::{CharRange, FromStr, StrAllocating, MaybeOwned, Owned};
use str::Slice as MaybeOwnedSlice; // So many `Slice`s...
use vec::{DerefVec, Vec, as_vec};

Expand Down Expand Up @@ -795,6 +795,33 @@ pub fn as_string<'a>(x: &'a str) -> DerefString<'a> {
DerefString { x: as_vec(x.as_bytes()) }
}

impl FromStr for String {
#[inline]
fn from_str(s: &str) -> Option<String> {
Some(String::from_str(s))
}
}

/// Trait for converting a type to a string, consuming it in the process.
pub trait IntoString {
/// Consume and convert to a string.
fn into_string(self) -> String;
}

/// A generic trait for converting a value to a string
pub trait ToString {
/// Converts the value of `self` to an owned string
fn to_string(&self) -> String;
}

impl<T: fmt::Show> ToString for T {
fn to_string(&self) -> String {
let mut buf = Vec::<u8>::new();
let _ = format_args!(|args| fmt::write(&mut buf, args), "{}", self);
String::from_utf8(buf).unwrap()
}
}

/// Unsafe operations
#[unstable = "waiting on raw module conventions"]
pub mod raw {
Expand Down Expand Up @@ -860,7 +887,7 @@ mod tests {

use str;
use str::{Str, StrPrelude, Owned};
use super::{as_string, String};
use super::{as_string, String, ToString};
use vec::Vec;
use slice::CloneSliceAllocPrelude;

Expand Down Expand Up @@ -1164,6 +1191,28 @@ mod tests {
assert_eq!("oob", s[1..4]);
}

#[test]
fn test_simple_types() {
assert_eq!(1i.to_string(), "1".to_string());
assert_eq!((-1i).to_string(), "-1".to_string());
assert_eq!(200u.to_string(), "200".to_string());
assert_eq!(2u8.to_string(), "2".to_string());
assert_eq!(true.to_string(), "true".to_string());
assert_eq!(false.to_string(), "false".to_string());
assert_eq!(().to_string(), "()".to_string());
assert_eq!(("hi".to_string()).to_string(), "hi".to_string());
}

#[test]
fn test_vectors() {
let x: Vec<int> = vec![];
assert_eq!(x.to_string(), "[]".to_string());
assert_eq!((vec![1i]).to_string(), "[1]".to_string());
assert_eq!((vec![1i, 2, 3]).to_string(), "[1, 2, 3]".to_string());
assert!((vec![vec![], vec![1i], vec![1i, 1]]).to_string() ==
"[[], [1], [1, 1]]".to_string());
}

#[bench]
fn bench_with_capacity(b: &mut Bencher) {
b.iter(|| {
Expand Down
8 changes: 4 additions & 4 deletions src/libcollections/tree/set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -504,9 +504,9 @@ impl<T: Ord> TreeSet<T> {
/// # Example
///
/// ```
/// use std::collections::BTreeSet;
/// use std::collections::TreeSet;
///
/// let mut set = BTreeSet::new();
/// let mut set = TreeSet::new();
///
/// assert_eq!(set.insert(2i), true);
/// assert_eq!(set.insert(2i), false);
Expand All @@ -522,9 +522,9 @@ impl<T: Ord> TreeSet<T> {
/// # Example
///
/// ```
/// use std::collections::BTreeSet;
/// use std::collections::TreeSet;
///
/// let mut set = BTreeSet::new();
/// let mut set = TreeSet::new();
///
/// set.insert(2i);
/// assert_eq!(set.remove(&2), true);
Expand Down
8 changes: 7 additions & 1 deletion src/libcollections/vec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -645,7 +645,6 @@ impl<T> Vec<T> {
/// assert!(vec.capacity() >= 3);
/// ```
#[stable]
#[unstable = "matches collection reform specification, waiting for dust to settle"]
pub fn shrink_to_fit(&mut self) {
if mem::size_of::<T>() == 0 { return }

Expand Down Expand Up @@ -1653,6 +1652,13 @@ impl<T> Vec<T> {
}
}

impl<'a> fmt::FormatWriter for Vec<u8> {
fn write(&mut self, buf: &[u8]) -> fmt::Result {
self.push_all(buf);
Ok(())
}
}

#[cfg(test)]
mod tests {
extern crate test;
Expand Down
4 changes: 1 addition & 3 deletions src/libcore/any.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ use intrinsics::TypeId;
#[stable]
pub trait Any: 'static {
/// Get the `TypeId` of `self`
#[stable]
fn get_type_id(&self) -> TypeId;
}

Expand Down Expand Up @@ -117,7 +118,6 @@ pub trait AnyRefExt<'a> {
#[stable]
impl<'a> AnyRefExt<'a> for &'a Any {
#[inline]
#[stable]
fn is<T: 'static>(self) -> bool {
// Get TypeId of the type this function is instantiated with
let t = TypeId::of::<T>();
Expand All @@ -130,7 +130,6 @@ impl<'a> AnyRefExt<'a> for &'a Any {
}

#[inline]
#[unstable = "naming conventions around acquiring references may change"]
fn downcast_ref<T: 'static>(self) -> Option<&'a T> {
if self.is::<T>() {
unsafe {
Expand Down Expand Up @@ -159,7 +158,6 @@ pub trait AnyMutRefExt<'a> {
#[stable]
impl<'a> AnyMutRefExt<'a> for &'a mut Any {
#[inline]
#[unstable = "naming conventions around acquiring references may change"]
fn downcast_mut<T: 'static>(self) -> Option<&'a mut T> {
if self.is::<T>() {
unsafe {
Expand Down
Loading