Commit Graph

41074 Commits

Author SHA1 Message Date
bors
e4f9ddb878 Auto merge of #24180 - huonw:optimise-max-etc, r=alexcrichton
The main change in this patch is removing the use of `Option` inside the
inner loops of those functions to avoid comparisons where one branch
will only trigger on the first pass through the loop.

The included benchmarks go from:

    test bench_max    ... bench:       372 ns/iter (+/- 118)
    test bench_max_by ... bench:       428 ns/iter (+/- 33)
    test bench_max_by2 ... bench:      7128 ns/iter (+/- 326)

to:

    test bench_max    ... bench:       317 ns/iter (+/- 64)
    test bench_max_by ... bench:       356 ns/iter (+/- 270)
    test bench_max_by2 ... bench:      1387 ns/iter (+/- 183)

Problem noticed in http://www.reddit.com/r/rust/comments/31syce/using_iterators_to_find_the_index_of_the_min_or/
2015-04-10 07:54:18 +00:00
Luke Gallagher
2a88b79223 Add tests for E-needstest issues
Closes #20772
Closes #20939
Closes #21950
Closes #22034
2015-04-10 16:12:54 +10:00
Huon Wilson
c2258d6d04 Optimise Iterator::{max, max_by, min, min_by}.
The main change in this patch is removing the use of `Option` inside the
inner loops of those functions to avoid comparisons where one branch
will only trigger on the first pass through the loop.

The included benchmarks go from:

    test bench_max    ... bench:       372 ns/iter (+/- 118)
    test bench_max_by ... bench:       428 ns/iter (+/- 33)
    test bench_max_by2 ... bench:      7128 ns/iter (+/- 326)

to:

    test bench_max    ... bench:       317 ns/iter (+/- 64)
    test bench_max_by ... bench:       356 ns/iter (+/- 270)
    test bench_max_by2 ... bench:      1387 ns/iter (+/- 183)

