]> git.lizzy.rs Git - rust.git/log
rust.git
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 #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 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

10 years agotest: Add missing `#![feature(managed_boxes)]`
klutzy [Thu, 17 Apr 2014 09:20:37 +0000 (18:20 +0900)]
test: Add missing `#![feature(managed_boxes)]`

The tests use managed boxes, but are not perfectly feature-gated because
they use `@` inside macros. (It causes issue after `--pretty expanded`.)

10 years agolibsyntax: Workaround pprust `for` issue
klutzy [Thu, 17 Apr 2014 08:35:36 +0000 (17:35 +0900)]
libsyntax: Workaround pprust `for` issue

10 years agopprust: Remove unnecessary && of `print_tt`
klutzy [Fri, 18 Apr 2014 06:48:47 +0000 (15:48 +0900)]
pprust: Remove unnecessary && of `print_tt`

10 years agopprust: Print `&&e` instead of `& &e`
klutzy [Fri, 18 Apr 2014 06:44:25 +0000 (15:44 +0900)]
pprust: Print `&&e` instead of `& &e`

10 years agopprust: Fix asm output
klutzy [Thu, 17 Apr 2014 08:35:40 +0000 (17:35 +0900)]
pprust: Fix asm output

10 years agopprust: Add parentheses to some Expr
klutzy [Wed, 16 Apr 2014 20:33:58 +0000 (05:33 +0900)]
pprust: Add parentheses to some Expr

Some `Expr` needs parentheses when printed. For example, without
parentheses, `ExprUnary(UnNeg, ExprBinary(BiAdd, ..))` becomes
`-lhs + rhs` which is wrong.

Those cases don't appear in ordinary code (since parentheses are
explicitly added) but they can appear in manually crafted ast by
extensions.

10 years agorustc: Make std_inject valid for pretty-printer
klutzy [Wed, 16 Apr 2014 05:32:35 +0000 (14:32 +0900)]
rustc: Make std_inject valid for pretty-printer

Inject `extern crate {std, native}` before `use` statements.
Add `#![feature(glob)]` since `use std::prelude::*` is used.

(Unfortunately `rustc --pretty expanded` does not converge,
since `extern crate` and `use std::prelude::*` is injected at every
iteration.)

10 years agoadd a line to the example to clarify semantics
Zooko Wilcox-O'Hearn [Mon, 12 May 2014 03:57:04 +0000 (03:57 +0000)]
add a line to the example to clarify semantics

This is to clarify that match construct doesn't define a new variable, since I
observed a person reading the Rust tutorial who seemed to incorrectly think
that it did. Fixes https://github.com/mozilla/rust/issues/13571 .

10 years agodocs: Add a not found page
Richo Healey [Mon, 12 May 2014 06:10:40 +0000 (23:10 -0700)]
docs: Add a not found page

10 years agostd: Rename str::Normalizations to str::Decompositions
Florian Zeitz [Mon, 12 May 2014 20:44:21 +0000 (22:44 +0200)]
std: Rename str::Normalizations to str::Decompositions

The Normalizations iterator has been renamed to Decompositions.
It does not currently include all forms of Unicode normalization,
but only encompasses decompositions.
If implemented recomposition would likely be a separate iterator
which works on the result of this one.

[breaking-change]

10 years agocore: Move Hangul decomposition into unicode.rs
Florian Zeitz [Mon, 12 May 2014 20:25:38 +0000 (22:25 +0200)]
core: Move Hangul decomposition into unicode.rs

10 years agocore: Use appropriately sized integers for codepoints and bytes
Florian Zeitz [Mon, 12 May 2014 19:53:53 +0000 (21:53 +0200)]
core: Use appropriately sized integers for codepoints and bytes

10 years agostd, core: Generate unicode.rs using unicode.py
Florian Zeitz [Mon, 12 May 2014 17:56:41 +0000 (19:56 +0200)]
std, core: Generate unicode.rs using unicode.py

10 years agocheck_match: get rid of superfluous clones
Edward Wang [Tue, 13 May 2014 06:30:21 +0000 (14:30 +0800)]
check_match: get rid of superfluous clones

10 years agoFix #8391
Edward Wang [Tue, 13 May 2014 05:20:52 +0000 (13:20 +0800)]
Fix #8391

Closes #8391

10 years agoImplements Default trait for BigInt and BigUint
Piotr Jawniak [Tue, 13 May 2014 09:00:11 +0000 (11:00 +0200)]
Implements Default trait for BigInt and BigUint

10 years agoReplaced ~T by Box<T> in manual
Adolfo Ochagavía [Tue, 13 May 2014 13:43:10 +0000 (15:43 +0200)]
Replaced ~T by Box<T> in manual

10 years agoAdd tests for from_bits.
OGINO Masanori [Tue, 13 May 2014 14:12:55 +0000 (23:12 +0900)]
Add tests for from_bits.

Signed-off-by: OGINO Masanori <masanori.ogino@gmail.com>
10 years agoAllow blocks in const expressions
Marvin Löbel [Sun, 4 May 2014 08:39:11 +0000 (10:39 +0200)]
Allow blocks in const expressions

Only blocks with tail expressions that are const expressions
and items are allowed.

10 years agostd: Move the owned module from core to std
Alex Crichton [Tue, 13 May 2014 21:58:29 +0000 (14:58 -0700)]
std: Move the owned module from core to std

The compiler was updated to recognize that implementations for ty_uniq(..) are
allowed if the Box lang item is located in the current crate. This enforces the
idea that libcore cannot allocated, and moves all related trait implementations
from libcore to libstd.

This is a breaking change in that the AnyOwnExt trait has moved from the any
module to the owned module. Any previous users of std::any::AnyOwnExt should now
use std::owned::AnyOwnExt instead. This was done because the trait is intended
for Box traits and only Box traits.

[breaking-change]

10 years agoSuppress warnings on 32bit platforms.
OGINO Masanori [Tue, 13 May 2014 15:44:04 +0000 (00:44 +0900)]
Suppress warnings on 32bit platforms.

On 32bit platforms, int is the same as i32, so 0xffffffff is "out of
range." Annotating variables as u32 fixes the problems.

Signed-off-by: OGINO Masanori <masanori.ogino@gmail.com>
10 years agoSuppress a "unused variable" warning.
OGINO Masanori [Tue, 13 May 2014 15:41:58 +0000 (00:41 +0900)]
Suppress a "unused variable" warning.

Signed-off-by: OGINO Masanori <masanori.ogino@gmail.com>
10 years agoauto merge of #14075 : Rufflewind/rust/patch-3, r=alexcrichton
bors [Tue, 13 May 2014 23:01:48 +0000 (16:01 -0700)]
auto merge of #14075 : Rufflewind/rust/patch-3, r=alexcrichton

- Use Unicode-aware versions of `CreateProcess` (Fixes #13815) and `Get/FreeEnvironmentStrings`.
    - Includes a helper function `os::win32::as_mut_utf16_p`, which does the same thing as `os::win32::as_utf16_p` except the pointer is mutable.
    - Fixed `make_command_line` to handle Unicode correctly.
- Tests for the above.

10 years agoTest Unicode support of process spawning
Phil Ruffwind [Wed, 7 May 2014 23:26:16 +0000 (19:26 -0400)]
Test Unicode support of process spawning

Added a run-pass test to ensure that processes can be correctly spawned
using non-ASCII arguments, working directory, and environment variables.
It also tests Unicode support of os::env_as_bytes.

An additional assertion was added to the test for make_command_line to
verify it handles Unicode correctly.