Commit Graph

3286 Commits

Author SHA1 Message Date
bors
4afc15e30c auto merge of #14259 : alexcrichton/rust/core-mem, r=brson
Excluding the functions inherited from the cast module last week (with marked
stability levels), these functions received the following treatment.

* size_of - this method has become #[stable]
* nonzero_size_of/nonzero_size_of_val - these methods have been removed
* min_align_of - this method is now #[stable]
* pref_align_of - this method has been renamed without the
  `pref_` prefix, and it is the "default alignment" now. This decision is in line
  with what clang does (see url linked in comment on function). This function
  is now #[stable].
* init - renamed to zeroed and marked #[stable]
* uninit - marked #[stable]
* move_val_init - renamed to overwrite and marked #[stable]
* {from,to}_{be,le}{16,32,64} - all functions marked #[stable]
* swap/replace/drop - marked #[stable]
* size_of_val/min_align_of_val/align_of_val - these functions are marked
  #[unstable], but will continue to exist in some form. Concerns have been
  raised about their `_val` prefix.
2014-05-20 23:31:30 -07:00
Alex Crichton
19dc3b50bd core: Stabilize the mem module
Excluding the functions inherited from the cast module last week (with marked
stability levels), these functions received the following treatment.

* size_of - this method has become #[stable]
* nonzero_size_of/nonzero_size_of_val - these methods have been removed
* min_align_of - this method is now #[stable]
* pref_align_of - this method has been renamed without the
  `pref_` prefix, and it is the "default alignment" now. This decision is in line
  with what clang does (see url linked in comment on function). This function
  is now #[stable].
* init - renamed to zeroed and marked #[stable]
* uninit - marked #[stable]
* move_val_init - renamed to overwrite and marked #[stable]
* {from,to}_{be,le}{16,32,64} - all functions marked #[stable]
* swap/replace/drop - marked #[stable]
* size_of_val/min_align_of_val/align_of_val - these functions are marked
  #[unstable], but will continue to exist in some form. Concerns have been
  raised about their `_val` prefix.

