Commit graph

15284 commits

Author SHA1 Message Date
Daniel Micay
ae1c9ebf3c move iterator adaptor tests to iterator module 2013-04-19 09:01:40 -04:00
Huon Wilson
8ae6b33ed0 libcore: clarify documentation for char_at(_reverse) 2013-04-19 22:30:49 +10:00
Daniel Micay
962a753890 takewhile -> take_while, dropwhile -> skip_while 2013-04-19 07:28:51 -04:00
Daniel Micay
0f85cf180a iterator: add skip and take 2013-04-19 07:22:20 -04:00
bors
d3a58f3797 auto merge of #5943 : brson/rust/struct-return, r=graydon
Mac appears to follow the same ABI as MSVC. This fixes one case
but leaves others broken, like windows.
2013-04-18 19:45:48 -07:00
bors
9618e5b459 auto merge of #5938 : thestinger/rust/iterator, r=pcwalton 2013-04-18 18:51:49 -07:00
bors
225d74f211 auto merge of #5914 : catamorphism/rust/copy-cops, r=catamorphism 2013-04-18 17:51:51 -07:00
Tim Chevalier
3d43af15d8 rustc: Anti-copy police
In this case, some copies are still necessary to convert from
a mutable to an immutable @-box. It's still an improvement,
I hope.
2013-04-18 17:40:42 -07:00
bors
df9cc2eb66 auto merge of #5924 : catamorphism/rust/non-fatal-errors, r=catamorphism 2013-04-18 16:57:51 -07:00
bors
50cd218c1e auto merge of #5920 : catamorphism/rust/rustpkg, r=catamorphism
r? @graydon
2013-04-18 16:06:52 -07:00
Tim Chevalier
1aebf30f72 Tidy 2013-04-18 15:24:25 -07:00
Tim Chevalier
62847b0f24 rustc: Make some typechecker errors non-fatal 2013-04-18 15:12:27 -07:00
Brian Leibig
d2718e6324 xfail box and vec debug info tests 2013-04-18 18:05:33 -04:00
Tim Chevalier
18db9a2954 rustc: One less copy 2013-04-18 14:50:29 -07:00
Graydon Hoare
5a3d26f271 core: replace unicode match exprs with bsearch in const arrays, minor perf win. 2013-04-18 14:39:40 -07:00
Graydon Hoare
14b7277c4f core: add vec::bsearch. 2013-04-18 14:39:40 -07:00
bors
b19c644d54 auto merge of #5921 : brson/rust/pipes, r=brson
This builds on #5909. I've been combing through the pipes code to understand it and started refactoring a bit.

* Removes pipes::spawn_* functions. These are not particularly useful since they deal with low-level pipes types.
* Inlines the protocol-compiled definitions of `oneshot` and `streamp`. These are the only two uses of the protocol compiler in core and I'm inlining them so I can understand what they are doing as I work on pipes. I may un-inline them in the future.
* Removes redundant functions from core::comm
* Change the constructors to use the `new` convention
2013-04-18 14:36:53 -07:00
Brian Anderson
8a6d6dd868 rustc: Fix struct returns on x86 mac for 8-byte structs
Mac appears to follow the same ABI as MSVC. This fixes one case
but leaves others broken, like windows.
2013-04-18 14:14:17 -07:00
Brian Anderson
decd3901d5 core::comm: Modernize constructors to use new 2013-04-18 14:07:35 -07:00
Brian Anderson
bc60d84507 core::pipes: Just reordering declarations 2013-04-18 14:07:35 -07:00
Brian Anderson
0617d580e6 core::comm: Remove functions in favor of methods
`send`, etc. are never used. I've left the functions for oneshot pipes
because by-value methods don't work.
2013-04-18 14:07:35 -07:00
Brian Anderson
4e22461cd8 core: Remove a stray #[doc(hidden)] attribute 2013-04-18 14:07:35 -07:00
Brian Anderson
056164ac19 core: Inline the protocol definitions of sendp and oneshot
I want to be able to see what is going on
2013-04-18 14:07:35 -07:00
Brian Anderson
3dce936753 core: Remove #[doc(hidden)] attributes and atomic wrapper functions from pipes
Neither are needed
2013-04-18 14:07:35 -07:00
Brian Anderson
8f2d21dc0d core: Just reordering some code 2013-04-18 14:07:35 -07:00
Brian Anderson
ab08b4fbfd core: Remove pipes::spawn_service, spawn_service_recv
These are only used in test cases; pipes isn't the right place for them;
they are unnecessary.

Conflicts:
	src/libcore/rt/uv/mod.rs
2013-04-18 14:07:35 -07:00
bors
2a86485277 auto merge of #5418 : luqmana/rust/stack-float, r=brson
Like I commented in #2043, I can't reproduce the weirdness from #1388 on either mac or linux (x84_64) and pushing to try gives all green.

That's 128 less bytes to have to keep in the stack for every call to __morestack.
2013-04-18 13:45:55 -07:00
bors
b329f2fa82 auto merge of #5798 : recrack/rust/multiple-errors, r=brson
Fix #4569.
2013-04-18 12:21:57 -07:00
Brian Anderson
b18f12fb16 test: xfail-macos some tests that don't work on mac i686 2013-04-18 11:17:34 -07:00
Brian Anderson
2686dcb98e test: Add more comments about why extern-pass-TwoU64s is xfailed 2013-04-18 11:17:01 -07:00
Daniel Micay
a523abd75c add dropwhile and takewhile iterators 2013-04-18 13:22:38 -04:00
bors
8796c9fe2d auto merge of #5935 : bjz/rust/master, r=thestinger 2013-04-18 09:03:55 -07:00
Brendan Zabarauskas
a7f6ec8542 Use assert_eq! instead of assert! and remove extraneous parentheses 2013-04-19 01:37:21 +10:00
bors
e4f35a7326 auto merge of #5933 : huonw/rust/core-read-until-byte, r=thestinger
`read_until` is just doing a bytewise comparison. This means the following program prints `xyå12`, not `xy`, which it should if it was actually checking chars.

