Commit Graph

28941 Commits

Author SHA1 Message Date
Felix S. Klock II
39b271f4a3 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`.
2014-05-15 13:50:42 -07:00
Kevin Butler
b9e4fcbf04 shootout-mandelbrot: Precalc initial values & use SIMD in the main loop. +80-100% 2014-05-15 13:50:39 -07:00
Kevin Butler
03f48534b3 shootout-mandlebrot: calculate two bits of the result per inner loop, +10-15% 2014-05-15 13:50:39 -07:00
Alex Crichton
a7bee7b05d 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
2014-05-15 13:50:37 -07:00
Daniel Micay
e043644cea 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.
2014-05-15 13:50:36 -07:00
Alex Crichton
8211539114 Register new snapshots 2014-05-15 13:50:34 -07:00
Aaron Turon
912a9675c0 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
2014-05-15 13:50:33 -07:00
Kevin Ballard
d547de998d 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.
2014-05-15 13:50:29 -07:00
Corey Richardson
4bcc4d76a0 rustdoc: functions in ffi blocks are unsafe
Fixes #14188
2014-05-15 13:50:28 -07:00
Brian Anderson
ef788d51dd 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.
2014-05-15 13:50:24 -07:00
Alex Crichton
bfbd732dae 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.
2014-05-15 13:50:14 -07:00
bors
182c96c921 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.
2014-05-15 13:17:28 -07:00
bors
ba5f53009a 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.)
2014-05-15 11:22:02 -07:00
bors
fbd8f4a3a3 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.
2014-05-15 08:36:50 -07:00
bors
6a2b3d1471 auto merge of #14198 : thestinger/rust/valgrind, r=luqmana 2014-05-15 07:06:47 -07:00
Hanno Braun
b7676f2df5 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.
2014-05-15 13:12:53 +00:00
Huon Wilson
18c13de5e6 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.
2014-05-15 23:04:09 +10:00
Huon Wilson
b1ee3200b5 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.
2014-05-15 23:04:09 +10:00
Huon Wilson
19f9181654 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.
2014-05-15 23:04:09 +10:00
Huon Wilson
2f0f017d3e test: implement a no-alloc -> &str method for TestName.
This is far cheaper than the `.to_str` technique that was used previously.
2014-05-15 21:17:35 +10:00
bors
f2c4c88ff1 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: ||) { ... }
```
2014-05-15 04:16:47 -07:00
bors
fedffa785e 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.
2014-05-15 02:41:50 -07:00
Felix S. Klock II
5236af8c0f 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.)
2014-05-15 11:09:26 +02:00
Felix S. Klock II
930308b16e 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.
2014-05-15 11:09:26 +02:00
Felix S. Klock II
a92d162026 Some basic acceptance tests for better SVH. 2014-05-15 11:09:26 +02:00
Felix S. Klock II
b9ed9ed5ad 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.
2014-05-15 11:09:18 +02:00
Felix S. Klock II
d6cf0dfbab syntax::visit: pub walk_explicit_self so impls can call it as defaults do.
drive-by: added some doc.
2014-05-15 10:55:02 +02:00
bors
579e0a5f55 auto merge of #14162 : brson/rust/fixvercmd, r=brson
Instead of just blindly printing arg[0], use a constant string.

Partial fix for #13582
2014-05-15 01:02:11 -07:00
Aaron Turon
e71202aecf 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.
2014-05-14 22:52:31 -07:00
Aaron Turon
046062d3bf 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]
2014-05-14 22:52:31 -07:00
Aaron Turon
8f9cbe08c6 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.
2014-05-14 22:42:46 -07:00
bors
73a68cdba0 auto merge of #14133 : db48x/rust/ord-for-mut-refs, r=alexcrichton
Also Show, which is useful in assertions. Fixes #14074
2014-05-14 22:06:50 -07:00
bors
e10fd31721 auto merge of #14170 : pcwalton/rust/detildestr-misclibs, r=alexcrichton
r? @brson
2014-05-14 19:31:52 -07:00
Patrick Walton
351a564df5 libnum: Remove all uses of ~str from libnum 2014-05-14 18:29:14 -07:00
Patrick Walton
1ef8246946 libcollections: Remove most uses of ~str from libcollections 2014-05-14 18:29:14 -07:00
Patrick Walton
dfe021625a liburl: Remove all uses of ~str from liburl 2014-05-14 18:29:14 -07:00
Patrick Walton
ded860c0e8 libterm: Remove all uses of ~str from libterm 2014-05-14 18:29:13 -07:00
Patrick Walton
93499b1eaf libtest: Remove all uses of ~str from libtest. 2014-05-14 18:29:13 -07:00
Patrick Walton
1440e09839 libsync: Remove all uses of ~str from libsync 2014-05-14 18:29:13 -07:00
Patrick Walton
7abf6f1346 librand: Remove all uses of ~str from librand 2014-05-14 18:29:13 -07:00
Patrick Walton
6415d06616 libtime: Remove all uses of ~str from libtime 2014-05-14 18:29:13 -07:00
Patrick Walton
5a93b4f192 libsemver: Remove all uses of ~str from libsemver 2014-05-14 18:29:12 -07:00
Patrick Walton
30dbcf5f88 libglob: Remove all uses of ~str from libglob 2014-05-14 18:29:12 -07:00
Patrick Walton
8a1aaac396 liblog: Remove all uses of ~str from liblog 2014-05-14 18:29:12 -07:00
Patrick Walton
e786a745b5 libgraphviz: Remove all uses of ~str from libgraphviz. 2014-05-14 18:29:12 -07:00
Patrick Walton
ec5911b2a6 libregex: Remove all uses of ~str from libregex 2014-05-14 18:29:12 -07:00
Kevin Ballard
ba7844a7ff Change StrBuf::from_utf8() to return Result
This allows the original vector to be recovered in the event that it is
not UTF-8.

[breaking-change]
2014-05-14 17:35:55 -07:00
Kevin Ballard
d0f3cb05df Change str::from_utf8_owned() to return Result
This allows the original vector to be recovered in the event that it is
not valid UTF-8.

[breaking-change]
2014-05-14 17:35:55 -07:00
Chris Morgan
5b13ddb5f2 Use assertions in find_with_or_insert_with example
This lets us test it automatically and also makes it more obvious what
the expected result is.
2014-05-15 10:28:48 +10:00
Chris Morgan
73dc1e016d Rename HashMap.mangle to find_with_or_insert_with.
This also entails swapping the order of the find and insert callbacks so
that their order matches the order of the terms in the method name.
2014-05-15 10:13:36 +10:00