Commit Graph

18607 Commits

Author SHA1 Message Date
blake2-ppc
520f292e48 std: Use method name Option::consume
With Option as the simplest container, `consume` is the way to turn it
into a by-value iterator.
2013-08-06 04:05:07 +02:00
blake2-ppc
78effe7626 std: Rewrite the HashSet set operation iterators
Use the Repeat iterator to carry the "explicit closure capture" that was
previously done with the custom EnvFilterIterator.
2013-08-06 04:05:07 +02:00
blake2-ppc
8046218f0f std: Add iterator::Repeat to repeat an element endlessly 2013-08-06 04:05:07 +02:00
blake2-ppc
a05a9a1c02 std: Improve vec::ChunkIter
Implement clone, bidirectionality and random access for this iterator
2013-08-06 04:05:07 +02:00
blake2-ppc
872d15d464 std: Implement RandomAccessIterator for Invert 2013-08-06 04:05:07 +02:00
blake2-ppc
c5e4c55989 std: Remove unused trait bound in Result::map 2013-08-06 04:05:07 +02:00
blake2-ppc
109e0d85a1 std: Convert Result to use external iterators
convert iter() and iter_err() for Result. Use OptionIterator.
2013-08-06 04:02:21 +02:00
blake2-ppc
ce682cb45f std: Add .consume_iter() for Option, to make it reusable
Let Option be a base for a widely useful one- or zero- item iterator.
Refactor OptionIterator to support any generic element type, so the same
iterator impl can be used for both &T, &mut T and T iterators.
2013-08-06 03:59:56 +02:00
Alex Crichton
d5de801cc1 Re-enable rusti tests 2013-08-05 18:55:53 -07:00
bors
bbda3fa938 auto merge of #8288 : Kimundi/rust/opteitres4, r=brson
This is an alternative version to https://github.com/mozilla/rust/pull/8268, where instead of transitioning to `get()` completely, I transitioned to `unwrap()` completely.

My reasoning for also opening this PR is that having two different functions with identical behavior on a common datatype is bad for consistency and confusing for users, and should be solved as soon as possible. The fact that apparently half the code uses `get()`, and the other half `unwrap()` only makes it worse.

If the final naming decision ends up different, there needs to be a big renaming anyway, but until then it should at least be consistent.

---

- Made naming schemes consistent between Option, Result and Either
- Lifted the quality of the either and result module to that of option
- Changed Options Add implementation to work like the maybe Monad (return None if any of the inputs is None)  
  See https://github.com/mozilla/rust/issues/6002, especially my last comment.
- Removed duplicate Option::get and renamed all related functions to use the term `unwrap` instead  
  See also https://github.com/mozilla/rust/issues/7887.

Todo: 

Adding testcases for all function in the three modules. Even without the few functions I added, the coverage wasn't complete to begin with. But I'd rather do that as a follow up PR, I've touched to much code here already, need to go through them again later.
2013-08-05 16:47:01 -07:00
Ben Blum
1f95bd7684 Lazily initialize 'leaf node' taskgroups for unlinked spawns, for an apparent 11% speedup. 2013-08-05 19:30:25 -04:00
Ben Blum
47e82c8555 (cleanup) Uncomment an assertion that now holds. 2013-08-05 18:40:42 -04:00
bors
29099e450a auto merge of #8298 : darkf/rust/fix-3948, r=pcwalton 2013-08-05 13:49:55 -07:00
Marvin Löbel
0ac7a219f0 Updated std::Option, std::Either and std::Result
- Made naming schemes consistent between Option, Result and Either
- Changed Options Add implementation to work like the maybe monad (return None if any of the inputs is None)
- Removed duplicate Option::get and renamed all related functions to use the term `unwrap` instead
2013-08-05 22:42:21 +02:00
Alex Crichton
991648d099 Use TreeMap's ord implementation for Json
Closes #4430
2013-08-05 13:20:48 -07:00
Michael Sullivan
53c6de5684 Improve debug spew in _match. 2013-08-05 12:30:28 -07:00
Michael Sullivan
7dbc5ae79f Get rid of some NOTEs. 2013-08-05 12:30:28 -07:00
Michael Sullivan
fd01031f3a Warn when using -o option on libraries. Closes #6554. 2013-08-05 11:41:06 -07:00
Michael Sullivan
a20081666b Fix an unused variable warning and clean up some dead code/names. 2013-08-05 11:41:06 -07:00
bors
d8b299d179 auto merge of #8293 : dim-an/rust/trie-iterator, r=thestinger
Closes #5506.
2013-08-05 11:28:56 -07:00
Michael Sullivan
bcf62e7901 Make node_id_to_str print more useful info in some cases. Closes #2410. 2013-08-05 10:33:55 -07:00
bors
2d1eb1916e auto merge of #8292 : thestinger/rust/fix_loop_warning, r=brson 2013-08-05 09:49:56 -07:00
blake2-ppc
476dfc24b3 std: Use correct lifetime parameter on str::raw::slice_bytes
fn slice_bytes is marked unsafe since it allows violating the valid
string encoding property; but the function did also allow extending the
lifetime of the slice by mistake, since it's returning `&str`.

