]> git.lizzy.rs Git - rust.git/log
rust.git
8 years agoEmit destructor invocation in FnOnce shim for Fn/FnMut
John Hodge [Sun, 7 Feb 2016 11:35:39 +0000 (19:35 +0800)]
Emit destructor invocation in FnOnce shim for Fn/FnMut

- Fixes #29946

8 years agoAuto merge of #31433 - nagisa:fix-man-ur, r=brson
bors [Sun, 7 Feb 2016 10:33:36 +0000 (10:33 +0000)]
Auto merge of #31433 - nagisa:fix-man-ur, r=brson

seems to not work on OS X (or requires label, which would make link repeat twice on non-OS X)

Fixes https://github.com/rust-lang/rust/issues/31432

8 years agoAuto merge of #31450 - bluss:no-null-markers, r=Gankro
bors [Sun, 7 Feb 2016 07:57:06 +0000 (07:57 +0000)]
Auto merge of #31450 - bluss:no-null-markers, r=Gankro

Document that Unique<T> and Shared<T> are non-null

8 years agoAuto merge of #31445 - saurvs:master, r=brson
bors [Sun, 7 Feb 2016 03:50:39 +0000 (03:50 +0000)]
Auto merge of #31445 - saurvs:master, r=brson

Similar to https://github.com/rust-lang/rust/issues/31432. Links do not show in OS X for the ```rustdoc``` man page.

8 years agoAuto merge of #31440 - reem:rwlock-map-fix, r=alexcrichton
bors [Sun, 7 Feb 2016 00:16:58 +0000 (00:16 +0000)]
Auto merge of #31440 - reem:rwlock-map-fix, r=alexcrichton

Also update the instability reason to include a note about a possible
bad interaction with condition variables on systems that allow
waiting on a RwLock guard.

8 years agoAuto merge of #30629 - brson:emscripten-upstream, r=alexcrichton
bors [Sat, 6 Feb 2016 21:18:50 +0000 (21:18 +0000)]
Auto merge of #30629 - brson:emscripten-upstream, r=alexcrichton

Here's another go at adding emscripten support. This needs to wait again on new [libc definitions](https://github.com/rust-lang-nursery/libc/pull/122) landing. To get the libc definitions right I had to add support for i686-unknown-linux-musl, which are very similar to emscripten's, which are derived from arm/musl.

This branch additionally removes the makefile dependency on the `EMSCRIPTEN` environment variable by not building the unused compiler-rt.

Again, this is not sufficient for actually compiling to asmjs since it needs additional LLVM patches.

r? @alexcrichton

8 years agoAdd emscripten support to compiletest
Brian Anderson [Wed, 6 Jan 2016 19:21:28 +0000 (19:21 +0000)]
Add emscripten support to compiletest

8 years agoAdd support for i686-unknown-linux-musl
Brian Anderson [Tue, 29 Dec 2015 22:33:58 +0000 (22:33 +0000)]
Add support for i686-unknown-linux-musl

8 years agorustc: Add obj_is_bitcode to TargetOptions
Brian Anderson [Fri, 27 Nov 2015 19:44:33 +0000 (19:44 +0000)]
rustc: Add obj_is_bitcode to TargetOptions

This tells trans::back::write not to LLVM codegen to create .o
files but to put LLMV bitcode in .o files.

Emscripten's emcc supports .o in this format, and this is,
I think, slightly easier than making rlibs work without .o
files.

8 years agoAdd the asmjs-unknown-emscripten triple. Add cfgs to libs.
Brian Anderson [Thu, 26 Nov 2015 19:05:10 +0000 (19:05 +0000)]
Add the asmjs-unknown-emscripten triple. Add cfgs to libs.

Backtraces, and the compilation of libbacktrace for asmjs, are disabled.

This port doesn't use jemalloc so, like pnacl, it disables jemalloc *for all targets*
in the configure file.

It disables stack protection.

8 years agoAuto merge of #31428 - reem:remove-mutexguard-map, r=alexcrichton
bors [Sat, 6 Feb 2016 19:16:10 +0000 (19:16 +0000)]
Auto merge of #31428 - reem:remove-mutexguard-map, r=alexcrichton

It could return in the future if it returned a different guard type, which
could not be used with Condvar, otherwise it is unsafe as another thread
can invalidate an "inner" reference during a Condvar::wait.

cc #27746

8 years agoAuto merge of #31427 - reem:more-debug-mutex, r=sfackler
bors [Sat, 6 Feb 2016 17:13:49 +0000 (17:13 +0000)]
Auto merge of #31427 - reem:more-debug-mutex, r=sfackler

There is no reason to require T: 'static; the bound appears to be
a historical artifact.

8 years agoDocument that Unique<T> and Shared<T> are non-null
Ulrik Sverdrup [Sat, 6 Feb 2016 15:18:23 +0000 (16:18 +0100)]
Document that Unique<T> and Shared<T> are non-null

8 years agoAuto merge of #31417 - alexcrichton:cloexec-all-the-things, r=brson
bors [Sat, 6 Feb 2016 15:15:56 +0000 (15:15 +0000)]
Auto merge of #31417 - alexcrichton:cloexec-all-the-things, r=brson

These commits finish up closing out https://github.com/rust-lang/rust/issues/24237 by filling out all locations we create new file descriptors with variants that atomically create the file descriptor and set CLOEXEC where possible. Previous support for doing this in `File::open` was added in #27971 and support for `try_clone` was added in #27980. This commit fills out:

