]> git.lizzy.rs Git - rust.git/log
rust.git
10 years agoauto merge of #14234 : alexcrichton/rust/rollup, r=alexcrichton
bors [Thu, 15 May 2014 22:56:54 +0000 (15:56 -0700)]
auto merge of #14234 : alexcrichton/rust/rollup, r=alexcrichton

Let's try this again!

10 years agoTest fixes from rollup
Alex Crichton [Thu, 15 May 2014 21:59:01 +0000 (14:59 -0700)]
Test fixes from rollup

Closes #14231 (mk: Don't run benchmarks with `make check`)
Closes #14215 (std: Modify TempDir to not fail on drop. Closes #12628)
Closes #14211 (rustdoc: functions in ffi blocks are unsafe)
Closes #14210 (Make Vec.truncate() resilient against failure in Drop)
Closes #14208 (Make `from_bits` in `bitflags!` safe; add `from_bits_truncate`)
Closes #14206 (Register new snapshots)
Closes #14205 (use sched_yield on linux and freebsd)
Closes #14204 (Add a crate for missing stubs from libcore)
Closes #14203 (shootout-mandelbrot: Either 10-20% or 80-100% improvement.)
Closes #14202 (Add flow-graph visualization (via graphviz) to rustc)
Closes #14201 (Render not_found with an absolute path to the rust stylesheet)
Closes #14200 (std cleanup)
Closes #14189 (Implement cell::clone_ref)

10 years agoImplement cell::clone_ref
Keegan McAllister [Wed, 14 May 2014 00:29:30 +0000 (17:29 -0700)]
Implement cell::clone_ref

Per discussion with @alexcrichton, this is a free function.

10 years agocore: Remove the unit module
Brian Anderson [Tue, 13 May 2014 04:02:27 +0000 (21:02 -0700)]
core: Remove the unit module

10 years agostd: Delete unused file
Brian Anderson [Wed, 14 May 2014 08:36:12 +0000 (01:36 -0700)]
std: Delete unused file

10 years agostd: Remove run_in_bare_thread
Brian Anderson [Wed, 14 May 2014 08:13:29 +0000 (01:13 -0700)]
std: Remove run_in_bare_thread

10 years agoRender not_found with an absolute path to the rust stylesheet
Richo Healey [Wed, 14 May 2014 17:45:51 +0000 (10:45 -0700)]
Render not_found with an absolute path to the rust stylesheet

10 years agoUnit tests for flowgraph pretty printing.
Felix S. Klock II [Mon, 5 May 2014 15:00:14 +0000 (17:00 +0200)]
Unit tests for flowgraph pretty printing.

Each test works by rendering the flowgraph for the last identified
block we see in expanded pretty-printed output, and comparing it (via
`diff`) against a checked in "foo.dot-expected.dot" file.

Each test post-processes the output to remove NodeIds ` (id=NUM)` so
that the expected output is somewhat stable (or at least independent
of how we assign NodeIds) and easier for a human to interpret when
looking at the expected output file itself.

----

Test writing style notes:

I usually tried to write the tests in a way that would avoid duplicate
labels in the output rendered flow graph, when possible.

The tests that have string literals "unreachable" in the program text
are deliberately written that way to remind the reader that the
unreachable nodes in the resulting graph are not an error in the
control flow computation, but rather a natural consequence of its
construction.

10 years agoGraphviz based flow graph pretty-printing.
Felix S. Klock II [Thu, 17 Apr 2014 19:00:08 +0000 (21:00 +0200)]
Graphviz based flow graph pretty-printing.

Passing `--pretty flowgraph=<NODEID>` makes rustc print a control flow graph.

In pratice, you will also need to pass the additional option:
`-o <FILE>` to emit output to a `.dot` file for graphviz.

(You can only print the flow-graph for a particular block in the AST.)

----

An interesting implementation detail is the way the code puts both the
node index (`cfg::CFGIndex`) and a reference to the payload
(`cfg::CFGNode`) into the single `Node` type that is used for
labelling and walking the graph.  I had once mistakenly thought that I
only wanted the `cfg::CFGNode`, but for labelling, you really want the
cfg index too, rather than e.g. trying to use the `ast::NodeId` as the
label (which breaks down e.g. due to `ast::DUMMY_NODE_ID`).

----

As a drive-by fix, I had to fix `rustc::middle::cfg::construct`
interface to reflect changes that have happened on the master branch
while I was getting this integrated into the compiler.  (The next
commit actually adds tests of the `--pretty flowgraph` functionality,
so that should ensure that the `rustc::middle::cfg` code does not go
stale again.)

10 years agoBugfixes for rustc::middle::cfg::construct.
Felix S. Klock II [Thu, 8 May 2014 22:07:57 +0000 (00:07 +0200)]
Bugfixes for rustc::middle::cfg::construct.

1. Only insert non-dummy nodes into the exit map.

2. Revise handling of `break` and `continue` forms so that they are
   not treated as if control falls through to the next node (since it
   does not, it just jumps to the end or start of the loop body).

3. Fixed support for return expression in flow graph construction.

10 years agorustc::middle::graph API revisions.
Felix S. Klock II [Tue, 6 May 2014 07:34:29 +0000 (09:34 +0200)]
rustc::middle::graph API revisions.

Refine lifetimes in signature for graph node/edge iteration methods.

Added `pub` `node_id` and `edge_id` methods that correspond to
NodeIndex and EdgeIndex `get` methods (note that the inner index is
already `pub` in the struct definitions).  (I decided that `get()`,
used internally, just looks too generic and that client code is
clearer with more explicit method names.)

10 years agoAdd `IntoMaybeOwned` impl for `StrBuf` to ease conversion to `MaybeOwned`.
Felix S. Klock II [Thu, 8 May 2014 17:11:43 +0000 (19:11 +0200)]
Add `IntoMaybeOwned` impl for `StrBuf` to ease conversion to `MaybeOwned`.