Problem noticed in http://www.reddit.com/r/rust/comments/31syce/using_iterators_to_find_the_index_of_the_min_or/
2015-04-10 14:42:17 +10:00
Richo Healey
64da4e171d fmt: Assume that we'll only ever see 32 or 64 bit pointers 2015-04-09 18:06:01 -07:00
Richo Healey
d8bb08037f test: Unignore test for fixed issue #20676 2015-04-09 18:03:48 -07:00
Richo Healey
333eb85d4b fmt: {:p#} formats pointers padded to native width 2015-04-09 18:03:47 -07:00
Aaron Turon
76d468ae26 Ensure that .join().unwrap() works
Makes `Any + Send` implement `Debug`.

Fixes #21291
2015-04-09 17:33:17 -07:00
Alex Crichton
33a2191d0b std: Clean up process spawn impl on unix
* De-indent quite a bit by removing usage of FnOnce closures
* Clearly separate code for the parent/child after the fork
* Use `fs2::{File, OpenOptions}` instead of calling `open` manually
* Use RAII to close I/O objects wherever possible
* Remove loop for closing all file descriptors, all our own ones are now
  `CLOEXEC` by default so they cannot be inherited
2015-04-09 17:09:37 -07:00
Alex Crichton
d6c72306c8 std: Set CLOEXEC for all fds opened on unix
This commit starts to set the CLOEXEC flag for all files and sockets opened by
the standard library by default on all unix platforms. There are a few points of
note in this commit:

* The implementation is not 100% satisfactory in the face of threads. File
  descriptors only have the `F_CLOEXEC` flag set *after* they are opened,
  allowing for a fork/exec to happen in the middle and leak the descriptor.
  Some platforms do support atomically opening a descriptor while setting the
  `CLOEXEC` flag, and it is left as a future extension to bind these apis as it
  is unclear how to do so nicely at this time.

* The implementation does not offer a method of opting into the old behavior of
  not setting `CLOEXEC`. This will possibly be added in the future through
  extensions on `OpenOptions`, for example.

* This change does not yet audit any Windows APIs to see if the handles are
  inherited by default by accident.

This is a breaking change for users who call `fork` or `exec` outside of the
standard library itself and expect file descriptors to be inherted. All file
descriptors created by the standard library will no longer be inherited.

[breaking-change]
2015-04-09 17:07:02 -07:00
Steve Klabnik
7bb0cd76f3 Write the 'primitive types' section of TRPL
A brief introduction to each type, with pointers to the primitive pages
for more info.
2015-04-09 20:05:10 -04:00
bors
6b95d8bed8 Auto merge of #24205 - brson:debug, r=alexcrichton
This makes the default configuration fully optimized, with no debugging options, no llvm asserts, renames --enable-debug to --enable-debug-assertions, and adds --enable-debug as a blanket option that toggles various things, per #17665. It does not add a `--enable-release` flag since that would be a no-op.

cc @nrc

Fixes https://github.com/rust-lang/rust/issues/22390
Fixes https://github.com/rust-lang/rust/issues/17081
Partially addresses https://github.com/rust-lang/rust/issues/17665
2015-04-09 23:52:02 +00:00
Steve Klabnik
bf88539cc9 TRPL: new introduction 2015-04-09 19:39:06 -04:00
Steve Klabnik
9eb85288c1 Copyediting for 'variable bindings' 2015-04-09 19:07:32 -04:00
bors
88fc543866 Auto merge of #24232 - Manishearth:rollup, r=Manishearth
None
2015-04-09 20:38:36 +00:00
Manish Goregaokar
ea731797b8 fixup windows std_misc 2015-04-10 02:09:19 +05:30
Niko Matsakis
8578fee5d8 Don't use skolemized parameters but rather fresh variables in
coherence. Skolemized parameters wind up preventing unification.
Surprised we had no test for this! Fixes #24241.
2015-04-09 15:57:04 -04:00
Corey Farwell
69f63e9c72 Indicate keyword in doc comment is code-like 2015-04-09 12:02:14 -07:00
Manish Goregaokar
53a609b1df Rollup merge of #24217 - aturon:iterator-fixes, r=alexcrichton 2015-04-10 00:24:45 +05:30
Manish Goregaokar
ede25fe5d1 Rollup merge of #24225 - nrc:for-span, r=pnkfelix 2015-04-10 00:24:45 +05:30
Manish Goregaokar
ce825ab37b Rollup merge of #24170 - omo:omo-typo-fix, r=steveklabnik
Can anyone take a look? Very trivial.
2015-04-10 00:24:45 +05:30
Manish Goregaokar
27ecaa236b Rollup merge of #24221 - nrc:debug-loc, r=sfackler 2015-04-10 00:24:44 +05:30
Manish Goregaokar
b389207975 Rollup merge of #24218 - lstat:remove-ignore-tidy, r=alexcrichton
This is a really minor issue. I noticed some tests no longer need the ignore
tidy comment directive.

A quick grep turned up the following files:

    src/test/compile-fail/bad-mid-path-type-params.rs
    src/test/compile-fail/bad-sized.rs
    src/test/compile-fail/coherence-default-trait-impl.rs
    src/test/compile-fail/coherence-orphan.rs
    src/test/compile-fail/issue-8767.rs
    src/test/compile-fail/lint-stability.rs
    src/test/compile-fail/lint-uppercase-variables.rs
    src/test/compile-fail/typeck-default-trait-impl-outside-crate.rs
    src/test/compile-fail/use-after-move-implicity-coerced-object.rs
    src/test/debuginfo/gdb-pretty-std.rs

It didn't seem like it was worth opening an issue for this, but if that is not
the case (i.e. it is required), I'll open one up. Thanks!
2015-04-10 00:24:44 +05:30
Manish Goregaokar
1a6e100f72 Rollup merge of #24216 - alexcrichton:stabilize-from-raw-os-error, r=aturon
This commit stabilizes the old `io::Error::from_os_error` after being renamed to
use the `raw_os_error` terminology instead. This function is often useful when
writing bindings to OS functions but only actually converting to an I/O error at
a later point.
2015-04-10 00:24:44 +05:30
Manish Goregaokar
cdfbb11f68 Rollup merge of #24215 - alexcrichton:stabilize-clone-from, r=aturon
This method hasn't really changed since is inception, and it can often be a
nice performance win for some situations. This method also imposes no burden on
implementors or users of `Clone` as it's just a default method on the side.
2015-04-10 00:24:44 +05:30
Manish Goregaokar
5daee19eca Rollup merge of #24212 - alexcrichton:destabilize-begin-unwind, r=huonw
Now that we have a `#[allow_internal_unstable]` attribute for macros there's no
need for these two `begin_unwind` functions to be stable. Right now the `panic!`
interface is the only one we wish to stabilize, so remove the stability markers
from these functions.

While this is a breaking change, it is highly unlikely to break any actual code.
It is recommended to use the `panic!` macro instead if it breaks explicit calls
into `std::rt`.

[breaking-change]
cc #24208
2015-04-10 00:24:43 +05:30
Manish Goregaokar
4e466e730b Rollup merge of #24207 - kmcallister:llvm-plugin, r=brson
r? @brson

I'm using this to integrate rustc with [american-fuzzy-lop](http://lcamtuf.coredump.cx/afl/). Building with afl instrumentation is no different from loading any other plugin library.

I'd like this PR to include a `run-make` test with a custom LLVM pass; however I'm not sure it's worth the trouble of building C++ code and linking LLVM from the test suite (are there existing tests that do this?)
2015-04-10 00:24:43 +05:30
Manish Goregaokar
2dffe78979 Rollup merge of #24205 - brson:debug, r=alexcrichton
This makes the default configuration fully optimized, with no debugging options, no llvm asserts, renames --enable-debug to --enable-debug-assertions, and adds --enable-debug as a blanket option that toggles various things, per #17665. It does not add a `--enable-release` flag since that would be a no-op.

cc @nrc

Fixes https://github.com/rust-lang/rust/issues/22390
Fixes https://github.com/rust-lang/rust/issues/17081
Partially addresses https://github.com/rust-lang/rust/issues/17665
2015-04-10 00:24:43 +05:30
Manish Goregaokar
67fa4d3a0c Rollup merge of #24193 - lstat:needstest, r=alexcrichton
Closes #22289
Closes #22370
Closes #22384
2015-04-10 00:24:42 +05:30
Manish Goregaokar
3b87140299 Rollup merge of #24191 - nikomatsakis:issue-20791, r=pnkfelix
Modify the ExprUseVisitor to walk each part of an AutoRef, and in
particular to treat an AutoUnsize as as kind of \"instantaneous\" borrow
of the value being unsized. This prevents us from feeding uninitialized
data.

This caused a problem for the eager reborrow of comparison traits,
because that wound up introducing a \"double AutoRef\", which was not
being thoroughly checked before but turned out not to type check.
Fortunately, we can just remove that \"eager reborrow\" as it is no longer
needed now that `PartialEq` doesn't force both LHS and RHS to have the
same type (and even if we did have this problem, the better way would be
to lean on introducing a common supertype).

Fixes #20791.

r? @nrc
2015-04-10 00:24:42 +05:30
Brian Anderson
0e0c841bd5 Nightly gets LLVM assertions 2015-04-09 11:51:46 -07:00
Andrew Paseltiner
644a75ecd1 Fix borrow docs 2015-04-09 12:51:19 -04:00
Aaron Turon
c3aa05752c Add regression test for #19097
Closes #19097
2015-04-09 09:29:40 -07:00
Thiago Carvalho
549bd55eed resurrect research paper list #24004 2015-04-09 18:07:33 +02:00
Aaron Turon
e3f324cd9d Improve bounds in Iterator API
This commit changes `Iterator`'s API by:

* Generalizing bounds from `Iterator` to `IntoIterator` whenever
  possible, matching the semantics and ergonomics of `for` loops.

* Tightens up a few method-level bounds so that you get an error
  earlier. For example, `rev` did not require `DoubleEndedIterator` even
  though the result is only an `Iterator` when the original iterator was
  double-ended.

Closes #23587

The bound-tightening is technically a:

[breaking-change]

but no code should break in practice.
2015-04-09 08:54:09 -07:00
bors
e326aa197b Auto merge of #24176 - kballard:bufreader-seek-impl, r=aturon 2015-04-09 12:07:24 +00:00
Manish Goregaokar
68100e4c07 Rollup merge of #24176 - kballard:bufreader-seek-impl, r=aturon 2015-04-09 15:53:48 +05:30
Manish Goregaokar
a00ab58f3c Rollup merge of #24175 - dhuseby:bitrig_fixing_tests_2, r=alexcrichton
I'm not sure why this is failing.  This patch disables this test until I can figure out what is wrong.
2015-04-09 15:53:43 +05:30
Manish Goregaokar
ce765896c1 Rollup merge of #24171 - rillian:rustup, r=brson
The idea here is if you don't want rust in /usr/local
you can put something like this is your .profile:

```
export RUSTUP_PREFIX=$HOME/.local/rust
export PATH=$PATH:${RUSTUP_PREFIX}/bin
export DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH:${RUSTUP_PREFIX}/lib
```
Then when you run rustup, it will update the install
in ${RUSTUP_PREFIX} without having to remember to pass
an explicit --prefix argument every time.
2015-04-09 15:53:36 +05:30
Nick Cameron
341870a2d1 Fix the span for for expressions 2015-04-09 20:36:07 +12:00
bors
e57410cd92 Auto merge of #24171 - rillian:rustup, r=brson
The idea here is if you don't want rust in /usr/local
you can put something like this is your .profile:

```
export RUSTUP_PREFIX=$HOME/.local/rust
export PATH=$PATH:${RUSTUP_PREFIX}/bin
export DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH:${RUSTUP_PREFIX}/lib
```
Then when you run rustup, it will update the install
in ${RUSTUP_PREFIX} without having to remember to pass
an explicit --prefix argument every time.
2015-04-09 07:49:26 +00:00
Nick Cameron
613cf9a2a1 Debug impls for a few things in syntax::codemap 2015-04-09 18:25:48 +12:00
bors
0e5e669272 Auto merge of #24168 - kballard:clone-for-extern-c-unsafe-fns, r=alexcrichton
We only implemented Clone on `extern "Rust" fn`s (for up to 8
parameters). This didn't cover `extern "C"` or `unsafe` (or
`unsafe extern "C"`) `fn`s, but there's no reason why they shouldn't be
cloneable as well.