* `Socket::new` now passes `SOCK_CLOEXEC`
* `Socket::accept` now uses `accept4`
* `pipe2` is used instead of `pipe`

Unfortunately most of this support is Linux-specific, and most of it is post-2.6.18 (our oldest supported version), so all of the detection here is done dynamically. It looks like OSX does not have equivalent variants for these functions, so there's nothing more we can do there. Support for BSDs can be added over time if they also have these functions.

Closes #24237

8 years agoAuto merge of #31410 - rkruppe:issue31109, r=pnkfelix
bors [Sat, 6 Feb 2016 13:16:03 +0000 (13:16 +0000)]
Auto merge of #31410 - rkruppe:issue31109, r=pnkfelix

Issue #31109 uncovered two semi-related problems:

* A panic in `str::parse::<f64>`
* A panic in `rustc::middle::const_eval::lit_to_const` where the result of float parsing was unwrapped.

This series of commits fixes both issues and also drive-by-fixes some things I noticed while tracking down the parsing panic.

8 years agoReuse MIR visitors for EraseRegions pass
Simonas Kazlauskas [Sun, 31 Jan 2016 18:25:17 +0000 (20:25 +0200)]
Reuse MIR visitors for EraseRegions pass

8 years agoAuto merge of #31333 - lambda:31273-abort-on-stack-overflow, r=brson
bors [Sat, 6 Feb 2016 09:24:04 +0000 (09:24 +0000)]
Auto merge of #31333 - lambda:31273-abort-on-stack-overflow, r=brson

Abort on stack overflow instead of re-raising SIGSEGV

We use guard pages that cause the process to abort to protect against
undefined behavior in the event of stack overflow.  We have a handler
that catches segfaults, prints out an error message if the segfault was
due to a stack overflow, then unregisters itself and returns to allow
the signal to be re-raised and kill the process.

This caused some confusion, as it was unexpected that safe code would be
able to cause a segfault, while it's easy to overflow the stack in safe
code.  To avoid this confusion, when we detect a segfault in the guard
page, abort instead of the previous behavior of re-raising SIGSEGV.

To test this, we need to adapt the tests for segfault to actually check
the exit status.  Doing so revealed that the existing test for segfault
behavior was actually invalid; LLVM optimizes the explicit null pointer
reference down to an illegal instruction, so the program aborts with
SIGILL instead of SIGSEGV and the test didn't actually trigger the
signal handler at all.  Use a C helper function to get a null pointer
that LLVM can't optimize away, so we get our segfault instead.

This is a [breaking-change] if anyone is relying on the exact signal
raised to kill a process on stack overflow.

Closes #31273

8 years agoRemoved .UR from rustdoc man page
qpid [Sat, 6 Feb 2016 05:32:47 +0000 (11:02 +0530)]
Removed .UR from rustdoc man page

8 years agoFix RwLock*Guard::map to not allow escaping a reference to the data.
Jonathan Reem [Sat, 6 Feb 2016 01:11:17 +0000 (17:11 -0800)]
Fix RwLock*Guard::map to not allow escaping a reference to the data.

Also update the instability reason to include a note about a possible
bad interaction with condition variables on systems that allow
waiting on a RwLock guard.

8 years agoAbort on stack overflow instead of re-raising SIGSEGV
Brian Campbell [Sun, 31 Jan 2016 23:30:32 +0000 (18:30 -0500)]
Abort on stack overflow instead of re-raising SIGSEGV

We use guard pages that cause the process to abort to protect against
undefined behavior in the event of stack overflow.  We have a handler
that catches segfaults, prints out an error message if the segfault was
due to a stack overflow, then unregisters itself and returns to allow
the signal to be re-raised and kill the process.

This caused some confusion, as it was unexpected that safe code would be
able to cause a segfault, while it's easy to overflow the stack in safe
code.  To avoid this confusion, when we detect a segfault in the guard
page, abort instead of the previous behavior of re-raising the SIGSEGV.

To test this, we need to adapt the tests for segfault to actually check
the exit status.  Doing so revealed that the existing test for segfault
behavior was actually invalid; LLVM optimizes the explicit null pointer
reference down to an illegal instruction, so the program aborts with
SIGILL instead of SIGSEGV and the test didn't actually trigger the
signal handler at all.  Use a C helper function to get a null pointer
that LLVM can't optimize away, so we get our segfault instead.

This is a [breaking-change] if anyone is relying on the exact signal
raised to kill a process on stack overflow.

Closes #31273

8 years agoAuto merge of #31307 - nagisa:mir-drop-terminator, r=nikomatsakis
bors [Sat, 6 Feb 2016 01:24:22 +0000 (01:24 +0000)]
Auto merge of #31307 - nagisa:mir-drop-terminator, r=nikomatsakis

The scope of these refactorings is a little bit bigger than the title implies. See each commit for details.

I’m submitting this for nitpicking now (the first 4 commits), because I feel the basic idea/implementation is sound and should work. I will eventually expand this PR to cover the translator changes necessary for all this to work (+ tests), ~~and perhaps implement a dynamic dropping scheme while I’m at it as well.~~

r? @nikomatsakis