10 years agoAdd `EntryPat` and `NodePat` variants to ast_map.
Felix S. Klock II [Thu, 8 May 2014 13:50:54 +0000 (15:50 +0200)]
Add `EntryPat` and `NodePat` variants to ast_map.

Add `EntryPat` and `NodePat` variants to ast_map, so that lookups for
id 1 in `let S{val: _x /* pat 2 */} /* pat 1 */ = ...` will actually
resolve to the pattern `S{ ... }`, rather than "unknown node", in a
function like `node_id_to_str`.

10 years agoshootout-mandelbrot: Precalc initial values & use SIMD in the main loop. +80-100%
Kevin Butler [Wed, 14 May 2014 18:08:06 +0000 (19:08 +0100)]
shootout-mandelbrot: Precalc initial values & use SIMD in the main loop. +80-100%

10 years agoshootout-mandlebrot: calculate two bits of the result per inner loop, +10-15%
Kevin Butler [Tue, 13 May 2014 20:15:11 +0000 (21:15 +0100)]
shootout-mandlebrot: calculate two bits of the result per inner loop, +10-15%

10 years agoAdd a crate for missing stubs from libcore
Alex Crichton [Wed, 14 May 2014 18:24:12 +0000 (11:24 -0700)]
Add a crate for missing stubs from libcore

The core library in theory has 0 dependencies, but in practice it has some in
order for it to be efficient. These dependencies are in the form of the basic
memory operations provided by libc traditionally, such as memset, memcmp, etc.
These functions are trivial to implement and themselves have 0 dependencies.

This commit adds a new crate, librlibc, which will serve the purpose of
providing these dependencies. The crate is never linked to by default, but is
available to be linked to by downstream consumers. Normally these functions are
provided by the system libc, but in other freestanding contexts a libc may not
be available. In these cases, librlibc will suffice for enabling execution with
libcore.

cc #10116

10 years agouse sched_yield on linux and freebsd
Daniel Micay [Wed, 14 May 2014 19:54:19 +0000 (15:54 -0400)]
use sched_yield on linux and freebsd

pthread_yield is non-standard, while sched_yield is POSIX

The Linux documentation recommends using the standard function. This is
the only feature we're currently using that's present in glibc but not
in musl.

10 years agoRegister new snapshots
Alex Crichton [Wed, 14 May 2014 21:24:41 +0000 (14:24 -0700)]
Register new snapshots

10 years agoMake `from_bits` in `bitflags!` safe; add `from_bits_truncate`
Aaron Turon [Wed, 14 May 2014 21:39:16 +0000 (14:39 -0700)]
Make `from_bits` in `bitflags!` safe; add `from_bits_truncate`

Previously, the `from_bits` function in the `std::bitflags::bitflags`
macro was marked as unsafe, as it did not check that the bits being
converted actually corresponded to flags.

This patch changes the function to check against the full set of
possible flags and return an `Option` which is `None` if a non-flag bit
is set. It also adds a `from_bits_truncate` function which simply zeros
any bits not corresponding to a flag.

This addresses the concern raised in https://github.com/mozilla/rust/pull/13897

10 years agoMake Vec.truncate() resilient against failure in Drop
Kevin Ballard [Wed, 14 May 2014 21:57:27 +0000 (14:57 -0700)]
Make Vec.truncate() resilient against failure in Drop

If a vector element fails in Drop, Vec needs to make sure it doesn't try
to re-drop any elements it already dropped.

10 years agorustdoc: functions in ffi blocks are unsafe
Corey Richardson [Wed, 14 May 2014 23:33:15 +0000 (16:33 -0700)]
rustdoc: functions in ffi blocks are unsafe

Fixes #14188

10 years agostd: Modify TempDir to not fail on drop. Closes #12628
Brian Anderson [Thu, 15 May 2014 00:49:14 +0000 (17:49 -0700)]
std: Modify TempDir to not fail on drop. Closes #12628

After discussion with Alex, we think the proper policy is for dtors
to not fail. This is consistent with C++. BufferedWriter already
does this, so this patch modifies TempDir to not fail in the dtor,
adding a `close` method for handling errors on destruction.

10 years agomk: Don't run benchmarks with `make check`
Alex Crichton [Thu, 15 May 2014 18:15:35 +0000 (11:15 -0700)]
mk: Don't run benchmarks with `make check`

The current suite of benchmarks for the standard distribution take a significant
amount of time to run, but it's unclear whether we're gaining any benefit from
running them. Some specific pain points:

* No one is looking at the data generated by the benchmarks. We have no graphs
  or analysis of what's happening, so all the data is largely being cast into
  the void.

* No benchmark has ever uncovered a bug, they have always run successfully.

* Benchmarks not only take a significant amount of time to run, but also take a
  significant amount of time to compile. I don't think we should mitigate this
  for now because it's useful to ensure that they do indeed still compile.

This commit disables --bench test runs by default as part of `make check`,
flipping the NO_BENCH environment variable to a PLEASE_BENCH variable which will
manually enable benchmarking. If and when a dedicated bot is set up for
benchmarking, this flag can be enabled on that bot.

10 years agoauto merge of #14040 : hannobraun/rust/force-color-output, r=alexcrichton
bors [Thu, 15 May 2014 20:17:28 +0000 (13:17 -0700)]
auto merge of #14040 : hannobraun/rust/force-color-output, r=alexcrichton

This pull request fixes #12881.

Two caveats:

1. As explained in the commit message, this doesn't include a regression test. If this is unacceptable, please let me know, I'll see what I can do.
1. I'm getting some test failures on make check, all from debuginfo. I suspect this is due to #13680 and  not related to my changes (I have GDB 7.7). This is the list of failed tests:

