Commit Graph

23890 Commits

Author SHA1 Message Date
bors
7cff3c74b8 auto merge of #10119 : Kimundi/rust/option_and_generic, r=alexcrichton
This takes the last reforms on the `Option` type and applies them to `Result` too. For that, I reordered and grouped the functions in both modules, and also did some refactorings:

- Added `as_ref` and `as_mut` adapters to `Result`.
- Renamed `Result::map_move` to `Result::map` (same for `_err` variant), deleted other map functions. 
- Made the `.expect()` methods be generic over anything you can
  fail with.
- Updated some doc comments to the line doc comment style
- Cleaned up and extended standard trait implementations on `Option` and `Result`
- Removed legacy implementations in the `option` and `result` module
2013-11-01 09:36:25 -07:00
Alex Crichton
e2a68b6867 Give test and main tasks better names
Tests now have the same name as the test that they're running (to allow for
easier diagnosing of failure sources), and the main task is now specially named
<main> instead of <unnamed>.

Closes #10195
Closes #10073
2013-11-01 09:16:11 -07:00
Gyorgy Andrasek
0f66856e53 Fix typo in to_digit 2013-11-01 17:13:43 +01:00
bors
3a15482b9c auto merge of #10218 : alexcrichton/rust/stdio-flush-safe, r=cmr
The previous method was unsound because you could very easily create two mutable
pointers which alias the same location (not sound behavior). This hides the
function which does so and then exports an explicit flush() function (with
documentation about how it works).
2013-11-01 08:26:24 -07:00
Marvin Löbel
415a04315e Fixed unused import warning in tests 2013-11-01 15:37:29 +01:00
Marvin Löbel
45fe20515c Removed legacy implementations 2013-11-01 15:01:56 +01:00
Marvin Löbel
c22e7f02d1 Cleaned up the option and result module in more detail
Made both types implement more standard traits in a nicer way

Derived more traits
2013-11-01 15:01:56 +01:00
Marvin Löbel
0d92c53f4a Reordered the methods in std::Option and std::Result
Cleaned up the source in a few places

Renamed `map_move` to `map`, removed other `map` methods

Added `as_ref` and `as_mut` adapters to `Result`

Added `fmt::Default` impl
2013-11-01 15:00:46 +01:00
bors
a300314827 auto merge of #10213 : telotortium/rust/rand-fill_bytes-stack-overflow, r=huonw
Fix the implementation of `std::rand::Rng::fill_bytes()` for
`std::rand::reseeding::ReseedingRng` to call the `fill_bytes()` method
of the underlying RNG rather than itself, which causes infinite
recursion.

Fixes #10202.
2013-11-01 05:21:24 -07:00
Huon Wilson
3c25baa540 std::rand: share the benchmark counter among the whole module tree. 2013-11-01 22:09:06 +11:00
Huon Wilson
cd50fb39b5 std::rand: Implement the Gamma distribution. 2013-11-01 22:09:06 +11:00
bors
04c58c9f81 auto merge of #10205 : brson/rust/unnamed_addr, r=thestinger 2013-11-01 04:06:23 -07:00
Huon Wilson
701b4d137e std::rand: Move distributions to a subfolder. 2013-11-01 21:47:07 +11:00
bors
fa8a202858 auto merge of #10203 : kud1ing/rust/ios, r=alexcrichton
This is based on the work by @dobkeratops, updated and extended to work for Xcode 5.

This gets you going. I will add separate PRs for compilation/linking fixes.
See also https://github.com/mozilla/rust/wiki/Doc-building-for-ios
2013-11-01 02:26:23 -07:00
bors
986d1f78be auto merge of #10196 : huonw/rust/fix-zig, r=alexcrichton
The code was using (in the notation of Doornik 2005) `f(x_{i+1}) -
f(x_{i+2})` rather than `f(x_i) - f(x_{i+1})`. This corrects that, and
removes the F_DIFF tables which caused this problem in the first place.

They `F_DIFF` tables are a micro-optimisation (in theory, they could
easily be a micro-pessimisation): that `if` gets hit about 1% of the
time for Exp/Normal, and the rest of the condition involves RNG calls
and a floating point `exp`, so it is unlikely that saving a single FP
subtraction will be very useful (especially as more tables means more
memory reads and higher cache pressure, as well as taking up space in
the binary (although only ~2k in this case)).

Closes #10084. Notably, unlike that issue suggests, this wasn't a
problem with the Exp tables. It affected Normal too, but since it is
symmetric, there was no bias in the mean (as the bias was equal on the
positive and negative sides and so cancelled out) but it was visible as
a variance slightly lower than it should be.

New plot:

