Commit Graph

250 Commits

Author SHA1 Message Date
bors 25d68366b7 auto merge of #12522 : erickt/rust/hash, r=alexcrichton
This patch series does a couple things:

* replaces manual `Hash` implementations with `#[deriving(Hash)]`
* adds `Hash` back to `std::prelude`
* minor cleanup of whitespace and variable names.
2014-02-25 06:41:36 -08:00
Erick Tryzelaar f12ff1964b std: minor whitespace cleanup 2014-02-24 19:52:29 -08:00
Eduard Burtescu 3e531ed0ed Gate default type parameter overrides.
Fixes #12423.
2014-02-24 22:45:31 +02:00
bors a5342d5970 auto merge of #12380 : alexcrichton/rust/run-rewrite, r=brson
The std::run module is a relic from a standard library long since past, and
there's not much use to having two modules to execute processes with where one
is slightly more convenient. This commit merges the two modules, moving lots of
functionality from std::run into std::io::process and then deleting
std::run.

New things you can find in std::io::process are:

* Process::new() now only takes prog/args
* Process::configure() takes a ProcessConfig
* Process::status() is the same as run::process_status
* Process::output() is the same as run::process_output
* I/O for spawned tasks is now defaulted to captured in pipes instead of ignored
* Process::kill() was added (plus an associated green/native implementation)
* Process::wait_with_output() is the same as the old finish_with_output()
* destroy() is now signal_exit()
* force_destroy() is now signal_kill()

Closes #2625
Closes #10016
2014-02-23 22:06:50 -08:00
Alex Crichton a9bd447400 Roll std::run into std::io::process
The std::run module is a relic from a standard library long since past, and
there's not much use to having two modules to execute processes with where one
is slightly more convenient. This commit merges the two modules, moving lots of
functionality from std::run into std::io::process and then deleting
std::run.

New things you can find in std::io::process are:

* Process::new() now only takes prog/args
* Process::configure() takes a ProcessConfig
* Process::status() is the same as run::process_status
* Process::output() is the same as run::process_output
* I/O for spawned tasks is now defaulted to captured in pipes instead of ignored
* Process::kill() was added (plus an associated green/native implementation)
* Process::wait_with_output() is the same as the old finish_with_output()
* destroy() is now signal_exit()
* force_destroy() is now signal_kill()

Closes #2625
Closes #10016
2014-02-23 21:51:17 -08:00
Huon Wilson efaf4db24c Transition to new `Hash`, removing IterBytes and std::to_bytes. 2014-02-24 07:44:10 +11:00
bors 551da06157 auto merge of #12311 : brson/rust/unstable, r=alexcrichton
With the stability attributes we can put public-but unstable modules next to others, so this moves `intrinsics` and `raw` out of the `unstable` module (and marks both as `#[experimental]`).
2014-02-23 02:21:53 -08:00
Brian Anderson 3e57808a01 std: Move raw to std::raw
Issue #1457
2014-02-23 01:07:53 -08:00
Brian Anderson 4d10bdc5b9 std: Move intrinsics to std::intrinsics.
Issue #1457
2014-02-23 01:07:53 -08:00
Alex Crichton 2a14e084cf Move std::{trie, hashmap} to libcollections
These two containers are indeed collections, so their place is in
libcollections, not in libstd. There will always be a hash map as part of the
standard distribution of Rust, but by moving it out of the standard library it
makes libstd that much more portable to more platforms and environments.

This conveniently also removes the stuttering of 'std::hashmap::HashMap',
although 'collections::HashMap' is only one character shorter.
2014-02-23 00:35:11 -08:00
Erick Tryzelaar d223dd1e57 std: rewrite Hash to make it more generic
This patch merges IterBytes and Hash traits, which clears up the
confusion of using `#[deriving(IterBytes)]` to support hashing.
Instead, it now is much easier to use the new `#[deriving(Hash)]`
for making a type hashable with a stream hash.

Furthermore, it supports custom non-stream-based hashers, such as
if a value's hash was cached in a database.

This does not yet replace the old IterBytes-hash with this new
version.
2014-02-21 21:33:23 -08:00
Alex Crichton 867988c1dc rustdoc: Show macros in documentation
Any macro tagged with #[macro_export] will be showed in the documentation for
that module. This also documents all the existing macros inside of std::macros.

