]> git.lizzy.rs Git - rust.git/log
rust.git
10 years agointroduce `base_and_len` fns for element length
Daniel Micay [Wed, 16 Oct 2013 16:04:51 +0000 (12:04 -0400)]
introduce `base_and_len` fns for element length

10 years agorename `base_and_len` -> `base_and_byte_len`
Daniel Micay [Wed, 16 Oct 2013 15:59:35 +0000 (11:59 -0400)]
rename `base_and_len` -> `base_and_byte_len`

10 years agoremove executable flag from source file
Daniel Micay [Tue, 15 Oct 2013 23:34:45 +0000 (19:34 -0400)]
remove executable flag from source file

10 years agouse element count in slices, not size in bytes
Daniel Micay [Tue, 15 Oct 2013 04:37:32 +0000 (00:37 -0400)]
use element count in slices, not size in bytes

This allows the indexing bounds check or other comparisons against an
element length to avoid a multiplication by the size.

10 years agofix overflow on bounds checks
Daniel Micay [Tue, 15 Oct 2013 03:25:33 +0000 (23:25 -0400)]
fix overflow on bounds checks

Closes #9020

10 years agofix bounds checking failure message
Daniel Micay [Tue, 15 Oct 2013 02:43:03 +0000 (22:43 -0400)]
fix bounds checking failure message

casting the `uint` to an `int` can result in printing high values as
negative intege

10 years agoauto merge of #9823 : pnkfelix/rust/issue7655-bench-papercuts, r=alexcrichton
bors [Mon, 14 Oct 2013 22:06:36 +0000 (15:06 -0700)]
auto merge of #9823 : pnkfelix/rust/issue7655-bench-papercuts, r=alexcrichton

r? anyone.

You can see a bit more discussion on #7655.

This does not close any ticket; I am just scratching an itch.  Note in particular that I picked the value `{:>9} ns/iter` pretty much out of a hat.  :)

10 years agoOnly use padded test names to calculate the target padding size.
Felix S. Klock II [Mon, 14 Oct 2013 19:45:57 +0000 (15:45 -0400)]
Only use padded test names to calculate the target padding size.

10 years agoIssue 7655: align the bench printouts so that the numbers tend to be aligned.
Felix S. Klock II [Sat, 12 Oct 2013 13:49:50 +0000 (09:49 -0400)]
Issue 7655: align the bench printouts so that the numbers tend to be aligned.

(scratching an itch.)

Rebased and updated.
Fixed bug: omitted field init from embedded struct literal in a test.
Fixed bug: int underflow during padding length calculation.

10 years agoauto merge of #9606 : steveklabnik/rust/abi_removal, r=alexcrichton
bors [Mon, 14 Oct 2013 14:26:47 +0000 (07:26 -0700)]
auto merge of #9606 : steveklabnik/rust/abi_removal, r=alexcrichton

They've been replaced by putting the name on the extern block.

  #[abi = "foo"]

goes to

  extern "foo" { }

Closes #9483.

10 years agoauto merge of #9848 : huonw/rust/move-trait-doc, r=alexcrichton
bors [Mon, 14 Oct 2013 13:16:32 +0000 (06:16 -0700)]
auto merge of #9848 : huonw/rust/move-trait-doc, r=alexcrichton

This means the text is visible in rustdoc.

10 years agoRemoving ccdecl
Steve Klabnik [Mon, 14 Oct 2013 12:33:05 +0000 (14:33 +0200)]
Removing ccdecl

as per https://github.com/mozilla/rust/pull/9606#discussion_r6930872

10 years agostd::vec: move documentation from impls to traits.
Huon Wilson [Mon, 14 Oct 2013 11:21:47 +0000 (22:21 +1100)]
std::vec: move documentation from impls to traits.

This means the text is visible in rustdoc.

10 years agoRemove unused abi attributes.
Steve Klabnik [Sun, 29 Sep 2013 14:46:26 +0000 (07:46 -0700)]
Remove unused abi attributes.

They've been replaced by putting the name on the extern block.

  #[abi = "foo"]

goes to

  extern "foo" { }

Closes #9483.

10 years agoauto merge of #9844 : bytbox/rust/master, r=alexcrichton
bors [Mon, 14 Oct 2013 06:41:30 +0000 (23:41 -0700)]
auto merge of #9844 : bytbox/rust/master, r=alexcrichton

10 years agoauto merge of #9843 : sfackler/rust/rustdoc-strip-private, r=alexcrichton
bors [Mon, 14 Oct 2013 05:31:29 +0000 (22:31 -0700)]
auto merge of #9843 : sfackler/rust/rustdoc-strip-private, r=alexcrichton