> [debuginfo-gdb] debuginfo/basic-types-globals.rs
> [debuginfo-gdb] debuginfo/basic-types-mut-globals.rs
> [debuginfo-gdb] debuginfo/basic-types.rs
> [debuginfo-gdb] debuginfo/borrowed-basic.rs
> [debuginfo-gdb] debuginfo/borrowed-managed-basic.rs
> [debuginfo-gdb] debuginfo/borrowed-struct.rs
> [debuginfo-gdb] debuginfo/borrowed-unique-basic.rs
> [debuginfo-gdb] debuginfo/box.rs
> [debuginfo-gdb] debuginfo/by-value-non-immediate-argument.rs
> [debuginfo-gdb] debuginfo/by-value-self-argument-in-trait-impl.rs
> [debuginfo-gdb] debuginfo/closure-in-generic-function.rs
> [debuginfo-gdb] debuginfo/evec-in-struct.rs
> [debuginfo-gdb] debuginfo/function-arg-initialization.rs
> [debuginfo-gdb] debuginfo/function-prologue-stepping-no-split-stack.rs
> [debuginfo-gdb] debuginfo/generic-function.rs
> [debuginfo-gdb] debuginfo/generic-functions-nested.rs
> [debuginfo-gdb] debuginfo/generic-method-on-generic-struct.rs
> [debuginfo-gdb] debuginfo/generic-static-method-on-struct-and-enum.rs
> [debuginfo-gdb] debuginfo/generic-struct.rs
> [debuginfo-gdb] debuginfo/lexical-scope-in-stack-closure.rs
> [debuginfo-gdb] debuginfo/lexical-scope-in-unique-closure.rs
> [debuginfo-gdb] debuginfo/method-on-generic-struct.rs
> [debuginfo-gdb] debuginfo/method-on-tuple-struct.rs
> [debuginfo-gdb] debuginfo/name-shadowing-and-scope-nesting.rs
> [debuginfo-gdb] debuginfo/recursive-struct.rs
> [debuginfo-gdb] debuginfo/self-in-generic-default-method.rs
> [debuginfo-gdb] debuginfo/shadowed-argument.rs
> [debuginfo-gdb] debuginfo/shadowed-variable.rs
> [debuginfo-gdb] debuginfo/simd.rs
> [debuginfo-gdb] debuginfo/simple-lexical-scope.rs
> [debuginfo-gdb] debuginfo/simple-struct.rs
> [debuginfo-gdb] debuginfo/simple-tuple.rs
> [debuginfo-gdb] debuginfo/static-method-on-struct-and-enum.rs
> [debuginfo-gdb] debuginfo/tuple-struct.rs
> [debuginfo-gdb] debuginfo/var-captured-in-nested-closure.rs
> [debuginfo-gdb] debuginfo/var-captured-in-sendable-closure.rs
> [debuginfo-gdb] debuginfo/var-captured-in-stack-closure.rs

I can provide the full output on request.

10 years agoauto merge of #13948 : huonw/rust/test-regex-filter, r=alexcrichton
bors [Thu, 15 May 2014 18:22:02 +0000 (11:22 -0700)]
auto merge of #13948 : huonw/rust/test-regex-filter, r=alexcrichton

This allows writing a regex to filter tests more precisely, rather than having to list long paths e.g.

```
$ ./stdtest-x86_64-unknown-linux-gnu 'vec.*clone'

running 2 tests
test vec::tests::test_clone ... ok
test vec::tests::test_clone_from ... ok

test result: ok. 2 passed; 0 failed; 0 ignored; 0 measured
```

The regex change is fully backwards compatible, since test names are Rust
identifiers + `:`, and hence not special regex characters.

(See commits for details.)

10 years agoauto merge of #13954 : aturon/rust/issue-11650, r=alexcrichton
bors [Thu, 15 May 2014 15:36:50 +0000 (08:36 -0700)]
auto merge of #13954 : aturon/rust/issue-11650, r=alexcrichton

## Process API

The existing APIs for spawning processes took strings for the command
and arguments, but the underlying system may not impose utf8 encoding,
so this is overly limiting.

The assumption we actually want to make is just that the command and
arguments are viewable as [u8] slices with no interior NULLs, i.e., as
CStrings. The ToCStr trait is a handy bound for types that meet this
requirement (such as &str and Path).

However, since the commands and arguments are often a mixture of
strings and paths, it would be inconvenient to take a slice with a
single T: ToCStr bound. So this patch revamps the process creation API
to instead use a builder-style interface, called `Command`, allowing
arguments to be added one at a time with differing ToCStr
implementations for each.

The initial cut of the builder API has some drawbacks that can be
addressed once issue #13851 (libstd as a facade) is closed. These are
detailed as FIXMEs.

## Dynamic library API

`std::unstable::dynamic_library::open_external` currently takes a
`Path`, but because `Paths` produce normalized strings, this can
change the semantics of lookups in a given environment. This patch
generalizes the function to take a `ToCStr`-bounded type, which
includes both `Path`s and `str`s.

## ToCStr API