8 years agostd: Try to use pipe2 on Linux for pipes
Alex Crichton [Thu, 4 Feb 2016 23:23:26 +0000 (15:23 -0800)]
std: Try to use pipe2 on Linux for pipes

This commit attempts to use the `pipe2` syscall on Linux to atomically set the
CLOEXEC flag for pipes created. Unfortunately this was added in 2.6.27 so we
have to dynamically determine whether we can use it or not.

This commit also updates the `fds-are-cloexec.rs` test to test stdio handles for
spawned processes as well.

8 years agostd: Add support for accept4 on Linux
Alex Crichton [Thu, 4 Feb 2016 23:22:41 +0000 (15:22 -0800)]
std: Add support for accept4 on Linux

This is necessary to atomically accept a socket and set the CLOEXEC flag at the
same time. Support only appeared in Linux 2.6.28 so we have to dynamically
determine which syscall we're supposed to call in this case.

8 years agostd: Add a helper for symbols that may not exist
Alex Crichton [Thu, 4 Feb 2016 21:56:59 +0000 (13:56 -0800)]
std: Add a helper for symbols that may not exist

Right now we only attempt to call one symbol which my not exist everywhere,
__pthread_get_minstack, but this pattern will come up more often as we start to
bind newer functionality of systems like Linux.

Take a similar strategy as the Windows implementation where we use `dlopen` to
lookup whether a symbol exists or not.

8 years agostd: Atomically set CLOEXEC for sockets if possible
Alex Crichton [Thu, 4 Feb 2016 21:30:24 +0000 (13:30 -0800)]
std: Atomically set CLOEXEC for sockets if possible

This commit adds support for creating sockets with the `SOCK_CLOEXEC` flag.
Support for this flag was added in Linux 2.6.27, however, and support does not
exist on platforms other than Linux. For this reason we still have the same
fallback as before but just special case Linux if we can.

8 years agostd: When duplicating fds, skip extra set_cloexec
Alex Crichton [Thu, 4 Feb 2016 21:22:51 +0000 (13:22 -0800)]
std: When duplicating fds, skip extra set_cloexec

Similar to the previous commit, if `F_DUPFD_CLOEXEC` succeeds then there's no
need for us to then call `set_cloexec` on platforms other than Linux. The bug
mentioned of kernels not actually setting the `CLOEXEC` flag has only been
repored on Linux, not elsewhere.

8 years agostd: Only have extra set_cloexec for files on Linux
Alex Crichton [Thu, 4 Feb 2016 19:59:31 +0000 (11:59 -0800)]
std: Only have extra set_cloexec for files on Linux

On Linux we have to do this for binary compatibility with 2.6.18, but for other
OSes (e.g. OSX/BSDs/etc) they all support this flag so we don't need to pass it.

8 years agoIgnore a test on MSVC
Simonas Kazlauskas [Sat, 6 Feb 2016 00:31:19 +0000 (02:31 +0200)]
Ignore a test on MSVC

The MSVC SEH is still not implemented, so we go ahead and ignore it.

8 years agoAuto merge of #31304 - nikomatsakis:incr-comp-read-from-hir-map, r=michaelwoerister
bors [Fri, 5 Feb 2016 20:13:25 +0000 (20:13 +0000)]
Auto merge of #31304 - nikomatsakis:incr-comp-read-from-hir-map, r=michaelwoerister

This change also modifies the dep graph infrastructure to keep track of the number of active tasks, so that even if we are not building the full dep-graph, we still get assertions when there is no active task and one does something that would add a read/write edge. This is particularly helpful since, if the assertions are *not* active, you wind up with the error happening in the message processing thread, which is too late to know the correct backtrace.

~~Before landing, I need to do some performance measurements. Those are underway.~~

See measurements below. No real effect on time.

r? @michaelwoerister

8 years agoDo not .UR in man
Simonas Kazlauskas [Fri, 5 Feb 2016 18:51:36 +0000 (20:51 +0200)]
Do not .UR in man

seems to not work on OS X (or requires label, which would make link repeat twice on non-OS X)

8 years agoAddress nits.
Niko Matsakis [Fri, 5 Feb 2016 18:19:21 +0000 (13:19 -0500)]
Address nits.

8 years agoUpdate collect to use the standard visit routine, rather than rolling
Niko Matsakis [Fri, 29 Jan 2016 21:25:21 +0000 (16:25 -0500)]
Update collect to use the standard visit routine, rather than rolling
its own.

8 years agoInstrument a bunch of tasks that employ the HIR map in one way or
Niko Matsakis [Fri, 29 Jan 2016 20:04:07 +0000 (15:04 -0500)]
Instrument a bunch of tasks that employ the HIR map in one way or
another and were not previously instrumented.

8 years agoInstrument the AST map so that it registers reads when data is
Niko Matsakis [Fri, 29 Jan 2016 20:07:04 +0000 (15:07 -0500)]
Instrument the AST map so that it registers reads when data is
acccessed.

8 years agoAdd a local counter that tracks how many tasks are pushed or not pushed,
Niko Matsakis [Fri, 29 Jan 2016 20:00:46 +0000 (15:00 -0500)]
Add a local counter that tracks how many tasks are pushed or not pushed,
so that we can still get assertion failures even when dep-graph
construction is disabled.

8 years agoAuto merge of #31349 - nikomatsakis:issue-31157-obligation-forest-cache, r=aturon
bors [Fri, 5 Feb 2016 17:16:03 +0000 (17:16 +0000)]
Auto merge of #31349 - nikomatsakis:issue-31157-obligation-forest-cache, r=aturon