In addition, the renderer will add comments to structs and enums saying
that fields or variants have been stripped.

The comments are currently
```rust
// some fields stripped
// some variants stripped
```

I was thinking of changing that to "some private..." but passes other than
strip-private may strip fields or variants as well.

cc @alexcrichton

10 years agoMake Rustdoc strip private fields
Steven Fackler [Mon, 14 Oct 2013 03:37:43 +0000 (20:37 -0700)]
Make Rustdoc strip private fields

In addition, the renderer will add comments to structs and enums saying
that fields or variants have been stripped.

10 years agostd::libc: rustdoc indicates reexports now
Scott Lawrence [Mon, 14 Oct 2013 04:46:02 +0000 (00:46 -0400)]
std::libc: rustdoc indicates reexports now

10 years agoauto merge of #9836 : eriklyon/rust/doc-typos, r=alexcrichton
bors [Sun, 13 Oct 2013 18:31:26 +0000 (11:31 -0700)]
auto merge of #9836 : eriklyon/rust/doc-typos, r=alexcrichton

10 years agofix typos in doc/tutorial.md
Erik Lyon [Sun, 13 Oct 2013 17:49:44 +0000 (10:49 -0700)]
fix typos in doc/tutorial.md

10 years agoauto merge of #9832 : luqmana/rust/sps, r=alexcrichton
bors [Sun, 13 Oct 2013 04:26:20 +0000 (21:26 -0700)]
auto merge of #9832 : luqmana/rust/sps, r=alexcrichton

Fixes #9830.

10 years agolibrustc: Combine C_struct and C_packed_struct.
Luqman Aden [Sun, 13 Oct 2013 03:19:22 +0000 (23:19 -0400)]
librustc: Combine C_struct and C_packed_struct.

10 years agoauto merge of #9608 : hmarr/rust/vec-get-opt, r=huonw
bors [Sun, 13 Oct 2013 03:16:19 +0000 (20:16 -0700)]
auto merge of #9608 : hmarr/rust/vec-get-opt, r=huonw

This adds `get_opt` to `std::vec`, which looks up an item by index and returns an `Option`. If the given index is out of range, `None` will be returned, otherwise a `Some`-wrapped item will be returned.

Example use case:

```rust
use std::os;

fn say_hello(name: &str) {
  println(fmt!("Hello, %s", name));
}

fn main(){
  // Try to get the first cmd line arg, but default to "World"
  let args = os::args();
  let default = ~"World";
  say_hello(*args.get_opt(1).unwrap_or(&default));
}
```

If there's an existing way of implementing this pattern that's cleaner, I'll happily close this. I'm also open to naming suggestions (`index_opt`?)

10 years agoUpdate test for packed structs to also test being placed in statics.
Luqman Aden [Sun, 13 Oct 2013 01:52:14 +0000 (21:52 -0400)]
Update test for packed structs to also test being placed in statics.

10 years agolibrustc: Don't ICE on packed structs in statics.
Luqman Aden [Sun, 13 Oct 2013 01:42:24 +0000 (21:42 -0400)]
librustc: Don't ICE on packed structs in statics.

10 years agoauto merge of #9825 : thestinger/rust/rc, r=thestinger
bors [Sat, 12 Oct 2013 14:26:20 +0000 (07:26 -0700)]
auto merge of #9825 : thestinger/rust/rc, r=thestinger

10 years agorc: fix docstring
Daniel Micay [Sat, 12 Oct 2013 14:19:56 +0000 (10:19 -0400)]
rc: fix docstring

10 years agoauto merge of #9815 : thestinger/rust/type, r=huonw
bors [Sat, 12 Oct 2013 02:21:16 +0000 (19:21 -0700)]
auto merge of #9815 : thestinger/rust/type, r=huonw

Example:

    void ({ i64, %tydesc*, i8*, i8*, i8 }*, i64*, %"struct.std::fmt::Formatter[#1]"*)*

Before, we would print 20 levels deep due to recursion in the type
definition.

10 years agoauto merge of #9799 : catamorphism/rust/rustpkg-exitcodes, r=catamorphism,metajack
bors [Sat, 12 Oct 2013 01:11:17 +0000 (18:11 -0700)]
auto merge of #9799 : catamorphism/rust/rustpkg-exitcodes, r=catamorphism,metajack

r? @metajack When I started writing the rustpkg tests, task failure didn't set the
exit code properly. But bblum's work from July fixed that. Hooray! I
just didn't know about it till now.

