Commit Graph

43607 Commits

Author SHA1 Message Date
Manish Goregaokar
3afc385ae1 Rollup merge of #26349 - petrochenkov:bitwise, r=steveklabnik
I'm surprised that bitwise operators `&`, `|` and `^` are implemented for `bool` arguments, because inspection of boolean's bits is not something that should be encouraged and because `&&` -> `&` is a common typo, but if they are implemented, then their behavior should be documented.
2015-06-18 13:38:10 +05:30
Manish Goregaokar
b5f2b098d7 Rollup merge of #26348 - eefriedman:unused-interiorsafety, r=luqmana 2015-06-18 13:38:09 +05:30
Manish Goregaokar
39e4d03e35 Rollup merge of #26342 - steveklabnik:quix_reference_fix, r=alexcrichton
https://github.com/rust-lang/rust/pull/26323/files#r32503568
2015-06-18 13:38:09 +05:30
Manish Goregaokar
b780bc513c Rollup merge of #26314 - steveklabnik:gh26312, r=bluss
Fixes #26312
2015-06-18 13:38:09 +05:30
bors
a19ed8ad15 Auto merge of #26340 - bluss:bench-sigfix, r=alexcrichton
test: Fix a bug in bench result formatting

It would skip the middle part if it was 0, displaying a number a 1000
times too small. The MB/s number next to it gave it away.

Fixed it looks like this:

```
test h ... bench:   1,000,129 ns/iter (+/- 4,730)
```
2015-06-18 04:52:28 +00:00
bors
1d33318018 Auto merge of #26336 - dotdash:raw_ptr_coercions, r=nrc
Unlike coercing from reference to unsafe pointer, coercing between two
unsafe pointers doesn't need an AutoDerefRef, because there is no region
that regionck would need to know about.

In unoptimized libcore, this reduces the number of "auto_deref" allocas
from 174 to 4.
2015-06-18 03:16:40 +00:00
bors
20d23d8e57 Auto merge of #26347 - nagisa:macro-exp, r=nrc
r? @nrc, because breakage was caused by https://github.com/rust-lang/rust/pull/25318
2015-06-18 00:26:23 +00:00
bors
713d9176ad Auto merge of #26326 - nikomatsakis:optimize-fulfillment-cache-in-tcx, r=pcwalton
When we successfully resolve a trait reference with no type/lifetime parameters, like `i32: Foo` or `Box<u32>: Sized`, this is in fact globally true. This patch adds a simple global to the tcx to cache such cases. The main advantage of this is really about caching things like `Box<Vec<Foo>>: Sized`. It also points to the need to revamp our caching infrastructure -- the current caches make selection cost cheaper, but we still wind up paying a high cost in the confirmation process, and in particular unrolling out dependent obligations. Moreover, we should probably do caching more uniformly and with a key that takes the where-clauses into account. But that's for later.

For me, this shows up as a reasonably nice win (20%) on Servo's script crate (when built in dev mode). This is not as big as my initial measurements suggested, I think because I was building my rustc with more debugging enabled at the time. I've not yet done follow-up profiling and so forth to see where the new hot spots are. Bootstrap times seem to be largely unaffected.

cc @pcwalton 

This is technically a [breaking-change] in that functions with unsatisfiable where-clauses may now yield errors where before they may have been accepted. Even before, these functions could never have been *called* by actual code. In the future, such functions will probably become illegal altogether, but in this commit they are still accepted, so long as they do not rely on the unsatisfiable where-clauses. As before, the functions still cannot be called in any case.
2015-06-17 22:50:17 +00:00
bors
8af39cebc5 Auto merge of #26321 - srwalter:remove-i386-textrel, r=alexcrichton
This prevents a relocation in the text section.  Text relocations are
incompatible with hardened kernels.

