Commit Graph

50128 Commits

Author SHA1 Message Date
bors
695c907dcc 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.
2016-02-06 13:16:03 +00:00
bors
35635aebab 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
2016-02-06 09:24:04 +00:00
Brian Campbell
ee79bfa18a 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
2016-02-05 20:41:18 -05:00
bors
5147c1f2c0 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
2016-02-06 01:24:22 +00:00
Simonas Kazlauskas
caf62ef984 Ignore a test on MSVC
The MSVC SEH is still not implemented, so we go ahead and ignore it.
2016-02-06 02:31:19 +02:00
bors
34af2de409 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
2016-02-05 20:13:25 +00:00
Niko Matsakis
a0f96d631e Address nits. 2016-02-05 13:19:55 -05:00
Niko Matsakis
8a29040989 Update collect to use the standard visit routine, rather than rolling
its own.
2016-02-05 13:19:55 -05:00
Niko Matsakis
35b6e2b0bb Instrument a bunch of tasks that employ the HIR map in one way or
another and were not previously instrumented.
2016-02-05 13:19:55 -05:00
Niko Matsakis
d09fd1a529 Instrument the AST map so that it registers reads when data is
acccessed.
2016-02-05 13:19:55 -05:00
Niko Matsakis
37fbfaf183 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.
2016-02-05 13:19:55 -05:00
bors
6dc112dbb7 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`
2016-02-05 17:16:03 +00:00
bors
98422e8c15 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](eeb94886ad) (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?
2016-02-05 15:11:45 +00:00
bors
38dfb96b46 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
2016-02-05 13:02:26 +00:00
bors
f12d32d307 Auto merge of #31389 - mitaa:schars, r=nrc
A span spanning only a single character would render like `^~`
instead of just `^`.

r? @nrc
2016-02-05 10:58:52 +00:00
bors
06fac8298f 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.
2016-02-05 08:54:46 +00:00
bors
2ad6dc2556 Auto merge of #31386 - tbu-:pr_cow_from_vec, r=alexcrichton
Fixes #31354.
2016-02-05 06:51:05 +00:00
bors
dcf8ef2723 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
2016-02-05 03:03:45 +00:00
bors
7bcced73b7 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`.
2016-02-05 01:00:31 +00:00
bors
9d8e3a024a Auto merge of #31416 - steveklabnik:rollup, r=steveklabnik
- Successful merges: #31007, #31396, #31401, #31411, #31412, #31413, #31415
- Failed merges:
2016-02-04 22:55:47 +00:00
Robin Kruppe
a76cb45e34 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
2016-02-04 23:06:50 +01:00
Steve Klabnik
96d866a19d Rollup merge of #31415 - tshepang:2-space-indent, r=steveklabnik 2016-02-04 16:39:06 -05:00
Steve Klabnik
09e62bac0f Rollup merge of #31413 - tshepang:improve, r=steveklabnik 2016-02-04 16:39:06 -05:00
Steve Klabnik
fc6e7698c1 Rollup merge of #31412 - tshepang:add-trailing-commas, r=steveklabnik 2016-02-04 16:39:05 -05:00
Steve Klabnik
cd418ba09b Rollup merge of #31411 - tshepang:idiom, r=steveklabnik 2016-02-04 16:39:05 -05:00
Steve Klabnik
73db842617 Rollup merge of #31401 - frewsxcv:clarify-ascii, r=steveklabnik
Fixes https://github.com/rust-lang/rust/issues/31203
2016-02-04 16:39:05 -05:00
Steve Klabnik
3cccf261fc Rollup merge of #31396 - mbrubeck:grammar-stmts, r=alexcrichton
"stmt" already includes the terminating semicolon.
2016-02-04 16:39:05 -05:00
Steve Klabnik
c98833d41e 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 d5c8f626a8 and f979f91ae2 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 90ba013bde  )

--------------------------------------
Edit 1: Added screenshot
2016-02-04 16:39:05 -05:00
Tshepang Lekhonkhobe
9721752d35 doc: Rust indents are 4-space wide by convention 2016-02-04 23:31:22 +02:00
Alex Crichton
d1681bbde5 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`.
2016-02-04 13:15:28 -08:00
bors
c007e4a010 Auto merge of #30759 - Manishearth:attr-tls, r=alexcrichton
fixes #30756

r? @Gankro
2016-02-04 20:52:22 +00:00
Tshepang Lekhonkhobe
a2f22a00ec reference: add trailing commas 2016-02-04 22:44:32 +02:00
Tshepang Lekhonkhobe
69b1d75b76 reference: make the line a little more readable 2016-02-04 22:39:15 +02:00
Tshepang Lekhonkhobe
85b19d8aa3 reference: explicit return at function end is not idiomatic 2016-02-04 22:32:53 +02:00
bors
d0ef740266 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.
2016-02-04 18:48:41 +00:00
Manish Goregaokar
4b68c293fd Test for unsafe code in TLS macro 2016-02-04 22:23:23 +05:30
Manish Goregaokar
6c4f0bf79b Stop using unsafe code in TLS macro expansion (fixes #30756) 2016-02-04 22:23:20 +05:30
Corey Farwell
93d6425b43 Clarify scenario where AsciiExt appears to operate on non-ASCII
Fixes https://github.com/rust-lang/rust/issues/31203
2016-02-04 11:34:11 -05:00
bors
f01b85b103 Auto merge of #31382 - DanielJCampbell:SaveSpans, r=nrc
r? @nrc
2016-02-04 15:44:35 +00:00
Paul Dicker
fb172b676e Allow dead code for symlink_junction() 2016-02-04 16:29:55 +01:00
Robin Kruppe
33713bca49 drive-by doc fixes 2016-02-04 16:28:08 +01:00
Robin Kruppe
cc68f2c6bf Enable unit tests for literals that overflow. I have no idea why this condition was ever added. 2016-02-04 16:28:07 +01:00
Robin Kruppe
af5d574d1f 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).
2016-02-04 16:28:06 +01:00
Robin Kruppe
a8dc1f974b Add the kind of input from #31109 to the expensive tests (not run by default) 2016-02-04 16:27:22 +01:00
Robin Kruppe
25c9ac3280 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.
2016-02-04 16:24:23 +01:00
Simonas Kazlauskas
5638847ae3 Address nits on build/scope.rs 2016-02-04 15:56:05 +02:00
Simonas Kazlauskas
ebf6341d1d Translation part of drop panic recovery
With this commit we now finally execute all the leftover drops once some drop panics for some
reason!
2016-02-04 15:56:05 +02:00
Simonas Kazlauskas
98265d3385 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.
2016-02-04 15:56:05 +02:00
Simonas Kazlauskas
65dd5e6a84 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!
2016-02-04 15:56:04 +02:00
Simonas Kazlauskas
02365fe753 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.
2016-02-04 15:56:04 +02:00