[breaking-change]
2014-05-20 23:06:54 -07:00
bors
feb9f302ca auto merge of #14293 : alexcrichton/rust/weak-lang-items, r=brson
This commit is part of the ongoing libstd facade efforts (cc #13851). The
compiler now recognizes some language items as "extern { fn foo(...); }" and
will automatically perform the following actions:

1. The foreign function has a pre-defined name.
2. The crate and downstream crates can only be built as rlibs until a crate
   defines the lang item itself.
3. The actual lang item has a pre-defined name.

This is essentially nicer compiler support for the hokey
core-depends-on-std-failure scheme today, but it is implemented the same way.
The details are a little more hidden under the covers.

In addition to failure, this commit promotes the eh_personality and
rust_stack_exhausted functions to official lang items. The compiler can generate
calls to these functions, causing linkage errors if they are left undefined. The
checking for these items is not as precise as it could be. Crates compiling with
`-Z no-landing-pads` will not need the eh_personality lang item, and crates
compiling with no split stacks won't need the stack exhausted lang item. For
ease, however, these items are checked for presence in all final outputs of the
compiler.

It is quite easy to define dummy versions of the functions necessary:

    #[lang = "stack_exhausted"]
    extern fn stack_exhausted() { /* ... */ }

    #[lang = "eh_personality"]
    extern fn eh_personality() { /* ... */ }

cc #11922, rust_stack_exhausted is now a lang item
cc #13851, libcollections is blocked on eh_personality becoming weak
2014-05-20 21:36:25 -07:00
Kevin Ballard
c7454853d2 Remove useless ToPrimitive bound on range_inclusive() 2014-05-20 20:27:34 -07:00
Brian Anderson
c9ab33a8fd Address review comments 2014-05-20 11:39:40 -07:00
Brian Anderson
26e4680ae5 core: Convert TODOs to FIXMEs 2014-05-20 10:40:14 -07:00
Brian Anderson
cea4c27806 core: Spruce up the crate description 2014-05-20 10:38:22 -07:00
Brian Anderson
220313e5e6 core: More concise description for mod ops 2014-05-20 10:38:21 -07:00
Brian Anderson
8f2a2e2dd8 core: Improve docs for cell 2014-05-20 10:38:21 -07:00
bors
ec8ec54192 auto merge of #14289 : TyOverby/rust/master, r=alexcrichton
Closes #14278.

Previously the type signatures of the ordering functions in `core::iter::order` took two iterators, but only if they were the same type of iterator.  This commit loosens that restriction and allows different kinds of iterators (but with the same type of elements) to be compared.
2014-05-19 22:01:21 -07:00
TyOverby
3001450f95 core::iter::order functions now take two types of iterators.
Previously the type signatures of the ordering functions in
`core::iter::order` took two iterators, but only if they were
the same type of iterator.  This commit loosens that restriction
and allows different kinds of iterators (but with the same type
of elements) to be compared.
2014-05-19 17:37:39 -07:00
bors
1c4a9b98b9 auto merge of #14294 : kballard/rust/result_unwrap_or_else, r=alexcrichton
Result.unwrap_or_handle() is the equivalent of Option.unwrap_or_else().
In the interests of naming consistency, call it the same thing.

[breaking-change]
2014-05-19 13:36:22 -07:00
Kevin Ballard
24468278fd Rename Result.unwrap_or_handle() to .unwrap_or_else()
Result.unwrap_or_handle() is the equivalent of Option.unwrap_or_else().
In the interests of naming consistency, call it the same thing.

[breaking-change]
2014-05-19 13:11:49 -07:00
bors
44fcf46b00 auto merge of #14292 : limeburst/rust/master, r=alexcrichton 2014-05-19 11:56:32 -07:00
Alex Crichton
6efd16629c rustc: Add official support for weak failure
This commit is part of the ongoing libstd facade efforts (cc #13851). The
compiler now recognizes some language items as "extern { fn foo(...); }" and
will automatically perform the following actions:

1. The foreign function has a pre-defined name.
2. The crate and downstream crates can only be built as rlibs until a crate
   defines the lang item itself.
3. The actual lang item has a pre-defined name.

This is essentially nicer compiler support for the hokey
core-depends-on-std-failure scheme today, but it is implemented the same way.
The details are a little more hidden under the covers.

In addition to failure, this commit promotes the eh_personality and
rust_stack_exhausted functions to official lang items. The compiler can generate
calls to these functions, causing linkage errors if they are left undefined. The
checking for these items is not as precise as it could be. Crates compiling with
`-Z no-landing-pads` will not need the eh_personality lang item, and crates
compiling with no split stacks won't need the stack exhausted lang item. For
ease, however, these items are checked for presence in all final outputs of the
compiler.

It is quite easy to define dummy versions of the functions necessary:

    #[lang = "stack_exhausted"]
    extern fn stack_exhausted() { /* ... */ }

    #[lang = "eh_personality"]
    extern fn eh_personality() { /* ... */ }

cc #11922, rust_stack_exhausted is now a lang item
cc #13851, libcollections is blocked on eh_personality becoming weak
2014-05-19 11:04:44 -07:00
Jihyeok Seo
564b925036 Fix typo in libcore 2014-05-20 00:51:16 +09:00
Piotr Jawniak
cea63ecfb1 Minor doc fixes in various places 2014-05-19 15:41:06 +02:00
bors
4b81b6d5f4 auto merge of #14276 : aochagavia/rust/pr, r=alexcrichton 2014-05-18 19:51:26 -07:00
Adolfo Ochagavía
9a8ef9197b Removed unnecessary transmute 2014-05-18 11:48:46 -07:00
bors
2b4cdea7f1 auto merge of #14258 : alexcrichton/rust/dox-format-writer, r=cmr
This commit fills in the documentation holes for the FormatWriter trait which
were previously accidentally left blank. Additionally, this adds the `write_fmt`
method to the trait to allow usage of the `write!` macro with implementors of
the `FormatWriter` trait. This is not useful for consumers of the standard
library who should generally avoid the `FormatWriter` trait, but it is useful
for consumers of the core library who are not using the standard library.
2014-05-18 02:51:30 -07:00
bors
a62395f01c auto merge of #14249 : alexcrichton/rust/issue-14246, r=huonw
Closes #14246
2014-05-17 23:41:28 -07:00
Alex Crichton
14d3dbe292 core: Document FormatWriter and allow write!
This commit fills in the documentation holes for the FormatWriter trait which
were previously accidentally left blank. Additionally, this adds the `write_fmt`
method to the trait to allow usage of the `write!` macro with implementors of
the `FormatWriter` trait. This is not useful for consumers of the standard
library who should generally avoid the `FormatWriter` trait, but it is useful
for consumers of the core library who are not using the standard library.
2014-05-17 22:10:39 -07:00
Alex Crichton
0989f5c2e7 core: Clarify the documentation on core's prelude
Closes #14246
2014-05-17 22:08:49 -07:00
Alex Crichton
4a1d21ab7b Register new snapshots 2014-05-17 21:54:11 -07:00
bors
cea4803d4c auto merge of #14135 : gereeter/rust/two-way-search, r=brson
This changes the previously naive string searching algorithm to a two-way search like glibc, which should be faster on average while still maintaining worst case linear time complexity. This fixes #14107. Note that I don't think this should be merged yet, as this is the only approach to speeding up search I've tried - it's worth considering options like Boyer-Moore or adding a bad character shift table to this. However, the benchmarks look quite good so far:

    test str::bench::bench_contains_bad_naive                   ... bench:       290 ns/iter (+/- 12)     from 1309 ns/iter (+/- 36)
    test str::bench::bench_contains_equal                       ... bench:       479 ns/iter (+/- 10)     from  137 ns/iter (+/- 2)
    test str::bench::bench_contains_short_long                  ... bench:      2844 ns/iter (+/- 105)    from 5473 ns/iter (+/- 14)
    test str::bench::bench_contains_short_short                 ... bench:        55 ns/iter (+/- 4)      from   57 ns/iter (+/- 6)

Except for the case specifically designed to be optimal for the naive case (`bench_contains_equal`), this gets as good or better performance as the previous code.
2014-05-16 14:46:24 -07:00
Alex Crichton
2e2160b026 core: Update all tests for fmt movement 2014-05-15 23:22:15 -07:00
Alex Crichton
d12a136b22 std: Fix float tests 2014-05-15 23:22:06 -07:00
Alex Crichton
bcab97a32e core: Implement f32/f64 formatting
This is a migration of the std::{f32, f64}::to_str* functionality to the core
library. This removes the growable `Vec` used in favor of a large stack buffer.
The maximum base 10 exponent for f64 is 308, so a stack buffer of 512 bytes
should be sufficient to store all floats.
2014-05-15 23:22:06 -07:00
Alex Crichton
1de4b65d2a Updates with core::fmt changes
1. Wherever the `buf` field of a `Formatter` was used, the `Formatter` is used
   instead.
2. The usage of `write_fmt` is minimized as much as possible, the `write!` macro
   is preferred wherever possible.
3. Usage of `fmt::write` is minimized, favoring the `write!` macro instead.
2014-05-15 23:22:06 -07:00
Alex Crichton
3c06a0328a core: Derive Show impls wherever possible
These were temporarily moved to explicit implementations, but now that fmt is in
core it's possible to derive again.
2014-05-15 23:22:06 -07:00
Alex Crichton
27d8ea05a2 core: Implement and export the try! macro
This is used quite extensively by core::fmt
2014-05-15 23:22:06 -07:00
Alex Crichton
f2af4ca3e6 core: Allow formatted failure and assert in core
With std::fmt having migrated, the failure macro can be expressed in its full
glory.
2014-05-15 23:22:06 -07:00
Alex Crichton
c255568652 core: Implement unwrap()/unwrap_err() on Result
Now that std::fmt is in libcore, it's possible to implement this as an inherit
method rather than through extension traits.

This commit also tweaks the failure interface of libcore to libstd to what it
should be, one method taking &fmt::Arguments
2014-05-15 23:22:06 -07:00
Alex Crichton
cf0619383d core: Inherit the std::fmt module
This commit moves all possible functionality from the standard library's string
formatting utilities into the core library. This is a breaking change, due to a
few tweaks in the semantics of formatting:

1. In order to break the dependency on the std::io module, a new trait,
   FormatWriter was introduced in core::fmt. This is the trait which is used
   (instead of Writer) to format data into a stream.
2. The new FormatWriter trait has one method, write(), which takes some bytes
   and can return an error, but the error contains very little information. The
   intent for this trait is for an adaptor writer to be used around the standard
   library's Writer trait.
3. The fmt::write{,ln,_unsafe} methods no longer take &mut io::Writer, but
   rather &mut FormatWriter. Since this trait is less common, all functions were
   removed except fmt::write, and it is not intended to be invoked directly.

The main API-breaking change here is that the fmt::Formatter structure will no
longer expose its `buf` field. All previous code writing directly to `f.buf`
using writer methods or the `write!` macro will now instead use `f` directly.

The Formatter object itself implements the `Writer` trait itself for
convenience, although it does not implement the `FormatWriter` trait. The
fallout of these changes will be in the following commits.

[breaking-change]
2014-05-15 23:22:06 -07:00
Alex Crichton
ba0a984a86 core: Move intrinsic float functionality from std
The Float trait in libstd is quite a large trait which has dependencies on cmath
(libm) and such, which libcore cannot satisfy. It also has many functions that
libcore can implement, however, as LLVM has intrinsics or they're just bit
twiddling.

This commit moves what it can of the Float trait from the standard library into
libcore to allow floats to be usable in the core library. The remaining
functions are now resident in a FloatMath trait in the standard library (in the
prelude now). Previous code which was generic over just the Float trait may now
need to be generic over the FloatMath trait.

[breaking-change]
2014-05-15 23:22:06 -07:00
Keegan McAllister
9c35ac5666 Implement cell::clone_ref
Per discussion with @alexcrichton, this is a free function.
2014-05-15 13:50:55 -07:00
Brian Anderson
a0594ebb8b core: Remove the unit module 2014-05-15 13:50:50 -07:00
Alex Crichton
a7bee7b05d Add a crate for missing stubs from libcore
The core library in theory has 0 dependencies, but in practice it has some in
order for it to be efficient. These dependencies are in the form of the basic
memory operations provided by libc traditionally, such as memset, memcmp, etc.
These functions are trivial to implement and themselves have 0 dependencies.

This commit adds a new crate, librlibc, which will serve the purpose of
providing these dependencies. The crate is never linked to by default, but is
available to be linked to by downstream consumers. Normally these functions are
provided by the system libc, but in other freestanding contexts a libc may not
be available. In these cases, librlibc will suffice for enabling execution with
libcore.

cc #10116
2014-05-15 13:50:37 -07:00
Alex Crichton
8211539114 Register new snapshots 2014-05-15 13:50:34 -07:00
bors
73a68cdba0 auto merge of #14133 : db48x/rust/ord-for-mut-refs, r=alexcrichton
Also Show, which is useful in assertions. Fixes #14074
2014-05-14 22:06:50 -07:00
Jonathan S
39cb5b13e6 Switched to the two-way algorithm for string searching
test str::bench::bench_contains_bad_naive                   ... bench:       300 ns/iter (+/- 12)     from 1309 ns/iter (+/- 36)
test str::bench::bench_contains_equal                       ... bench:       154 ns/iter (+/- 7)      from  137 ns/iter (+/- 2)
test str::bench::bench_contains_short_long                  ... bench:      2998 ns/iter (+/- 74)     from 5473 ns/iter (+/- 14)
test str::bench::bench_contains_short_short                 ... bench:        65 ns/iter (+/- 2)      from   57 ns/iter (+/- 6)
2014-05-14 20:34:43 -05:00
Daniel Brooks
9eb723d000 define Eq,TotalEq,Ord,TotalOrd for &mut T
Also Show, which is useful in assertions. Fixes #14074
2014-05-14 00:48:02 -07:00
Alex Crichton
949443eff6 core: Allow using failure outside of libcore
Due to our excellent macro hygiene, this involves having a global path and a
hidden module in libcore itself.
2014-05-13 23:59:03 -07:00
Alex Crichton
82a8a5ebb3 core: Document should_not_exist's existence
Explain why it should not exist, and the plan of attack for removing it.
2014-05-13 23:59:03 -07:00
Alex Crichton
57f3b6ee5c core: Add a crate doc block 2014-05-13 23:59:03 -07:00
Alex Crichton
325cc51502 core: Inherit the atomics module 2014-05-13 23:59:03 -07:00
Alex Crichton
f09592a5d1 io: Implement process wait timeouts
This implements set_timeout() for std::io::Process which will affect wait()
operations on the process. This follows the same pattern as the rest of the
timeouts emerging in std::io::net.

The implementation was super easy for everything except libnative on unix
(backwards from usual!), which required a good bit of signal handling. There's a
doc comment explaining the strategy in libnative. Internally, this also required
refactoring the "helper thread" implementation used by libnative to allow for an
extra helper thread (not just the timer).

This is a breaking change in terms of the io::Process API. It is now possible
for wait() to fail, and subsequently wait_with_output(). These two functions now
return IoResult<T> due to the fact that they can time out.

Additionally, the wait_with_output() function has moved from taking `&mut self`
to taking `self`. If a timeout occurs while waiting with output, the semantics
are undesirable in almost all cases if attempting to re-wait on the process.
Equivalent functionality can still be achieved by dealing with the output
handles manually.

[breaking-change]

cc #13523
2014-05-13 17:27:42 -07:00
Florian Zeitz
df802a2754 std: Rename str::Normalizations to str::Decompositions
The Normalizations iterator has been renamed to Decompositions.
It does not currently include all forms of Unicode normalization,
but only encompasses decompositions.
If implemented recomposition would likely be a separate iterator
which works on the result of this one.

[breaking-change]
2014-05-13 17:24:07 -07:00
Florian Zeitz
8c54d5bf40 core: Move Hangul decomposition into unicode.rs 2014-05-13 17:24:07 -07:00
Florian Zeitz
2f71b72a12 core: Use appropriately sized integers for codepoints and bytes 2014-05-13 17:24:07 -07:00
Florian Zeitz
74ad023674 std, core: Generate unicode.rs using unicode.py 2014-05-13 17:24:07 -07:00
Alex Crichton
cbc31df4fc std: Move the owned module from core to std
The compiler was updated to recognize that implementations for ty_uniq(..) are
allowed if the Box lang item is located in the current crate. This enforces the
idea that libcore cannot allocated, and moves all related trait implementations
from libcore to libstd.

This is a breaking change in that the AnyOwnExt trait has moved from the any
module to the owned module. Any previous users of std::any::AnyOwnExt should now
use std::owned::AnyOwnExt instead. This was done because the trait is intended
for Box traits and only Box traits.

[breaking-change]
2014-05-13 17:24:07 -07:00
Adolfo Ochagavía
85e34b2396 Improved example code in Option 2014-05-12 19:52:29 -07:00
Kevin Butler
826aeea007 libcore: remove fails from slice.rs and remove duplicated length checking
core::slice::raw::{shift_ptr,pop_ptr} now returns Option<*T> rather than
*T. They no longer fail on empty slices.

[breaking-change]
2014-05-12 19:52:29 -07:00
Brian Anderson
c1da4f875f Add the patch number to version strings. Closes #13289 2014-05-12 19:52:29 -07:00
Daniel Micay
8b912bc56b register snapshots 2014-05-12 02:52:32 -04:00
Alex Crichton
f94d671bfa core: Remove the cast module
This commit revisits the `cast` module in libcore and libstd, and scrutinizes
all functions inside of it. The result was to remove the `cast` module entirely,
folding all functionality into the `mem` module. Specifically, this is the fate
of each function in the `cast` module.

* transmute - This function was moved to `mem`, but it is now marked as
              #[unstable]. This is due to planned changes to the `transmute`
              function and how it can be invoked (see the #[unstable] comment).
              For more information, see RFC 5 and #12898

* transmute_copy - This function was moved to `mem`, with clarification that is
                   is not an error to invoke it with T/U that are different
                   sizes, but rather that it is strongly discouraged. This
                   function is now #[stable]

* forget - This function was moved to `mem` and marked #[stable]

* bump_box_refcount - This function was removed due to the deprecation of
                      managed boxes as well as its questionable utility.

* transmute_mut - This function was previously deprecated, and removed as part
                  of this commit.

* transmute_mut_unsafe - This function doesn't serve much of a purpose when it
                         can be achieved with an `as` in safe code, so it was
                         removed.

* transmute_lifetime - This function was removed because it is likely a strong
                       indication that code is incorrect in the first place.

* transmute_mut_lifetime - This function was removed for the same reasons as
                           `transmute_lifetime`

* copy_lifetime - This function was moved to `mem`, but it is marked
                  `#[unstable]` now due to the likelihood of being removed in
                  the future if it is found to not be very useful.

* copy_mut_lifetime - This function was also moved to `mem`, but had the same
                      treatment as `copy_lifetime`.

* copy_lifetime_vec - This function was removed because it is not used today,
                      and its existence is not necessary with DST
                      (copy_lifetime will suffice).

In summary, the cast module was stripped down to these functions, and then the
functions were moved to the `mem` module.

    transmute - #[unstable]
    transmute_copy - #[stable]
    forget - #[stable]
    copy_lifetime - #[unstable]
    copy_mut_lifetime - #[unstable]

[breaking-change]
2014-05-11 01:13:02 -07:00
Daniel Micay
138437956c initial port of the exchange allocator to jemalloc
In stage0, all allocations are 8-byte aligned. Passing a size and
alignment to free is not yet implemented everywhere (0 size and 8 align
are used as placeholders). Fixing this is part of #13994.

Closes #13616
2014-05-10 19:58:17 -04:00
Daniel Micay
03a5eb4b52 add an align parameter to exchange_malloc
Closes #13094
2014-05-10 19:58:17 -04:00
bors
1001635dc1 auto merge of #14073 : alexcrichton/rust/snapshots, r=huonw 2014-05-10 09:56:34 -07:00
bors
e850316408 auto merge of #14068 : alexcrichton/rust/rustdoc-xcrate-links, r=brson
This should improve the libcore experience quite a bit when looking at the
libstd documentation.
2014-05-10 03:36:30 -07:00
Alex Crichton
3f5e3af838 Register new snapshots 2014-05-09 21:13:02 -07:00
Alex Crichton
620b4352f2 doc: Fix some broken links 2014-05-09 14:42:12 -07:00
bors
58d540f0c6 auto merge of #14053 : FlaPer87/rust/master, r=huonw
This patch allows for using derivings for `kinds` in libcore

r? @alexcrichton
2014-05-09 09:11:35 -07:00
bors
fcf25ae83d auto merge of #14019 : brson/rust/docs, r=alexcrichton
Just small bits of polish.
2014-05-08 23:01:40 -07:00
Flavio Percoco
d90b4daac9 core: Allow kinds derivings 2014-05-09 00:08:26 +02:00
Kevin Ballard
9fb8741b2e Handle breakage after libcore split
API Changes:

- &[T] and ~[T] no longer support the addition operator (+)
2014-05-08 12:08:01 -07:00
Kevin Ballard
eab6bb2ece Handle fallout in documentation
Tweak the tutorial's section on vectors and strings, to slightly clarify
the difference between fixed-size vectors, vectors, and slices.
2014-05-08 12:06:22 -07:00
Kevin Ballard
2a0dac6f58 Handle fallout for vector addition
Adding two vectors now results in a Vec<T> instead of a ~[T].

Implement Add on Vec<T>.
2014-05-08 12:06:22 -07:00
Kevin Ballard
001a8741b4 Handle fallout in iter, option, result, and sync::arc
API changes:

- UnsafeArc::newN() returns Vec<UnsafeArc<T>>
2014-05-08 12:06:21 -07:00
Kevin Ballard
bf1e065371 Remove FromIterator impl for ~[T]
As part of the shift from ~[T] to Vec<T>, recently ~[T] was made
non-growable. However, the FromIterator implementation for ~[T] was left
intact (albeit implemented inefficiently), which basically provided a
loophole to grow a ~[T] despite its non-growable nature. This is a
problem, both for performance reasons and because it encourages APIs to
continue returning ~[T] when they should return Vec<T>. Removing
FromIterator forces these APIs to adopt the correct type.

Furthermore, during today's weekly meeting it was decided that we should
remove all instances of ~[T] from the standard libraries in favor of
Vec<T>. Removing the FromIterator impl makes sense to do as a result.

This commit only includes the removal of the FromIterator impl. The
subsequent commits involve handling all of the breakage that results,
including changing APIs to use Vec<T> instead of ~[T]. The precise API
changes are documented in the subsequent commit messages, but each
commit is not individually marked as a breaking change.

Finally, a new trait FromVec is introduced that provides a mechanism to
convert Vec<T> back into ~[T] if truly necessary. It is a bit awkward to
use by design, and is anticipated that it will be more useful in a
post-DST world to convert to an arbitrary Foo<[T]> smart pointer.

[breaking-change]
2014-05-08 12:06:21 -07:00
Brian Anderson
2aa4253377 std: Small doc tweaks 2014-05-07 14:12:44 -07:00
Brian Anderson
eb5f9feadb std: Change names of transmute's type parameters
from L, G to T, U. I don't know what L and G mean.
T, U easier to understand.
2014-05-07 14:12:43 -07:00
Brian Anderson
3a11509e00 std: Reorder definitions in cast
Prioritize `transmute` and `forget`.
2014-05-07 14:12:43 -07:00
Brian Anderson
1868cf5073 std: Remove bump_box_refcount. Deprecated and unused. Deprecused. 2014-05-07 14:12:43 -07:00
Alex Crichton
07caa22450 Test fixes and rebase conflicts 2014-05-07 11:03:12 -07:00
Alex Crichton
0d8f5fa618 core: Move Option::expect to libstd from libcore
See #14008 for more details
2014-05-07 08:17:32 -07:00
Alex Crichton
4a974413dc core: Fix an unsigned negation warning 2014-05-07 08:17:05 -07:00
Alex Crichton
104e285eb8 core: Get coretest working
This mostly involved frobbing imports between realstd, realcore, and the core
being test. Some of the imports are a little counterintuitive, but it mainly
focuses around libcore's types not implementing Show while libstd's types
implement Show.
2014-05-07 08:16:42 -07:00
Alex Crichton
f62c121eb0 core: Inherit the cell module 2014-05-07 08:16:14 -07:00
Alex Crichton
a156534a96 core: Inherit the result module
The unwrap()/unwrap_err() methods are temporarily removed, and will be added
back in the next commit.
2014-05-07 08:16:14 -07:00
Alex Crichton
f12b51705b core: Remove generics from Option::expect
The prospects of a generic failure function such as this existing in libcore are
bleak, due to monomorphization not working across the crate boundary, and
allocation into a ~Any is not allowed in libcore.

The argument to expect() is now &str instead of <M: Send + Any>

[breaking-change]
2014-05-07 08:16:14 -07:00
Alex Crichton
e4271cae54 core: Add a limited implementation of failure
This adds an small of failure to libcore, hamstrung by the fact that std::fmt
hasn't been migrated yet. A few asserts were re-worked to not use std::fmt
features, but these asserts can go back to their original form once std::fmt has
migrated.

The current failure implementation is to just have some symbols exposed by
std::rt::unwind that are linked against by libcore. This is an explicit circular
dependency, unfortunately. This will be officially supported in the future
through compiler support with much nicer failure messages. Additionally, there
are two depended-upon symbols today, but in the future there will only be one
(once std::fmt has migrated).
2014-05-07 08:16:14 -07:00
Alex Crichton
4686cf2018 core: Bring char/finally test style up to date 2014-05-07 08:16:14 -07:00
Alex Crichton
c9447c5d95 core: Allow some #[deriving] in libcore 2014-05-07 08:16:14 -07:00
Alex Crichton
e0d43b023e core: Implement necessary traits for ~[T]/~str
Coherence requires that libcore's traits be implemented in libcore for ~[T] and
~str (due to them being language defined types). These implementations cannot
live in libcore forever, but for now, until Heap/Box/Uniq is a lang item, these
implementations must reside inside of libcore. While not perfect
implementations, these shouldn't reside in libcore for too long.

With some form of lang item these implementations can be in a proper crate
because the lang item will not be present in libcore.
2014-05-07 08:16:14 -07:00
Alex Crichton
9bae6ec828 core: Inherit possible string functionality
This moves as much allocation as possible from teh std::str module into
core::str. This includes essentially all non-allocating functionality, mostly
iterators and slicing and such.

This primarily splits the Str trait into only having the as_slice() method,
adding a new StrAllocating trait to std::str which contains the relevant new
allocation methods. This is a breaking change if any of the methods of "trait
Str" were overriden. The old functionality can be restored by implementing both
the Str and StrAllocating traits.

[breaking-change]
2014-05-07 08:16:14 -07:00
Alex Crichton
544d909401 core: Inherit necessary unicode functionality
The unicode module remains private, but the normalization iterators require an
allocation, so some functionality needs to remain in libstd
2014-05-07 08:15:58 -07:00
Alex Crichton
91ede1f09a core: Inherit non-allocating slice functionality
This commit adds a new trait, MutableVectorAllocating, which represents
functions on vectors which can allocate.

This is another extension trait to slices which should be removed once a lang
item exists for the ~ allocation.
2014-05-07 08:15:58 -07:00
Alex Crichton
be0a11729e core: Inherit the specific numeric modules
This implements all traits inside of core::num for all the primitive types,
removing all the functionality from libstd. The std modules reexport all of the
necessary items from the core modules.
2014-05-07 08:15:58 -07:00
Alex Crichton
0c30293886 core: Inherit what's possible from the num module
This strips out all string-related functionality from the num module. The
inherited functionality is all that will be implemented in libcore (for now).
Primarily, libcore will not implement the Float trait or any string-related
functionality.

It may be possible to migrate string parsing functionality into libcore in the
future, but for now it will remain in libstd.

All functionality in core::num is reexported in std::num.
2014-05-07 08:15:58 -07:00
Alex Crichton
c5229e5d2e core: Inhert ~/@/& cmp traits, remove old modules
This commit removes the std::{managed, reference} modules. The modules serve
essentially no purpose, and the only free function removed was `managed::ptr_eq`
which can be achieved by comparing references.

[breaking-change]
2014-05-07 08:15:58 -07:00
Alex Crichton
5592a8f5db core: Inherit the cmp module
This removes the TotalOrd and TotalEq implementation macros, they will be added
later to the numeric modules (where the other comparison implementations live).
2014-05-07 08:15:19 -07:00
Alex Crichton
b024ba544c core: Inherit the iter module 2014-05-07 08:14:56 -07:00
Alex Crichton
06fcb6b1c8 core: Inherit the option module 2014-05-07 08:14:56 -07:00
Alex Crichton
6636215a44 core: Inherit the bool module 2014-05-07 08:14:56 -07:00
Alex Crichton
92095d125a core: Inherit the tuple module 2014-05-07 08:14:54 -07:00
Alex Crichton
1a989d6769 core: Bring clone tests up to date in style 2014-05-07 08:14:26 -07:00
Alex Crichton
54b81997f3 core: Inherit the clone module 2014-05-07 08:13:56 -07:00
Alex Crichton
e7eed5f670 core: Inherit the unit module 2014-05-07 08:13:56 -07:00
Alex Crichton
dfd967f239 core: Inherit the default module 2014-05-07 08:13:56 -07:00
Alex Crichton
17cb238ee8 core: Inherit the raw module 2014-05-07 08:13:56 -07:00
Alex Crichton
8ed728babb core: Inherit the any module 2014-05-07 08:13:56 -07:00
Alex Crichton
85a8e6b80a core: Inherit the finally module 2014-05-07 08:13:24 -07:00
Alex Crichton
7192452545 core: Inherit the char module 2014-05-07 08:13:24 -07:00
Alex Crichton
d9708539af core: Inherit the container module 2014-05-07 08:13:24 -07:00
Alex Crichton
2ad98fbb27 core: Inherit the ty module 2014-05-07 08:13:24 -07:00
Alex Crichton
ead6e16a60 core: Inherit the ops module 2014-05-07 08:13:06 -07:00
Alex Crichton
ec8a805b6d core: Inherit the kinds module 2014-05-07 08:13:06 -07:00
Alex Crichton
28624661c3 core: Inherit the cast module 2014-05-07 08:13:06 -07:00
Alex Crichton
645b157564 core: Inherit the ptr module 2014-05-07 08:13:06 -07:00
Alex Crichton
dca8a0d6e4 core: Inherit the mem module 2014-05-07 08:12:48 -07:00
Alex Crichton
5b75e44fb0 core: Inherit the intrinsics module 2014-05-07 08:12:48 -07:00
Alex Crichton
836d4b96a9 mk: Add libcore 2014-05-07 08:12:48 -07:00
Patrick Walton
18df18c817 libstd: Fix merge fallout. 2013-05-22 21:57:11 -07:00
Patrick Walton
0c820d4123 libstd: Rename libcore to libstd and libstd to libextra; update makefiles.
This only changes the directory names; it does not change the "real"
metadata names.
2013-05-22 21:57:05 -07:00
Jyun-Yan You
499b02213d fix arm stack alignment 2013-05-22 08:49:16 +08:00
bors
dc7b83d186 auto merge of #6650 : crabtw/rust/mips-rt, r=sanxiyn
Results of libcore and libstd tests

```
failures:
    rand::tests::test_rng_seeded_custom_seed2
    time::tests::run_tests
    uv_ll::test::test_uv_ll_struct_size_addrinfo
    uv_ll::test::test_uv_ll_struct_size_uv_timer_t

segfaults:
    stackwalk::test_simple
    stackwalk::test_simple_deep
```
2013-05-21 03:01:17 -07:00
bors
329d8e2622 auto merge of #6648 : alexcrichton/rust/issue-6633, r=graydon
Resolves #6633 and removes an unnecessary import in libcore
2013-05-21 01:04:16 -07:00
bors
5a3e320514 auto merge of #6647 : alexcrichton/rust/unnecessary-alloc, r=graydon
This adds a lint mode for detecting unnecessary allocations on the heap. This isn't super fancy, currently it only has two rules

1. For a function's arguments, if you allocate a `[~|@]str` literal, when the type of the argument is a `&str`, emit a warning.
2. For the same case, emit warnings for boxed vectors when slices are required.

After adding the lint, I rampaged through the libraries and removed all the unnecessary allocations I could find.
2013-05-20 23:55:20 -07:00
bors
d49a9dbc7f auto merge of #6646 : dotdash/rust/method_lookup, r=brson 2013-05-20 22:52:22 -07:00
bors
7abcc142e5 auto merge of #6626 : brson/rust/io-upstream, r=graydon
r?

Mostly refactoring, and adding some of the remaining types described in #4419.

The [`Local`](3b4ff41511/src/libcore/rt/local.rs (L17)) trait collects some common, often unsafe patterns around task-local and thread-local values. Making all these types safe is largely the aim of #6210.
2013-05-20 21:40:27 -07:00
Jyun-Yan You
d86a32bbb2 fix mips stack alignment 2013-05-21 11:58:30 +08:00
bors
adaae45c3e auto merge of #6604 : bjz/rust/ptr-to-option, r=brson 2013-05-20 20:31:26 -07:00
bors
24609675eb auto merge of #6528 : brson/rust/docs, r=brson
Remove the uncommon term 'object tree' in favor of 'value'.
2013-05-20 16:55:36 -07:00
Brian Anderson
a246e8faf3 core::rt: Convert unsafe_borrow_io to a Local impl 2013-05-20 15:21:29 -07:00
Brian Anderson
2042696236 core::rt: Implement Local for Task 2013-05-20 15:21:29 -07:00
Brian Anderson
2f99fb8efa core::rt: Remove local_sched module 2013-05-20 15:21:29 -07:00
Brian Anderson
06f1a64bd6 core::rt: Convert users of local_sched to Local trait 2013-05-20 15:21:09 -07:00
Brian Anderson
18fab45aab core::rt: Make local_sched a wrapper around Local 2013-05-20 15:20:50 -07:00
Brian Anderson
71aa6b6631 core::rt: Move more TLS functionality into local_ptr 2013-05-20 15:20:50 -07:00
Brian Anderson
97c2fd1a96 core::rt: Move some TLS functions from local_sched to local_ptr 2013-05-20 15:20:50 -07:00
Brian Anderson
86ba457349 rt: Rename rust_initialize_global_state to rust_initialize_rt_tls_key 2013-05-20 15:20:50 -07:00
Brian Anderson
f59fcd5d5f core::rt: Store Task as a ~ pointer 2013-05-20 15:20:50 -07:00
Brian Anderson
43c6f32ece core::rt: Add Local trait 2013-05-20 15:20:50 -07:00
Brian Anderson
b0722c55f8 core:rt:: Rename LocalServices to Task 2013-05-20 15:20:49 -07:00
Brian Anderson
fa18a861fb core::rt: Queues MessageQueue and WorkQueue are cloneable 2013-05-20 15:20:49 -07:00
Brian Anderson
d2a1378ed8 core::rt: Add MessageQueue type
This is the queue used to send messages to Schedulers
2013-05-20 15:20:49 -07:00
Brian Anderson
ee06ed2bfd core::rt: Put a lock on the work queue 2013-05-20 15:20:49 -07:00
Brian Anderson
f03c9bd08c core::rt: Rename WorkQueue methods, remove extra push method 2013-05-20 15:20:49 -07:00
Brian Anderson
7ffd523354 core: Update clone docs 2013-05-20 15:19:35 -07:00
Brian Anderson
7bd4217766 Replace all uses of rust-intrinsic ABI with calls to unstable::intrinsics 2013-05-20 14:41:56 -07:00
Alex Crichton
82fa0018c8 Remove all unnecessary allocations (as flagged by lint) 2013-05-20 16:10:40 -05:00
Alex Crichton
15f97acdc8 Correctly track the source of imports with the same name 2013-05-20 13:02:08 -05:00
Björn Steinbrink
b5be7d8a2c Avoid range checks in HashMap::each() 2013-05-20 18:42:31 +02:00
Brendan Zabarauskas
eef03c39cf Update to stop unsolicited copying and mark methods as unsafe 2013-05-20 22:07:35 +10:00
Björn Steinbrink
09efd472a9 Remove outdated function transmute_for_stage0
The function was a workaround for bootstrapping that isn't required
anymore and just degrades hashmap performance, as it doesn't get inlined
cross-crate and turns a no-op into a call.
2013-05-20 12:10:55 +02:00
bors
2e6cda254a auto merge of #6635 : brson/rust/snapshot, r=brson 2013-05-20 02:46:36 -07:00
bors
ab46a38039 auto merge of #6632 : steveklabnik/rust/remove_more_warnings, r=thestinger
With this, the build is almost 100% warning free.

One more can be fixed after the next snapshot, and there's one other that I filed an issue about already.
2013-05-20 01:37:39 -07:00
bors
ea0640764a auto merge of #6629 : steveklabnik/rust/remove_uvio_warnings, r=catamorphism
Mostly of the 'unused imports' kind.

I'm unsure about the 'no unsafe' bit, but that's what it says...
2013-05-20 00:25:40 -07:00
Brian Anderson
66319b0278 Register snapshots 2013-05-19 23:34:32 -07:00
bors
d019e145c0 auto merge of #6621 : steveklabnik/rust/expand_reader_docs, r=thestinger
Had a conversation with @cmr in IRC about some places that these
docs were confusing. The functions that advance the stream now say so.

In addition, I think that calling out the similarities to familliar C
functions should help people coming from other languages.
2013-05-19 23:13:36 -07:00
bors
3a481c0f88 auto merge of #6627 : steveklabnik/rust/remove_warnings, r=thestinger,catamorphism
These imports were not being used.
2013-05-19 21:58:38 -07:00
Steve Klabnik
dcc2879266 Add a few 'function's.
This is now 100% consistent. Whoops!
2013-05-19 22:40:13 -06:00
Steve Klabnik
d3f70b141a Fix many warnings. 2013-05-19 21:32:32 -07:00
bors
0b39bc275e auto merge of #6624 : steveklabnik/rust/io_prelude, r=catamorphism
Let's actually give a top-level description of what's in here, eh?
2013-05-19 20:49:42 -07:00
Steve Klabnik
dc57d15b69 Remove more warnings.
Mostly of the 'unused imports' kind.
2013-05-19 20:00:39 -07:00
Steve Klabnik
06d196ad5f Removing some warnings from logging.rs
These imports were not being used.
2013-05-19 19:40:36 -07:00
Steve Klabnik
91d3e7f1a0 Fix wording per feedback
Thanks @catamorphism!
2013-05-19 20:39:02 -06:00
Steve Klabnik
b1e805694b Add a better introduction for the io module.
Let's actually give a top-level description of what's in here, eh?
2013-05-19 19:02:55 -07:00
bors
9283dfe0b4 auto merge of #6619 : steveklabnik/rust/stdout_docs, r=thestinger
Added docs for stdout, stderr, print, and println.
2013-05-19 18:22:33 -07:00
Steve Klabnik
5877727285 Fix trailing whitespace 2013-05-19 15:31:19 -07:00
Steve Klabnik
1065a92bf3 Elaborate a bit in the Reader docs regarding stream position.
Had a conversation with @cmr in IRC about some places that these
docs were confusing. The functions that advance the stream now say so.

In addition, I think that calling out the similarities to familliar C
functions should help people coming from other languages.
2013-05-19 12:57:00 -07:00
Steve Klabnik
929050de73 Added note about prelude inclusion. 2013-05-19 12:42:00 -07:00
Steve Klabnik
a389d86fa4 Add docs for stdin in core::io. 2013-05-19 12:33:01 -07:00
Steve Klabnik
e0b1bdca5b Add additional documentation in core::io.
Added docs for stdout, stderr, print, and println.
2013-05-19 12:06:39 -07:00
bors
9f671698e6 auto merge of #6106 : thestinger/rust/iter, r=bstrie
I don't have a strong opinion on the function vs. method, but there's no point in having both. I'd like to make a `repeat` adaptor like Python/Haskell for turning a value into an infinite stream of the value, so this has to at least be renamed.
2013-05-19 08:13:30 -07:00
Corey Richardson
cc57ca012a Use assert_eq! rather than assert! where possible 2013-05-19 08:16:02 -04:00
bors
3acf37897a auto merge of #6595 : bjz/rust/core-tuple, r=thestinger 2013-05-19 03:01:28 -07:00
Huon Wilson
3a11ddb1b2 Correct tuple Ord impl, add Total{Eq,Ord} impls and add some tests. 2013-05-19 18:51:14 +10:00
bors
aa827838e1 auto merge of #6606 : thestinger/rust/vers, r=brson
I don't see a reason to encode this information in all the `extern mod` statements, it's not a precise enough version to actually provide any sort of robustness.
2013-05-18 21:55:30 -07:00
Daniel Micay
20ef4238bb reduce the usage of explicit version markers 2013-05-19 00:21:41 -04:00
Brendan Zabarauskas
d1e091a27a Add Ptr::to_option method 2013-05-19 14:08:27 +10:00
bors
ccf6353fd5 auto merge of #6589 : thestinger/rust/iterator, r=thestinger 2013-05-18 19:40:25 -07:00
Daniel Micay
9b6b0e1e64 fix stage0 compile 2013-05-18 22:10:56 -04:00
bors
3ee479f3e9 auto merge of #6577 : brson/rust/io-upstream, r=pcwalton
r?

This is all of my scheduler work on #4419 from the last 3 weeks or so. I've had a few failed pull requests so far but I think the problems are ironed out.

* TCP
* The beginnings of runtime embedding APIs
* Porting various corners of core to be compatible with both schedulers
* libuv timer bindings
* Further refinement of I/O error handling, including a new, incomplete, `read_error` condition
* Incomplete refactoring to make tasks work without coroutines and user-space scheduling
* Implementations of Reader/Writer extension methods
* Implementations of the most important part of core::comm

I'm particularly happy with how easy the [comm types on top of the scheduler](https://github.com/brson/rust/blob/io-upstream/src/libcore/rt/comm.rs). Note that these implementations do not use pipes. If anything here needs careful review though it's this code.

This branch passes 95% of the run-pass tests (with `TESTARGS=--newrt`)

In the next week I'll probably spend some time adding preliminary multithreading and seeing how close we are to removing the old runtime.
2013-05-18 18:37:25 -07:00
Brendan Zabarauskas
f687b9d771 Use /// style doc-comments and add missing headings 2013-05-19 06:45:54 +10:00
Brendan Zabarauskas
efe6564a0e Code modernisation and cleanup 2013-05-19 05:58:33 +10:00
Brendan Zabarauskas
d73f31b31d Create Char trait 2013-05-19 05:50:02 +10:00
Brendan Zabarauskas
7103c39dbb Move tuple tests into submodule 2013-05-19 02:36:08 +10:00
Brendan Zabarauskas
d9eec664fd Fix Ord implementation to use lexical ordering 2013-05-19 02:35:36 +10:00
Brendan Zabarauskas
db453ec0e5 Replace Tuple{2..12} trait with CloneableTuple{2..12} and ImmutableTuple{2..12}
Make n{0..11} methods return cloned values, and create n{0..12}_ref methods for returning references
2013-05-19 02:19:16 +10:00
Brendan Zabarauskas
ee4d11f37e Use match instead of intermediate variable 2013-05-19 02:19:16 +10:00
Brendan Zabarauskas
ce1e211eeb Adapt the getter macro to implement Clone, Eq and Ord for n-ary tuples 2013-05-19 02:19:16 +10:00
Brendan Zabarauskas
b6038b7633 Return a reference to the tuple elements instead of copying 2013-05-18 20:05:40 +10:00
Brendan Zabarauskas
5242464d54 Merge trait and impl macros by using an inner module 2013-05-18 19:43:14 +10:00
Brendan Zabarauskas
c1eb539e12 Use assert_eq! instead of assert! 2013-05-18 19:10:49 +10:00
Brendan Zabarauskas
96cb0dc8a0 use n{0..11} instead of _{0..12} for accessor method names 2013-05-18 19:10:12 +10:00
Brendan Zabarauskas
6742f91192 Create tuple element accessor traits 2013-05-18 18:59:16 +10:00
Daniel Micay
d953a5ce43 replace old_iter::repeat with the Times trait 2013-05-18 04:57:21 -04:00
Daniel Micay
fc656262a9 iterator: use advance to implement FilterMapIterator 2013-05-18 04:48:22 -04:00
Daniel Micay
073225572a iterator: reword docstring 2013-05-18 04:44:44 -04:00
Daniel Micay
883d583faa iterator: reuse iter::to_vec, and use &mut self 2013-05-18 04:37:48 -04:00
Daniel Micay
ea8a55b821 iterator: make nth and last return Option
There isn't a way to take the length of any iterator, so failing on a
zero length would make these much less useful.
2013-05-18 04:35:58 -04:00
Daniel Micay
a9c465ce1f iterator: remove first
it's the same as `next.unwrap()`, but there's no way to check the
length of an iterator so this isn't a good pattern
2013-05-18 04:35:48 -04:00
bors
e91daaa8a9 auto merge of #6586 : bjz/rust/formatting-and-conditionals, r=thestinger 2013-05-18 00:34:24 -07:00
Brendan Zabarauskas
ad6ee5f4e5 Use four-space indentation, add trailing commas, and remove unnecessary uses of the return keyword 2013-05-18 17:29:19 +10:00
Brendan Zabarauskas
60ea6d6957 Convert various inner doc-comments to outer doc-comments 2013-05-18 17:29:14 +10:00
Brendan Zabarauskas
728fe775a2 Use pattern-matching instead of conditionals where appropriate to improve code clarity 2013-05-18 17:29:12 +10:00
Brendan Zabarauskas
a10974da2d Use cond! macro where appropriate 2013-05-18 17:29:07 +10:00
bors
799d9fa32b auto merge of #6560 : gifnksm/rust/iterator-utils, r=thestinger
This pull request adds following methods and traits.
```rust
pub trait IteratorUtil {
(snip)
    fn filter_map<'r,  B>(self, f: &'r fn(A) -> Option<B>) -> FilterMapIterator<'r, A, B, Self>;
(snip)
    fn to_vec(self) -> ~[A];
    fn nth(&mut self, n: uint) -> A;
    fn first(&mut self) -> A;
    fn last(&mut self) -> A;
    fn fold<B>(&mut self, start: B, f: &fn(B, A) -> B) -> B;
    fn count(&mut self) -> uint;
    fn all(&mut self, f: &fn(&A) -> bool) -> bool;
    fn any(&mut self, f: &fn(&A) -> bool) -> bool;
}

pub trait AdditiveIterator<A> {
    fn sum(&mut self) -> A;
}

pub trait MultiplicativeIterator<A> {
    fn product(&mut self) -> A;
}

pub trait OrdIterator<A> {
    fn max(&mut self) -> Option<A>;
    fn min(&mut self) -> Option<A>;
}
```
2013-05-17 19:58:24 -07:00
Brian Anderson
633af4c8ab Whitespace 2013-05-17 18:11:47 -07:00
Brian Anderson
df9e41278e core: Wire up stream to newsched 2013-05-17 17:54:32 -07:00
Brian Anderson
26becc308e core: Wire up oneshot pipes to newsched 2013-05-17 17:54:27 -07:00
Brian Anderson
f5987b03b8 core::rt: implement oneshot and stream. 2013-05-17 17:54:18 -07:00
Brian Anderson
03a8e59615 Merge remote-tracking branch 'brson/io' into incoming 2013-05-17 17:53:50 -07:00
Marvin Löbel
916942d006 Some cosmetic changes to num.rs 2013-05-18 00:25:03 +02:00
gifnksm
3122d8027b libcore: Add IteratorUtil::all, any method 2013-05-18 00:24:43 +09:00
gifnksm
54fbac505e libcore: Add AdditiveIterator, MultiplicativeIterator, OrdIterator 2013-05-18 00:18:09 +09:00
gifnksm
b4cea351ba libcore: Add IteratorUtil::fold, count 2013-05-18 00:17:56 +09:00
gifnksm
02945f1cb1 libcore: Add IteratoUtil::nth, first, last method 2013-05-17 23:49:11 +09:00
gifnksm
9ffbe69234 libcore: Add IteratorUtil::filter_map method 2013-05-17 23:00:48 +09:00
gifnksm
f7e58ebe84 libcore: Add IteratorUtil::to_vec() method 2013-05-17 22:54:32 +09:00
bors
290a2ebab6 auto merge of #6442 : sstewartgallus/rust/incoming, r=pcwalton
Added unit test to prevent similar mistakes from happening again. The
previous method was wrong because it dereferenced a pointer to a void type to
match on the result. No self pointer was needed, and the correct method
signature took the self value by value.

I feel silly that I made this mistake in https://github.com/mozilla/rust/pull/6348
2013-05-17 06:46:32 -07:00
bors
dbbc244f73 auto merge of #6534 : brson/rust/intrinsic-docs, r=bstrie 2013-05-17 05:22:32 -07:00
bors
8badea49b0 auto merge of #6549 : bjz/rust/numeric-traits, r=thestinger
As discussed on issue #4819. This is a naive implementation, trusting LLVM to do the relevant optimizations. In the future this could be implemented more efficiently, but it's a start.
2013-05-16 23:43:30 -07:00
bors
c69f8ea91a auto merge of #6093 : alexcrichton/rust/issue-2647, r=thestinger
Closes #2647

This way it's much easier to add lints throughout compilation correctly, and
functions on impls can alter the way lints are emitted. This involved pretty much rewriting how lints are emitted. Beforehand, only items could alter the lint settings, so whenever a lint was added it had to be associated with whatever item id it was coming from. I removed this (possibly questionably) in favor of just specifying a span and a message when adding a lint. When lint checking comes around, it looks at all the lints and sees which node with attributes best encloses it and uses that level of linting. This means that all consumer code doesn't have to deal with what item things came from (especially because functions on impls aren't items). More details of this can be found in the code (and comments).

As a bonus, I managed to greatly simplify emission of lints in resolve.rs about unused imports. Now instead of it manually tracking what the lint level is, it's all moved over into the lint module (as is to be expected).
2013-05-16 22:25:39 -07:00
Alex Crichton
030c666cc1 Re-implement lint with less emphasis on item ids
This way it's much easier to add lints throughout compilation correctly, and
functions on impls can alter the way lints are emitted.
2013-05-17 00:49:16 -04:00
bors
918bfa710c auto merge of #6546 : cmr/rust/warning, r=thestinger 2013-05-16 21:19:38 -07:00
bors
77c98f0815 auto merge of #6523 : cmr/rust/faster_each_permutation, r=luqmana
Closes #5127
2013-05-16 20:04:41 -07:00
Corey Richardson
af54d58891 Update to new for-loop protocol 2013-05-16 22:57:49 -04:00
Brendan Zabarauskas
5696081781 Implement sin_cos method for float, f64 and f32 2013-05-17 12:30:02 +10:00
Corey Richardson
c67a85ada1 Remove each_permutation_ref 2013-05-16 22:05:05 -04:00
Corey Richardson
c2baaa8d84 fix warnings 2013-05-16 21:53:54 -04:00
Daniel Micay
08ef229a65 iter: add fold, sum and product 2013-05-16 21:51:31 -04:00
Corey Richardson
c99d1de85b Update to modern rust 2013-05-16 20:59:06 -04:00
Tommy M. McGuire
5948d8a826 Ensure reverse_part does not access outside given vector 2013-05-16 20:59:06 -04:00
Tommy M. McGuire
2264c7927d Add reverse_part, replace each_permutation, add tests 2013-05-16 20:59:06 -04:00
Brian Anderson
305331c00f core: Document some intrinsics 2013-05-16 12:03:58 -07:00
bors
92a1f6de97 auto merge of #6509 : thestinger/rust/clone, r=nikomatsakis
somewhat annoying to actually call thanks to auto-deref, but it does let `deriving(Clone)` work
2013-05-16 01:07:45 -07:00
bors
92b7a45395 auto merge of #6488 : sammykim/rust/issue-6430, r=sanxiyn
Fix issue #6430.
2013-05-15 22:52:47 -07:00
Sangeun Kim
f097f4309e Change unsafe functions to safe functions 2013-05-16 13:34:32 +09:00
bors
62caa1e5c8 auto merge of #6505 : cmr/rust/unsetenv, r=catamorphism 2013-05-15 21:31:45 -07:00
bors
f6360b4eab auto merge of #6527 : thestinger/rust/deep_clone, r=pcwalton 2013-05-15 20:28:45 -07:00
bors
2329651770 auto merge of #6503 : sonwow/rust/at_vec-renamed, r=graydon
`str::from_slice` and `vec::from_slice` are changed to `str::to_owned` and `vec::to_owned`. (#6389)

Replace `at_vec::from_owned` and `at_vec::from_slice` with `at_vec::to_managed_consume` and `at_vec::to_managed`.
2013-05-15 19:22:49 -07:00
Daniel Micay
d6a8343470 add DeepClone impl for @T and @mut T with T: Const 2013-05-15 21:02:54 -04:00
bors
08b4cdd395 auto merge of #6499 : dotdash/rust/static_keywords, r=thestinger 2013-05-15 15:10:48 -07:00
Brian Anderson
018dfaf9a6 core::rt: Unignore a fixed TCP test 2013-05-15 13:57:08 -07:00
Daniel Micay
22c3db5df7 add a Clone impl for borrowed pointers 2013-05-15 15:58:20 -04:00
bors
8a15333c06 auto merge of #6498 : thestinger/rust/deep_clone, r=thestinger
This is mostly for `std::rc` and `std::arc` (but I haven't implemented it for ARC yet).

Implementing it correctly for managed boxes is *very* non-trivial. It would probably require an unholy mix of reflection and TLS.
2013-05-15 12:22:58 -07:00
Brian Anderson
0d1331f4a0 Merge remote-tracking branch 'brson/io' into incoming 2013-05-15 12:09:15 -07:00
Brian Anderson
d951da8276 core::rt: Fix TCP test on mac 2013-05-15 12:19:17 -07:00
Brian Anderson
2bc1e6ba60 core::rt: Copy many of the old io extensions to the new io
Some resolve problem is keeping the tests from working
2013-05-15 12:19:16 -07:00
Brian Anderson
d45dc8df72 core::rt: More work on Reader extensions and error handling 2013-05-15 12:19:16 -07:00
Brian Anderson
28a13ec8d7 core::rt: Make push_bytes raise read_error on EOF 2013-05-15 12:19:16 -07:00
Brian Anderson
1c1f11e649 core::rt: Warnings 2013-05-15 12:19:16 -07:00
Brian Anderson
390dde571e core::rt: Rename Task to Coroutine 2013-05-15 12:19:16 -07:00
Brian Anderson
7f5746f6d2 core::rt: Rename Sched.task_queue to work_queue 2013-05-15 12:19:16 -07:00
Brian Anderson
56c0b188b6 rt: Rename sched_key to rt_key
It is more general-purpose than holding scheduler pointers
2013-05-15 12:19:16 -07:00
Brian Anderson
c42b03de17 core::rt: Fix scheduling logic for enqueued tasks 2013-05-15 12:19:15 -07:00
Brian Anderson
4724966b06 core::rt: Add uv timer bindings 2013-05-15 12:19:15 -07:00
Brian Anderson
76e097761e core::rt: read raises read_error 2013-05-15 12:19:15 -07:00
Brian Anderson
b764d4cb4f core::rt: Begin implementing Reader extension methods 2013-05-15 12:19:15 -07:00
Brian Anderson
013b7760b7 core: Turn task::unkillable, etc. into no-ops in newsched. #6377
Not necessary just yet but they make ARC not work.
2013-05-15 12:19:15 -07:00
Brian Anderson
afcf4f2639 core::rt: Don't abort when reporting an unknown uv error 2013-05-15 12:19:15 -07:00
Brian Anderson
174ec1e422 core::rt: Error handling for TcpStream.read 2013-05-15 12:19:15 -07:00
Brian Anderson
0a54bad3d1 core::rt: Initialize logging 2013-05-15 12:19:14 -07:00
Brian Anderson
cc2897d559 core: Replace use of libc::getenv with os::getenv 2013-05-15 12:19:14 -07:00
Brian Anderson
f6401bad24 core: Use a global lock instead of runtime lock for os::getenv, etc. #4726 2013-05-15 12:19:14 -07:00
Brian Anderson
36ad366519 core::rt: Add a test of standalone use of the runtime 2013-05-15 12:19:14 -07:00
Brian Anderson
bfd9aa9755 core:rt: A few micro-opts 2013-05-15 12:19:14 -07:00
Corey Richardson
6ef226d5d9 Add unsetenv wrapper 2013-05-15 13:40:35 -04:00
bors
bcec83aaee auto merge of #6493 : brson/rust/tls, r=thestinger 2013-05-15 10:14:04 -07:00
Youngsoo Son
f11297f608 rename at_vec::from_owned and at_vec::from_slice to at_vec::to_managed_consume and at_vec::to_managed 2013-05-16 00:33:54 +09:00
bors
4e82610099 auto merge of #6487 : recrack/rust/vec_len, r=thestinger
Rename vec::len(var) to var.len()

```
libcore, libfuzzer, librustc, librustdoc, libstd, libsyntax
test/auxiliary
test/bench
test/run-pass
```
2013-05-15 07:38:07 -07:00
Daniel Micay
cda3ac905a rc: fix tests 2013-05-15 04:34:31 -04:00
Björn Steinbrink
109bb7c78b Allow static strings to be used with keyword checks 2013-05-15 08:01:04 +02:00
Daniel Micay
75822f2894 add a DeepClone trait
for deep copies through shared ownership boundaries
2013-05-15 01:36:41 -04:00
bors
31cedf6927 auto merge of #6478 : dotdash/rust/inlining, r=catamorphism
Not inlining these affects the hash table performance quite badly.
2013-05-14 22:00:01 -07:00
Daniel Micay
fa45958ec8 clone: clarify docstring 2013-05-15 00:42:52 -04:00
Brian Anderson
5af8646a8b core: Fix leak in TLS. #6231 2013-05-14 20:50:43 -07:00
Brian Anderson
6a6076ae81 core::rt: Ignore tcp test multiple_connect_interleaved_lazy_schedule
Hangs on mac.
2013-05-14 19:06:22 -07:00
Youngmin Yoo
a2a8596c3d Rename vec::len(var) to var.len() 2013-05-15 11:05:28 +09:00
Brian Anderson
b04fce6a90 Merge remote-tracking branch 'brson/io-upstream' into incoming
Conflicts:
	src/libcore/logging.rs
	src/libcore/rt/local_services.rs
	src/libcore/rt/uv/mod.rs
	src/libcore/rt/uv/net.rs
	src/libcore/rt/uv/uvio.rs
	src/libcore/unstable.rs
2013-05-14 15:30:01 -07:00
Brian Anderson
ee0ce64d9d core::rt: Wait for handles to close 2013-05-14 14:52:07 -07:00
Brian Anderson
204e3d82cc core::rt: Register stacks with valgrind. #6428 2013-05-14 14:52:07 -07:00
Brian Anderson
f934fa73ac core::rt: Docs 2013-05-14 14:52:07 -07:00
Brian Anderson
329dfcaba0 core: Move unstable::exchange_alloc to rt::global_heap 2013-05-14 14:52:07 -07:00
Brian Anderson
52f015aceb core: Cleanup warnings 2013-05-14 14:52:07 -07:00
Brian Anderson
4472a50ceb rtdebug off 2013-05-14 14:52:07 -07:00
Brian Anderson
101aaa3861 core::rt: 0 is a valid TLS key 2013-05-14 14:52:06 -07:00
Brian Anderson
d234cf7e44 core::rt: Make TCP servers work 2013-05-14 14:52:06 -07:00
Brian Anderson
414f3c7d25 core::rt: Add a simple channel type for passing buffered messages between Scheduler and Task
Called 'Tube' for lack of anything better.
2013-05-14 14:52:06 -07:00
Brian Anderson
40a9de5ebc core::rt: Add a very simple ref counted pointer 2013-05-14 14:52:06 -07:00
Brian Anderson
936fce5515 Warnings 2013-05-14 14:52:06 -07:00
Brian Anderson
272c3c2cfb Tidy 2013-05-14 14:52:06 -07:00
Brian Anderson
10355d7a7d core::rt Wire up logging to newsched tasks 2013-05-14 14:52:06 -07:00
Brian Anderson
ad6719ee0b core::rt: Just a small fix to TcpStream 2013-05-14 14:52:06 -07:00
Brian Anderson
a134503d74 core::rt: Move all the uv callback definitions to one place 2013-05-14 14:52:06 -07:00
Brian Anderson
dbf89664aa core::rt: Move the implementation of IdleWatcher to its own file 2013-05-14 14:52:06 -07:00
Brian Anderson
9138feab15 core::rt: Only use one mechanism for attaching custom data to uv handles 2013-05-14 14:52:06 -07:00
Brian Anderson
91ca3a9b29 core::rt: Reording code 2013-05-14 14:52:05 -07:00
Brian Anderson
6ab02c03da core::rt: Convert some uv functions to extension methods 2013-05-14 14:52:05 -07:00
Brian Anderson
cfd183db15 core::rt: Fix some copies in uv 2013-05-14 14:52:05 -07:00
Brian Anderson
b771c99304 core::rt: Fix the finalizer on UvTcpStream and UvTcpListener
Eliminates a lot of calls to `close`
2013-05-14 14:52:05 -07:00
Brian Anderson
01b7b7d5a0 core::rt: Use unsafe pointers instead of transmuted regions 2013-05-14 14:52:02 -07:00
bors
043d02213e auto merge of #6468 : gifnksm/rust/rposition-immutable, r=brson
`position` and `rposition` belonged to `ImmutableCopyableVector`, but they don't need the value is copyable.
2013-05-14 14:05:07 -07:00
Björn Steinbrink
7ba685c7ab Add inlining for iter_bytes for types used as hashmap keys
Not inlining these affects the hash table performance quite badly.
2013-05-14 20:32:49 +02:00
Marvin Löbel
04de8f852c Fix cosmetics for fail!() calls 2013-05-14 16:36:24 +02:00
Björn Steinbrink
bdc182cc41 Use static string with fail!() and remove fail!(fmt!())
fail!() used to require owned strings but can handle static strings
now. Also, it can pass its arguments to fmt!() on its own, no need for
the caller to call fmt!() itself.
2013-05-14 16:36:23 +02:00