https://github.com/rust-lang/rust/issues/5714
2015-06-17 20:04:19 +00:00
bors
37cc79f81c Auto merge of #26315 - steveklabnik:gh26287, r=alexcrichton
The font can make this hard to read, and we don't even strictly need
the annotation, so let's just remove it

Fixes #26287
2015-06-17 18:09:10 +00:00
bors
6065bed37b Auto merge of #26062 - eefriedman:cleanup-cached, r=nikomatsakis
Using the wrong landing pad has obvious bad effects, like dropping a value
twice.

Testcase written by Alex Crichton.

Fixes #25089.
2015-06-17 16:14:30 +00:00
bors
e7a5a1c33a Auto merge of #25961 - sanxiyn:dead-variant-2, r=huonw
Rebase of #21468.

Fix #25960.
2015-06-17 13:30:31 +00:00
Seo Sanghyeon
ae0716d962 Add a test 2015-06-17 21:37:36 +09:00
bors
d24dd3191a Auto merge of #26261 - tshepang:more-brief-example, r=huonw
Also, it feels more suitable to use hex to represent unicode
2015-06-17 11:54:25 +00:00
bors
d2c223a377 Auto merge of #26126 - Nashenas88:sync-send-libcore-iter, r=huonw
This addresses an item in #22709. SizeHint in libcore/iter.rs also implements Iterator, but it's implementation is not accessible and is only used to send size hints to extend (it appears to be a performance improvement to avoid unnecessary memory reallocations). The is the only implementation of Iterator within libcore/iter.rs that is not/cannot be tested in this PR.
2015-06-17 10:19:14 +00:00
bors
aa00f2e972 Auto merge of #26025 - alexcrichton:update-llvm, r=brson
This commit updates the LLVM submodule in use to the current HEAD of the LLVM
repository. This is primarily being done to start picking up unwinding support
for MSVC, which is currently unimplemented in the revision of LLVM we are using.
Along the way a few changes had to be made:

* As usual, lots of C++ debuginfo bindings in LLVM changed, so there were some
  significant changes to our RustWrapper.cpp
* As usual, some pass management changed in LLVM, so clang was re-scrutinized to
  ensure that we're doing the same thing as clang.
* Some optimization options are now passed directly into the
  `PassManagerBuilder` instead of through CLI switches to LLVM.
* The `NoFramePointerElim` option was removed from LLVM, favoring instead the
  `no-frame-pointer-elim` function attribute instead.
* The `LoopVectorize` option of the LLVM optimization passes has been disabled
  as it causes a divide-by-zero exception to happen in LLVM for zero-sized
  types. This is reported as https://llvm.org/bugs/show_bug.cgi?id=23763

Additionally, LLVM has picked up some new optimizations which required fixing an
existing soundness hole in the IR we generate. It appears that the current LLVM
we use does not expose this hole. When an enum is moved, the previous slot in
memory is overwritten with a bit pattern corresponding to "dropped". When the
drop glue for this slot is run, however, the switch on the discriminant can
often start executing the `unreachable` block of the switch due to the
discriminant now being outside the normal range. This was patched over locally
for now by having the `unreachable` block just change to a `ret void`.
2015-06-17 06:56:15 +00:00
Alex Crichton
f9d4149c29 rustc: Update LLVM
This commit updates the LLVM submodule in use to the current HEAD of the LLVM
repository. This is primarily being done to start picking up unwinding support
for MSVC, which is currently unimplemented in the revision of LLVM we are using.
Along the way a few changes had to be made:

* As usual, lots of C++ debuginfo bindings in LLVM changed, so there were some
  significant changes to our RustWrapper.cpp
* As usual, some pass management changed in LLVM, so clang was re-scrutinized to
  ensure that we're doing the same thing as clang.
* Some optimization options are now passed directly into the
  `PassManagerBuilder` instead of through CLI switches to LLVM.
* The `NoFramePointerElim` option was removed from LLVM, favoring instead the
  `no-frame-pointer-elim` function attribute instead.