Closes #3163
cc #5605
Closes #9954
2014-02-19 01:10:31 -08:00
Alex Crichton a41b0c2529 extern mod => extern crate
This was previously implemented, and it just needed a snapshot to go through
2014-02-14 22:55:21 -08:00
Edward Wang e9ff91e9be Move replace and swap to std::mem. Get rid of std::util
Also move Void to std::any, move drop to std::mem and reexport in
prelude.
2014-02-11 05:21:35 +08:00
Kevin Ballard 086c0dd33f Delete send_str, rewrite clients on top of MaybeOwned<'static>
Declare a `type SendStr = MaybeOwned<'static>` to ease readibility of
types that needed the old SendStr behavior.

Implement all the traits for MaybeOwned that SendStr used to implement.
2014-02-07 22:31:52 -08:00
Alex Crichton 454882dcb7 Remove std::condition
This has been a long time coming. Conditions in rust were initially envisioned
as being a good alternative to error code return pattern. The idea is that all
errors are fatal-by-default, and you can opt-in to handling the error by
registering an error handler.

While sounding nice, conditions ended up having some unforseen shortcomings:

* Actually handling an error has some very awkward syntax:

    let mut result = None;
    let mut answer = None;
    io::io_error::cond.trap(|e| { result = Some(e) }).inside(|| {
        answer = Some(some_io_operation());
    });
    match result {
        Some(err) => { /* hit an I/O error */ }
        None => {
            let answer = answer.unwrap();
            /* deal with the result of I/O */
        }
    }

  This pattern can certainly use functions like io::result, but at its core
  actually handling conditions is fairly difficult

* The "zero value" of a function is often confusing. One of the main ideas
  behind using conditions was to change the signature of I/O functions. Instead
  of read_be_u32() returning a result, it returned a u32. Errors were notified
  via a condition, and if you caught the condition you understood that the "zero
  value" returned is actually a garbage value. These zero values are often
  difficult to understand, however.

  One case of this is the read_bytes() function. The function takes an integer
  length of the amount of bytes to read, and returns an array of that size. The
  array may actually be shorter, however, if an error occurred.

  Another case is fs::stat(). The theoretical "zero value" is a blank stat
  struct, but it's a little awkward to create and return a zero'd out stat
  struct on a call to stat().

  In general, the return value of functions that can raise error are much more
  natural when using a Result as opposed to an always-usable zero-value.

* Conditions impose a necessary runtime requirement on *all* I/O. In theory I/O
  is as simple as calling read() and write(), but using conditions imposed the
  restriction that a rust local task was required if you wanted to catch errors
  with I/O. While certainly an surmountable difficulty, this was always a bit of
  a thorn in the side of conditions.

* Functions raising conditions are not always clear that they are raising
  conditions. This suffers a similar problem to exceptions where you don't
  actually know whether a function raises a condition or not. The documentation
  likely explains, but if someone retroactively adds a condition to a function
  there's nothing forcing upstream users to acknowledge a new point of task
  failure.

* Libaries using I/O are not guaranteed to correctly raise on conditions when an
  error occurs. In developing various I/O libraries, it's much easier to just
  return `None` from a read rather than raising an error. The silent contract of
  "don't raise on EOF" was a little difficult to understand and threw a wrench
  into the answer of the question "when do I raise a condition?"

Many of these difficulties can be overcome through documentation, examples, and
general practice. In the end, all of these difficulties added together ended up
being too overwhelming and improving various aspects didn't end up helping that
much.

A result-based I/O error handling strategy also has shortcomings, but the
cognitive burden is much smaller. The tooling necessary to make this strategy as
usable as conditions were is much smaller than the tooling necessary for
conditions.

Perhaps conditions may manifest themselves as a future entity, but for now
we're going to remove them from the standard library.

Closes #9795
Closes #8968
2014-02-06 15:48:56 -08:00
Huon Wilson 2ed980fe25 std,extra: remove use of & support for @[]. 2014-02-02 02:59:03 +11:00
xales f17d972014 Remove seldom-used std::reference functions. 2014-01-29 20:31:03 -05:00
xales d547f7ac21 Remove double-use of logging. 2014-01-29 20:31:03 -05:00
xales d7f97e3018 Rename std::borrow to std::reference.
Fixes #11814
2014-01-29 20:31:03 -05:00
David Manescu 28b987b99a Feature gate #[simd]
Fixes #11721
2014-01-28 01:04:15 +11:00
Steven Fackler 86a8b031f5 Move macro_rules! macros to libstd
They all have to go into a single module at the moment unfortunately.
Ideally, the logging macros would live in std::logging, condition! would
live in std::condition, format! in std::fmt, etc. However, this
introduces cyclic dependencies between those modules and the macros they
use which the current expansion system can't deal with. We may be able
to get around this by changing the expansion phase to a two-pass system
but that's for a later PR.

