Commit Graph

21277 Commits

Author SHA1 Message Date
bors
790e6bb397 auto merge of #8490 : huonw/rust/fromiterator-extendable, r=catamorphism
If they are on the trait then it is extremely annoying to use them as
generic parameters to a function, e.g. with the iterator param on the trait
itself, if one was to pass an Extendable<int> to a function that filled it
either from a Range or a Map<VecIterator>, one needs to write something
like:

    fn foo<E: Extendable<int, Range<int>> +
              Extendable<int, Map<&'self int, int, VecIterator<int>>>
          (e: &mut E, ...) { ... }

since using a generic, i.e. `foo<E: Extendable<int, I>, I: Iterator<int>>`
means that `foo` takes 2 type parameters, and the caller has to specify them
(which doesn't work anyway, as they'll mismatch with the iterators used in
`foo` itself).

This patch changes it to:

    fn foo<E: Extendable<int>>(e: &mut E, ...) { ... }
2013-08-15 02:56:08 -07:00
Kevin Ballard
5ca4cdc7b8 Remove inappropriate .to_c_str() in C_cstr()
LLVMConstStringInContext() doesn't need a null-terminated string. It
takes a length instead. Using .to_c_str() here triggers an ICE whenever
the string literal embeds a null, as in "\x00".
2013-08-15 01:33:10 -07:00
Kevin Ballard
f744cf157e Make CString.iter() public 2013-08-15 01:33:10 -07:00
Kevin Ballard
03ef71e262 Add ToCStr method .with_c_str()
.with_c_str() is a replacement for the old .as_c_str(), to avoid
unnecessary boilerplate.

Replace all usages of .to_c_str().with_ref() with .with_c_str().
2013-08-15 01:33:10 -07:00
Kevin Ballard
48265b779f Check for interior nulls in .to_c_str()
Previous dicussions about CString suggested that interior nulls should
throw an error. This was never implemented. Add this now, using a
condition (named null_byte) to allow for recovery.

Add method .to_c_str_unchecked() that skips this check.
2013-08-15 01:32:10 -07:00
bors
7f58552cce auto merge of #8483 : luqmana/rust/rexprs, r=catamorphism
Fixes #8152.
2013-08-15 00:29:11 -07:00
Brian Anderson
15fca2dad7 compiletest: Run tests in their own thread to avoid blocking the scheduler
The calls to waitpid are interacting badly with the message passing that goes
on between schedulers and causing us to have very little parallelism in
the test suite. I don't fully understand the sequence of events that causes
the problem here but clearly blocking on waitpid is something that a
well-behaved task should not be doing.