Additionally, LLVM has picked up some new optimizations which required fixing an
existing soundness hole in the IR we generate. It appears that the current LLVM
we use does not expose this hole. When an enum is moved, the previous slot in
memory is overwritten with a bit pattern corresponding to "dropped". When the
drop glue for this slot is run, however, the switch on the discriminant can
often start executing the `unreachable` block of the switch due to the
discriminant now being outside the normal range. This was patched over locally
for now by having the `unreachable` block just change to a `ret void`.
2015-06-16 22:56:42 -07:00
bors
0250ff9a5f Auto merge of #22681 - mzabaluev:extend-faster, r=huonw
Instead of a fast branch with a sized iterator falling back to a potentially poorly optimized iterate-and-push loop, a single efficient loop can serve all cases.

In my benchmark runs, I see some good gains, but also some regressions, possibly due to different inlining choices by the compiler. YMMV.
2015-06-17 00:44:25 +00:00
bors
014a5c12ac Auto merge of #26280 - Marwes:deriving_discriminant, r=pcwalton
PR for #26128.

Improves codegen in deriving by utilizing the discriminant_value intrinsic.

I have a more detailed comment on the changes in a comment on the issue [here](https://github.com/rust-lang/rust/issues/26128#issuecomment-111509863)

### Old
```
running 7 tests
test large_c_like       ... bench:   2,694,129 ns/iter (+/- 5,170)
test large_c_like_ord   ... bench:   2,723,521 ns/iter (+/- 9,098)
test test1_partial_eq   ... bench:   2,439,317 ns/iter (+/- 2,135)
test test1_partial_ord  ... bench:   2,499,114 ns/iter (+/- 55,766)
test test2_partial_eq   ... bench:   3,562,815 ns/iter (+/- 45,590)
test test2_partial_ord  ... bench:   3,398,306 ns/iter (+/- 22,180)
test test_match_success ... bench:   1,509,267 ns/iter (+/- 1,982)
```

### New
```
running 7 tests
test large_c_like       ... bench:     286,509 ns/iter (+/- 474)
test large_c_like_ord   ... bench:     286,666 ns/iter (+/- 8,756)
test test1_partial_eq   ... bench:     286,584 ns/iter (+/- 2,789)
test test1_partial_ord  ... bench:     286,470 ns/iter (+/- 516)
test test2_partial_eq   ... bench:   2,228,997 ns/iter (+/- 34,191)
test test2_partial_ord  ... bench:   1,731,699 ns/iter (+/- 21,756)
test test_match_success ... bench:   1,509,630 ns/iter (+[- 3,765)
```

[Benchmark](https://gist.github.com/Marwes/7c0b3468d0cae972a2b4)
2015-06-16 22:20:15 +00:00
Vadim Petrochenkov
a8f666f1f4 Document behavior of bitwise operators with boolean arguments 2015-06-17 00:44:40 +03:00
Eli Friedman
199e60aa22 Remove unused type InteriorSafety. 2015-06-16 13:05:07 -07:00
bors
467e4a6681 Auto merge of #25952 - alexcrichton:fix-scoped-tls, r=aturon
Currently the compiler has no knowledge of `#[thread_local]` which forces users
to take on two burdens of unsafety:

* The lifetime of the borrow of a `#[thread_local]` static is **not** `'static`
* Types in `static`s are required to be `Sync`

The thread-local modules mostly curb these facets of unsafety by only allowing
very limited scopes of borrows as well as allowing all types to be stored in a
thread-local key (regardless of whether they are `Sync`) through an `unsafe
impl`.

Unfortunately these measures have the consequence of being able to take the
address of the key itself and send it to another thread, allowing the same key
to be accessed from two different threads. This is clearly unsafe, and this
commit fixes this problem with the same trick used by `LocalKey`, which is to
have an indirect function call to find the address of the *current thread's*
thread local. This way the address of thread local keys can safely be sent among
threads as their lifetime truly is `'static`.

This commit will reduce the performance of cross-crate scoped thread locals as
it now requires an indirect function call, but this can likely be overcome in a
future commit.

Closes #25894
2015-06-16 20:00:46 +00:00
Simonas Kazlauskas
09ed27c05e Remove superfluous variable 2015-06-16 22:29:41 +03:00
Simonas Kazlauskas
ca72d7fe3f Add a test for issue 26322 2015-06-16 22:23:01 +03:00
Simonas Kazlauskas
7ff55eaf25 Fix file!(), line!() and column!() macros
These used to return wrong results in case they were expanded inside compiler’s
iternal syntax sugar (closures, if-let) expansions

Fixes #26322
2015-06-16 21:47:09 +03:00
bors
10356458a7 Auto merge of #24738 - joliv:patch-2, r=steveklabnik
The "unit value" is a value of the "unit type," not the "unit value type." Regardless of correctness, this straight syntax is easier to grok.

Part of #16676

Sorry if something's off here, it's my first pull request to rust!
2015-06-16 17:08:36 +00:00
Niko Matsakis
957935a002 Fix merge errors 2015-06-16 12:08:37 -04:00
Steve Klabnik
5a63326442 One more consistency fix in the reference
https://github.com/rust-lang/rust/pull/26323/files#r32503568
2015-06-16 11:29:20 -04:00
Björn Steinbrink
cabd0682e9 Avoid deref/ref cycles for no-op coercions between unsafe pointers
Unlike coercing from reference to unsafe pointer, coercing between two
unsafe pointers doesn't need an AutoDerefRef, because there is no region
that regionck would need to know about.

In unoptimized libcore, this reduces the number of "auto_deref" allocas
from 174 to 4.
2015-06-16 14:10:52 +02:00
Ulrik Sverdrup
04315949fb test: Fix a bug in bench result formatting
It would skip the middle part if it was 0, displaying a number a 1000
times too small. The MB/s number next to it gave it away.

Fixed it looks like this:

```
test h ... bench:   1,000,129 ns/iter (+/- 4,730)
```
2015-06-16 13:10:27 +02:00
bors
520a471bc5 Auto merge of #26323 - steveklabnik:gh26320, r=alexcrichton
Fixes #26320
2015-06-16 10:40:33 +00:00
bors
4806210db9 Auto merge of #26318 - steveklabnik:gh26268, r=alexcrichton
Fixes #26268
2015-06-16 08:20:57 +00:00
bors
00382a592b Auto merge of #26317 - steveklabnik:gh25956, r=alexcrichton
It isn't really neccesary, but is pretty dense.

Fixes #25956
2015-06-16 06:44:56 +00:00
bors
f6d53af85f Auto merge of #24719 - :patch-1, r=steveklabnik 2015-06-16 05:08:13 +00:00
joliv
b87056fa31 Add unit type info and update associated link
Fixes #25244
2015-06-15 23:04:55 -04:00
bors
af8a4a0805 Auto merge of #26313 - steveklabnik:fix_str_docs, r=alexcrichton
Because these structures are created by a macro, the doc comments
don't quite work: the leading /// isn't stripped. Instead, just
use #[doc] so that they render correctly.
2015-06-16 01:57:34 +00:00
bors
906ad72462 Auto merge of #26311 - jooert:fix25855, r=steveklabnik
Use result of the computation to prevent the compiler from optimising
too much. Change `_x` to `x` and therefore remove the paragraph about
the underscore.

Fixes #25855.

r? @steveklabnik
2015-06-15 23:48:39 +00:00
Niko Matsakis
13cee1e198 This new caching sometimes suppresses duplicate errors that occur in
different parts of the crate, so modify the test cases that were relying
on that to test distinct types etc.
2015-06-15 17:31:27 -04:00
Niko Matsakis
f0f13f86ef Rather than expanding the where-clauses in the environment over and over
again, do it once and then just remember the expanded form. At the same
time, filter globally nameable predicates out of the environment, since
they can cause cache errors (and they are not necessary in any case).
2015-06-15 17:31:27 -04:00
Niko Matsakis
ff89fcf83b Add a (somewhat hacky) cache to the tcx that tracks "global" trait refs
that are known to have been satisfied *somewhere*. This means that if
one fn finds that `SomeType: Foo`, then every other fn can just consider
that to hold.

Unfortunately, there are some complications:

1. If `SomeType: Foo` includes dependent conditions, those conditions
   may trigger an error. This error will be repored in the first fn
   where `SomeType: Foo` is evaluated, but not in the other fns, which
   can lead to uneven error reporting (which is sometimes confusing).

2. This kind of caching can be unsound in the presence of
   unsatisfiable where clauses. For example, suppose that the first fn
   has a where-clause like `i32: Bar<u32>`, which in fact does not
   hold. This will "fool" trait resolution into thinking that `i32:
   Bar<u32>` holds. This is ok currently, because it means that the
   first fn can never be calle (since its where clauses cannot be
   satisfied), but if the first fn's successful resolution is cached, it
   can allow other fns to compile that should not. This problem is fixed
   in the next commit.
2015-06-15 17:31:26 -04:00
bors
c656e99e43 Auto merge of #26282 - arielb1:probe-leak, r=nikomatsakis
It can introduce obligations to the fulfillment context, which would
incorrectly still remain after the probe finished.

Fixes #25679.

r? @eddyb
2015-06-15 21:27:43 +00:00
Steve Klabnik
22b6a5dc2a Significantly simplify generic example
Fixes #26320
2015-06-15 16:38:05 -04:00
bors
73fb19c04a Auto merge of #26275 - arielb1:unconstrained-projection, r=nikomatsakis
Fixes #26262

Because this rejects code that previously compiled, this is a [breaking-change]

r? @nikomatsakis
2015-06-15 19:52:15 +00:00
Steven Walter
85be7c5f75 src/rt/arch/i386/morestack.S: call rust_stack_exhausted via plt
This prevents a relocation in the text section.  Text relocations are
incompatible with hardened kernels.

https://github.com/rust-lang/rust/issues/5714
2015-06-15 14:56:50 -04:00
bors
a53a098b72 Auto merge of #26293 - mihneadb:rustdoc-search-orphan-methods, r=alexcrichton
In https://github.com/rust-lang/rust/pull/23289, I did not include the type information for searching for orphan methods (methods that are defined in a module and implemented in another - doing this causes rustdoc sometimes to first find the impl before the actual type).

This PR fixes this. By merging this, searches for `char -> bool` will also find `is_alphabetic`, for example (which otherwise was only found for `charext -> bool`).


cc @alexcrichton
2015-06-15 18:17:22 +00:00
Steve Klabnik
1792ef6ae4 Clarify that the following will error
Fixes #26268
2015-06-15 13:18:07 -04:00
Steve Klabnik
75ffcd8e59 Remove confusing paragraph from Trait Objects
It isn't really neccesary, but is pretty dense.

Fixes #25956
2015-06-15 13:16:16 -04:00
Johannes Oertel
3e7ab1b5cb Update example in "Rust Inside Other Languages"
Use result of the computation to prevent the compiler from optimising
too much. Change `_x` to `x` and therefore remove the paragraph about
the underscore.

Fixes #25855.
2015-06-15 19:12:34 +02:00
Steve Klabnik
3db26db24a remove confusing 1i32
The font can make this hard to read, and we don't even strictly need
the annotation, so let's just remove it

Fixes #26287
2015-06-15 12:42:07 -04:00
Steve Klabnik
f84ad0a001 Fix broken link in TRPL: introduction
Fixes #26312
2015-06-15 12:31:40 -04:00