Closes #2247
cc #11763
2014-01-24 08:35:39 -08:00
Daniel Micay 1798de7d08 add new vector representation as a library 2014-01-22 23:13:57 -05:00
Alex Crichton cb12de14c9 Register new snapshots
Upgrade the version to 0.10-pre
2014-01-20 19:45:38 -08:00
Brian Anderson 46905c04f5 Bump version to 0.10-pre 2014-01-12 17:45:22 -08:00
Brendan Zabarauskas ceea85a148 Remove ApproxEq and assert_approx_eq!
This trait seems to stray too far from the mandate of a standard library as implementations may vary between use cases.
2014-01-09 15:41:46 +11:00
Brian Anderson d323632669 'borrowed pointer' -> 'reference' 2014-01-07 18:49:13 -08:00
Corey Richardson b6d4d117f4 std: mark some modules as unstable
Obviously everything is unstable, but these particularly so, and they will
likely remain that way.

Closes #10239
2014-01-05 21:52:16 -05:00
bors 08321f1c49 auto merge of #11149 : alexcrichton/rust/remove-either, r=brson
Had to change some stuff in typeck to bootstrap (getting methods in fmt off of Either), but other than that not so painful.

Closes #9157
2014-01-03 12:16:48 -08:00
Alex Crichton 4bea679dbe Remove std::either 2014-01-03 10:25:23 -08:00
Brian Anderson 56ec9c23a4 Bump version to 0.9 2014-01-02 12:55:20 -08:00
Alex Crichton ab431a20c0 Register new snapshots 2013-12-26 11:30:23 -08:00
Alex Crichton 018d60509c std: Get stdtest all passing again
This commit brings the library up-to-date in order to get all tests passing
again
2013-12-24 19:59:52 -08:00
Alex Crichton a55c57284d std: Introduce std::sync
For now, this moves the following modules to std::sync

* UnsafeArc (also removed unwrap method)
* mpsc_queue
* spsc_queue
* atomics
* mpmc_bounded_queue
* deque

We may want to remove some of the queues, but for now this moves things out of
std::rt into std::sync
2013-12-24 14:42:00 -08:00
Corey Richardson dee1107571 Rename pkgid to crate_id
Closes #11035
2013-12-19 10:10:23 -05:00
Alex Crichton 529e268ab9 Fallout of rewriting std::comm 2013-12-16 17:47:11 -08:00
Alex Crichton bfa9064ba2 Rewrite std::comm
* Streams are now ~3x faster than before (fewer allocations and more optimized)
    * Based on a single-producer single-consumer lock-free queue that doesn't
      always have to allocate on every send.
    * Blocking via mutexes/cond vars outside the runtime
* Streams work in/out of the runtime seamlessly
* Select now works in/out of the runtime seamlessly
* Streams will now fail!() on send() if the other end has hung up
    * try_send() will not fail
* PortOne/ChanOne removed
* SharedPort removed
* MegaPipe removed
* Generic select removed (only one kind of port now)
* API redesign
    * try_recv == never block
    * recv_opt == block, don't fail
    * iter() == Iterator<T> for Port<T>
    * removed peek
    * Type::new
* Removed rt::comm
2013-12-16 17:47:11 -08:00
Alex Crichton d9ea475feb Register new snapshots
Understand 'pkgid' in stage0. As a bonus, the snapshot now contains now metadata
(now that those changes have landed), and the snapshot download is half as large
as it used to be!
2013-12-15 22:17:59 -08:00
Jack Moffitt b349036e5f Make crate hash stable and externally computable.
This replaces the link meta attributes with a pkgid attribute and uses a hash
of this as the crate hash. This makes the crate hash computable by things
other than the Rust compiler. It also switches the hash function ot SHA1 since
that is much more likely to be available in shell, Python, etc than SipHash.

Fixes #10188, #8523.
2013-12-10 17:04:24 -07:00
Alex Crichton acc5e32e53 Register new snapshots 2013-12-03 14:31:54 -08:00
Alex Crichton 56e4c82a38 Test fixes and merge conflicts 2013-11-30 14:34:59 -08:00
Alex Crichton e338a4154b Add generation of static libraries to rustc
This commit implements the support necessary for generating both intermediate
and result static rust libraries. This is an implementation of my thoughts in
https://mail.mozilla.org/pipermail/rust-dev/2013-November/006686.html.