Have the `ObligationForest` keep some per-tree state (or type `T`) and have it give a mutable reference for use when processing obligations. In this case, it will be a hashmap. This obviously affects the work that @soltanmm has been doing on snapshotting. I partly want to toss this out there for discussion.

Fixes #31157. (The test in question goes to approx. 30s instead of 5 minutes for me.)
cc #30977.
cc @aturon @arielb1 @soltanmm

r? @aturon who reviewed original `ObligationForest`

8 years agoAuto merge of #31400 - durka:civilized-deriving, r=alexcrichton
bors [Fri, 5 Feb 2016 15:11:45 +0000 (15:11 +0000)]
Auto merge of #31400 - durka:civilized-deriving, r=alexcrichton

You can `#[derive(FromPrimitive)]`, but it [fails later in the compile](https://play.rust-lang.org/?gist=82cb8ad2fac49e3fe472&version=stable) due to hardcoding `std::num::FromPrimitive` which [was removed](https://github.com/rust-lang/rust/commit/eeb94886adccb3f13003f92f117115d17846ce1f) (for some reason Github doesn't show `FromPrimitive` in the diff, but `git show` does).

Anyway, this PR removes the code. I didn't mark it as a breaking change, even though [this extremely contrived code using highly unstable features](https://play.rust-lang.org/?gist=1e1b1bbff962837b228a&version=nightly) is broken by it -- should I?

8 years agoAuto merge of #31390 - dotdash:fix_quadratic_drop, r=nagisa
bors [Fri, 5 Feb 2016 13:02:26 +0000 (13:02 +0000)]
Auto merge of #31390 - dotdash:fix_quadratic_drop, r=nagisa

If a new cleanup is added to a cleanup scope, the cached exits for that
scope are cleared, so all previous cleanups have to be translated
again. In the worst case this means that we get N distinct landing pads
where the last one has N cleanups, then N-1 and so on.

As new cleanups are to be executed before older ones, we can instead
cache the number of already translated cleanups in addition to the
block that contains them, and then only translate new ones, if any and
then jump to the cached ones, getting away with linear growth instead.

For the crate in #31381 this reduces the compile time for an optimized
build from >20 minutes (I cancelled the build at that point) to about 11
seconds. Testing a few crates that come with rustc show compile time
improvements somewhere between 1 and 8%. The "big" winner being
rustc_platform_intrinsics which features code similar to that in #31381.

Fixes #31381

8 years agoAuto merge of #31389 - mitaa:schars, r=nrc
bors [Fri, 5 Feb 2016 10:58:52 +0000 (10:58 +0000)]
Auto merge of #31389 - mitaa:schars, r=nrc

A span spanning only a single character would render like `^~`
instead of just `^`.

r? @nrc

8 years agoRemove MutexGuard::map, as it is not safe in combination with Condvar.
Jonathan Reem [Fri, 5 Feb 2016 10:22:32 +0000 (02:22 -0800)]
Remove MutexGuard::map, as it is not safe in combination with Condvar.

It could return in the future if it returned a different guard type, which
could not be used with Condvar, otherwise it is unsafe as another thread
can invalidate an "inner" reference during a Condvar::wait.

cc #27746

8 years agoRemove an unnecessary 'static bound in the impl of Debug for Mutex.
Jonathan Reem [Fri, 5 Feb 2016 09:19:29 +0000 (01:19 -0800)]
Remove an unnecessary 'static bound in the impl of Debug for Mutex.

There is no reason to require T: 'static; the bound appears to be
a historical artifact.

8 years agoAuto merge of #31388 - gmbonnet:compiler-rt-werror, r=alexcrichton
bors [Fri, 5 Feb 2016 08:54:46 +0000 (08:54 +0000)]
Auto merge of #31388 - gmbonnet:compiler-rt-werror, r=alexcrichton

Without this patch, `compiler-rt` fails to build when the `CFLAGS` environment variable contains a `-Werror=*` flag (for example `-Werror=format-security`).

The build system was removing only the `-Werror` part from the flag, thus passing an unrecognized `=*` (for example `=format-security`) argument to gcc.

8 years agoAuto merge of #31386 - tbu-:pr_cow_from_vec, r=alexcrichton
bors [Fri, 5 Feb 2016 06:51:05 +0000 (06:51 +0000)]
Auto merge of #31386 - tbu-:pr_cow_from_vec, r=alexcrichton

Fixes #31354.

8 years agoAuto merge of #31321 - jseyfried:cleanup, r=nrc
bors [Fri, 5 Feb 2016 03:03:45 +0000 (03:03 +0000)]
Auto merge of #31321 - jseyfried:cleanup, r=nrc

The first commit improves detection of unused imports -- it should have been part of #30325. Right now, the unused import in the changed test would not be reported.

The rest of the commits are miscellaneous, independent clean-ups in resolve that I didn't think warranted individual PRs.

r? @nrc

8 years agoAuto merge of #30865 - alexcrichton:mtime-system-time, r=aturon
bors [Fri, 5 Feb 2016 01:00:31 +0000 (01:00 +0000)]
Auto merge of #30865 - alexcrichton:mtime-system-time, r=aturon

These accessors are used to get at the last modification, last access, and
creation time of the underlying file. Currently not all platforms provide the
creation time, so that currently returns `Option`.

8 years agoAuto merge of #31416 - steveklabnik:rollup, r=steveklabnik
bors [Thu, 4 Feb 2016 22:55:47 +0000 (22:55 +0000)]
Auto merge of #31416 - steveklabnik:rollup, r=steveklabnik

- Successful merges: #31007, #31396, #31401, #31411, #31412, #31413, #31415
- Failed merges:

8 years agoICE more gracefully in constant evaluation when float parsing fails
Robin Kruppe [Thu, 4 Feb 2016 15:18:20 +0000 (16:18 +0100)]
ICE more gracefully in constant evaluation when float parsing fails

Ideally float parsing wouldn't fail at all, but for the moment let's give a helpful message.

Fixes #31109

8 years agoRollup merge of #31415 - tshepang:2-space-indent, r=steveklabnik
Steve Klabnik [Thu, 4 Feb 2016 21:39:06 +0000 (16:39 -0500)]
Rollup merge of #31415 - tshepang:2-space-indent, r=steveklabnik

8 years agoRollup merge of #31413 - tshepang:improve, r=steveklabnik
Steve Klabnik [Thu, 4 Feb 2016 21:39:06 +0000 (16:39 -0500)]
Rollup merge of #31413 - tshepang:improve, r=steveklabnik

8 years agoRollup merge of #31412 - tshepang:add-trailing-commas, r=steveklabnik
Steve Klabnik [Thu, 4 Feb 2016 21:39:05 +0000 (16:39 -0500)]
Rollup merge of #31412 - tshepang:add-trailing-commas, r=steveklabnik

8 years agoRollup merge of #31411 - tshepang:idiom, r=steveklabnik
Steve Klabnik [Thu, 4 Feb 2016 21:39:05 +0000 (16:39 -0500)]
Rollup merge of #31411 - tshepang:idiom, r=steveklabnik

8 years agoRollup merge of #31401 - frewsxcv:clarify-ascii, r=steveklabnik
Steve Klabnik [Thu, 4 Feb 2016 21:39:05 +0000 (16:39 -0500)]
Rollup merge of #31401 - frewsxcv:clarify-ascii, r=steveklabnik

Fixes https://github.com/rust-lang/rust/issues/31203

8 years agoRollup merge of #31396 - mbrubeck:grammar-stmts, r=alexcrichton
Steve Klabnik [Thu, 4 Feb 2016 21:39:05 +0000 (16:39 -0500)]
Rollup merge of #31396 - mbrubeck:grammar-stmts, r=alexcrichton

"stmt" already includes the terminating semicolon.

8 years agoRollup merge of #31007 - pra85:license, r=aturon
Steve Klabnik [Thu, 4 Feb 2016 21:39:05 +0000 (16:39 -0500)]
Rollup merge of #31007 - pra85:license, r=aturon

According to http://www.copyright.gov/circs/circ01.pdf (See screenshot of relevant section below) , listing the first year of publication in the copyright is enough

![selection_008](https://cloud.githubusercontent.com/assets/829526/12409934/7021c3a6-be95-11e5-8d1a-18f6948571e0.png)

The commits d5c8f626a8e4c5166833 and f979f91ae20b2da9b24140334 have changed the copyright years

This commit reverts back those changes, so that license year is again 2014 (As it was, when this license was first introduced in commit 90ba013bde2396f200196  )

--------------------------------------
Edit 1: Added screenshot

8 years agodoc: Rust indents are 4-space wide by convention
Tshepang Lekhonkhobe [Thu, 4 Feb 2016 21:31:22 +0000 (23:31 +0200)]
doc: Rust indents are 4-space wide by convention

8 years agostd: Expose SystemTime accessors on fs::Metadata
Alex Crichton [Wed, 13 Jan 2016 01:24:16 +0000 (17:24 -0800)]
std: Expose SystemTime accessors on fs::Metadata

These accessors are used to get at the last modification, last access, and
creation time of the underlying file. Currently not all platforms provide the
creation time, so that currently returns `Option`.

8 years agoAuto merge of #30759 - Manishearth:attr-tls, r=alexcrichton
bors [Thu, 4 Feb 2016 20:52:22 +0000 (20:52 +0000)]
Auto merge of #30759 - Manishearth:attr-tls, r=alexcrichton

fixes #30756

r? @Gankro

8 years agoreference: add trailing commas
Tshepang Lekhonkhobe [Thu, 4 Feb 2016 20:31:47 +0000 (22:31 +0200)]
reference: add trailing commas

8 years agoreference: make the line a little more readable
Tshepang Lekhonkhobe [Thu, 4 Feb 2016 20:39:15 +0000 (22:39 +0200)]
reference: make the line a little more readable

8 years agoreference: explicit return at function end is not idiomatic
Tshepang Lekhonkhobe [Thu, 4 Feb 2016 20:32:53 +0000 (22:32 +0200)]
reference: explicit return at function end is not idiomatic

8 years agoAuto merge of #31360 - pitdicker:fs_tests_cleanup, r=alexcrichton
bors [Thu, 4 Feb 2016 18:48:41 +0000 (18:48 +0000)]
Auto merge of #31360 - pitdicker:fs_tests_cleanup, r=alexcrichton

- use `symlink_file` and `symlink_dir` instead of the old `soft_link`
- create a junction instead of a directory symlink for testing recursive_rmdir (as it causes the
  same troubles, but can be created by users without `SeCreateSymbolicLinkPrivilege`)
- `remove_dir_all` was unable to remove directory symlinks and junctions
- only run tests that create symlinks if we have the right permissions.
- rename `Path2` to `Path`
- remove the global `#[allow(deprecated)]` and outdated comments
- After factoring out `create_junction()` from the test `directory_junctions_are_directories` and
  removing needlessly complex code, what I was left with was:
  ```
  #[test]
  #[cfg(windows)]
  fn directory_junctions_are_directories() {
      use sys::fs::create_junction;

      let tmpdir = tmpdir();

      let foo = tmpdir.join("foo");
      let bar = tmpdir.join("bar");

      fs::create_dir(&foo).unwrap();
      check!(create_junction(&foo, &bar));
      assert!(bar.metadata().unwrap().is_dir());
  }
  ```
  It test whether a junction is a directory instead of a reparse point. But it actually test the
  target of the junction (which is a directory if it exists) instead of the junction itself, which
  should always be a symlink. So this test is invalid, and I expect it only exists because the
  author was suprised by it. So I removed it.

Some things that do not yet work right:
- relative symlinks do not accept forward slashes
- the conversion of paths for `create_junction` is hacky
- `remove_dir_all` now messes with the internal data of `FileAttr` to be able to remove symlinks.
  We should add some method like `is_symlink_dir()` to it, so code outside the standard library
  can see the difference between file and directory symlinks too.

8 years agoTest for unsafe code in TLS macro
Manish Goregaokar [Thu, 4 Feb 2016 12:20:32 +0000 (17:50 +0530)]
Test for unsafe code in TLS macro

8 years agoStop using unsafe code in TLS macro expansion (fixes #30756)
Manish Goregaokar [Thu, 4 Feb 2016 12:20:20 +0000 (17:50 +0530)]
Stop using unsafe code in TLS macro expansion (fixes #30756)

8 years agoClarify scenario where AsciiExt appears to operate on non-ASCII
Corey Farwell [Thu, 4 Feb 2016 05:11:18 +0000 (00:11 -0500)]
Clarify scenario where AsciiExt appears to operate on non-ASCII

Fixes https://github.com/rust-lang/rust/issues/31203

8 years agoAuto merge of #31382 - DanielJCampbell:SaveSpans, r=nrc
bors [Thu, 4 Feb 2016 15:44:35 +0000 (15:44 +0000)]
Auto merge of #31382 - DanielJCampbell:SaveSpans, r=nrc

r? @nrc

8 years agoAllow dead code for `symlink_junction()`
Paul Dicker [Thu, 4 Feb 2016 15:29:55 +0000 (16:29 +0100)]
Allow dead code for `symlink_junction()`

8 years agodrive-by doc fixes
Robin Kruppe [Thu, 4 Feb 2016 13:09:59 +0000 (14:09 +0100)]
drive-by doc fixes

8 years agoEnable unit tests for literals that overflow. I have no idea why this condition was...
Robin Kruppe [Thu, 4 Feb 2016 12:51:18 +0000 (13:51 +0100)]
Enable unit tests for literals that overflow. I have no idea why this condition was ever added.

8 years agoPrevent the immediate panic uncovered by #31109 and add a test.
Robin Kruppe [Tue, 26 Jan 2016 21:10:21 +0000 (22:10 +0100)]
Prevent the immediate panic uncovered by #31109 and add a test.

The code there still triggers an ICE, but for different reasons (const eval unwraps the parse result).

8 years agoAdd the kind of input from #31109 to the expensive tests (not run by default)
Robin Kruppe [Tue, 26 Jan 2016 21:05:21 +0000 (22:05 +0100)]
Add the kind of input from #31109 to the expensive tests (not run by default)

8 years agoUse the right target ratio in Algorithm M quickstart.
Robin Kruppe [Tue, 26 Jan 2016 21:08:01 +0000 (22:08 +0100)]
Use the right target ratio in Algorithm M quickstart.

Using f64's bit size probably wasn't actually *wrong*, but it would overshoot for no reason. This might have slowed down f32 parsing significantly.

8 years agoAddress nits on build/scope.rs
Simonas Kazlauskas [Tue, 2 Feb 2016 20:50:26 +0000 (22:50 +0200)]
Address nits on build/scope.rs

8 years agoTranslation part of drop panic recovery
Simonas Kazlauskas [Sat, 30 Jan 2016 17:32:50 +0000 (19:32 +0200)]
Translation part of drop panic recovery

With this commit we now finally execute all the leftover drops once some drop panics for some
reason!

8 years agoConvert Drop statement into terminator
Simonas Kazlauskas [Fri, 29 Jan 2016 22:18:47 +0000 (00:18 +0200)]
Convert Drop statement into terminator

The structure of the old translator as well as MIR assumed that drop glue cannot possibly panic and
translated the drops accordingly. However, in presence of `Drop::drop` this assumption can be
trivially shown to be untrue. As such, the Rust code like the following would never print number 2:

```rust
struct Droppable(u32);
impl Drop for Droppable {
    fn drop(&mut self) {
        if self.0 == 1 { panic!("Droppable(1)") } else { println!("{}", self.0) }
    }
}
fn main() {
    let x = Droppable(2);
    let y = Droppable(1);
}
```

While the behaviour is allowed according to the language rules (we allow drops to not run), that’s
a very counter-intuitive behaviour. We fix this in MIR by allowing `Drop` to have a target to take
on divergence and connect the drops in such a way so the leftover drops are executed when some drop
unwinds.

Note, that this commit still does not implement the translator part of changes necessary for the
grand scheme of things to fully work, so the actual observed behaviour does not change yet. Coming
soon™.

See #14875.

8 years agoRemove the CallKind
Simonas Kazlauskas [Fri, 29 Jan 2016 18:42:02 +0000 (20:42 +0200)]
Remove the CallKind

We used to have CallKind only because there was a requirement to have all successors in a
contiguous memory block. Now that the requirement is gone, remove the CallKind and instead just
have the necessary information inline.

Awesome!

8 years agoChange successor{,_mut} to return a Vec
Simonas Kazlauskas [Fri, 29 Jan 2016 17:06:23 +0000 (19:06 +0200)]
Change successor{,_mut} to return a Vec

This helps to avoid the unpleasant restriction of being unable to have multiple successors in
non-contiguous block of memory.

8 years agoSynthesize calls to box_free language item
Simonas Kazlauskas [Thu, 28 Jan 2016 21:59:00 +0000 (23:59 +0200)]
Synthesize calls to box_free language item

This gets rid of Drop(Free, _) MIR construct by synthesizing a call to language item which
takes care of dropping instead.

8 years agoAuto merge of #31161 - sfackler:slice-to-socket-addrs, r=alexcrichton
bors [Thu, 4 Feb 2016 13:41:42 +0000 (13:41 +0000)]
Auto merge of #31161 - sfackler:slice-to-socket-addrs, r=alexcrichton

This is useful when you have an API that takes a `T: ToSocketAddrs` and needs to turn that into an owned value which will be passed to another API taking `T: ToSocketAddrs` at a later time, for example: https://github.com/sfackler/rust-hyper-socks/blob/master/src/lib.rs#L15

8 years agoAuto merge of #31069 - sfackler:file-try-clone, r=alexcrichton
bors [Thu, 4 Feb 2016 11:39:27 +0000 (11:39 +0000)]
Auto merge of #31069 - sfackler:file-try-clone, r=alexcrichton

I have it set as stable right now under the rationale that it's extending an existing, stable API to another type in the "obvious" way.

r? @alexcrichton

cc @reem

8 years agoImplement ToSocketAddrs for &[SocketAddr]
Steven Fackler [Sun, 24 Jan 2016 08:31:22 +0000 (00:31 -0800)]
Implement ToSocketAddrs for &[SocketAddr]

8 years agoAdd File::try_clone
Steven Fackler [Thu, 21 Jan 2016 05:24:23 +0000 (21:24 -0800)]
Add File::try_clone

8 years agoAuto merge of #31378 - nagisa:target-man, r=alexcrichton
bors [Thu, 4 Feb 2016 09:38:15 +0000 (09:38 +0000)]
Auto merge of #31378 - nagisa:target-man, r=alexcrichton

8 years agoFix unclear make_mut docs
Richard Bradfield [Wed, 3 Feb 2016 22:18:04 +0000 (22:18 +0000)]
Fix unclear make_mut docs

Changed the description of the `make_mut` copy-on-write behaviour in arc.rs

The sentence "doesn't have one strong reference and no weak references." is a
hard to understand double negative, which can be much more easily explained.

8 years agoAuto merge of #31326 - sdleffler:master, r=nikomatsakis
bors [Thu, 4 Feb 2016 06:07:26 +0000 (06:07 +0000)]
Auto merge of #31326 - sdleffler:master, r=nikomatsakis

After the truly incredible and embarrassing mess I managed to make in my last pull request, this should be a bit less messy.

Fixes #31267 - with this change, the code mentioned in the issue compiles.

Found and fixed another issue as well - constants of zero-size types, when used in ExprRepeats inside associated constants, were causing the compiler to crash at the same place as #31267. An example of this:
```

struct Bar;

const BAZ: Bar = Bar;

struct Foo([Bar; 1]);

struct Biz;

impl Biz {
    const BAZ: Foo = Foo([BAZ; 1]);
}

fn main() {
    let foo = Biz::BAZ;
    println!("{:?}", foo);
}
```
However, I'm fairly certain that my fix for this is not as elegant as it could be. The problem seems to occur only with an associated constant of a tuple struct containing a fixed size array which is initialized using a repeat expression, and when the element to be repeated provided to the repeat expression is another constant which is of a zero-sized type. The fix works by looking for constants and associated constants which are zero-width and consequently contain no data, but for which rustc is still attempting to emit an LLVM value; it simply stops rustc from attempting to emit anything. By my logic, this should work fine since the only values that are emitted in this case (according to the comments) are for closures with side effects, and constants will never have side effects, so it's fine to simply get rid of them. It fixes the error and things compile fine with it, but I have a sneaking suspicion that it could be done in a far better manner.

r? @nikomatsakis

8 years agotest #[derive(FromPrimitive)] triggers custom-derive error
Alex Burka [Thu, 4 Feb 2016 00:58:07 +0000 (19:58 -0500)]
test #[derive(FromPrimitive)] triggers custom-derive error

8 years agoAuto merge of #30962 - Amanieu:non_volatile_atomic, r=alexcrichton
bors [Thu, 4 Feb 2016 02:46:44 +0000 (02:46 +0000)]
Auto merge of #30962 - Amanieu:non_volatile_atomic, r=alexcrichton

Rust currently emits atomic loads and stores with the LLVM `volatile` qualifier. This is unnecessary and prevents LLVM from performing optimization on these atomic operations.

8 years agoremove dead #[derive(FromPrimitive)] code
Alex Burka [Thu, 4 Feb 2016 00:41:54 +0000 (19:41 -0500)]
remove dead #[derive(FromPrimitive)] code

8 years agoAuto merge of #30796 - GuillaumeGomez:impl_box_error, r=alexcrichton
bors [Thu, 4 Feb 2016 00:39:55 +0000 (00:39 +0000)]
Auto merge of #30796 - GuillaumeGomez:impl_box_error, r=alexcrichton

Fixes #30349

8 years agoRemove unneeded borrows and slices
Jeffrey Seyfried [Fri, 29 Jan 2016 23:34:58 +0000 (23:34 +0000)]
Remove unneeded borrows and slices

8 years agoRemove unneeded use of Cell
Jeffrey Seyfried [Sun, 31 Jan 2016 00:41:26 +0000 (00:41 +0000)]
Remove unneeded use of Cell

8 years agoRefactor away resolve_item_by_name_in_lexical_scope
Jeffrey Seyfried [Sat, 30 Jan 2016 13:33:02 +0000 (13:33 +0000)]
Refactor away resolve_item_by_name_in_lexical_scope

8 years agoRefactor resolve_import_for_module
Jeffrey Seyfried [Sat, 16 Jan 2016 11:41:19 +0000 (11:41 +0000)]
Refactor resolve_import_for_module

8 years agoRefactor away resolve_module_in_lexical_scope
Jeffrey Seyfried [Sun, 31 Jan 2016 00:38:45 +0000 (00:38 +0000)]
Refactor away resolve_module_in_lexical_scope

8 years agoRefactor block_needs_anonymous_module
Jeffrey Seyfried [Wed, 27 Jan 2016 10:51:22 +0000 (10:51 +0000)]
Refactor block_needs_anonymous_module

8 years agoRefactor more functionality into record_import_use
Jeffrey Seyfried [Sat, 16 Jan 2016 12:09:13 +0000 (12:09 +0000)]
Refactor more functionality into record_import_use

8 years agoRefactor resolve_item_in_lexical_scope
Jeffrey Seyfried [Sun, 31 Jan 2016 04:27:39 +0000 (04:27 +0000)]
Refactor resolve_item_in_lexical_scope

8 years agoImprove detection of unused imports
Jeffrey Seyfried [Sun, 31 Jan 2016 04:25:49 +0000 (04:25 +0000)]
Improve detection of unused imports

8 years agoAvoid quadratic growth of functions due to cleanups
Björn Steinbrink [Wed, 3 Feb 2016 18:27:32 +0000 (19:27 +0100)]
Avoid quadratic growth of functions due to cleanups

If a new cleanup is added to a cleanup scope, the cached exits for that
scope are cleared, so all previous cleanups have to be translated
again. In the worst case this means that we get N distinct landing pads
where the last one has N cleanups, then N-1 and so on.

As new cleanups are to be executed before older ones, we can instead
cache the number of already translated cleanups in addition to the
block that contains them, and then only translate new ones, if any and
then jump to the cached ones, getting away with linear growth instead.

For the crate in #31381 this reduces the compile time for an optimized
build from >20 minutes (I cancelled the build at that point) to about 11
seconds. Testing a few crates that come with rustc show compile time
improvements somewhere between 1 and 8%. The "big" winner being
rustc_platform_intrinsics which features code similar to that in #31381.

Fixes #31381

8 years agoAuto merge of #31078 - nbaksalyar:illumos, r=alexcrichton
bors [Wed, 3 Feb 2016 22:40:32 +0000 (22:40 +0000)]
Auto merge of #31078 - nbaksalyar:illumos, r=alexcrichton

This pull request adds support for [Illumos](http://illumos.org/)-based operating systems: SmartOS, OpenIndiana, and others. For now it's x86-64 only, as I'm not sure if 32-bit installations are widespread. This PR is based on #28589 by @potatosalad, and also closes #21000, #25845, and #25846.

Required changes in libc are already merged: https://github.com/rust-lang-nursery/libc/pull/138

Here's a snapshot required to build a stage0 compiler:
https://s3-eu-west-1.amazonaws.com/nbaksalyar/rustc-sunos-snapshot.tar.gz
It passes all checks from `make check`.

There are some changes I'm not quite sure about, e.g. macro usage in `src/libstd/num/f64.rs` and `DirEntry` structure in `src/libstd/sys/unix/fs.rs`, so any comments on how to rewrite it better would be greatly appreciated.

Also, LLVM configure script might need to be patched to build it successfully, or a pre-built libLLVM should be used. Some details can be found here: https://llvm.org/bugs/show_bug.cgi?id=25409

Thanks!

r? @brson

8 years agoRemove redundant semicolon from "block_expr" in grammar reference
Matt Brubeck [Wed, 3 Feb 2016 21:42:23 +0000 (13:42 -0800)]
Remove redundant semicolon from "block_expr" in grammar reference

"stmt" already includes the terminating semicolon.