about summary refs log tree commit diff
path: root/src/libcore
AgeCommit message (Collapse)AuthorLines
2014-07-26std: Stabilize unit, bool, ty, tuple, arc, anyAlex Crichton-197/+182
This commit applies stability attributes to the contents of these modules, summarized here: * The `unit` and `bool` modules have become #[unstable] as they are purely meant for documentation purposes and are candidates for removal. * The `ty` module has been deprecated, and the inner `Unsafe` type has been renamed to `UnsafeCell` and moved to the `cell` module. The `marker1` field has been removed as the compiler now always infers `UnsafeCell` to be invariant. The `new` method i stable, but the `value` field, `get` and `unwrap` methods are all unstable. * The `tuple` module has its name as stable, the naming of the `TupleN` traits as stable while the methods are all #[unstable]. The other impls in the module have appropriate stability for the corresponding trait. * The `arc` module has received the exact same treatment as the `rc` module previously did. * The `any` module has its name as stable. The `Any` trait is also stable, with a new private supertrait which now contains the `get_type_id` method. This is to make the method a private implementation detail rather than a public-facing detail. The two extension traits in the module are marked #[unstable] as they will not be necessary with DST. The `is` method is #[stable], the as_{mut,ref} methods have been renamed to downcast_{mut,ref} and are #[unstable]. The extension trait `BoxAny` has been clarified as to why it is unstable as it will not be necessary with DST. This is a breaking change because the `marker1` field was removed from the `UnsafeCell` type. To deal with this change, you can simply delete the field and only specify the value of the `data` field in static initializers. [breaking-change]
2014-07-26auto merge of #15982 : alexcrichton/rust/rustdoc-fixes, r=brsonbors-0/+1
Sadly there's still a lot of open issues, but this tackles some of the more pressing ones. Each commit has its own description along with the issues it closes.
2014-07-25core: Remove unneeded cfgsBrian Anderson-37/+0
2014-07-25rustdoc: Hide impls for #[doc(hidden)] traitsAlex Crichton-0/+1
Closes #14585
2014-07-25Fix assert messageRandati-1/+1
2014-07-25librustc: Check built-in trait bounds on implementations when directPatrick Walton-1/+1
method calls are involved. This breaks code like: impl<T:Copy> Foo for T { ... } fn take_param<T:Foo>(foo: &T) { ... } fn main() { let x = box 3i; // note no `Copy` bound take_param(&x); } Change this code to not contain a type error. For example: impl<T:Copy> Foo for T { ... } fn take_param<T:Foo>(foo: &T) { ... } fn main() { let x = 3i; // satisfies `Copy` bound take_param(&x); } Closes #15860. [breaking-change]
2014-07-25Put the struct passed to unwinding functions into a staticBrian Anderson-1/+2
Produces very clean asm, but makes bigger binaries.
2014-07-25Make most of the failure functions take &(&'static str, uint)Brian Anderson-4/+43
Passing one pointer takes less code than one pointer and an integer.
2014-07-24librustc: Stop desugaring `for` expressions and translate them directly.Patrick Walton-9/+32
This makes edge cases in which the `Iterator` trait was not in scope and/or `Option` or its variants were not in scope work properly. This breaks code that looks like: struct MyStruct { ... } impl MyStruct { fn next(&mut self) -> Option<int> { ... } } for x in MyStruct { ... } { ... } Change ad-hoc `next` methods like the above to implementations of the `Iterator` trait. For example: impl Iterator<int> for MyStruct { fn next(&mut self) -> Option<int> { ... } } Closes #15392. [breaking-change]
2014-07-24librustc: Make bare functions implement the `FnMut` trait.Patrick Walton-0/+34
This is done entirely in the libraries for functions up to 16 arguments. A macro is used so that more arguments can be easily added if we need. Note that I had to adjust the overloaded call algorithm to not try calling the overloaded call operator if the callee is a built-in function type, to prevent loops. Closes #15448.
2014-07-24Add examples for Checked[Add|Sub|Mul|Div]nham-0/+32
2014-07-24auto merge of #15407 : sneves/rust/master, r=aturonbors-13/+13
At the moment, writing generic functions for integer types that involve shifting is rather verbose. For example, a function at shifts an integer left by 1 currently requires use std::num::One; fn f<T: Int>(x : T) -> T { x << One::one() } If the shift amount is not 1, it's even worse: use std::num::FromPrimitive; fn f<T: Int + FromPrimitive>(x: T) -> T { x << FromPrimitive::from_int(2).unwrap() } This patch allows the much simpler implementation fn f<T: Int>(x: T) -> T { x << 2 } It accomplishes this by changing the built-in integer types (and the `Int` trait) to implement `Shl<uint, T>` instead of `Shl<T, T>` as it currently is defined. Note that the internal implementations of `shl` already cast the right-hand side to `uint`. `BigInt` also implements `Shl<uint, BigInt>`, so this increases consistency. All of the above applies similarly to right shifts, i.e., `Shr<uint, T>`.
2014-07-23auto merge of #15900 : tbu-/rust/pr_numcleanup, r=kballardbors-18/+7
This removes the special casing for `float`s where it was not necessary, as `-0.0 == 0.0`.
2014-07-22Clean up some trait impls in core::num.Tobias Bucher-18/+7
This removes the special casing for `float`s where it was not necessary, as `-0.0 == 0.0`.
2014-07-22clarifying iterator trait documentationAlexis Beingessner-3/+10
2014-07-22auto merge of #15867 : cmr/rust/rewrite-lexer4, r=alexcrichtonbors-0/+4
2014-07-21Add a ton of ignore-lexer-testCorey Richardson-0/+2
2014-07-21Clarify range's exclusivity.Steve Klabnik-1/+13
Inspired by http://www.reddit.com/r/rust/comments/298js2/what_is_the_rationale_behind_the_second_parameter/
2014-07-21ignore-lexer-test to broken files and remove some tray hyphensCorey Richardson-0/+2
I blame @ChrisMorgan for the hyphens.
2014-07-20auto merge of #15806 : treeman/rust/std-doc, r=alexcrichtonbors-0/+24
Used `HashMap` and `HashSet` as the base of most examples. Could change it up with different containers, but I don't think it's a big deal.
2014-07-20auto merge of #15797 : brson/rust/taskstab, r=alexcrichtonbors-0/+33
Summary: * alloc::rc module stable * Rc type stable * Functions relating to weak references experimental * core::cmp module stable * PartialEq/Eq/PartialOrd/Ord unstable because trait reform will make them change again * Equiv experimental because there may be better sol'ns * lexical_ordering deprecated because it can be done trivially with the Ord trait * min/max stable * std::task module stable * TaskBuilder::stdout/stderr experimental because we aren't certain we want to configure the environment this way * try_future experimental because Future is experimental * try unstable because the error type might change * deschedule/failing unstable The major thing I did differently than previously-discussed is that I made `try` experimental: there's been discussion that the error type `Box<Any + Send>` is not sufficient. Per https://github.com/rust-lang/meeting-minutes/blob/master/Meeting-API-review-2014-07-16.md.
2014-07-19auto merge of #15638 : blake2-ppc/rust/ptr-arithmetic-chars, r=huonwbors-51/+113
Reimplement the string slice's `Iterator<char>` by wrapping the already efficient slice iterator. The iterator uses our guarantee that the string contains valid UTF-8, but its only unsafe code is transmuting the decoded `u32` into `char`. Benchmarks suggest that the runtime of `Chars` benchmarks are reduced by up to 30%, runtime of `Chars` reversed reduced by up to 60%. ``` BEFORE test str::bench::char_indicesator ... bench: 124 ns/iter (+/- 1) test str::bench::char_indicesator_rev ... bench: 188 ns/iter (+/- 9) test str::bench::char_iterator ... bench: 122 ns/iter (+/- 2) test str::bench::char_iterator_ascii ... bench: 302 ns/iter (+/- 41) test str::bench::char_iterator_for ... bench: 123 ns/iter (+/- 4) test str::bench::char_iterator_rev ... bench: 189 ns/iter (+/- 14) test str::bench::char_iterator_rev_for ... bench: 177 ns/iter (+/- 4) AFTER test str::bench::char_indicesator ... bench: 85 ns/iter (+/- 3) test str::bench::char_indicesator_rev ... bench: 82 ns/iter (+/- 2) test str::bench::char_iterator ... bench: 100 ns/iter (+/- 3) test str::bench::char_iterator_ascii ... bench: 317 ns/iter (+/- 3) test str::bench::char_iterator_for ... bench: 86 ns/iter (+/- 2) test str::bench::char_iterator_rev ... bench: 80 ns/iter (+/- 6) test str::bench::char_iterator_rev_for ... bench: 68 ns/iter (+/- 0) ``` Note: Branch name is no longer indicative of the implementation.
2014-07-19Simplify str CharOffsets iteratorroot-7/+7
Only one uint is needed to keep track of the offset from the original full string.
2014-07-19Document some trait methods.Jonas Hietala-0/+24
2014-07-18std: Stabilize defaultBrian Anderson-0/+2
All stable.
2014-07-18core: Stabliize core::cmpBrian Anderson-0/+31
Mark Eq, PartialEq, Ord, PartialOrd as unstable: they will change slightly after trait reform. Equiv as experimental: better solutions are desired. min/max stable.
2014-07-19Write multibyte case for str Chars iterator in-lineroot-59/+48
Thanks to comments from @alexcrichton, write the next/next_back function bodies without nested functions in a more top-to-bottom flow style. Also improve comment style and motivate the unsafe blocks with comments.
2014-07-19Clarify str Chars iterator implementationroot-13/+16
Thanks to comments from @huonw, clarify decoding details and use statics for important constants for UTF-8 decoding. Convert some magic numbers scattered in the same file to use the statics too.
2014-07-18librustc: Implement unboxed closures with mutable receiversPatrick Walton-0/+5
2014-07-17core::str: Implement Chars iterator using slice::Itemsroot-44/+114
Re-use the vector iterator to implement the chars iterator. The iterator uses our guarantee that the string contains valid UTF-8, but its only unsafe code is transmuting the decoded u32 into char.
2014-07-14auto merge of #15632 : masklinn/rust/patch-1, r=alexcrichtonbors-2/+8
I saw that it was bounded by `Show` but the implication is no guarantee (and had only 0.10 to test, where this behavior has been added to 0.11)
2014-07-14Document that Result.unwrap prints the Err's valuemasklinn-2/+8
It is implied by the Show bound, but that implication can be missed.
2014-07-13auto merge of #15591 : aturon/rust/box-cell-stability, r=alexcrichtonbors-3/+21
This PR is the outcome of the library stabilization meeting for the `liballoc::owned` and `libcore::cell` modules. Aside from the stability attributes, there are a few breaking changes: * The `owned` modules is now named `boxed`, to better represent its contents. (`box` was unavailable, since it's a keyword.) This will help avoid the misconception that `Box` plays a special role wrt ownership. * The `AnyOwnExt` extension trait is renamed to `BoxAny`, and its `move` method is renamed to `downcast`, in both cases to improve clarity. * The recently-added `AnySendOwnExt` extension trait is removed; it was not being used and is unnecessary. [breaking-change]
2014-07-13Stabilization for `owned` (now `boxed`) and `cell`Aaron Turon-3/+21
This PR is the outcome of the library stabilization meeting for the `liballoc::owned` and `libcore::cell` modules. Aside from the stability attributes, there are a few breaking changes: * The `owned` modules is now named `boxed`, to better represent its contents. (`box` was unavailable, since it's a keyword.) This will help avoid the misconception that `Box` plays a special role wrt ownership. * The `AnyOwnExt` extension trait is renamed to `BoxAny`, and its `move` method is renamed to `downcast`, in both cases to improve clarity. * The recently-added `AnySendOwnExt` extension trait is removed; it was not being used and is unnecessary. [breaking-change]
2014-07-13Add an iterate function to core::iterJakub Wieczorek-4/+25
Implementation by Kevin Ballard. The function returns an Unfold iterator producing an infinite stream of results of repeated applications of the function, starting from the provided seed value.
2014-07-12auto merge of #15610 : brson/rust/0.12.0, r=alexcrichtonbors-1/+1
2014-07-11Update doc URLs for version bumpBrian Anderson-1/+1
2014-07-11auto merge of #15575 : mvdnes/rust/spinlock_error, r=alexcrichtonbors-1/+1
The current example of a spinlock was not correct. The lock is actually acquired when `old == result`. So we only need to deschedule when this is not the case.
2014-07-10auto merge of #14519 : hirschenberger/rust/issue-10934, r=alexcrichtonbors-0/+4
Issue #10934
2014-07-10auto merge of #15569 : pcwalton/rust/reexport-intrinsics, r=cmrbors-89/+67
code bloat. This didn't make a difference in any compile times that I saw, but it fits what we're doing with `transmute` and seems prudent. r? @alexcrichton
2014-07-10Mistake in AtomicBool spinlock exampleMathijs van de Nes-1/+1
The current example of a spinlock was not correct. The lock is actually acquired when old == result. So we only need to deschedule when this is not the case.
2014-07-10Add range lint for float literals, fixing #10934Falco Hirschenberger-0/+4
2014-07-09libcore: Reexport a couple of widely-used low-level intrinsics to reducePatrick Walton-89/+67
code bloat. This didn't make a difference in any compile times that I saw, but it fits what we're doing with `transmute` and seems prudent.
2014-07-10auto merge of #15561 : huonw/rust/must-use-iterators, r=alexcrichtonbors-1/+18
Similar to the stability attributes, a type annotated with `#[must_use = "informative snippet"]` will print the normal warning message along with "informative snippet". This allows the type author to provide some guidance about why the type should be used. --- It can be a little unintuitive that something like `v.iter().map(|x| println!("{}", x));` does nothing: the majority of the iterator adaptors are lazy and do not execute anything until something calls `next`, e.g. a `for` loop, `collect`, `fold`, etc. The majority of such errors can be seen by someone writing something like the above, i.e. just calling an iterator adaptor and doing nothing with it (and doing this is certainly useless), so we can co-opt the `must_use` lint, using the message functionality to give a hint to the reason why. Fixes #14666.
2014-07-10auto merge of #15556 : alexcrichton/rust/snapshots, r=brsonbors-5/+0
Closes #15544
2014-07-09libcore: Deprecate advance method on Iterators.Luqman Aden-1/+2
2014-07-10core: add `#[must_use]` attributes to iterator adaptor structs.Huon Wilson-1/+18
It can be a little unintuitive that something like `v.iter().map(|x| println!("{}", x));` does nothing: the majority of the iterator adaptors are lazy and do not execute anything until something calls `next`, e.g. a `for` loop, `collect`, `fold`, etc. The majority of such errors can be seen by someone writing something like the above, i.e. just calling an iterator adaptor and doing nothing with it (and doing this is certainly useless), so we can co-opt the `must_use` lint, using the message functionality to give a hint to the reason why. Fixes #14666.
2014-07-09auto merge of #15283 : kwantam/rust/master, r=alexcrichtonbors-5377/+4
Add libunicode; move unicode functions from core - created new crate, libunicode, below libstd - split `Char` trait into `Char` (libcore) and `UnicodeChar` (libunicode) - Unicode-aware functions now live in libunicode - `is_alphabetic`, `is_XID_start`, `is_XID_continue`, `is_lowercase`, `is_uppercase`, `is_whitespace`, `is_alphanumeric`, `is_control`, `is_digit`, `to_uppercase`, `to_lowercase` - added `width` method in UnicodeChar trait - determines printed width of character in columns, or None if it is a non-NULL control character - takes a boolean argument indicating whether the present context is CJK or not (characters with 'A'mbiguous widths are double-wide in CJK contexts, single-wide otherwise) - split `StrSlice` into `StrSlice` (libcore) and `UnicodeStrSlice` (libunicode) - functionality formerly in `StrSlice` that relied upon Unicode functionality from `Char` is now in `UnicodeStrSlice` - `words`, `is_whitespace`, `is_alphanumeric`, `trim`, `trim_left`, `trim_right` - also moved `Words` type alias into libunicode because `words` method is in `UnicodeStrSlice` - unified Unicode tables from libcollections, libcore, and libregex into libunicode - updated `unicode.py` in `src/etc` to generate aforementioned tables - generated new tables based on latest Unicode data - added `UnicodeChar` and `UnicodeStrSlice` traits to prelude - libunicode is now the collection point for the `std::char` module, combining the libunicode functionality with the `Char` functionality from libcore - thus, moved doc comment for `char` from `core::char` to `unicode::char` - libcollections remains the collection point for `std::str` The Unicode-aware functions that previously lived in the `Char` and `StrSlice` traits are no longer available to programs that only use libcore. To regain use of these methods, include the libunicode crate and `use` the `UnicodeChar` and/or `UnicodeStrSlice` traits: extern crate unicode; use unicode::UnicodeChar; use unicode::UnicodeStrSlice; use unicode::Words; // if you want to use the words() method NOTE: this does *not* impact programs that use libstd, since UnicodeChar and UnicodeStrSlice have been added to the prelude. closes #15224 [breaking-change]
2014-07-09Register new snapshotsAlex Crichton-5/+0
Closes #15544
2014-07-09auto merge of #15483 : AlisdairO/rust/master, r=alexcrichtonbors-6/+55
Noticed there wasn't an awful lot of info out there on using Any types, so added an example to the rustdocs.