```rust
fn main() {
    do io::with_str_reader("xyå12") |r| {
        io::println(r.read_until('å', false));
    }
}
```

This patch makes the type of read_until match what it is actually doing.
2013-04-18 08:09:55 -07:00
bors
24fb719b8c auto merge of #5932 : huonw/rust/core-str-iterator, r=thestinger 2013-04-18 07:12:55 -07:00
Huon Wilson
19cc352302 core: io: the read_until function checks bytes not chars, so type should reflect that. 2013-04-18 23:36:38 +10:00
Brendan Zabarauskas
939a97f5cb Add #[inline(always)] to each operator method 2013-04-18 23:24:24 +10:00
bors
2c8278746d auto merge of #5930 : osaut/rust/master, r=thestinger
Just small typos I found during my study of rust sources. 
I have added the fbuild URL for reader's convenience.
2013-04-18 06:15:54 -07:00
Huon Wilson
c967f2bb1e core: add a str iterator 2013-04-18 22:56:21 +10:00
bors
938ddeeed6 auto merge of #5929 : intgr/rust/sketch_output, r=thestinger
The last line of any command output should always have a newline. Also fixed typo, "on on"

summary of 25 test runs: 4563 passed; 0 failed; 344 ignored
2013-04-18 05:21:55 -07:00
bors
bd75463839 auto merge of #5928 : huonw/rust/core-task-spawn-supervised-doc, r=thestinger
The doc-comment didn't reflect the [tasks tutorial](http://static.rust-lang.org/doc/tutorial-tasks.html#failure-modes), or how it works in practice.
2013-04-18 04:30:54 -07:00
Brendan Zabarauskas
d2a81b95c3 Implement bitwise operator traits for ints and uints 2013-04-18 20:58:58 +10:00
Huon Wilson
f43fc5fff8 libcore: make spawn_supervised documentation reflect its behaviour. 2013-04-18 20:46:23 +10:00
Huon Wilson
0ff568a3c1 libcore: add an EnumerateIterator, like Python's enumerate. 2013-04-18 20:37:27 +10:00
Olivier Saut
a35376e24e Small typos, year date and URL of the fbuild system for reference. 2013-04-18 11:51:12 +02:00
Marti Raudsepp
5dda8ab129 sketch: Make rust sketch barf output prettier 2013-04-18 12:46:01 +03:00
bors
d32d4d1209 auto merge of #5923 : thestinger/rust/iterator, r=graydon 2013-04-18 01:36:53 -07:00
Youngmin Yoo
6030e3982a Errors with the same span print the span once 2013-04-18 17:19:41 +09:00
bors
d4daee453c auto merge of #5918 : catamorphism/rust/Warnings, r=catamorphism 2013-04-17 23:45:57 -07:00
bors
3b48063373 auto merge of #5912 : Dretch/rust/issue-2626, r=graydon
which does currently seem to work on win32 (and linux).

Just mentioning issue #2626 again to make sure github picks it up.
2013-04-17 21:39:56 -07:00
bors
16652c9c17 auto merge of #5909 : brson/rust/rt4, r=graydon
This is just a bunch of minor changes and simplifications to the structure of core::rt. It makes ownership of the ~Scheduler more strict (though it is still mutably aliased sometimes), turns the scheduler cleanup_jobs vector into just a single job, shunts the thread-local scheduler code off to its own file.
2013-04-17 20:42:58 -07:00
bors
a089c6f8fc auto merge of #5908 : jbclements/rust/add-hygiene-machinery, r=graydon
This pull request changes the representation of identifiers by adding an integer to the side of each one.  This integer will eventually be a reference to a side-table of syntax contexts, presumably stored in TLS. This pull request also adds a bunch of utility functions required for hygiene, and associated tests, but doesn't actually deploy those functions.

Finally, it also has a number of small cleanup items.
2013-04-17 19:48:59 -07:00
Tim Chevalier
128e95b89d rustpkg: Add more tests
These are examples of what *should* work, and probably don't
work yet.
2013-04-17 19:00:52 -07:00
Tim Chevalier
958189dba1 rustpkg: Add a list of rustpkg commands that should pass
This is a test file containing examples of commands that should
succeed. When we write the test runner, we will have to figure
out how to automate them.
2013-04-17 18:59:32 -07:00
Tim Chevalier
e2d947d72f rustpkg: Don't execute the standard build logic if there is a pkg.rs 2013-04-17 18:58:59 -07:00
Tim Chevalier
a2761ac7b5 rustpkg: Change this example to show how to do a custom build 2013-04-17 18:58:41 -07:00
Tim Chevalier
35f3b6324f rustpkg: Remove bogus .rc file 2013-04-17 18:58:12 -07:00
Daniel Micay
c98f0cb362 vec: add an external iterator 2013-04-17 21:53:23 -04:00
bors
fdb4ef321e auto merge of #5726 : brson/rust/struct-return, r=brson
r? @nikomatsakis

This doesn't completely fix the x86 ABI for structs, but it does fix some cases. On linux, structs appear to be returned correctly now. On windows, structs are only returned by pointer when they are greater than 8 bytes. That scenario works now.