Unfortunately this adds quite a bit of overhead to each test: one thread, two
tasks, three stacks, so there's a tradeoff. The time to execute run-pass on
my 4-core machine goes from ~750s to ~300s.
2013-08-14 23:41:31 -07:00
bors
7cda0d4316 auto merge of #8481 : cmr/rust/bench/std/at_vec, r=graydon 2013-08-14 22:29:06 -07:00
Brian Anderson
494da5a30b rustc: Change ICE message to reflect that ::rt::backtrace doesn't exist 2013-08-14 22:27:03 -07:00
bors
13c82549bd auto merge of #8525 : graydon/rust/2013-08-14-register-snapshots, r=brson
r? someone
2013-08-14 20:29:10 -07:00
Kevin Ballard
1e4f13f95f Clarify docs on CString.unwrap()
CString.unwrap() drops ownership of the buffer on the floor. Put this in
the docs.
2013-08-14 19:18:24 -07:00
Felix S. Klock II
14830209c8 Port regionck from oldvisit to <V:Visitor> trait API. 2013-08-15 04:10:21 +02:00
Felix S. Klock II
41a60ab7ac Ported typeck/check/mod.rs from oldvisit to <V:Visitor> trait API. 2013-08-15 04:09:19 +02:00
Felix S. Klock II
7328f4cc12 port type_use.rs from oldvisit to <V:Visitor> trait. 2013-08-15 04:09:19 +02:00
Felix S. Klock II
23ce08a4cd port callee.rs from oldvisit to <V:Visitor> trait API. 2013-08-15 04:09:19 +02:00
Felix S. Klock II
3281d58a5d Ported typeck::collect from oldvisit to <V:Visitor> trait API. 2013-08-15 04:09:19 +02:00
Felix S. Klock II
9290721625 Ported liveness.rs from oldvisit to <V:Visitor> trait API. 2013-08-15 04:09:19 +02:00
Felix S. Klock II
ac5825057f Ported trans/base.rs from oldvisit to <V:Visitor> trait API. 2013-08-15 04:09:19 +02:00
Felix S. Klock II
3ac6334f32 port resolve.rs from oldvisit to <V:Visitor> trait. 2013-08-15 04:09:19 +02:00
Felix S. Klock II
6c15f21bd7 port region.rs from oldvisit to <V:Visitor> trait API. 2013-08-15 04:09:18 +02:00
Felix S. Klock II
69e822dcb3 port reachable.rs from oldvisit to <V:Visitor> trait. 2013-08-15 04:09:18 +02:00
Felix S. Klock II
18be88f64a Port privacy.rs from oldvisit to <V:Visitor> trait. 2013-08-15 04:09:18 +02:00
Felix S. Klock II
ef854c9b04 Switch main borrowck to <V:Visitor> trait API.
fix borrowck/mod.rs to deal with fn_kind enum fallout.
2013-08-15 04:06:17 +02:00
Felix S. Klock II
b97cc955c2 Ported effect checker from oldvisit to <V:Visitor> trait API. 2013-08-15 04:06:17 +02:00
Felix S. Klock II
0d85928e37 Switch borrowck::gather_loans to <V:Visitor> visit API.
Placate make tidy.  Remove unnecessary references to oldvisit.
2013-08-15 04:06:17 +02:00
Felix S. Klock II
635d91737a Port const_eval from oldvisit to <V:Visitor> trait API. 2013-08-15 04:06:17 +02:00
Felix S. Klock II
a5a5432f98 Switch metadata::encoder to <V:Visitor> trait.
placate make tidy.  Remove dead code.
2013-08-15 04:06:17 +02:00
Felix S. Klock II
54ee3d03ff Port check_match from oldvisit to <V:Visitor> trait API. 2013-08-15 04:06:17 +02:00
Felix S. Klock II
3d83010648 Switch to new <V:Visitor> visitor (rather than @Visitor).
Alpha-renamed top-level visit_* functions to walk_*.
(Motivation: Distinguish visit action and recursive traversal.)

Abstract over `&mut self` rather than over `@mut self`.

This required some acrobatics, notably the

  `impl<E> Visitor<E> for @mut Visitor<E>`

and corresponding introduction of `@mut Visitor` and some local `let
mut` bindings.

Remove oldvisit reference.

Added default implementations for all of the Visitor trait methods.

Note that both `visit_expr_post` and `visit_ty` are no-op's by
default, just like they are in `oldvisit::default_visitor`.

Refactoring: extract logic to ease swapping visit for oldvisit (hopefully).
2013-08-15 04:06:17 +02:00
Felix S. Klock II
356341192f Ported check_loop from oldvisit to <V:Visit> trait API. 2013-08-15 04:06:17 +02:00
Felix S. Klock II
4127c67406 Ported check_const from oldvisit to <V:Visitor> trait API. 2013-08-15 04:06:17 +02:00
Graydon Hoare
3411846d58 register new snapshots 2013-08-14 18:45:51 -07:00
bors
3dde8e0f29 auto merge of #8480 : cmr/rust/tutorial, r=metajack 2013-08-14 18:29:09 -07:00
Graydon Hoare
9b9250052c Merge pull request #8479 from catamorphism/derived-errors
rustc: Eliminate a derived error in check::_match
2013-08-14 18:23:55 -07:00
blake2-ppc
88c149195a std: Replace map_vec, map_vec2, iter_vec2 in std::result
Replace these with three functions based on iterators: collect, fold,
and fold_. The mapping part is replaced by iterator .map(), so the part
that these functions do is to accumulate the final Result<,> value.

* `result::collect` gathers `Iterator<Result<V, U>>` to `Result<~[V], U>`
* `result::fold` folds `Iterator<Result<T, E>>` to `Result<V, E>`
* `result::fold_` folds `Iterator<Result<T, E>>` to `Result<(), E>`
2013-08-15 02:52:55 +02:00
blake2-ppc
6fe4c871f1 Update either::partition
Remove the only use of either::partition since it was better
accomplished with vector methods.