So, now rustpkg uses exit codes in a more conventional way, and some of
the tests are simpler.

The bigger issue will be to make task failure propagate the error message.
Right now, rustpkg does most of the work in separate tasks, which means if
a task fails, rustpkg can't distinguish between different types of failure
(see #3408)

10 years agohave LLVM print type strings for us
Daniel Micay [Fri, 11 Oct 2013 23:56:11 +0000 (19:56 -0400)]
have LLVM print type strings for us

Example:

    void ({ i64, %tydesc*, i8*, i8*, i8 }*, i64*, %"struct.std::fmt::Formatter[#1]"*)*

Before, we would print 20 levels deep due to recursion in the type
definition.

10 years agorustpkg: Set exit codes properly and make tests take advantage of that
Tim Chevalier [Thu, 10 Oct 2013 20:48:11 +0000 (13:48 -0700)]
rustpkg: Set exit codes properly and make tests take advantage of that

When I started writing the rustpkg tests, task failure didn't set the
exit code properly. But bblum's work from July fixed that. Hooray! I
just didn't know about it till now.

So, now rustpkg uses exit codes in a more conventional way, and some of
the tests are simpler.

The bigger issue will be to make task failure propagate the error message.
Right now, rustpkg does most of the work in separate tasks, which means if
a task fails, rustpkg can't distinguish between different types of failure
(see #3408)

10 years agoauto merge of #9809 : fhahn/rust/remove-old-cratemap-code, r=alexcrichton
bors [Fri, 11 Oct 2013 19:21:20 +0000 (12:21 -0700)]
auto merge of #9809 : fhahn/rust/remove-old-cratemap-code, r=alexcrichton

This patch removes the code responsible for handling older CrateMap versions (as discussed during #9593). Only the new (safer) layout is supported now.

10 years agoauto merge of #9794 : thestinger/rust/rc, r=alexcrichton
bors [Fri, 11 Oct 2013 18:11:21 +0000 (11:11 -0700)]
auto merge of #9794 : thestinger/rust/rc, r=alexcrichton

I've left out a way to construct from a `Send` type until #9509 is resolved. I am confident that this interface can remain backwards compatible though, assuming we name the `Pointer` trait method `borrow`.

When there is a way to convert from `Send` (`from_send`), a future RAII-based `Mut` type can be used with this to implemented a mutable reference-counted pointer. For now, I've left around the `RcMut` type but it may drastically change or be removed.

10 years agoclean up the `Rc`/`RcMut` types and move to libstd
Daniel Micay [Thu, 10 Oct 2013 15:45:52 +0000 (11:45 -0400)]
clean up the `Rc`/`RcMut` types and move to libstd

10 years agoRemove support for older CrateMap versions
Florian Hahn [Fri, 11 Oct 2013 10:32:02 +0000 (12:32 +0200)]
Remove support for older CrateMap versions

10 years agocorrect names for `#[no_send]`/`#[no_freeze]` tests
Daniel Micay [Fri, 11 Oct 2013 15:59:26 +0000 (11:59 -0400)]
correct names for `#[no_send]`/`#[no_freeze]` tests

10 years agoauto merge of #9803 : alexcrichton/rust/less-pub2, r=brson
bors [Fri, 11 Oct 2013 15:56:19 +0000 (08:56 -0700)]
auto merge of #9803 : alexcrichton/rust/less-pub2, r=brson

This change was waiting for privacy to get sorted out, which should be true now
that #8215 has landed.

Closes #4427

10 years agoauto merge of #9802 : ben0x539/rust/mkdtemp-raii, r=alexcrichton
bors [Fri, 11 Oct 2013 14:11:23 +0000 (07:11 -0700)]
auto merge of #9802 : ben0x539/rust/mkdtemp-raii, r=alexcrichton

this incidentally stops `make check` from leaving directories in `/tmp` (Closes #9764)

10 years agoextra::tempfile: replace mkdtemp with an RAII wrapper
Benjamin Herr [Fri, 11 Oct 2013 13:55:37 +0000 (15:55 +0200)]
extra::tempfile: replace mkdtemp with an RAII wrapper

this incidentally stops `make check` from leaving directories in `/tmp`

10 years agoDe-pub some private runtime components
Alex Crichton [Wed, 9 Oct 2013 17:34:27 +0000 (10:34 -0700)]
De-pub some private runtime components

This change was waiting for privacy to get sorted out, which should be true now
that #8215 has landed.

Closes #4427

10 years agoauto merge of #9805 : alexcrichton/rust/needstest, r=brson
bors [Fri, 11 Oct 2013 05:51:20 +0000 (22:51 -0700)]
auto merge of #9805 : alexcrichton/rust/needstest, r=brson

Closes #4545
Closes #5791
Closes #6470
Closes #8044

10 years agoauto merge of #9804 : alexcrichton/rust/always-anon-extern, r=brson
bors [Fri, 11 Oct 2013 04:31:21 +0000 (21:31 -0700)]
auto merge of #9804 : alexcrichton/rust/always-anon-extern, r=brson

There's currently a fair amount of code which is being ignored on unnamed blocks
(which are the default now), and I opted to leave it commented out for now. I
intend on very soon revisiting on how we perform linking with extern crates in
an effort to support static linking.

10 years agoauto merge of #9517 : crabtw/rust/cabi, r=nikomatsakis
bors [Fri, 11 Oct 2013 02:56:22 +0000 (19:56 -0700)]
auto merge of #9517 : crabtw/rust/cabi, r=nikomatsakis

I borrow some ideas from clang's ABIInfo.h and TargetInfo.cpp.
LLVMType is replaced with ArgType, which is similar to clang's ABIArgInfo,
and I also merge attrs of FnType into it.

Now ABI implementation doesn't need to insert hidden return pointer
to arg_tys of FnType. Instead it is handled in foreign.rs.

This change also fixes LLVM assertion failure when compiling MIPS target.

10 years agoAdd tests and un-xfail a few issues
Alex Crichton [Fri, 11 Oct 2013 01:37:56 +0000 (18:37 -0700)]
Add tests and un-xfail a few issues

Closes #4545
Closes #5791
Closes #6470
Closes #8044

10 years agoauto merge of #9785 : catamorphism/rust/remove-convenience-tool, r=pcwalton
bors [Fri, 11 Oct 2013 01:46:23 +0000 (18:46 -0700)]
auto merge of #9785 : catamorphism/rust/remove-convenience-tool, r=pcwalton

r? @pcwalton Sadly, there's a lack of resources for maintaining the `rust` tool,
and we decided in the 2013-10-08 Rust team meeting that it's better
to remove it altogether than to leave it in a broken state.

This deletion is without prejudice. If a person or people appear who
would like to maintain the tool, we will probably be happy to
resurrect it!

Closes #9775

10 years agoRemove named extern blocks from the AST
Alex Crichton [Thu, 10 Oct 2013 19:57:34 +0000 (12:57 -0700)]
Remove named extern blocks from the AST

There's currently a fair amount of code which is being ignored on unnamed blocks
(which are the default now), and I opted to leave it commented out for now. I
intend on very soon revisiting on how we perform linking with extern crates in
an effort to support static linking.

10 years agoauto merge of #9732 : catamorphism/rust/rustpkg-read-only, r=brson
bors [Fri, 11 Oct 2013 00:36:21 +0000 (17:36 -0700)]
auto merge of #9732 : catamorphism/rust/rustpkg-read-only, r=brson

r? @metajack rustpkg now makes source files that it checks out automatically read-only, and stores
them under build/.

Also, refactored the `PkgSrc` type to keep track of separate source and destination
workspaces, as well as to have a `build_workspace` method that returns the workspace
to put temporary files in (usually the source, sometimes the destination -- see
comments for more details).

Closes #6480

10 years agoimprove C ABI
Jyun-Yan You [Wed, 25 Sep 2013 10:30:44 +0000 (18:30 +0800)]
improve C ABI

I borrow some ideas from clang's ABIInfo.h and TargetInfo.cpp.
LLVMType is replaced with ArgType, which is similar to clang's ABIArgInfo,
and I also merge attrs of FnType into it.

Now ABI implementation doesn't need to insert hidden return pointer
to arg_tys of FnType. Instead it is handled in foreign.rs.

This change also fixes LLVM assertion failure when compiling MIPS target.

10 years agoauto merge of #9800 : vmx/rust/fix-random-doc, r=thestinger
bors [Thu, 10 Oct 2013 23:26:20 +0000 (16:26 -0700)]
auto merge of #9800 : vmx/rust/fix-random-doc, r=thestinger

The example for std::rand::random was still
using <float>, which got removed from Rust.

10 years agorustpkg: Make checked-out source files read-only, and overhaul where temporary files...
Tim Chevalier [Sat, 5 Oct 2013 20:40:01 +0000 (16:40 -0400)]
rustpkg: Make checked-out source files read-only, and overhaul where temporary files are stored

rustpkg now makes source files that it checks out automatically read-only, and stores
them under build/.

Also, refactored the `PkgSrc` type to keep track of separate source and destination
workspaces, as well as to have a `build_workspace` method that returns the workspace
to put temporary files in (usually the source, sometimes the destination -- see
comments for more details).

Closes #6480

10 years agoauto merge of #9798 : mtwilliams/rust/master, r=brson
bors [Thu, 10 Oct 2013 21:36:34 +0000 (14:36 -0700)]
auto merge of #9798 : mtwilliams/rust/master, r=brson

I also removed superfluous trailing whitespace.

I don't think I need to run the test suite.

10 years agorust / build: Remove the `rust` tool
Tim Chevalier [Wed, 9 Oct 2013 19:13:43 +0000 (12:13 -0700)]
rust / build: Remove the `rust` tool

Sadly, there's a lack of resources for maintaining the `rust` tool,
and we decided in the 2013-10-08 Rust team meeting that it's better
to remove it altogether than to leave it in a broken state.

This deletion is without prejudice. If a person or people appear who
would like to maintain the tool, we will probably be happy to
resurrect it!

Closes #9775

10 years agoFixed typo under 'Segmented stacks and the linter', and removed superfluous trailing...
Michael 'devbug' Williams [Thu, 10 Oct 2013 20:57:55 +0000 (13:57 -0700)]
Fixed typo under 'Segmented stacks and the linter', and removed superfluous trailing whitespace.

10 years agoauto merge of #9797 : alexcrichton/rust/snapshots, r=thestinger
bors [Thu, 10 Oct 2013 20:26:30 +0000 (13:26 -0700)]
auto merge of #9797 : alexcrichton/rust/snapshots, r=thestinger

Some bug fixes to reexported statics in stage0 now, also some macro attribute goodies. Mostly just updating the snapshot to help enable some things that its patches have been blocking.

10 years agoRegister new snapshots
Alex Crichton [Thu, 10 Oct 2013 20:19:18 +0000 (13:19 -0700)]
Register new snapshots

10 years agoFix usage of <float> in docs
Volker Mische [Thu, 10 Oct 2013 19:54:29 +0000 (21:54 +0200)]
Fix usage of <float> in docs

The example for std::rand::random was still
using <float>, which got removed from Rust.

10 years agoauto merge of #9791 : alexcrichton/rust/reachable, r=catamorphism
bors [Thu, 10 Oct 2013 13:06:24 +0000 (06:06 -0700)]
auto merge of #9791 : alexcrichton/rust/reachable, r=catamorphism

This fixes a bug in which the visibility rules were approximated by
reachability, but forgot to cover the case where a 'pub use' reexports a private
item. This fixes the commit by instead using the results of the privacy pass of
the compiler to create the initial working set of the reachability pass.

This may have the side effect of increasing the size of metadata, but it's
difficult to avoid for correctness purposes sadly.

Closes #9790

10 years agoAdd `pub` to all the codegen tests
Alex Crichton [Thu, 10 Oct 2013 13:00:51 +0000 (06:00 -0700)]
Add `pub` to all the codegen tests

Otherwise the test function is internalized and LLVM will most likely optimize
it out.

10 years agoauto merge of #9749 : alexcrichton/rust/less-io, r=brson
bors [Thu, 10 Oct 2013 11:31:24 +0000 (04:31 -0700)]
auto merge of #9749 : alexcrichton/rust/less-io, r=brson

This implements a number of the baby steps needed to start eliminating everything inside of `std::io`. It turns out that there are a *lot* of users of that module, so I'm going to try to tackle them separately instead of bringing down the whole system all at once.

This pull implements a large amount of unimplemented functionality inside of `std::rt::io` including:

* Native file I/O (file descriptors, *FILE)
* Native stdio (through the native file descriptors)
* Native processes (extracted from `std::run`)

I also found that there are a number of users of `std::io` which desire to read an input line-by-line, so I added an implementation of `read_until` and `read_line` to `BufferedReader`.

With all of these changes in place, I started to axe various usages of `std::io`. There's a lot of one-off uses here-and-there, but the major use-case remaining that doesn't have a fantastic solution is `extra::json`. I ran into a few compiler bugs when attempting to remove that, so I figured I'd come back to it later instead.

There is one fairly major change in this pull, and it's moving from native stdio to uv stdio via `print` and `println`. Unfortunately logging still goes through native I/O (via `dumb_println`). This is going to need some thinking, because I still want the goal of logging/printing to be 0 allocations, and this is not possible if `io::stdio::stderr()` is called on each log message. Instead I think that this may need to be cached as the `logger` field inside the `Task` struct, but that will require a little more workings to get right (this is also a similar problem for print/println, do we cache `stdout()` to not have to re-create it every time?).

10 years agoMake the file::DirectoryInfo trait public
Alex Crichton [Mon, 7 Oct 2013 20:44:57 +0000 (13:44 -0700)]
Make the file::DirectoryInfo trait public

This was just a mistake that it was hidden.

10 years agoRemove some users of io::file_reader
Alex Crichton [Sun, 6 Oct 2013 23:08:56 +0000 (16:08 -0700)]
Remove some users of io::file_reader

10 years agoRemove usage of io::FILE_writer
Alex Crichton [Sun, 6 Oct 2013 22:07:27 +0000 (15:07 -0700)]
Remove usage of io::FILE_writer

10 years agoMigrate users of io::fd_t to io::native::file::fd_t
Alex Crichton [Sun, 6 Oct 2013 20:24:50 +0000 (13:24 -0700)]
Migrate users of io::fd_t to io::native::file::fd_t

10 years agoMove std::run off of std::io
Alex Crichton [Sun, 6 Oct 2013 20:23:03 +0000 (13:23 -0700)]
Move std::run off of std::io

This changes the implementation to instead use rt::io::native::process as well
as an example of using those bindings.

10 years agoImplement BufferedReader.{read_until, read_line}
Alex Crichton [Sun, 6 Oct 2013 22:39:42 +0000 (15:39 -0700)]
Implement BufferedReader.{read_until, read_line}

These two functions will be useful when replacing various other counterparts
used by std::io consumers.

10 years agoImplement rt::io::stdio
Alex Crichton [Mon, 7 Oct 2013 20:25:06 +0000 (13:25 -0700)]
Implement rt::io::stdio

Additionally, this moves the prelude imports of print/println from std::io to
std::rt::io.

Closes #6846

10 years agoUse the result of privacy for reachability
Alex Crichton [Thu, 10 Oct 2013 04:16:51 +0000 (21:16 -0700)]
Use the result of privacy for reachability

This fixes a bug in which the visibility rules were approximated by
reachability, but forgot to cover the case where a 'pub use' reexports a private
item. This fixes the commit by instead using the results of the privacy pass of
the compiler to create the initial working set of the reachability pass.

This may have the side effect of increasing the size of metadata, but it's
difficult to avoid for correctness purposes sadly.

Closes #9790

10 years agoauto merge of #9783 : huonw/rust/macro-items, r=bstrie
bors [Thu, 10 Oct 2013 04:56:20 +0000 (21:56 -0700)]
auto merge of #9783 : huonw/rust/macro-items, r=bstrie

Fixes #4471.

10 years agoauto merge of #9780 : sfackler/rust/extensions2, r=alexcrichton
bors [Thu, 10 Oct 2013 03:46:21 +0000 (20:46 -0700)]
auto merge of #9780 : sfackler/rust/extensions2, r=alexcrichton

This works around #9779, but is probably the right thing to do anyways
since that's the module where all of the documentation for those traits
lives.

10 years agoauto merge of #9774 : sebcrozet/rust/master, r=huonw
bors [Thu, 10 Oct 2013 00:41:23 +0000 (17:41 -0700)]
auto merge of #9774 : sebcrozet/rust/master, r=huonw

The minimum (negative) value of a float is `-Bounded::max_value()`, not `Bounded::min_value()`.
Otherwise the following has an incorrect behavior:

```rust
let a = -1.0f64;
let b: f32 = NumCast::from(a); // incorrectly returns None
```

10 years agosyntax: allow macros to expand to items with attributes.
Huon Wilson [Wed, 9 Oct 2013 12:13:43 +0000 (23:13 +1100)]
syntax: allow macros to expand to items with attributes.

Fixes #4471.

10 years agoauto merge of #9750 : alexcrichton/rust/safer-strings, r=brson
bors [Wed, 9 Oct 2013 22:31:26 +0000 (15:31 -0700)]
auto merge of #9750 : alexcrichton/rust/safer-strings, r=brson

This behavior was decided to get out-right forbidden by the compiler

Closes #8891

10 years agoauto merge of #9742 : alexcrichton/rust/issue-9739, r=brson
bors [Wed, 9 Oct 2013 21:21:38 +0000 (14:21 -0700)]
auto merge of #9742 : alexcrichton/rust/issue-9739, r=brson

This changes an `assert_once_ever!` assertion to just a plain old assertion
around an atomic boolean to ensure that one particular runtime doesn't attempt
to exit twice.

Closes #9739

10 years agoDon't abort if the runtime is run twice.
Alex Crichton [Sun, 6 Oct 2013 04:58:55 +0000 (21:58 -0700)]
Don't abort if the runtime is run twice.

This changes an `assert_once_ever!` assertion to just a plain old assertion
around an atomic boolean to ensure that one particular runtime doesn't attempt
to exit twice.

Closes #9739

10 years agoImplement io::native::process
Alex Crichton [Sun, 6 Oct 2013 20:22:18 +0000 (13:22 -0700)]
Implement io::native::process

10 years agoImplement io::native::stdio
Alex Crichton [Sun, 6 Oct 2013 20:21:42 +0000 (13:21 -0700)]
Implement io::native::stdio

10 years agoImplement io::native::file
Alex Crichton [Sun, 6 Oct 2013 20:21:29 +0000 (13:21 -0700)]
Implement io::native::file

10 years agoauto merge of #9386 : Geal/rust/base64-doc, r=alexcrichton
bors [Wed, 9 Oct 2013 17:41:31 +0000 (10:41 -0700)]
auto merge of #9386 : Geal/rust/base64-doc, r=alexcrichton

Standard is now uppercase in the base64 module, and from_base64 now returns a Result

10 years agoForbid modifications of strings in the compiler
Alex Crichton [Mon, 7 Oct 2013 21:25:30 +0000 (14:25 -0700)]
Forbid modifications of strings in the compiler

This disallows `str[0] = foo` along with `foo = &mut str[i]` to prevent strings
from being modified at runtime (except possibly through the `str` module)

Closes #8891

10 years agoCorrect code examples for base64 documentation
Geoffroy Couprie [Fri, 20 Sep 2013 13:17:32 +0000 (15:17 +0200)]
Correct code examples for base64 documentation

10 years agoauto merge of #9748 : klutzy/rust/print-git-revision, r=alexcrichton
bors [Wed, 9 Oct 2013 16:31:36 +0000 (09:31 -0700)]
auto merge of #9748 : klutzy/rust/print-git-revision, r=alexcrichton

Fixes a bug that `rustc.exe -v` didn't show git revision hash.
The bug is caused by that `$(wildcard $(CFG_GIT))` requires
space-escaped inputs while `$(CFG_GIT)` is usually
`C:\Program Files (x86)\Git\bin\git.exe`.

10 years agoauto merge of #9664 : alexcrichton/rust/logging, r=huonw
bors [Wed, 9 Oct 2013 14:31:36 +0000 (07:31 -0700)]
auto merge of #9664 : alexcrichton/rust/logging, r=huonw

This makes some headway on #3309, see commits for details.

10 years agoauto merge of #9359 : thestinger/rust/option, r=huonw
bors [Wed, 9 Oct 2013 13:21:36 +0000 (06:21 -0700)]
auto merge of #9359 : thestinger/rust/option, r=huonw

See #9355 for discussion.

10 years agooption: rewrite the API to use composition
Daniel Micay [Fri, 20 Sep 2013 06:08:47 +0000 (02:08 -0400)]
option: rewrite the API to use composition

10 years agoauto merge of #9695 : huonw/rust/rand2, r=alexcrichton
bors [Wed, 9 Oct 2013 12:11:33 +0000 (05:11 -0700)]
auto merge of #9695 : huonw/rust/rand2, r=alexcrichton

A pile of changes to `std::rand`:

- Add the 64-bit variant of the ISAAC Rng. This also splits the `Rng.next() -> u32` method into `Rng.next_u32() -> u32` and `Rng.next_u64() -> u64` to be able to actually take advantage of the wider numbers. They have default implementations in terms of each other. (This is ~2&times; faster than the 32 bit one for generating anything larger than a `u32` on 64-bit computers.)
- Add `ReaderRng` which just wraps a reader as an RNG, useful for `/dev/urandom`, `/dev/random`, `/dev/hwrng`, etc. This also adds the overrideable `fill_bytes` method to `Rng`, since readers can "generate" randomness more than just 8 bytes at a time.
- Add an interface to `/dev/urandom` (and the windows API) that implements `Rng` (`os::OSRng`) so that it is a first-class randomness source. This means that experimenting with things like seeding hashmaps from it will be much easier. It deletes most of the C++ supporting the old form, except for thin wrappers around the Windows API; I don't have access to a windows with Rust other than the try branch. ( **Note:** on unices, this means that `OSRng` requires the runtime, so it's not possible to use it to seed the scheduler RNG; I've replaced it with direct libc calls for reading from `/dev/urandom`.)
- Add the "blessed" `StdRng` which means users who just want a random number generator don't need to worry about the implementation details (which will make changing the underlying implementation from Isaac to something else will be easier, if this every happen). This actually changes between the 32 and 64-bit variants of Isaac depending on the platform at the moment.
- Add a `SeedableRng` trait for random number generators that can be explicitly seeded,
- Add the `ReseedingRng` wrapper for reseeding a RNG after a certain amount of randomness is emitted. (The method for reseeding is controlled via the `Reseeder` trait from the same module)
- changes to the task rng:
 - uses `StdRng`
 - it will reseed itself every 32KB, that is, after outputting 32KB of random data it will read new data from the OS (via `OSRng`)
- Implements `Rand` for `char`, and makes the `f32` and `f64` instances more reasonable (and more similar to most other languages I've looked at).
- Documentation, examples and tests

10 years agostd::rand: Minor clean-up of comments & add a missing default method.
Huon Wilson [Wed, 9 Oct 2013 06:39:37 +0000 (17:39 +1100)]
std::rand: Minor clean-up of comments & add a missing default method.

10 years agostd::rand: remove seed_task_rng and RUST_SEED.
Huon Wilson [Wed, 9 Oct 2013 06:36:31 +0000 (17:36 +1100)]
std::rand: remove seed_task_rng and RUST_SEED.

10 years agostd::rand: Make Rng.next_u32 non-default, waiting for #7771.
Huon Wilson [Tue, 8 Oct 2013 22:56:57 +0000 (09:56 +1100)]
std::rand: Make Rng.next_u32 non-default, waiting for #7771.

10 years agostd::rand::os: use the externfn! macro for the Windows RNG.
Huon Wilson [Tue, 8 Oct 2013 22:45:38 +0000 (09:45 +1100)]
std::rand::os: use the externfn! macro for the Windows RNG.

10 years agostd::rand::reseeding: seed the reseeder in the SeedableRng impl.
Huon Wilson [Tue, 8 Oct 2013 15:22:37 +0000 (02:22 +1100)]
std::rand::reseeding: seed the reseeder in the SeedableRng impl.

This stops us relying on Default here.

10 years agostd::rand::reader: describe cfg!(endianness).
Huon Wilson [Tue, 8 Oct 2013 15:13:34 +0000 (02:13 +1100)]
std::rand::reader: describe cfg!(endianness).

10 years agostd::rand: Correct the implementation of Rand for f32 & f64.
Huon Wilson [Tue, 8 Oct 2013 15:09:33 +0000 (02:09 +1100)]
std::rand: Correct the implementation of Rand for f32 & f64.

10 years agoDocumentation & address minor point.
Huon Wilson [Tue, 8 Oct 2013 14:54:21 +0000 (01:54 +1100)]
Documentation & address minor point.

10 years agostd::rand: remove `seed`.
Huon Wilson [Tue, 8 Oct 2013 13:21:26 +0000 (00:21 +1100)]
std::rand: remove `seed`.

This much better handled by directly calling out to `OSRng` where
appropriate.

10 years agoConvert rt::sched::new_sched_rng to use open/read/close rather than f*.
Huon Wilson [Tue, 8 Oct 2013 12:19:20 +0000 (23:19 +1100)]
Convert rt::sched::new_sched_rng to use open/read/close rather than f*.

10 years agostd::rand: adjust the f32 & f64 Rand instances.
Huon Wilson [Thu, 3 Oct 2013 03:10:34 +0000 (13:10 +1000)]
std::rand: adjust the f32 & f64 Rand instances.

The f32 generator now just uses a single u32, and the f64 uses a
single u64. This will make both significantly faster, especially
on 64-bit platforms.

10 years agostd::rand: documentation additions & fixes.
Huon Wilson [Tue, 1 Oct 2013 17:17:57 +0000 (03:17 +1000)]
std::rand: documentation additions & fixes.

10 years agostd::rand: move the Rand impls into a separate file for neatness.
Huon Wilson [Tue, 1 Oct 2013 17:16:22 +0000 (03:16 +1000)]
std::rand: move the Rand impls into a separate file for neatness.

10 years agostd::rand: add & split some tests.
Huon Wilson [Tue, 1 Oct 2013 16:23:22 +0000 (02:23 +1000)]
std::rand: add & split some tests.

10 years agostd::rand: make the windows OSRng more correct, remove some C++.
Huon Wilson [Tue, 1 Oct 2013 16:18:57 +0000 (02:18 +1000)]
std::rand: make the windows OSRng more correct, remove some C++.

This lets the C++ code in the rt handle the (slightly) tricky parts of
random number generation: e.g. error detection/handling, and using the
values of the `#define`d options to the various functions.