The new impls are marked unstable because the existing impl for `extern
"Rust" fn`s is.

Fixes #24161.
2015-04-09 04:56:23 +00:00
Kevin Ballard
16052053ac Implement io::Seek for io::BufWriter<W> where W: io::Seek
Seeking the `BufWriter` writes out its internal buffer before seeking.
2015-04-08 21:25:59 -07:00
Kevin Ballard
0a380a9318 Implement io::Seek for io::BufReader<R> where R: io::Seek
Seeking the `BufReader` discards the internal buffer (and adjusts the
offset appropriately when seeking with `SeekFrom::Current(_)`).
2015-04-08 21:25:58 -07:00
Brian Anderson
a725426ec8 Don't deoptimize llvm when --enable-debug
libLTO fails to link here.
2015-04-08 18:01:46 -07:00
bors
287a544a30 Auto merge of #24158 - sanxiyn:cast, r=nrc
Fix #13993.
Fix #17167.
2015-04-09 01:00:37 +00:00
Alex Crichton
ec7c800d2f Remove pretty-expanded from failing tests
This commit removes pretty-expanded from all tests that wind up calling panic!
one way or another now that its internals are unstable.
2015-04-08 17:21:34 -07:00
Alex Crichton
561fdec135 std: Stabilize io::Error::from_raw_os_error
This commit stabilizes the old `io::Error::from_os_error` after being renamed to
use the `raw_os_error` terminology instead. This function is often useful when
writing bindings to OS functions but only actually converting to an I/O error at
a later point.
2015-04-08 16:49:49 -07:00
Alex Crichton
6b32072c0c std: Stabilize Clone::clone_from
This method hasn't really changed since is inception, and it can often be a
nice performance win for some situations. This method also imposes no burden on
implementors or users of `Clone` as it's just a default method on the side.
2015-04-08 16:40:03 -07:00
Alex Crichton
65e3f0325a std: Destabilize the internals of panic!
Now that we have a `#[allow_internal_unstable]` attribute for macros there's no
need for these two `begin_unwind` functions to be stable. Right now the `panic!`
interface is the only one we wish to stabilize, so remove the stability markers
from these functions.

While this is a breaking change, it is highly unlikely to break any actual code.
It is recommended to use the `panic!` macro instead if it breaks explicit calls
into `std::rt`.

[breaking-change]
cc #24208
2015-04-08 15:48:46 -07:00