When compiling a library, we still retain the "lib" option, although now there
are "rlib", "staticlib", and "dylib" as options for crate_type (and these are
stackable). The idea of "lib" is to generate the "compiler default" instead of
having too choose (although all are interchangeable). For now I have left the
"complier default" to be a dynamic library for size reasons.

Of the rust libraries, lib{std,extra,rustuv} will bootstrap with an
rlib/dylib pair, but lib{rustc,syntax,rustdoc,rustpkg} will only be built as a
dynamic object. I chose this for size reasons, but also because you're probably
not going to be embedding the rustc compiler anywhere any time soon.

Other than the options outlined above, there are a few defaults/preferences that
are now opinionated in the compiler:

* If both a .dylib and .rlib are found for a rust library, the compiler will
  prefer the .rlib variant. This is overridable via the -Z prefer-dynamic option
* If generating a "lib", the compiler will generate a dynamic library. This is
  overridable by explicitly saying what flavor you'd like (rlib, staticlib,
  dylib).
* If no options are passed to the command line, and no crate_type is found in
  the destination crate, then an executable is generated

With this change, you can successfully build a rust program with 0 dynamic
dependencies on rust libraries. There is still a dynamic dependency on
librustrt, but I plan on removing that in a subsequent commit.

This change includes no tests just yet. Our current testing
infrastructure/harnesses aren't very amenable to doing flavorful things with
linking, so I'm planning on adding a new mode of testing which I believe belongs
as a separate commit.

Closes #552
2013-11-29 18:36:13 -08:00
Alex Crichton ab387a6838 Register new snapshots 2013-11-28 20:27:56 -08:00
Alex Crichton 7dcc066bd2 Remove unused std::routine 2013-11-26 15:19:41 -08:00
Daniel Micay 543cae9a46 add an initial `Gc<T>` stub with the API 2013-11-19 23:52:43 -05:00
Alex Crichton 49ee49296b Move std::rt::io to std::io 2013-11-11 20:44:07 -08:00
Alex Crichton 7755ffd013 Remove #[fixed_stack_segment] and #[rust_stack]
These two attributes are no longer useful now that Rust has decided to leave
segmented stacks behind. It is assumed that the rust task's stack is always
large enough to make an FFI call (due to the stack being very large).

There's always the case of stack overflow, however, to consider. This does not
change the behavior of stack overflow in Rust. This is still normally triggered
by the __morestack function and aborts the whole process.

C stack overflow will continue to corrupt the stack, however (as it did before
this commit as well). The future improvement of a guard page at the end of every
rust stack is still unimplemented and is intended to be the mechanism through
which we attempt to detect C stack overflow.

Closes #8822
Closes #10155
2013-11-11 10:40:34 -08:00
Andrei Formiga 455de85163 Specify package_id for rust libs, to avoid spurious warnings 2013-11-08 17:42:46 -03:00
Carol Willing e6a1f6d7df Edited comment for docs to show std::io is deleted and replaced by std::rt::io 2013-11-07 15:29:06 -08:00
Chris Morgan 0369a41f0e Rename files to match current recommendations.
New standards have arisen in recent months, mostly for the use of
rustpkg, but the main Rust codebase has not been altered to match these
new specifications. This changeset rectifies most of these issues.

- Renamed the crate source files `src/libX/X.rs` to `lib.rs`, for
  consistency with current styles; this affects extra, rustc, rustdoc,
  rustpkg, rustuv, std, syntax.

- Renamed `X/X.rs` to `X/mod.rs,` as is now recommended style, for
  `std::num` and `std::terminfo`.

- Shifted `src/libstd/str/ascii.rs` out of the otherwise unused `str`
  directory, to be consistent with its import path of `std::ascii`;
  libstd is flat at present so it's more appropriate thus.

While this removes some `#[path = "..."]` directives, it does not remove
all of them, and leaves certain other inconsistencies, such as `std::u8`
et al. which are actually stored in `src/libstd/num/` (one subdirectory
down). No quorum has been reached on this issue, so I felt it best to
leave them all alone at present. #9208 deals with the possibility of
making libstd more hierarchical (such as changing the crate to match the
current filesystem structure, which would make the module path
`std::num::u8`).

There is one thing remaining in which this repository is not
rustpkg-compliant: rustpkg would have `src/std/` et al. rather than
`src/libstd/` et al. I have not endeavoured to change that at this point
as it would guarantee prompt bitrot and confusion. A change of that
magnitude needs to be discussed first.
2013-11-03 23:49:01 +11:00