In the case where the struct is less than 8 bytes our generated code looks peculiar. When returning a pair of u16, C packs both variables into %eax to return them. Our generated code though expects to find one of the pair in %ax and the other in %dx. Similar for u8. I haven't looked into it yet.

There appears to also be struct passing problems on linux, where my `extern-pass-TwoU8s` and `extern-pass-TwoU16s` tests are failing.
2013-04-17 18:45:58 -07:00
bors
68dea75296 auto merge of #5725 : jdm/rust/muttrait, r=nikomatsakis 2013-04-17 17:57:59 -07:00
Tim Chevalier
82765a0b48 rustpkg: Implement clean; replace boolean result flags with fail!()
1. Implemented the `clean` command

2. The methods implementing rustpkg commands all returned `bool`.
Since most of not all of the error situations seem unrecoverable,
I changed the methods to return unit (and also stubbed out several
more methods that were assuming a package script existed, to be
re-implemented in the future)
2013-04-17 15:58:11 -07:00
Brian Anderson
a5ddc00982 rustc: Use an out pointer to return structs in x86 C ABI. #5347
This Adds a bunch of tests for passing and returning structs
of various sizes to C. It fixes the struct return rules on unix,
and on windows for structs of size > 8 bytes. Struct passing
on unix for structs under a certain size appears to still be broken.
2013-04-17 15:49:19 -07:00
Tim Chevalier
e6c3c371a5 rustpkg: Add a few tests
There's no test runner for rustpkg yet; just sketching out a few
basic test scenarios. pass/ contains packages that should compile
successfully, whereas fail/ contains packages that should fail
to build.
2013-04-17 14:32:40 -07:00
Tim Chevalier
c01c3d9fc6 rustpkg: Fail when crate inference fails; inject link attributes
1. Fail when there's no package script and no crates named
main.rs, lib.rs, bench.rs, or test.rs.

2. Inject the crate link_meta "name" and "vers" attributes, so
that the output file gets named correctly in the library case.

3. Normalize '-' to '_' in package names.
2013-04-17 14:32:34 -07:00
Tim Chevalier
f86bf0ee6e Warning police 2013-04-17 13:42:43 -07:00
Josh Matthews
97303703ee Allow casting to mutable trait objects. 2013-04-17 00:34:25 +02:00
bors
c2f5a87cdd auto merge of #5913 : brson/rust/valgrind, r=brson 2013-04-16 13:42:58 -07:00
Brian Anderson
c6f7b595f0 More valgrind suppressions 2013-04-16 13:40:47 -07:00
gareth
caffe127c7 Fix issue 2626 by un-ignoring the mysterious test_leaks,
which does currently seem to work on win32 (and linux).
2013-04-16 21:23:44 +01:00
bors
07e087bf31 auto merge of #5890 : youknowone/rust/const-eval, r=catamorphism
This will help not to meet confusing errors.
In issue #5873, the error was "expected constant expr for vector length: Can't cast str to int".
It was originally "expected constant expr for vector length: Non-constant path in constant expr" (though still invalid error).
This patch make the original error to be printed.
2013-04-16 12:48:56 -07:00
Brian Anderson
7bfd0e5035 Merge remote-tracking branch 'brson/sched-cleanup'
Conflicts:
	src/libcore/rt/sched/mod.rs
2013-04-16 11:23:13 -07:00
John Clements
e7aa24de18 add self.token_to_str and is_any_keyword convenience abstractions 2013-04-16 10:06:06 -07:00
John Clements
7e4cd09e2e added MTWT functions 2013-04-16 10:06:06 -07:00
John Clements
1083ae6b06 better error message on failure to parse type 2013-04-16 10:06:06 -07:00
John Clements
313a5ab946 move interner_key macro 2013-04-16 10:06:05 -07:00
Huon Wilson
21723d5bdc libcore: vec::windowed iterates, not allocates. 2013-04-16 23:07:46 +10:00
bors
76e77af380 auto merge of #5901 : thestinger/rust/iterator, r=sanxiyn
Can now use them like `x.transform(|i| i + 3).zip(y.filter(|i| i % 2)`.
2013-04-15 21:03:55 -07:00
bors
16e8af9e47 auto merge of #5895 : huonw/rust/no-pub-tests, r=thestinger
This patch is a sledge hammer that moves all tests into `#[cfg(test)] mod test { .. }`, and makes them private, there were several instances of `pub mod tests { #[test] pub fn ... } `.