Use the annotation `slice_bytes<'a>(&'a str, ...) -> &'a str` so
that all uses of slice_bytes are region checked correctly.
2013-08-05 17:55:06 +02:00
bors
d89ff7eef9 auto merge of #8289 : sfackler/rust/push_byte, r=erickt
It was previously pushing the byte on top of the string's null
terminator. I added a test to make sure it doesn't break in the future.
2013-08-05 08:10:55 -07:00
bors
c2bacd2e80 auto merge of #8183 : omasanori/rust/migrate-new, r=sanxiyn
It seems that relatively new code uses `Foo::new()` instead of `Foo()` so I wrote a patch to migrate some structs to the former style.
Is it a right direction? If there are any guidelines not to use new()-style, could you add them to the [style guide](https://github.com/omasanori/rust/wiki/Note-style-guide)?
2013-08-05 06:22:57 -07:00
bors
dbaca98d78 auto merge of #8279 : pcwalton/rust/no-main, r=brson
Useful for SDL and possibly Android too.

r? @brson
2013-08-05 04:37:58 -07:00
bors
4db061160d auto merge of #8227 : dim-an/rust/tree-iter, r=thestinger 2013-08-05 02:52:55 -07:00
OGINO Masanori
eab97b5558 Add extra::arena::Arena::new{, _with_size}.
Signed-off-by: OGINO Masanori <masanori.ogino@gmail.com>
2013-08-05 17:43:40 +09:00
bors
7b2163d376 auto merge of #8303 : brson/rust/tls-magic-wtf, r=brson 2013-08-05 00:56:00 -07:00
Brian Anderson
1c1add23f6 std::rt: Use magic to make TLS work from annihilated boxes. #8302 2013-08-05 00:36:02 -07:00
bors
4fdd720421 auto merge of #8299 : brson/rust/yet-more-newsched-fixes, r=brson 2013-08-04 23:16:59 -07:00
Brian Anderson
167bdff041 std::rt: Schedule more scheduler callbacks to avoid dropping messages 2013-08-04 21:56:48 -07:00
Brian Anderson
d123df26ff std: Fix newsched logging truncation
The truncation needs to be done in the console logger in order
to catch all the logging output, and because truncation only matters
when outputting to the console.
2013-08-04 21:56:47 -07:00
darkf
180d050138 Open files in binary mode. Closes #3948 2013-08-04 21:54:24 -07:00
bors
83d2a0431c auto merge of #8220 : luqmana/rust/arm-linux, r=cmr
Update the arm linux support some more. We had a previous patch for the RasberryPi. This adds a new target `arm-unknown-linux-gnueabi` for more general arm linux support.

Build/Host machine: x86_64 Debian testing (jessie) with the `gcc-4.4-arm-linux-gnueabi` package

Tested on targets:

- TS-7800 Feroceon (ARMv5TEJ) running Debian 7.0 wheezy
- Beaglebone black (ARMv7) running Angstrom GNU/Linux v2012.12
   - rustc flags:  `--target=arm-unknown-linux-gnueabi --linker=arm-linux-gnueabi-gcc`

- Samsung Galaxy S II (to make sure android still works)
   - rustc flags:  `--target=arm-linux-androideabi --android-cross-path=[path to standalone toolchain]`

Since not all arm devices (i.e. afaik anything older than armv6 like the ts-7800 i tested on) supported getting the tls address via the `mrc` instruction, I made it also try via the magic address the kernel maps into the address space (0xFFFF0FF0). One or the other should work (and on android it seems like both work).

Also fixes a bug where rustc would always try to invoke the android assembler for any kind of arm target.
2013-08-04 21:34:54 -07:00
bors
6c12ca3ac2 auto merge of #8297 : brson/rust/dlist-dtor, r=brson
The compiler-generated dtor for DList recurses deeply to drop Nodes.
For big lists this can overflow the stack.

This is a problem for the new scheduler, where split stacks are not implemented.

Thanks @blake2-ppc
2013-08-04 19:52:57 -07:00
Brian Anderson
4898a0de04 extra: Don't recurse in DList drop glue. #8295
The compiler-generated dtor for DList recurses deeply to drop Nodes.
For big lists this can overflow the stack.
2013-08-04 18:38:06 -07:00
bors
dc5b0b9410 auto merge of #8282 : brson/rust/more-newsched-fixes, r=brson 2013-08-04 18:10:53 -07:00
Luqman Aden
9c39992021 Add support for vanilla linux on arm. 2013-08-04 19:28:06 -04:00
bors
77bc6c5955 auto merge of #8218 : brson/rust/nogc, r=brson
These are both obsoleted by the forthcoming new GC.
2013-08-04 16:25:54 -07:00
Dmitry Ermolov
28165d5ad8 Remove debug printing. 2013-08-05 02:51:43 +04:00
Dmitry Ermolov
d49bb43fc1 Implemented iterator for TrieMap
Closes #5506.
2013-08-05 02:29:51 +04:00
Daniel Micay
c327835a44 fix warning still mentioning the again keyword 2013-08-04 18:21:29 -04:00
Brian Anderson
3f4c6cead6 Remove old tests and code for select
Not compatible with newsched
2013-08-04 15:11:56 -07:00
Brian Anderson
2f8346b949 std::rt: Remove the test for context()
This is no longer testable once newsched is turned on
2013-08-04 15:11:56 -07:00
Brian Anderson
a27f339cb4 std::rt: Don't allow schedulers to exit before handling all messages
Every time run_sched_once performs a 'scheduling action' it needs to guarantee
that it runs at least one more time, so enqueue another run_sched_once callback.
The primary reason it needs to do this is because not all async callbacks
are guaranteed to run, it's only guaranteed that *a* callback will run after
enqueing one - some may get dropped.

At the moment this means we wastefully create lots of callbacks to ensure that
there will *definitely* be a callback queued up to continue running the scheduler.
The logic really needs to be tightened up here.
2013-08-04 15:11:56 -07:00
Brian Anderson
f0f7e1b3fc std::rt: 3MB stacks!
rustc needs *even more* megabytes when run without optimizations
2013-08-04 15:11:56 -07:00
Brian Anderson
75734a9cd3 std::rt: Run the tests for Local in a bare thread
Otherwise interferes with the existing runtime
2013-08-04 15:11:56 -07:00
Brian Anderson
835e963dbd std::rt: Improve the error message when the thread-local ptr is null
Also fix some incorrect comments and variable names.
2013-08-04 15:11:55 -07:00
bors
d6f2364076 auto merge of #8260 : omasanori/rust/fix-extra-unicode, r=pcwalton
WIth this patch `RUSTFLAGS='--cfg unicode' make check"` passed successfully.

* Why doesn't `#[link_name="icuuc"]` make libextra to link against libicuuc.so?
* In `extra::unicode::tests`, `use unicode; unicode::is_foo('a')` failed but `use unicode::*; is_foo('a')` succeeded. Is it right?
2013-08-04 14:43:51 -07:00
Steven Fackler
147c4fd81b Fixed str::raw::push_byte
It was previously pushing the byte on top of the string's null
terminator. I added a test to make sure it doesn't break in the future.
2013-08-04 16:19:40 -04:00
bors
3d14470be4 auto merge of #7115 : alexcrichton/rust/llvm-upgrades, r=thestinger
This is a reopening of #6713

This is still blocked on windows failures. I'll re-push try once the existing crisis has passed.
2013-08-04 12:49:53 -07:00
Daniel Micay
b49d026ecd Merge pull request #8284 from huonw/emacs-in-kw
etc: add the `in` keyword to the emacs mode.
2013-08-04 12:49:11 -07:00
Alex Crichton
60e9507086 Integrate new arm patch and fix an LLVM bug
Thanks @luqama!
2013-08-04 10:58:23 -07:00
Alex Crichton
bb93930575 Add a workaround for 8199 for now 2013-08-04 10:58:23 -07:00
Alex Crichton
4ace3b7434 Fix setting the fixed stack segment attribute on LLVM functions
At the same time create a more robust wrapper to try to prevent this type of
issue from cropping up in the future.
2013-08-04 10:58:23 -07:00
Alex Crichton
8d29367650 Fix build issues once LLVM has been upgraded
* LLVM now has a C interface to LLVMBuildAtomicRMW
* The exception handling support for the JIT seems to have been dropped
* Various interfaces have been added or headers have changed
2013-08-04 10:58:23 -07:00
Alex Crichton
1d06aaae64 Update LLVM 2013-08-04 10:58:22 -07:00
bors
8495ee52b2 auto merge of #8262 : dotdash/rust/no_rval_copies, r=pcwalton
rvalues aren't going to be used anywhere but as the argument, so
there's no point in copying them. LLVM used to eliminate the copy
later, but why bother emitting it in the first place?
2013-08-04 10:55:53 -07:00
bors
22f9ce4df6 auto merge of #8243 : stepancheg/rust/ipv, r=brson
multicast functions now take IpAddr (without port), because they dont't
need port.

Uv* types renamed:
* UvIpAddr -> UvSocketAddr
* UvIpv4 -> UvIpv4SocketAddr
* UvIpv6 -> UvIpv6SocketAddr

"Socket address" is a common name for (ip-address, port) pair (e.g. in
sockaddr_in struct).

P. S. Are there any backward compatibility concerns? What is std::rt module, is it a part of public API?
2013-08-04 08:49:55 -07:00
bors
f7c4359a2c auto merge of #8237 : blake2-ppc/rust/faster-utf8, r=brson
Use unchecked vec indexing since the vector bounds are checked by the
loop. Iterators are not easy to use in this case since we skip 1-4 bytes
each lap. This part of the commit speeds up is_utf8 for ASCII input.

Check codepoint ranges by checking the byte ranges manually instead of
computing a full decoding for multibyte encodings. This is easy to read
and corresponds to the UTF-8 syntax in the RFC.

No changes to what we accept. A comment notes that surrogate halves are
accepted.

Before:

	test str::bench::is_utf8_100_ascii ... bench: 165 ns/iter (+/- 3)
	test str::bench::is_utf8_100_multibyte ... bench: 218 ns/iter (+/- 5)

After:
	test str::bench::is_utf8_100_ascii ... bench: 130 ns/iter (+/- 1)
	test str::bench::is_utf8_100_multibyte ... bench: 156 ns/iter (+/- 3)

An improvement upon the previous pull #8133
2013-08-04 07:10:56 -07:00
bors
5cf69d5bf8 auto merge of #8254 : brson/rust/libuv-mac-supp, r=pcwalton
I suspect that this is a race between process exit and the termination of
worker threads used by libuv (if I sleep before exit it doesn't leak). This
isn't going to cause any real problems but should probably be fixed at
some point.

r? @pcwalton

cc #8253
2013-08-04 05:28:57 -07:00
bors
91b711883c auto merge of #8217 : brson/rust/reset_stack_limit, r=pcwalton
In some scenarios upcall_rust_stack_limit fails to record the stack
limit, leaving it 0, and allowing subsequent Rust code to run into
the red zone.
2013-08-04 03:34:56 -07:00
Huon Wilson
88620c25f5 std: implement Total{Ord,Eq} for pointers. 2013-08-04 19:46:52 +10:00
Huon Wilson
8407ec9fed syntax: make #[deriving(TotalOrd)] lazy.
Previously it would call:

  f(sf1.cmp(&of1), f(sf2.cmp(&of2), ...))

(where s/of1 = 'self/other field 1', and f was
std::cmp::lexical_ordering)

This meant that every .cmp subcall got evaluated when calling a derived
TotalOrd.cmp.

This corrects this to use

   let test = sf1.cmp(&of1);
   if test == Equal {
      let test = sf2.cmp(&of2);
      if test == Equal {
        // ...
      } else {
        test
      }
   } else {
     test
   }

This gives a lexical ordering by short-circuiting on the first comparison
that is not Equal.
2013-08-04 19:46:52 +10:00
Dmitry Ermolov
73ec9f36e4 Implemented TreeMap::{lower_bound_iter,upper_bound_iter}
(issue #4604)
2013-08-04 13:14:13 +04:00
Dmitry Ermolov
98a66568ce Remove redundant print. 2013-08-04 13:14:13 +04:00
Dmitry Ermolov
d8e74b3dcb Additional check in treemap iterator test. 2013-08-04 13:14:13 +04:00
Brian Anderson
044fa35bf8 rt: Fix a corner-case in unwinding that leads to stack overflow
In some scenarios upcall_rust_stack_limit fails to record the stack
limit, leaving it 0, and allowing subsequent Rust code to run into
the red zone.
2013-08-03 23:40:25 -07:00
Brian Anderson
ea84c1fd69 std: Remove gc and stackwalk
These are both obsoleted by the forthcoming new GC.
2013-08-03 23:39:04 -07:00
bors
fbeeeebf47 auto merge of #8264 : thestinger/rust/snapshot, r=Aatch 2013-08-03 23:25:55 -07:00
bors
93432a2c2f auto merge of #8269 : brson/rust/fix-task-cleanup, r=brson
...y/catch

And before collect_failure. These are both running user dtors and need to be handled
in the task try/catch block and before the final task cleanup code.
2013-08-03 21:46:56 -07:00
Daniel Micay
e7bb33aed8 rm obsolete for support from the compiler 2013-08-04 00:39:48 -04:00
Patrick Walton
9c08db58ab librustc: Implement #[no_main], which omits the entry point entirely.
Useful for SDL and possibly Android too.
2013-08-03 20:01:00 -07:00
Daniel Micay
1008945528 remove obsolete foreach keyword
this has been replaced by `for`
2013-08-03 22:48:02 -04:00
Corey Richardson
118158729e Work around #8256, do not fail the task, just return None 2013-08-03 22:36:48 -04:00
Daniel Micay
9f74217d80 register snapshots 2013-08-03 21:09:28 -04:00
Daniel Micay
8ce953347c Merge pull request #8251 from chris-morgan/vim-sigil-highlighting
Highlight sigils and operators in Vim.

r=huonw, known spurious failure on one bot
2013-08-03 18:02:04 -07:00
Brian Anderson
3c9e393354 std::rt: Run local storage cleanup and the box annihilator inside the try/catch
And before collect_failure. These are both running user dtors and need to be handled
in the task try/catch block and before the final task cleanup code.
2013-08-03 14:43:16 -07:00
bors
18e3db7392 auto merge of #8246 : stepancheg/rust/contains-key, r=thestinger
Map::contains_key can be implemented with Map::find.

Remove several implementations of contains_key.
2013-08-03 13:40:49 -07:00
bors
b5d77d20ec auto merge of #8223 : davidhalperin/rust/master, r=Aatch
Closes #7907

This is my first pull request so let me know if I've done anything wrong.  I tried to pick off a nice easy one.
2013-08-03 11:52:50 -07:00
bors
800dbffa69 auto merge of #8219 : sstewartgallus/rust/fix_dynamic_lib, r=graydon
A test case was also created for this situation to prevent the problem
occuring again.

A similar problem was also fixed for the symbol method.

There was some minor code cleanup.

I am unsatisfied with using /dev/null as an invalid dynamic library. It is not cross platform.
2013-08-03 10:04:58 -07:00
bors
34101d2320 auto merge of #8213 : kballard/rust/fd-limit, r=brson
Revert the workaround 49b72bd and instead bump the fd limit on OS X.
2013-08-03 07:46:53 -07:00
Björn Steinbrink
a51e3e46ef trans_arg_expr: Omit extra copies for rvalues
rvalues aren't going to be used anywhere but as the argument, so
there's no point in copying them. LLVM used to eliminate the copy
later, but why bother emitting it in the first place?
2013-08-03 15:03:58 +02:00
bors
6be014d23c auto merge of #8186 : huonw/rust/hashmap-=rt, r=Aatch
The `new` constructor uses the task-local RNG to retrieve seeds for the
two key values, which requires the runtime. Exposing a constructor that
takes the keys directly allows HashMaps to be used in programs that wish
to avoid the runtime.
2013-08-03 05:37:52 -07:00
Huon Wilson
c852a5bb68 std: expose the keyed HashMap constructor, for runtime-less use.
The `new` constructor uses the task-local RNG to retrieve seeds for the
two key values, which requires the runtime. Exposing a constructor that
takes the keys directly allows HashMaps to be used in programs that wish
to avoid the runtime.
2013-08-03 21:00:32 +10:00
OGINO Masanori
c1ad16db5a Fix building problems in extra::unicode.
Signed-off-by: OGINO Masanori <masanori.ogino@gmail.com>
2013-08-03 19:57:31 +09:00
bors
2765811cb6 auto merge of #8206 : omasanori/rust/blk-to-block, r=graydon
Just for consistency.
2013-08-03 03:55:52 -07:00
bors
39fafd655a auto merge of #8204 : kballard/rust/str-into-owned, r=graydon
The method .into_owned() is meant to be used as an optimization when you
need to get a ~str from a Str, but don't want to unnecessarily copy it
if it's already a ~str.

This is meant to ease functions that look like

  fn foo<S: Str>(strs: &[S])

Previously they could work with the strings as slices using .as_slice(),
but producing ~str required copying the string, even if the vector
turned out be a &[~str] already.

I don't have any concrete uses for this yet, since the one conversion I've done to `&[S]` so far (see PR #8203) didn't actually need owned strings. But having this here may make using `Str` more attractive.

It also may be worth adding an `into_managed()` function, but that one is less obviously useful than `into_owned()`.
2013-08-03 02:10:54 -07:00
Huon Wilson
cdad7f6f3b etc: add the in keyword to the emacs mode. 2013-08-03 18:31:23 +10:00
OGINO Masanori
def88913d8 Move use statements.
Signed-off-by: OGINO Masanori <masanori.ogino@gmail.com>
2013-08-03 03:21:01 -04:00
OGINO Masanori
682939724f Rename sum -> _sum.
Signed-off-by: OGINO Masanori <masanori.ogino@gmail.com>
2013-08-03 03:20:56 -04:00
OGINO Masanori
afaca4c822 Remove unused variables.
Signed-off-by: OGINO Masanori <masanori.ogino@gmail.com>
2013-08-03 03:20:45 -04:00
Kevin Ballard
75155cd1b0 Explicitly impl Clone for RWArc
RWArc had a clone() method, but it was part of impl RWArc instead of
an implementation of Clone.

Stick with the explicit implementation instead of deriving Clone so we
can have a docstring.

Fixes #8052.
2013-08-03 03:17:07 -04:00
Huon Wilson
1992765dd3 std: add benchmark for vec.mut_iter. 2013-08-03 03:13:13 -04:00
Huon Wilson
fbb7cd32c3 std: use ptr.offset where possible in the vec iterator.
Closes #8212.
2013-08-03 03:13:11 -04:00
Kevin Ballard
54e685d4fd option: mutate() and mutate_default() should return bool
Fixes #8047.
2013-08-03 03:11:11 -04:00
toddaaro
1f9c392389 fixed the buffer to make it a more reasonable size 2013-08-03 03:09:23 -04:00
toddaaro
eab749a5f3 modified logging function to truncate output and adjusted error output formatting tests to be compatible with both the new and old runtimes 2013-08-03 03:09:04 -04:00
Daniel Micay
b41d04763e make for parse as foreach does
Closes #6997
2013-08-03 03:00:42 -04:00