Adds ToCStr impl for &Path and ~str. This is a stopgap until DST (#12938) lands.

Until DST lands, we cannot decompose &str into & and str, so we cannot
usefully take ToCStr arguments by reference (without forcing an
additional & around &str). So we are instead temporarily adding an
instance for &Path and ~str, so that we can take ToCStr as owned. When
DST lands, the &Path instance should be removed, the string instances
should be revisted, and arguments bound by ToCStr should be passed by
reference.

FIXMEs have been added accordingly.

## Tickets closed

Closes #11650.
Closes #7928.

10 years agoauto merge of #14198 : thestinger/rust/valgrind, r=luqmana
bors [Thu, 15 May 2014 14:06:47 +0000 (07:06 -0700)]
auto merge of #14198 : thestinger/rust/valgrind, r=luqmana

10 years agoAdd compiler flag to configure output coloring
Hanno Braun [Thu, 8 May 2014 13:10:03 +0000 (13:10 +0000)]
Add compiler flag to configure output coloring

This adds the flag --color, which allows the user to force coloring or
turn it off. The default behavior stays the same as before (colorize, if
output goes to tty).
Why this is beneficial is explained in issue #12881.

Please note that this commit doesn't include any regression tests. I
thought about how I'd write a test for this and it doesn't seem to be
worth the effort to me for a UI change like this.

Fixes #12881.

10 years agostd:: switch the order in which dynamic_lib adds search paths.
Huon Wilson [Thu, 8 May 2014 13:33:22 +0000 (23:33 +1000)]
std:: switch the order in which dynamic_lib adds search paths.

The compiler needs to be opening e.g. libregex in the correct directory,
which requires getting these in the right order.

10 years agotest: ensure that the extended usage description gets printed.
Huon Wilson [Mon, 5 May 2014 12:44:07 +0000 (22:44 +1000)]
test: ensure that the extended usage description gets printed.

Previously the longer hand-written usage string was never being printed:
theoretically it was trying to detect when precisely `--help` was
passed (but not `-h`), but the getopts framework was considering a check
for the presence of `-h` to be a check for that of `--help` too,
i.e. the code was always going through the `-h` path.

This changes it to print the extended usage for both `-h` and `--help`,
meaning that it does actually appear correctly.

10 years agotest: allow the test filter to be a regex.
Huon Wilson [Mon, 5 May 2014 12:19:38 +0000 (22:19 +1000)]
test: allow the test filter to be a regex.

This is fully backwards compatible, since test names are Rust
identifiers + `:`, and hence not special regex characters.

Fixes #2866.

10 years agotest: implement a no-alloc -> &str method for TestName.
Huon Wilson [Mon, 5 May 2014 09:15:17 +0000 (19:15 +1000)]
test: implement a no-alloc -> &str method for TestName.

This is far cheaper than the `.to_str` technique that was used previously.

10 years agoauto merge of #14174 : stepancheg/rust/once, r=alexcrichton
bors [Thu, 15 May 2014 11:16:47 +0000 (04:16 -0700)]
auto merge of #14174 : stepancheg/rust/once, r=alexcrichton

Submitting PR again, because I cannot reopen #13349, and github does not attach new patch to that PR.

=======

Optimize `Once::doit`: perform optimistic check that initializtion is
already completed.  `load` is much cheaper than `fetch_add` at least
on x86_64.

Verified with this test:

```
static mut o: one::Once = one::ONCE_INIT;
unsafe {
    loop {
        let start = time::precise_time_ns();
        let iters = 50000000u64;
        for _ in range(0, iters) {
            o.doit(|| { println!("once!"); });
        }
        let end = time::precise_time_ns();
        let ps_per_iter = 1000 * (end - start) / iters;
        println!("{} ps per iter", ps_per_iter);

        // confuse the optimizer
        o.doit(|| { println!("once!"); });
    }
}
```

Test executed on Mac, Intel Core i7 2GHz. Result is:
* 20ns per iteration without patch
*  4ns per iteration with this patch applied

Once.doit could be even faster (800ps per iteration), if `doit` function
was split into a pair of `doit`/`doit_slow`, and `doit` marked as
`#[inline]` like this:

```
#[inline(always)]
pub fn doit(&self, f: ||) {
    if self.cnt.load(atomics::SeqCst) < 0 {
        return
    }

    self.doit_slow(f);
}

fn doit_slow(&self, f: ||) { ... }
```

10 years agoauto merge of #14145 : pnkfelix/rust/fsk-better-svh-via-visitor, r=alexcrichton
bors [Thu, 15 May 2014 09:41:50 +0000 (02:41 -0700)]
auto merge of #14145 : pnkfelix/rust/fsk-better-svh-via-visitor, r=alexcrichton

Teach SVH computation to ignore more implementation artifacts.

In particular, this version of strict version hash (SVH) works much
like the deriving(Hash)-based implementation did, except that it
deliberately:

  1. skips over content known not affect the generated crates, and,

  2. uses a content-based hash for names instead of using the value of
     the `Name` index itself, which can differ depending on the order
     in which strings are interned (which in turn is affected by
     e.g. the presence of `--cfg` options on the command line).

Fix #14132.

10 years agoAdded tests checking that changes in type sig are recognized in SVH.
Felix S. Klock II [Wed, 14 May 2014 13:24:10 +0000 (15:24 +0200)]
Added tests checking that changes in type sig are recognized in SVH.

(Only after adding the tests did I realize that this is not really a
special case at the AST level; as far as the visitor is concerned,
`int` and `i32` and `i64` are just idents.)

10 years agoA test case for a bug I found in the new SVH while reviewing it.
Felix S. Klock II [Wed, 14 May 2014 10:36:03 +0000 (12:36 +0200)]
A test case for a bug I found in the new SVH while reviewing it.

Namely: non-pub `use` declarations *are* significant to the SVH
computation, since they can change which traits are part of the method
resolution step, and thus affect which methods get called from the
(potentially inlined) code.

10 years agoSome basic acceptance tests for better SVH.
Felix S. Klock II [Tue, 13 May 2014 09:55:44 +0000 (11:55 +0200)]
Some basic acceptance tests for better SVH.

10 years agoTeach SVH computation to ignore more implementation artifacts.
Felix S. Klock II [Mon, 12 May 2014 17:11:46 +0000 (19:11 +0200)]
Teach SVH computation to ignore more implementation artifacts.

In particular, this version of strict version hash (SVH) works much
like the deriving(Hash)-based implementation did, except that uses a
content-based hash that filters rustc implementation artifacts and
surface syntax artifacts.

Fix #14132.

10 years agosyntax::visit: pub `walk_explicit_self` so impls can call it as defaults do.
Felix S. Klock II [Mon, 12 May 2014 16:58:23 +0000 (18:58 +0200)]
syntax::visit: pub `walk_explicit_self` so impls can call it as defaults do.

drive-by: added some doc.

10 years agoauto merge of #14162 : brson/rust/fixvercmd, r=brson
bors [Thu, 15 May 2014 08:02:11 +0000 (01:02 -0700)]
auto merge of #14162 : brson/rust/fixvercmd, r=brson

Instead of just blindly printing arg[0], use a constant string.

Partial fix for #13582

10 years agoChange dynamic_library::open_external to take ToCStr
Aaron Turon [Mon, 5 May 2014 21:53:57 +0000 (14:53 -0700)]
Change dynamic_library::open_external to take ToCStr

`std::unstable::dynamic_library::open_external` currently takes a
`Path`, but because `Paths` produce normalized strings, this can
change the semantics of lookups in a given environment. This patch
generalizes the function to take a `ToCStr`-bounded type, which
includes both `Path`s and `str`s.

Closes #11650.

10 years agoProcess::new etc should support non-utf8 commands/args
Aaron Turon [Mon, 5 May 2014 21:33:55 +0000 (14:33 -0700)]
Process::new etc should support non-utf8 commands/args

The existing APIs for spawning processes took strings for the command
and arguments, but the underlying system may not impose utf8 encoding,
so this is overly limiting.

The assumption we actually want to make is just that the command and
arguments are viewable as [u8] slices with no interior NULLs, i.e., as
CStrings. The ToCStr trait is a handy bound for types that meet this
requirement (such as &str and Path).

However, since the commands and arguments are often a mixture of
strings and paths, it would be inconvenient to take a slice with a
single T: ToCStr bound. So this patch revamps the process creation API
to instead use a builder-style interface, called `Command`, allowing
arguments to be added one at a time with differing ToCStr
implementations for each.

The initial cut of the builder API has some drawbacks that can be
addressed once issue #13851 (libstd as a facade) is closed. These are
detailed as FIXMEs.

Closes #11650.

[breaking-change]

10 years agoAdd ToCStr impl for &Path and StrBuf
Aaron Turon [Mon, 5 May 2014 21:15:11 +0000 (14:15 -0700)]
Add ToCStr impl for &Path and StrBuf

This is a stopgap until DST (#12938) lands.

Until DST lands, we cannot decompose &str into & and str, so we cannot
usefully take ToCStr arguments by reference (without forcing an
additional & around &str). So we are instead temporarily adding an
instance for &Path and StrBuf, so that we can take ToCStr as owned. When
DST lands, the &Path instance should be removed, the string instances
should be revisted, and arguments bound by ToCStr should be passed by
reference.

FIXMEs have been added accordingly.

10 years agoauto merge of #14133 : db48x/rust/ord-for-mut-refs, r=alexcrichton
bors [Thu, 15 May 2014 05:06:50 +0000 (22:06 -0700)]
auto merge of #14133 : db48x/rust/ord-for-mut-refs, r=alexcrichton

Also Show, which is useful in assertions. Fixes #14074

10 years agoauto merge of #14170 : pcwalton/rust/detildestr-misclibs, r=alexcrichton
bors [Thu, 15 May 2014 02:31:52 +0000 (19:31 -0700)]
auto merge of #14170 : pcwalton/rust/detildestr-misclibs, r=alexcrichton

r? @brson

10 years agolibnum: Remove all uses of `~str` from `libnum`
Patrick Walton [Wed, 14 May 2014 01:08:40 +0000 (18:08 -0700)]
libnum: Remove all uses of `~str` from `libnum`

10 years agolibcollections: Remove most uses of `~str` from `libcollections`
Patrick Walton [Wed, 14 May 2014 01:01:54 +0000 (18:01 -0700)]
libcollections: Remove most uses of `~str` from `libcollections`

10 years agoliburl: Remove all uses of `~str` from `liburl`
Patrick Walton [Wed, 14 May 2014 00:51:05 +0000 (17:51 -0700)]
liburl: Remove all uses of `~str` from `liburl`

10 years agolibterm: Remove all uses of `~str` from `libterm`
Patrick Walton [Wed, 14 May 2014 00:26:41 +0000 (17:26 -0700)]
libterm: Remove all uses of `~str` from `libterm`

10 years agolibtest: Remove all uses of `~str` from `libtest`.
Patrick Walton [Tue, 13 May 2014 23:44:05 +0000 (16:44 -0700)]
libtest: Remove all uses of `~str` from `libtest`.

10 years agolibsync: Remove all uses of `~str` from `libsync`
Patrick Walton [Tue, 13 May 2014 21:57:26 +0000 (14:57 -0700)]
libsync: Remove all uses of `~str` from `libsync`

10 years agolibrand: Remove all uses of `~str` from `librand`
Patrick Walton [Tue, 13 May 2014 21:38:13 +0000 (14:38 -0700)]
librand: Remove all uses of `~str` from `librand`

10 years agolibtime: Remove all uses of `~str` from `libtime`
Patrick Walton [Tue, 13 May 2014 05:24:20 +0000 (22:24 -0700)]
libtime: Remove all uses of `~str` from `libtime`

10 years agolibsemver: Remove all uses of `~str` from `libsemver`
Patrick Walton [Tue, 13 May 2014 04:39:26 +0000 (21:39 -0700)]
libsemver: Remove all uses of `~str` from `libsemver`

10 years agolibglob: Remove all uses of `~str` from `libglob`
Patrick Walton [Tue, 13 May 2014 04:36:30 +0000 (21:36 -0700)]
libglob: Remove all uses of `~str` from `libglob`

10 years agoliblog: Remove all uses of `~str` from `liblog`
Patrick Walton [Tue, 13 May 2014 04:35:40 +0000 (21:35 -0700)]
liblog: Remove all uses of `~str` from `liblog`

10 years agolibgraphviz: Remove all uses of `~str` from `libgraphviz`.
Patrick Walton [Tue, 13 May 2014 04:14:03 +0000 (21:14 -0700)]
libgraphviz: Remove all uses of `~str` from `libgraphviz`.

10 years agolibregex: Remove all uses of `~str` from `libregex`
Patrick Walton [Tue, 13 May 2014 04:12:50 +0000 (21:12 -0700)]
libregex: Remove all uses of `~str` from `libregex`

10 years agoPrint 'rustc' and 'rustdoc' as the command name for --version
Brian Anderson [Mon, 12 May 2014 22:39:07 +0000 (15:39 -0700)]
Print 'rustc' and 'rustdoc' as the command name for --version

Instead of just blindly printing arg[0], use a constant string.
Partial fix for #13582

10 years agolibarena: Remove all uses of `~str` from `libarena`
Patrick Walton [Tue, 13 May 2014 04:06:17 +0000 (21:06 -0700)]
libarena: Remove all uses of `~str` from `libarena`

10 years agolibhexfloat: Remove all uses of `~str` from `libhexfloat`
Patrick Walton [Tue, 13 May 2014 03:35:23 +0000 (20:35 -0700)]
libhexfloat: Remove all uses of `~str` from `libhexfloat`

10 years agolibuuid: Remove all uses of `~str` from `libuuid`.
Patrick Walton [Tue, 13 May 2014 03:33:17 +0000 (20:33 -0700)]
libuuid: Remove all uses of `~str` from `libuuid`.

10 years agolibworkcache: Remove all uses of `~str` from `libworkcache`.
Patrick Walton [Tue, 13 May 2014 03:32:05 +0000 (20:32 -0700)]
libworkcache: Remove all uses of `~str` from `libworkcache`.

10 years agotest: Remove all uses of `~str` from the test suite.
Patrick Walton [Tue, 13 May 2014 00:56:43 +0000 (17:56 -0700)]
test: Remove all uses of `~str` from the test suite.

10 years agoauto merge of #14086 : Ryman/rust/resolve_error_suggestions, r=alexcrichton
bors [Wed, 14 May 2014 19:06:29 +0000 (12:06 -0700)]
auto merge of #14086 : Ryman/rust/resolve_error_suggestions, r=alexcrichton

Provides better help for the resolve failures inside an `impl` if the name matches:
- a field on the self type
- a method on the self type
- a method on the current trait ref (in a trait impl)

Not handling trait method suggestions if in a regular `impl` (as you can see on line 69 of the test), I believe it is possible though.

Also, provides a better message when `self` fails to resolve due to being a static method.

It's using some unsafe pointers to skip copying the larger structures (which are only used in error conditions); it's likely possible to get it working with lifetimes (all the useful refs should outlive the visitor calls) but I haven't really figured that out for this case. (can switch to copying code if wanted)

Closes #2356.

10 years agorustc: Improve error messages for resolve failures.
Kevin Butler [Thu, 8 May 2014 21:35:09 +0000 (22:35 +0100)]
rustc: Improve error messages for resolve failures.

10 years agoupdate valgrind headers
Daniel Micay [Wed, 14 May 2014 16:30:57 +0000 (12:30 -0400)]
update valgrind headers

10 years agoauto merge of #14009 : jcmoyer/rust/bitflags-complement, r=alexcrichton
bors [Wed, 14 May 2014 16:21:25 +0000 (09:21 -0700)]
auto merge of #14009 : jcmoyer/rust/bitflags-complement, r=alexcrichton

I feel that this is a very vital, missing piece of functionality. This adds on to #13072.

Only bits used in the definition of the bitflag are considered for the universe set. This is a bit safer than simply inverting all of the bits in the wrapped value.

```rust
bitflags!(flags Flags: u32 {
    FlagA       = 0x00000001,
    FlagB       = 0x00000010,
    FlagC       = 0x00000100,
    FlagABC     = FlagA.bits
                | FlagB.bits
                | FlagC.bits
})

...

// `Not` implements set complement
assert!(!(FlagB | FlagC) == FlagA);
// `all` and `is_all` are the inverses of `empty` and `is_empty`
assert!(Flags::all() - FlagA == !FlagA);
assert!(FlagABC.is_all());
```

10 years agoauto merge of #14192 : pongad/rust/walkcleanup, r=pcwalton
bors [Wed, 14 May 2014 14:31:45 +0000 (07:31 -0700)]
auto merge of #14192 : pongad/rust/walkcleanup, r=pcwalton

Fixes #14134

10 years agoauto merge of #14191 : luqmana/rust/eu, r=alexcrichton
bors [Wed, 14 May 2014 12:56:18 +0000 (05:56 -0700)]
auto merge of #14191 : luqmana/rust/eu, r=alexcrichton

We were correctly determining the attributes needed for the parameters for extern fns, but when that extern fn was from another crate we never bothered to pass that information along to LLVM. (i.e never called `foreign::add_argument_attributes`).

I've just changed both local and non-local (crate) extern fn's to be dealt with together (through `foreign::register_foreign_item_fn`) so we don't run into something like again.

Fixes #14177.

10 years agoauto merge of #14186 : omasanori/rust/suppress-warnings, r=alexcrichton
bors [Wed, 14 May 2014 11:06:26 +0000 (04:06 -0700)]
auto merge of #14186 : omasanori/rust/suppress-warnings, r=alexcrichton

10 years agoOptimize common path of Once::doit
Stepan Koltsov [Wed, 14 May 2014 10:23:42 +0000 (10:23 +0000)]
Optimize common path of Once::doit

Optimize `Once::doit`: perform optimistic check that initializtion is
already completed.  `load` is much cheaper than `fetch_add` at least
on x86_64.

Verified with this test:

```
static mut o: one::Once = one::ONCE_INIT;
unsafe {
    loop {
        let start = time::precise_time_ns();
        let iters = 50000000u64;
        for _ in range(0, iters) {
            o.doit(|| { println!("once!"); });
        }
        let end = time::precise_time_ns();
        let ps_per_iter = 1000 * (end - start) / iters;
        println!("{} ps per iter", ps_per_iter);

        // confuse the optimizer
        o.doit(|| { println!("once!"); });
    }
}
```

Test executed on Mac, Intel Core i7 2GHz. Result is:
* 20ns per iteration without patch
*  4ns per iteration with this patch applied

Once.doit could be even faster (800ps per iteration), if `doit` function
was split into a pair of `doit`/`doit_slow`, and `doit` marked as
`#[inline]` like this:

```
#[inline(always)]
pub fn doit(&self, f: ||) {
    if self.cnt.load(atomics::SeqCst) < 0 {
        return
    }

    self.doit_slow(f);
}

fn doit_slow(&self, f: ||) { ... }
```

10 years agoauto merge of #14179 : luqmana/rust/acp, r=alexcrichton
bors [Wed, 14 May 2014 09:36:23 +0000 (02:36 -0700)]
auto merge of #14179 : luqmana/rust/acp, r=alexcrichton

It's a bit odd to single out just android when we don't do this for any other cross compiling targets. Android builds will still work since we just pass the full path for gcc and ar with `-C linker` and `-C ar`.

I did add the flag to compiletest though so it can find gdb. Though, i'm pretty sure we don't run debuginfo tests on android anyways right now.

[breaking-change]

10 years agoImplement set complement and universe for bitflags
J.C. Moyer [Wed, 7 May 2014 05:54:44 +0000 (01:54 -0400)]
Implement set complement and universe for bitflags

10 years agoauto merge of #14169 : alexcrichton/rust/atomics, r=sanxiyn
bors [Wed, 14 May 2014 08:06:24 +0000 (01:06 -0700)]
auto merge of #14169 : alexcrichton/rust/atomics, r=sanxiyn

This module is a foundation on which many other algorithms are built. When hardware support is missing, stubs are provided in libcompiler-rt.a, so this should be available on all platforms.

10 years agodefine Eq,TotalEq,Ord,TotalOrd for &mut T
Daniel Brooks [Mon, 12 May 2014 09:04:07 +0000 (02:04 -0700)]
define Eq,TotalEq,Ord,TotalOrd for &mut T

Also Show, which is useful in assertions. Fixes #14074

10 years agocore: Allow using failure outside of libcore
Alex Crichton [Tue, 13 May 2014 04:23:13 +0000 (21:23 -0700)]
core: Allow using failure outside of libcore

Due to our excellent macro hygiene, this involves having a global path and a
hidden module in libcore itself.

10 years agocore: Document should_not_exist's existence
Alex Crichton [Tue, 13 May 2014 04:22:50 +0000 (21:22 -0700)]
core: Document should_not_exist's existence

Explain why it should not exist, and the plan of attack for removing it.

10 years agocore: Add a crate doc block
Alex Crichton [Tue, 13 May 2014 04:22:35 +0000 (21:22 -0700)]
core: Add a crate doc block

10 years agocore: Inherit the atomics module
Alex Crichton [Tue, 13 May 2014 04:30:48 +0000 (21:30 -0700)]
core: Inherit the atomics module

10 years agoRemoved unnecessary arguments for walk_* functions
Michael Darakananda [Wed, 14 May 2014 06:20:25 +0000 (02:20 -0400)]
Removed unnecessary arguments for walk_* functions

10 years agolibrustc: Make sure to add argument attributes to extern fns from non-local crates.
Luqman Aden [Wed, 14 May 2014 06:07:33 +0000 (02:07 -0400)]
librustc: Make sure to add argument attributes to extern fns from non-local crates.

10 years agoGet rid of the android-cross-path flag to rustc.
Luqman Aden [Tue, 13 May 2014 18:44:30 +0000 (14:44 -0400)]
Get rid of the android-cross-path flag to rustc.

There's no need to include this specific flag just for android. We can
already deal with what it tries to solve by using -C linker=/path/to/cc
and -C ar=/path/to/ar. The Makefiles for rustc already set this up when
we're crosscompiling.

I did add the flag to compiletest though so it can find gdb. Though, I'm
pretty sure we don't run debuginfo tests on android anyways right now.

[breaking-change]

10 years agoauto merge of #14178 : alexcrichton/rust/more-ignores, r=brson
bors [Wed, 14 May 2014 04:41:25 +0000 (21:41 -0700)]
auto merge of #14178 : alexcrichton/rust/more-ignores, r=brson

It was thought that these failures only happened on windows, turns out they
happen on any 32-bit machine.

cc #14064

10 years agoauto merge of #13127 : kballard/rust/read_at_least, r=alexcrichton
bors [Wed, 14 May 2014 03:01:28 +0000 (20:01 -0700)]
auto merge of #13127 : kballard/rust/read_at_least, r=alexcrichton

Reader.read_at_least() ensures that at least a given number of bytes
have been read. The most common use-case for this is ensuring at least 1
byte has been read. If the reader returns 0 enough times in a row, a new
error kind NoProgress will be returned instead of looping infinitely.

This change is necessary in order to properly support Readers that
repeatedly return 0, either because they're broken, or because they're
attempting to do a non-blocking read on some resource that never becomes
available.

Also add .push() and .push_at_least() methods. push() is like read() but
the results are appended to the passed Vec.

Remove Reader.fill() and Reader.push_exact() as they end up being thin
wrappers around read_at_least() and push_at_least().

[breaking-change]

10 years agoio: Add .read_at_least() to Reader
Kevin Ballard [Tue, 25 Mar 2014 06:22:23 +0000 (23:22 -0700)]
io: Add .read_at_least() to Reader

Reader.read_at_least() ensures that at least a given number of bytes
have been read. The most common use-case for this is ensuring at least 1
byte has been read. If the reader returns 0 enough times in a row, a new
error kind NoProgress will be returned instead of looping infinitely.

This change is necessary in order to properly support Readers that
repeatedly return 0, either because they're broken, or because they're
attempting to do a non-blocking read on some resource that never becomes
available.

Also add .push() and .push_at_least() methods. push() is like read() but
the results are appended to the passed Vec.

Remove Reader.fill() and Reader.push_exact() as they end up being thin
wrappers around read_at_least() and push_at_least().

[breaking-change]

10 years agoauto merge of #14187 : alexcrichton/rust/rollup, r=alexcrichton
bors [Wed, 14 May 2014 01:31:51 +0000 (18:31 -0700)]
auto merge of #14187 : alexcrichton/rust/rollup, r=alexcrichton

Closes #14184 (std: Move the owned module from core to std)
Closes #14183 (Allow blocks in const expressions)
Closes #14176 (Add tests for from_bits.)
Closes #14175 (Replaced ~T by Box<T> in manual)
Closes #14173 (Implements Default trait for BigInt and BigUint)
Closes #14171 (Fix #8391)
Closes #14159 (Clean up unicode code in libstd)
Closes #14126 (docs: Add a not found page)
Closes #14123 (add a line to the example to clarify semantics)
Closes #14106 (Pretty printer improvements)
Closes #14083 (rustllvm: Add LLVMRustArrayType)
Closes #13957 (io: Implement process wait timeouts)

10 years agoio: Implement process wait timeouts
Alex Crichton [Mon, 5 May 2014 23:58:42 +0000 (16:58 -0700)]
io: Implement process wait timeouts

This implements set_timeout() for std::io::Process which will affect wait()
operations on the process. This follows the same pattern as the rest of the
timeouts emerging in std::io::net.

The implementation was super easy for everything except libnative on unix
(backwards from usual!), which required a good bit of signal handling. There's a
doc comment explaining the strategy in libnative. Internally, this also required
refactoring the "helper thread" implementation used by libnative to allow for an
extra helper thread (not just the timer).

This is a breaking change in terms of the io::Process API. It is now possible
for wait() to fail, and subsequently wait_with_output(). These two functions now
return IoResult<T> due to the fact that they can time out.

Additionally, the wait_with_output() function has moved from taking `&mut self`
to taking `self`. If a timeout occurs while waiting with output, the semantics
are undesirable in almost all cases if attempting to re-wait on the process.
Equivalent functionality can still be achieved by dealing with the output
handles manually.

[breaking-change]

cc #13523

10 years agorustllvm: Add LLVMRustArrayType
klutzy [Sat, 10 May 2014 08:30:55 +0000 (17:30 +0900)]
rustllvm: Add LLVMRustArrayType

LLVM internally uses `uint64_t` for array size, but the corresponding
C API (`LLVMArrayType`) uses `unsigned int` so ths value is truncated.
Therefore rustc generates wrong type for fixed-sized large vector e.g.
`[0 x i8]` for `[0u8, ..(1 << 32)]`.

This patch adds `LLVMRustArrayType` function for `uint64_t` support.

10 years agosyntax: Improve --pretty normal slightly
Alex Crichton [Sun, 11 May 2014 08:34:28 +0000 (01:34 -0700)]
syntax: Improve --pretty normal slightly

When printing doc comments, always put a newline after them in a macro
invocation to ensure that a line-doc-comment doesn't consume remaining tokens on
the line.

10 years agosyntax: Preserve attributes in #[deriving]
Alex Crichton [Sun, 11 May 2014 08:11:33 +0000 (01:11 -0700)]
syntax: Preserve attributes in #[deriving]

Now that the #[deriving] attribute is removed, the raw_pointers_deriving lint
was broken. This commit restores the lint by preserving lint attributes
across #[deriving] to the implementations and using #[automatically_derived] as
the trigger for activating the lint.

10 years agotest: Give a test a bigger stack for pretty printing
Alex Crichton [Sun, 11 May 2014 05:02:59 +0000 (22:02 -0700)]
test: Give a test a bigger stack for pretty printing

10 years agosyntax: Print suffixed token literals correctly
Alex Crichton [Sun, 11 May 2014 04:57:49 +0000 (21:57 -0700)]
syntax: Print suffixed token literals correctly

Previously, literals "1i" were printed as "1". This fixes the
numeric-method-autoexport test for pretty printing.

10 years agotest: Ignore a pretty expanded failing test
Alex Crichton [Sun, 11 May 2014 04:57:11 +0000 (21:57 -0700)]
test: Ignore a pretty expanded failing test

When expanding, an extra unsafe block is generated which is currently not
handled well.

10 years agotest: Fix a pretty printing test
Alex Crichton [Sun, 11 May 2014 04:46:46 +0000 (21:46 -0700)]
test: Fix a pretty printing test

The pretty printer handles inlines comments quite badly

10 years agosyntax: Fix parsing << with closure types
Alex Crichton [Sun, 11 May 2014 04:27:44 +0000 (21:27 -0700)]
syntax: Fix parsing << with closure types

This uses the trick of replacing the << token with a < token to parse closure
types correctly.

Closes #13324

10 years agosyntax: Fix printing INT64_MIN
Alex Crichton [Sun, 11 May 2014 03:16:51 +0000 (20:16 -0700)]
syntax: Fix printing INT64_MIN

Integers are always parsed as a u64 in libsyntax, but they're stored as i64. The
parser and pretty printer both printed an i64 instead of u64, sometimes
introducing an extra negative sign.

10 years agoTouch up and rebase previous commits
Alex Crichton [Sun, 11 May 2014 00:39:08 +0000 (17:39 -0700)]
Touch up and rebase previous commits

* Added `// no-pretty-expanded` to pretty-print a test, but not run it through
  the `expanded` variant.
* Removed #[deriving] and other expanded attributes after they are expanded
* Removed hacks around &str and &&str and friends (from both the parser and the
  pretty printer).
* Un-ignored a bunch of tests

10 years agocompiletest: Test `--pretty expanded`
klutzy [Wed, 16 Apr 2014 05:29:02 +0000 (14:29 +0900)]
compiletest: Test `--pretty expanded`

After testing `--pretty normal`, it tries to run `--pretty expanded` and
typecheck output.
Here we don't check convergence since it really diverges: for every
iteration, some extra lines (e.g.`extern crate std`) are inserted.

Some tests are `ignore-pretty`-ed since they cause various issues
with `--pretty expanded`.

10 years agocompiletest: Modernize typenames
klutzy [Wed, 16 Apr 2014 04:56:39 +0000 (13:56 +0900)]
compiletest: Modernize typenames