![exp-density](https://f.cloud.github.com/assets/1203825/1445796/42218dfe-422a-11e3-9f98-2cd146b82b46.png)

I've started writing some tests in [huonw/random-tests](https://github.com/huonw/random-tests) (not in the main repo because they can and do fail occasionally, due to randomness, but it is on Travis and Rust-CI so it will hopefully track the language), unsurprisingly, they're [currently failing](https://travis-ci.org/huonw/random-tests/builds/13313987) (note that both exp and norm are failing, the former due to both mean and variance the latter due to just variance), but pass at the 0.01 level reliably with this change.

(Currently the only test is essentially a quantitative version of the plots I've been showing, which is run on the `f64` `Rand` instance (uniform 0 to 1), and the Normal and Exp distributions.)
2013-11-01 01:16:22 -07:00
Luqman Aden
12222f9825 configure: Fix passing multiple target and host triples. 2013-11-01 03:34:16 -04:00
Alex Crichton
e35cd962a6 Drop struct fields if the user destructor fails
This commit changes drop glue generated for structs to use the invoke LLVM
instruction instead of call. What this means is that if the user destructor
triggers an unwinding, then the fields of the struct will still ge dropped.

This is not an attempt to support failing while failing, as that's mostly a
problem of runtime support. This is more of an issue of soundness in making sure
that destructors are appropriately run. The test included fails before this
commit, and only has one call to fail!(), yet it doesn't destroy its struct
fields.
2013-10-31 23:31:11 -07:00
bors
41ffc90e98 auto merge of #10187 : pcwalton/rust/remove-mocks, r=pcwalton
r? @alexcrichton
2013-10-31 22:26:24 -07:00
Alex Crichton
8f258ab532 Provide a sound method of flushing stdout
The previous method was unsound because you could very easily create two mutable
pointers which alias the same location (not sound behavior). This hides the
function which does so and then exports an explicit flush() function (with
documentation about how it works).
2013-10-31 22:09:48 -07:00
Alex Crichton
681fda0169 Reduce the aggressiveness of reachability
Previously, all functions called by a reachable function were considered
reachable, but this is only the case if the original function was possibly
inlineable (if it's type generic or #[inline]-flagged).
2013-10-31 20:47:23 -07:00
bors
1bbd4afb4a auto merge of #10181 : brson/rust/managed_boxes, r=thestinger 2013-10-31 20:36:17 -07:00
Brian Anderson
c874e64aa6 Name the rustc task 'rustc' 2013-10-31 20:08:17 -07:00
Robert Irelan
96589e7264 Fix infinite recursion in fill_bytes()
Fix the implementation of `std::rand::Rng::fill_bytes()` for
`std::rand::reseeding::ReseedingRng` to call the `fill_bytes()` method
of the underlying RNG rather than itself, which causes infinite
recursion.

Fixes #10202.
2013-10-31 21:19:47 -05:00
bors
d04a58cf2d auto merge of #9740 : alexcrichton/rust/concat, r=cmr
This extension can be used to concatenate string literals at compile time. C has
this useful ability when placing string literals lexically next to one another,
but this needs to be handled at the syntax extension level to recursively expand
macros.

The major use case for this is something like:

    macro_rules! mylog( ($fmt:expr $($arg:tt)*) => {
        error2!(concat!(file!(), ":", line!(), " - ", $fmt) $($arg)*);
    })

Where the mylog macro will automatically prepend the filename/line number to the
beginning of every log message.
2013-10-31 17:51:26 -07:00
bors
23df6f9775 auto merge of #10206 : brson/rust/configure, r=brson 2013-10-31 15:36:36 -07:00
Brian Anderson
424e91a47d Fix fallback configuration flags 2013-10-31 15:27:54 -07:00
Brian Anderson
2992720c9b Declare all Rust functions as unnamed_addr. Closes #8957 2013-10-31 14:53:22 -07:00
kud1ing
5864ad9ab1 add target triple arm-apple-darwin 2013-10-31 22:43:59 +01:00
David Creswick
ba436a8082 fix missing_doc lint on private traits
Fixes #10069.
2013-10-31 16:41:34 -05:00
Alex Crichton
a49e65c2ed Implement a concat!() format extension
This extension can be used to concatenate string literals at compile time. C has
this useful ability when placing string literals lexically next to one another,
but this needs to be handled at the syntax extension level to recursively expand
macros.

The major use case for this is something like:

    macro_rules! mylog( ($fmt:expr $($arg:tt)*) => {
        error2!(concat!(file!(), ":", line!(), " - ", $fmt) $($arg)*);
    })

Where the mylog macro will automatically prepend the filename/line number to the
beginning of every log message.
2013-10-31 13:46:10 -07:00
Brian Anderson
6a33cc244a Make managed_boxes feature gate error less opinionated 2013-10-31 10:45:03 -07:00
bors
b2f62acaeb auto merge of #10167 : briantdawn/rust/master, r=cmr
To keep consistency with the word "borrowing" I suppose an alternate way to write this could be "Having an object borrow an immutable pointer freezes it and prevents mutation".
2013-10-31 10:31:56 -07:00
Patrick Walton
a6f776d2dc libstd: Remove mocks. 2013-10-31 10:30:57 -07:00
Patrick Walton
f27272d60f librustc: Implement |A| -> B syntax for closures and make bare fn
work
2013-10-31 10:30:32 -07:00
bors
e976de32dc auto merge of #10193 : osaut/rust/Fix_install, r=huonw
Fix missing parentheses coming from a previous substitution '$(PREFIX_ROOT)' to  '$(CFG_MANDIR' on 1c4a348b07
2013-10-31 07:46:50 -07:00
Huon Wilson
1e2283de43 std::rand: correct an off-by-one in the Ziggurat code.
The code was using (in the notation of Doornik 2005) `f(x_{i+1}) -
f(x_{i+2})` rather than `f(x_i) - f(x_{i+1})`. This corrects that, and
removes the F_DIFF tables which caused this problem in the first place.

They `F_DIFF` tables are a micro-optimisation (in theory, they could
easily be a micro-pessimisation): that `if` gets hit about 1% of the
time for Exp/Normal, and the rest of the condition involves RNG calls
and a floating point `exp`, so it is unlikely that saving a single FP
subtraction will be very useful (especially as more tables means more
memory reads and higher cache pressure, as well as taking up space in
the binary (although only ~2k in this case)).

Closes #10084. Notably, unlike that issue suggests, this wasn't a
problem with the Exp tables. It affected Normal too, but since it is
symmetric, there was no bias in the mean (as the bias was equal on the
positive and negative sides and so cancelled out) but it was visible as
a variance slightly lower than it should be.
2013-10-31 23:49:39 +11:00
bors
c7d5a52144 auto merge of #10189 : alexcrichton/rust/inner-statics, r=cmr
Closes #9186
2013-10-31 04:46:34 -07:00
Olivier Saut
a6cd20bff9 Fix missing parenthesis in a previous substitution '$(PREFIX_ROOT)' to '$(CFG_MANDIR' on 1c4a348b07 2013-10-31 11:33:02 +01:00
bors
55eed055cf auto merge of #10180 : alexcrichton/rust/flush-default, r=brson
Closes #9126
2013-10-31 02:16:40 -07:00
bors
68bf48e044 auto merge of #10166 : brson/rust/meta, r=alexcrichton
This doesn't fix #623 but works around it by limiting the grammar.
2013-10-30 23:41:22 -07:00
bors
c888fc6db2 auto merge of #10164 : brson/rust/configure, r=brson
Rebase of #9990
2013-10-30 21:06:33 -07:00
Alex Crichton
0db50056ae Forbid type parameters in inner statics
Closes #9186
2013-10-30 19:52:00 -07:00
bors
f73a48e9fd auto merge of #10120 : Kimundi/rust/remove_sys, r=alexcrichton
- `begin_unwind` and `fail!` is now generic over any `T: Any + Send`.
- Every value you fail with gets boxed as an `~Any`.
- Because of implementation issues, `&'static str` and `~str` are still
  handled specially behind the scenes.
- Changed the big macro source string in libsyntax to a raw string
  literal, and enabled doc comments there.
2013-10-30 18:31:26 -07:00
Alex Crichton
452e5cdf11 Make Writer::flush a no-op default method
Closes #9126
2013-10-30 15:17:11 -07:00
Brian Anderson
6ef1ab99c1 syntax: Forbid non-string literals in meta items. #623 2013-10-30 14:06:22 -07:00
bors
6789a77fa0 auto merge of #10172 : pythonesque/rust/issue-9890, r=thestinger 2013-10-30 13:26:29 -07:00
Marvin Löbel
54f4dcd76a Prepared std::sys for removal, and made begin_unwind simpler
- `begin_unwind` is now generic over any `T: Any + Send`.
- Every value you fail with gets boxed as an `~Any`.
- Because of implementation details, `&'static str` and `~str` are still
  handled specially behind the scenes.
- Changed the big macro source string in libsyntax to a raw string
  literal, and enabled doc comments there.
2013-10-30 21:19:18 +01:00
Joshua Yanovski
eee892c4be Special-casing iter_vec_raw to use a counter for zero-size types (Closes #9890). 2013-10-30 04:48:53 -07:00
bors
623daf66a9 auto merge of #10123 : klutzy/rust/fix-7507, r=alexcrichton
This patch fixes rustc to emit explicit error if LHS of assignment is
not allowed.

Fixes #7507
Fixes #7508
2013-10-30 04:36:26 -07:00
bors
a0e6e0e9b7 auto merge of #10168 : reedlepee123/rust/priv_fields, r=brson
....rs #8180
2013-10-30 03:31:20 -07:00