(The reason for this is I was playing with using `syntax` to index code ([result so far](http://www.ug.it.usyd.edu.au/~hwil7821/rust-api/)) and it was getting some junk from the tests.)

The rustdoc commit is particularly brutal, so it's fine if that one isn't landed.
2013-04-15 20:00:56 -07:00
Tim Chevalier
39d45b75cc rustc: Anti-copy police 2013-04-15 19:06:36 -07:00
Huon Wilson
40e3577b08 libcore: missed an import for a test 2013-04-16 12:04:49 +10:00
Brian Anderson
1f94364aef core::rt: Clean up some more hacks 2013-04-15 18:56:39 -07:00
Brian Anderson
ed74ac169e core::rt: Narrow down the unsafety of the thread-local scheduler
Only when borrowing the I/O implementation do we need unsafety
2013-04-15 18:54:02 -07:00
Daniel Micay
f82c96446f iterator: use an IteratorUtil trait 2013-04-15 21:35:41 -04:00
Brian Anderson
68583a25a0 core::rt: Restructure context switches to take ownership of the Scheduler
In order to do a context switch you have to give up ownership of the scheduler,
effectively passing it to the next execution context. This could help avoid
some situations here tasks retain unsafe pointers to schedulers between context
switches, across which they may have changed threads.

There are still a number of uses of unsafe scheduler pointers.
2013-04-15 17:45:34 -07:00
Huon Wilson
ef3a8ebb9b librustdoc: move tests into dedicated tests module. 2013-04-16 09:57:47 +10:00
Huon Wilson
d3be98e9f5 libcore,std,syntax,rustc: move tests into mod tests, make them private (no pub mod or pub fn). 2013-04-16 09:57:47 +10:00
bors
dd2c7f61a9 auto merge of #5879 : astrieanna/rust/document_std_base64, r=catamorphism
This adds examples for the methods in std::base64.

Each example is complete in the sense that you can copy-paste it into a file and compile it successfully without adding anything (imports, etc). The hardest part of figuring out how to use this was figuring out the right import statements to put at the top.
2013-04-15 16:18:52 -07:00
Brian Anderson
ebefe07792 core::rt: Make Scheduler::unsafe_local return a fabricated region pointer
Instead of taking a closure. It's unsafe either way. Rename it to unsafe_local_borrow.
2013-04-15 16:00:15 -07:00
Brian Anderson
473b4d19ad core::rt: Rename Scheduler::local to Scheduler::unsafe_local 2013-04-15 15:32:43 -07:00
Brian Anderson
3b8a354c21 core::rt: A little bit of cleanup to thread-local scheduler 2013-04-15 15:25:29 -07:00
Brian Anderson
1f8ebb6a8e core::rt: Move thread-local scheduler to its own module 2013-04-15 15:18:49 -07:00
Brian Anderson
4f1dd1fd21 core::rt: Fix two incorrect uses of the thread-local scheduler
These would not be threadsafe
2013-04-15 15:13:36 -07:00
bors
f10cf26e25 auto merge of #5861 : catamorphism/rust/rustpkg, r=catamorphism
r? @graydon

Pulled out tests into their own modules inside the files they test,
as per the draft style guidelines.

Started a new module, path_util, for utility functions to do with
paths and directories.

Changed default_dest_dir to use a condition and return Path
instead of Option<Path>.
2013-04-15 14:48:55 -07:00
bors
6ce689d61c auto merge of #5891 : brson/rust/valgrind, r=brson
Hopefully this puts out the final fire
2013-04-15 13:54:57 -07:00
Brian Anderson
7cd681684f rt: Move test functions to rust_test_helpers.cpp 2013-04-15 13:39:15 -07:00
Brian Anderson
6beddb966d Make valgrind suppressions more liberal
Hopefully this puts out the final fire
2013-04-15 13:20:23 -07:00
bors
4beebc427c auto merge of #5797 : alexcrichton/rust/issue-1913, r=catamorphism
Closes #5487, #1913, and #4568

I tracked this by adding all used unsafe blocks/functions to a set on the `tcx` passed around, and then when the lint pass comes around if an unsafe block/function isn't listed in that set, it's unused.

I also removed everything from the compiler that was unused, and up to stage2 is now compiling without any known unused unsafe blocks.

I chose `unused_unsafe` as the name of the lint attribute, but there may be a better name...
2013-04-15 13:00:56 -07:00
Jeong YunWon
9b55d86e74 Prevent eval_const_expr_partial hides prior error in expr_cast arm.
This will help not to meet confusing errors.
In issue #5873, the error was "expected constant expr for vector length: Can't cast str to int".
It was originally "expected constant expr for vector length: Non-constant path in constant expr"
This patch make the original error to be printed.
2013-04-16 04:13:37 +09:00
Tim Chevalier
7881bde027 Tidy 2013-04-15 11:52:38 -07:00
bors
3809a04bf7 auto merge of #5778 : jld/rust/reflect-abstract-enum, r=graydon
This takes care of one of the last remnants of assumptions about enum layout.  A type visitor is now passed a function to read a value's discriminant, then accesses fields by being passed a byte offset for each one.  The latter may not be fully general, despite the constraints imposed on representations by borrowed pointers, but works for any representations currently planned and is relatively simple.

Closes #5652.
2013-04-15 09:57:55 -07:00
bors
7b152baddf auto merge of #5881 : danluu/rust/xfail_bind_by_move, r=graydon
Update an old test to pass. I'm not 100% sure what the intent of the test was, but it's hard to see how I could have corrupted the intent of the test from the tiny changes I made.
2013-04-15 08:06:57 -07:00
Brian Anderson
93757d8185 core::rt: Clean up the thread-local scheduler code
Remove the ThreadLocalScheduler type in favor of functions.
Move everything into the sched::local module.
2013-04-14 21:53:37 -07:00
Brian Anderson
a2e5827866 core::rt: All context switches are followed by a cleanup action 2013-04-14 20:49:22 -07:00
Brian Anderson
5f52aecb1e core::rt: Schedulers only need a single cleanup_job at a time
Each context switch has up to one cleanup job and it is always
executed immediately after the context switch.
2013-04-14 19:24:43 -07:00
Brian Anderson
6b084bad25 core::rt: Insert calls to run_cleanup_tasks after all context switches 2013-04-14 18:56:22 -07:00
Brian Anderson
1cb78e736f core::rt: Rename block_running_task_and_then to deschedul_... 2013-04-14 16:12:30 -07:00
Brian Anderson
8e966216c7 core::rt: Restructure task_from_last_cleanup_job to borrow correctly
We need a number of mutable references to contexts so name it
`get_contexts` and return a tuple of all of them.
2013-04-14 16:05:16 -07:00
Dan Luu
caa1079257 Fix xfail'd ARC test 2013-04-14 11:35:58 -04:00
Leah Hanson
b5c9990c38 Change to 4-space indents in code examples 2013-04-14 09:24:13 -04:00
bors
1ab1354937 auto merge of #5880 : Dretch/rust/signals, r=thestinger
This is a follow-up to #5761. Its purpose is to make core::libc more consistent - it currently only defines SIGKILL and SIGTERM, because they are the only values that happen to be needed by libcore.

This adds all the posix signal value constants, except for those that have different values on different architectures.

The output of the command `man 7 signal` was used to compile these signal values.
2013-04-14 06:21:54 -07:00
gareth
6994340ca0 Flesh out the SIG* constants: this adds all the posix signal
value constants, except for those that have different values
on different architectures.

The output of the command `man 7 signal` was used to
compile these signal values.
2013-04-14 14:08:22 +01:00
Leah Hanson
ced12a74cd update copyright notice on base64.rs 2013-04-14 08:01:54 -04:00
bors
79d4f1402e auto merge of #5779 : crabtw/rust/x86_64_abi, r=sanxiyn
This fixes #5754.
2013-04-14 00:03:54 -07:00
Alex Crichton
59e69aa0e7 test: remove unnecessary unsafe blocks/functions 2013-04-14 01:15:46 -04:00
Jyun-Yan You
685c4d0b76 add rust_dbg_extern_identity_TwoDoubles to prevent check-fast failure 2013-04-14 13:15:46 +08:00
Alex Crichton
8978643f92 syntax: remove unnecessary unsafe blocks/functions 2013-04-14 01:15:46 -04:00
Alex Crichton
72c24e20a9 rustc: remove unnecessary unsafe blocks/methods 2013-04-14 01:15:46 -04:00
Alex Crichton
52445129fd std: remove unused unsafe blocks/functions 2013-04-14 01:15:46 -04:00
Alex Crichton
d9595d1737 core: remove unnecessary unsafe blocks/functions 2013-04-14 01:15:46 -04:00
Alex Crichton
4bfa3c6663 Add a lint mode for unused unsafe blocks/functions 2013-04-14 01:15:46 -04:00
bors
8c2e5cceee auto merge of #5867 : dotdash/rust/reduce_reallocs, r=graydon
The foldl based implementation allocates lots of unneeded vectors.
iter::map_to_vec is already optimized to avoid these.

One place that benefits quite a lot from this is the metadata decoder, helping with compile times for tiny programs.
2013-04-13 17:15:55 -07:00
bors
04cc83614d auto merge of #5864 : huonw/rust/rusti-detect-tty, r=graydon
This is a fairly large hack, just passing an extra argument through, and I can't test it at all, since rusti doesn't work here to begin with.
2013-04-13 16:09:56 -07:00
bors
715810290f auto merge of #5810 : thestinger/rust/iterator, r=graydon
The current protocol is very comparable to Python, where `.__iter__()` returns an iterator object which implements `.__next__()` and throws `StopIteration` on completion. `Option` is much cleaner than using a exceptions as a flow control hack though. It requires that the container is frozen so there's no worry about invalidating them.

Advantages over internal iterators, which are functions that are passed closures and directly implement the iteration protocol:

* Iteration is stateful, so you can interleave iteration over arbitrary containers. That's needed to implement algorithms like zip, merge, set union, set intersection, set difference and symmetric difference. I already used this internally in the `TreeMap` and `TreeSet` implementations, but regions and traits weren't solid enough to make it generic yet.
* They provide a universal, generic interface. The same trait is used for a forward/reverse iterator, an iterator over a range, etc. Internal iterators end up resulting in a trait for each possible way you could iterate.
* They can be composed with adaptors like `ZipIterator`, which also implement the same trait themselves.

The disadvantage is that they're a pain to write without support from the compiler for compiling something like `yield` to a state machine. :)

This can coexist alongside internal iterators since both can use the current `for` protocol. It's easier to write an internal iterator, but external ones are far more powerful/useful so they should probably be provided whenever possible by the standard library.

## Current issues

#5801 is somewhat annoying since explicit type hints are required.

I just wanted to get the essentials working well, so I haven't put much thought into making the naming concise (free functions vs. static `new` methods, etc.).

Making an `Iterable` trait seems like it will have to be a long-term goal, requiring type system extensions. At least without resorting to objects which would probably be unacceptably slow.
2013-04-13 14:42:57 -07:00
Dan Luu
78bc10d94b Doc review, as requested :-).
Mostly just phrasing things differently, which is a matter of taste. Feel free to use or not use any of the changes I'm suggesting.

I would say this one thing should be changed, though, not necessarily the way I changed it here.

     * Convert any string (literal, `@`, `&`, `~`)
     * that contains a base64 encoded value, to the byte values it encodes.

If this structure is going to be used, either the entire clause, 'that contains a base64 encoded value', should be bracketed by commas, or the comma at the end of the clause should be removed.
2013-04-13 16:17:30 -04:00
Brendan Zabarauskas
0615fddd80 Remove unnecessary enclosing modules for NumCast impls 2013-04-14 05:27:32 +10:00
Brendan Zabarauskas
c4685477e0 Consolidate tests of numeric operations 2013-04-14 02:53:00 +10:00
Brendan Zabarauskas
ce6ee7bb04 Restore Num trait
This restores the trait that was lost in 216e85fadf. It will eventually be broken up into a more fine-grained trait hierarchy in the future once a design can be agreed upon.
2013-04-14 02:19:35 +10:00
Brendan Zabarauskas
fde6995229 Remove trailing whitespace 2013-04-14 01:25:56 +10:00
Brendan Zabarauskas
947ba206e1 Add a test to show how NumCast can be used in type parameters 2013-04-14 01:14:02 +10:00
Brendan Zabarauskas
353ce872e2 Generate NumCast impls and tests using macros 2013-04-14 01:14:02 +10:00
Brendan Zabarauskas
3ffd735b45 Clarify purpose of NumCast trait 2013-04-14 01:14:02 +10:00
Björn Steinbrink
a26d9db95f Avoid excessive allocations and copies in iter::to_vec
The foldl based implementation allocates lots of unneeded vectors.
iter::map_to_vec is already optimized to avoid these.
2013-04-13 14:29:14 +02:00
Leah Hanson
8e64b61df9 move rustdoc comments so that they attach to the functions rather than the impl blocks. 2013-04-13 08:11:39 -04:00
bors
e2d5cebe32 auto merge of #5761 : Dretch/rust/murder-death-kill, r=thestinger
As proposed in issue #5632.

I added some new stuff to libc - hopefully correctly. I only added a single signal constant (SIGKILL) because adding more seems complicated by differences between platforms - and since it is not required for issue #5632 then I figure that I can use a further pull request to flesh out the SIG* constants more.
2013-04-13 05:00:57 -07:00
Huon Wilson
c2b15345c7 librusti: only use std::rl if stdin is connected to a tty. 2013-04-13 21:30:21 +10:00
Huon Wilson
d70f0f1a6e librust: make rust run file.rs past any extra arguments to the compiled program. 2013-04-13 21:02:43 +10:00
Daniel Micay
8bf9fc52f4 initial iterator object library 2013-04-13 05:51:14 -04:00
Jyun-Yan You
4ad8ec351a fix index out of bounds error of x86_64 ABI 2013-04-13 15:04:30 +08:00
bors
65ff441b3d auto merge of #5839 : bjz/rust/master, r=brson
r? @brson
2013-04-12 21:00:57 -07:00
Leah Hanson
27a0269501 Add comments for the implementations of from_base64 and to_base64 for . 2013-04-12 22:15:56 -04:00
Brian Anderson
a9247e07ac Suppress a bunch of valgrind errors 2013-04-12 18:49:40 -07:00
Tim Chevalier
884c7c9326 rustpkg: Factor out tests; use a condition instead of returning an option
Pulled out tests into their own modules inside the files they test,
as per the draft style guidelines.

Started a new module, path_util, for utility functions to do with
paths and directories.

Changed default_dest_dir to use a condition and return Path
instead of Option<Path>.
2013-04-12 16:15:40 -07:00
bors
76f6606a8c auto merge of #5827 : nikomatsakis/rust/issue-5656-change-meaning-of-borrowed-self, r=pcwalton
See #5656 for details.

r? @pcwalton
2013-04-12 15:14:24 -07:00
bors
5bb2e8f62c auto merge of #5847 : catamorphism/rust/rustpkg, r=catamorphism
r? @graydon This is preliminary work on bringing rustpkg up to conformance with #5679
and related issues.

This change makes rustpkg infer a package ID from its containing directory,
instead of requiring name and vers attributes in the code. Many aspects of it
are incomplete; I've only tested one package (see README.txt) and one command,
"build". So far it only works for local packages.

I also removed code for several of the package commands other than "build",
replacing them with stubs that fail, since they used package IDs in ways that
didn't jibe well with the new scheme. I will re-implement the commands one
at a time.
2013-04-12 12:57:58 -07:00
Tim Chevalier
74fee15bc1 Tidy 2013-04-12 12:49:11 -07:00
Leah Hanson
2ec2d99bbd add rustdoc comments with examples for the string versions of to_base64 and from_base64 2013-04-12 09:41:07 -04:00
bors
2cb6974856 auto merge of #5640 : dbaupp/rust/syntax-generalise-deriving, r=thestinger
This refactors much of the ast generation required for `deriving` instances into a common interface, so that new instances only need to specify what they do with the actual data, rather than worry about naming function arguments and extracting fields from structs and enum. (This all happens in `generic.rs`. I've tried to make sure it was well commented and explained, since it's a little abstract at points, but I'm sure it's still a little confusing.)

It makes instances like the comparison traits and `Clone` short and easy to write.

Caveats:
- Not surprisingly, this slows the expansion pass (in some cases, dramatically, specifically deriving Ord or TotalOrd on enums with many variants).   However, this shouldn't be too concerning, since in a more realistic case (compiling `core.rc`) the time increased by 0.01s, which isn't worth mentioning. And, it possibly slows type checking very slightly (about 2% worst case), but I'm having trouble measuring it (and I don't understand why this would happen). I think this could be resolved by using traits and encoding it all in the type system so that monomorphisation handles everything, but that would probably be a little tricky to arrange nicely, reduce flexibility and make compiling rustc take longer. (Maybe some judicious use of `#[inline(always)]` would help too; I'll have a bit of a play with it.)
- The abstraction is not currently powerful enough for:
  - `IterBytes`: doesn't support arguments of type other than `&Self`.
  - `Encodable`/`Decodable` (#5090): doesn't support traits with parameters.
  - `Rand` & `FromStr`; doesn't support static functions and arguments of type other than `&Self`.
   - `ToStr`: I don't think it supports returning `~str` yet, but I haven't actually tried.

  (The last 3 are traits that might be nice to have: the derived `ToStr`/`FromStr` could just read/write the same format as `fmt!("%?", x)`, like `Show` and `Read` in Haskell.)
 
  I have ideas to resolve all of these, but I feel like it would essentially be a simpler version of the `mt` & `ty_` parts of `ast.rs`, and I'm not sure if the simplification is worth having 2 copies of similar code.

Also, makes Ord, TotalOrd and TotalEq derivable (closes #4269, #5588 and #5589), although a snapshot is required before they can be used in the rust repo.

If there is anything that is unclear (or incorrect) either here or in the code, I'd like to get it pointed out now, so I can explain/fix it while I'm still intimately familiar with the code.
2013-04-12 04:33:58 -07:00
Huon Wilson
5c376e53d0 libsyntax: another fix for deriving on windows. 2013-04-12 20:19:44 +10:00
bors
63e2724cdb auto merge of #5809 : Aatch/rust/start-attr, r=thestinger
This implements #5158. Currently it takes the command line args and the crate map. Since it doesn't take a `main` function pointer, you can't actually start the runtime easily, but that seems to be a shim to allow the current `rust_start` function to call into main.

However, you can do an end-run round the io library and do this:

```rust
use core::libc::{write, c_int, c_void, size_t, STDOUT_FILENO};

#[start]
fn my_start(_argc:int, _argv: **u8, _crate_map: *u8) -> int {
    do str::as_buf("Hello World!\n") |s,len| {
        unsafe {
            write(STDOUT_FILENO, s as *c_void, len as size_t);
        }
    }
    return 0;
}
```

Which is the most basic "Hello World" you can do in rust without starting up the runtime (though that has quite a lot to do with the fact that `core::io` uses `@` everywhere...)
2013-04-12 02:34:02 -07:00
Huon Wilson
ea9bdaaed9 libsyntax: (maybe) fix deriving(TotalOrd) on windows 2013-04-12 19:00:53 +10:00
James Miller
35c73c8088 Added xfail-fast to test so the windows buildbot doesn't choke 2013-04-12 20:59:46 +12:00
Huon Wilson
bff3748731 libsyntax: short-circuit on non-matching variants in deriving code.
Allow a deriving instance using the generic code to short-circuit for
any non-matching enum variants (grouping them all into a _ match),
reducing the number of arms required. Use this to speed up the Eq &
TotalEq implementations.
2013-04-12 17:12:02 +10:00
Huon Wilson
99492796dc testsuite: add tests for derived Eq, TotalEq, Ord, TotalOrd. 2013-04-12 17:11:58 +10:00
Huon Wilson
7906c5572a libsyntax: derive Clone, Eq, TotalEq, Ord, TotalOrd with the new generic deriving code.
Closes #4269, #5588 and #5589.
2013-04-12 17:10:27 +10:00
Huon Wilson
85b82c763b libcore: combine cmp::Ordering instances in lexical order. 2013-04-12 17:10:26 +10:00
Huon Wilson
3698ea7e54 libsyntax: abstract most of the deriving boilerplate into a simpler(r) interface.
Pulls out many of the common patterns from the Eq and Clone deriving code (and
invents a few of its own), so that deriving instances are very easy to write
for a certain class of traits. (Basically, those which don't have parameters
and where all methods only take arguments of type `&Self` and return either
`Self` or types with no parameters.)
2013-04-12 17:10:26 +10:00
Tim Chevalier
8158dd7e9a rustpkg: Use pkg IDs, remove old code for now that required packages to declare IDs explicitly
This is preliminary work on bringing rustpkg up to conformance with #5679
and related issues.

This change makes rustpkg infer a package ID from its containing directory,
instead of requiring name and vers attributes in the code. Many aspects of it
are incomplete; I've only tested one package (see README.txt) and one command,
"build". So far it only works for local packages.

I also removed code for several of the package commands other than "build",
replacing them with stubs that fail, since they used package IDs in ways that
didn't jibe well with the new scheme. I will re-implement the commands one
at a time.
2013-04-11 18:08:42 -07:00
bors
b3b8c0502b auto merge of #5845 : thestinger/rust/bool, r=catamorphism
This is mostly just to make deriving more convenient, which is probably why Haskell does this too.
2013-04-11 16:28:00 -07:00
Daniel Micay
61b29993dd bool: implement Ord and TotalOrd 2013-04-11 19:01:03 -04:00
gareth
995d44416b Make destroy() send SIGTERM and add a new method called
force_destroy() that sends SIGKILL - as suggested by 
@thestinger.
2013-04-11 21:51:39 +01:00
bors
cf34b31704 auto merge of #5825 : danluu/rust/rngdoc, r=erickt
This adds an example for most of the methods in Rng.

As a total newcomer to Rust, it took a while to figure out how to do basic things like use library functions, because there aren't many usage examples, and most examples that Google turns up are out of date. Something like this would have saved me a bit of time.

This might be a bit verbose. Some alternative options would be to consolidate all the examples into one section, or to only have code for the specific function call inline.
2013-04-11 09:37:01 -07:00
bors
a3c8f524b8 auto merge of #5823 : Kimundi/rust/str_from_bytes_slice, r=erickt
Added str::from_bytes_with_null
Added str::subslice_offset
Misc cleanup

Closes #5422
2013-04-11 08:25:00 -07:00
bors
2f8b36fc16 auto merge of #5819 : erickt/rust/incoming, r=erickt
Good morning,

This first patch series adds support for `#[deriving(Decodable, Encodable)]`, but does not yet remove `#[auto_encode]` and `#[auto_decode]`. I need a snapshot to remove the old code. Along the way it also extends support for tuple structs and struct enum variants.

Also, it includes a minor fix to the pretty printer. We decided a while ago to use 4 spaces to indent a match arm instead of 2. This updates the pretty printer to reflect that.
2013-04-11 06:55:01 -07:00
Dan Luu
aff558998e Fix formatting 2013-04-11 09:12:26 -04:00
Brendan Zabarauskas
5f59012cce Implement Finally for ~fn and @fn types 2013-04-11 21:04:20 +10:00
bors
e0defb8466 auto merge of #5826 : brson/rust/0.7-pre, r=brson
I accidentally changed the version to `0.7-rc` when `0.7-pre` is what @graydon and I agreed on. This fixes.
2013-04-11 02:48:59 -07:00
bors
c27fad7353 auto merge of #5811 : sanxiyn/rust/parse-uint, r=catamorphism
It does not handle signs.
2013-04-11 00:31:03 -07:00
Brian Anderson
5b457c1469 xail all debuginfo tests
The broke with the LLVM upgrade
2013-04-11 00:16:09 -07:00
ILyoan
03116f251d add unwind information on morestack 2013-04-10 18:49:51 -07:00
Brian Anderson
a34948a2c5 rustllvm: Initialize target analysis passes
Without this the target info for certain optimizations will not be
created and the compiler will sometimes crash
2013-04-10 18:49:51 -07:00
ILyoan
344628fe91 FIX meta_section_name for macos 2013-04-10 18:49:51 -07:00
ILyoan
3d0d144283 rust morestack assembly for arm
Conflicts:
	src/rt/arch/arm/morestack.S
2013-04-10 18:49:50 -07:00
Young-il Choi
4b4f48283b rustllvm: followup latest LLVM 2013-04-10 18:49:50 -07:00
Brian Anderson
a9741bd33d Update LLVM for ARM changes 2013-04-10 18:49:50 -07:00
Niko Matsakis
c97c03cd6a tests: changes in response to #5656 2013-04-10 17:32:03 -07:00
Niko Matsakis
03396473b8 libstd: changes to in response to #5656 2013-04-10 17:32:03 -07:00
Niko Matsakis
61b9e0ebfa core: changes in response to #5656 2013-04-10 17:32:03 -07:00
Niko Matsakis
49de82cdca Issue #5656: Make &self not mean "&'self self"
Fixes #5656.
Fixes #5541.
2013-04-10 17:32:02 -07:00
Erick Tryzelaar
26ecb30f55 test: update serialization tests to use new macro 2013-04-10 16:32:09 -07:00
Erick Tryzelaar
f3ab67ec5f syntax: add {read,emit}_enum_struct_variant{,_field} 2013-04-10 16:32:09 -07:00
Erick Tryzelaar
e31f7b7c74 std: add serialize {read,emit}_tuple{,_arg,_struct,_struct_arg} 2013-04-10 16:32:09 -07:00
Erick Tryzelaar
441df26f5a syntax: add support for #[deriving(Decodable)] 2013-04-10 16:32:09 -07:00
Erick Tryzelaar
5841564bf9 syntax: add support for #[deriving(Encodable)] 2013-04-10 16:32:09 -07:00
Erick Tryzelaar
f50a8e2833 syntax: Simplify deriving to handle classes that take generics, like Encodable 2013-04-10 16:32:09 -07:00
Erick Tryzelaar
419f6acf0e std: rename {read,emit}_field to {read,emit}_struct_field 2013-04-10 16:08:22 -07:00
Erick Tryzelaar
97cc571358 std: clean up the order of {De,En}codable methods 2013-04-10 16:08:22 -07:00
Erick Tryzelaar
4464e44750 syntax: update a deriving error message to use the new syntax 2013-04-10 16:08:22 -07:00
Erick Tryzelaar
74807b1594 syntax: match variants use 4 space indent by default 2013-04-10 16:08:22 -07:00
Marvin Löbel
4ad76e66aa Add example for str::subslice_offset 2013-04-11 00:48:31 +02:00
Marvin Löbel
9a16179fd3 Added str::from_slice_with_null() to cast a &[u8] to &str
Added str::subslice_offset()
Renamed slice_bytes_uniqe to slice_bytes_owned
2013-04-11 00:36:28 +02:00
Brian Anderson
23e44a529b Bump version to 0.7-pre 2013-04-10 13:12:53 -07:00
Dan Luu
ccae209b0d Clarify comment 2013-04-10 15:54:28 -04:00
Dan Luu
4b7d363495 Add examples for Rng functions. 2013-04-10 15:08:19 -04:00
bors
11f5f73b2b auto merge of #5818 : Kimundi/rust/iter_to_vec, r=catamorphism 2013-04-10 11:31:01 -07:00
Brian Leibig
a34921ae89 Add debug info test for vectors 2013-04-10 12:45:54 -04:00
Brian Leibig
3e5b98fc74 Add debug info test for boxes 2013-04-10 12:45:54 -04:00
Brian Leibig
10d930d51e Prevent debug info generation of zero-span nodes
If a node has a (0, 0) span, it was not in the source, so debug symbols should not be generated for it.
2013-04-10 12:45:54 -04:00
Brian Leibig
cf22d749eb Add debug info for bare_fn type 2013-04-10 12:45:53 -04:00
Brian Leibig
917d5ab34e Add debug info for vectors 2013-04-10 12:45:53 -04:00
Brian Leibig
3c08be9b48 Add debug info for boxes 2013-04-10 12:45:53 -04:00