Update either::partition so that it sizes the vectors correctly before
it starts.
2013-08-15 02:52:55 +02:00
blake2-ppc
a5f9494199 std: Change either::{lefts, rights} to return an iterator 2013-08-15 02:52:55 +02:00
Tim Chevalier
5be4408ef2 testsuite: Add xfailed test for #8498 2013-08-14 16:52:05 -07:00
Tim Chevalier
cf4694e73b std: Change ProcessOptions struct to have an option of a ~ vector
This is a workaround for #8498
2013-08-14 16:52:05 -07:00
Tim Chevalier
63083ee767 rustc: Eliminate a derived error in check::_match 2013-08-14 13:42:58 -07:00
bors
e7b572952c auto merge of #8469 : gifnksm/rust/tutorial-ja, r=graydon
This PR adds an Japanese translated version of `doc/tutorial.md`.
Other tutorials have not yet translated.
2013-08-14 13:05:22 -07:00
Kevin Ballard
15159a5638 Rewrite Saturating in terms of CheckedAdd/CheckedSub 2013-08-14 13:02:20 -07:00
bors
0a677bcf6e auto merge of #8462 : thestinger/rust/loop-cleanup, r=cmr
I missed some of this in e7bb33aed8. Hopefully it's all gone now :).
2013-08-14 10:35:12 -07:00
bors
927aff1724 auto merge of #8452 : Kimundi/rust/stuff02, r=bstrie
- Methodyfied the string ascii extionsion functions - They got added recently, I wrapped them in a trait.
- Added `into_owned()` method for vectors - similar to `Str`'s `into_owned()` function, allows to convert to a owned vector without making a copy if the source is a owned vector.
- Added `or_some` method to option - similar to `unwrap_or_default`, but keeps the values wrapped in an `Option`. Useful for `Option` chains, eg Iterator impls.
- Added `DoubleEndedIterator` impl to `Option` - Just for compatibility with generic Iterator functions.
- Renamed nil.rs to unit.rs - the type got renamed ages ago, it's time the source file is as well.
2013-08-14 08:35:15 -07:00
Huon Wilson
53487a0246 std: Move the iterator param on FromIterator and Extendable to the method.
If they are on the trait then it is extremely annoying to use them as
generic parameters to a function, e.g. with the iterator param on the trait
itself, if one was to pass an Extendable<int> to a function that filled it
either from a Range or a Map<VecIterator>, one needs to write something
like:

    fn foo<E: Extendable<int, Range<int>> +
              Extendable<int, Map<&'self int, int, VecIterator<int>>>
          (e: &mut E, ...) { ... }

since using a generic, i.e. `foo<E: Extendable<int, I>, I: Iterator<int>>`
means that `foo` takes 2 type parameters, and the caller has to specify them
(which doesn't work anyway, as they'll mismatch with the iterators used in
`foo` itself).

This patch changes it to:

    fn foo<E: Extendable<int>>(e: &mut E, ...) { ... }
2013-08-15 01:10:45 +10:00
Huon Wilson
58021be454 rustc: allow @ as-patterns to move when the sub-pattern contains no bindings.
A pattern like `foo @ Foo(Bar(*), _)` should be legal, even if `foo` moves,
since the subpatterns are purely structural.

Fixes #3761.
2013-08-15 01:05:52 +10:00
bors
836a3d9bdb auto merge of #8453 : dmanescu/rust/8451, r=cmr
I'm not sure that the supplied tests are suitable.
2013-08-14 06:44:18 -07:00
Marvin Löbel
a00becd0eb Methodyfied the string ascii extionsion functions
Added into_owned() method for vectors
Added DoubleEnded Iterator impl to Option
Renamed nil.rs to unit.rs
2013-08-14 14:48:25 +02:00
bors
ac49e65611 auto merge of #8440 : sfackler/rust/env-fix, r=pcwalton
The type of the result of option_env! was not fully specified in the
None case, leading to type check failures in the case where the variable
was not defined (e.g. option_env!("FOO").is_none()).

Also cleaned up some compilation warnings.
2013-08-14 04:41:20 -07:00
bors
cd656c74f6 auto merge of #8439 : huonw/rust/hashset-clone, r=cmr
Closes #5581.
2013-08-14 02:38:19 -07:00