Commit Graph

49389 Commits

Author SHA1 Message Date
Oliver Schneider 1471d932a9 move const block checks before lowering step
this makes sure the checks run before typeck (which might use the constant or const
function to calculate an array length) and gives prettier error messages in case of for
loops and such (since they aren't expanded yet).
2016-01-15 13:16:54 +01:00
bors 5b3a75fe56 Auto merge of #30883 - Manishearth:rollup, r=Manishearth
- Successful merges: #30626, #30662, #30770, #30801, #30818, #30823, #30828, #30835, #30837, #30839, #30845, #30848, #30850, #30851, #30863
- Failed merges:
2016-01-14 06:45:26 +00:00
Manish Goregaokar 1246f43bf9 Rollup merge of #30863 - jseyfried:no_rc, r=eddyb
Use arena allocation instead of reference counting for `Module`s to fix memory leaks from `Rc` cycles.

A module references its module children and its import resolutions, and an import resolution references the module defining the imported name, so there is a cycle whenever a module imports something from an ancestor module.

For example,
```rust
mod foo { // `foo` references `bar`.
    fn baz() {}
    mod bar { // `bar` references the import.
        use foo::baz; // The import references `foo`.
    }
}
```
2016-01-14 11:04:43 +05:30
Manish Goregaokar e51de045ef Rollup merge of #30851 - jonas-schievink:unneeded-dropflags, r=pnkfelix
Apparently we allocate and maintain non-working dropflag hints since June... In anticipation of a working implementation of on-stack drop flag hints, let's not spend even more time on types that don't even need to be dropped.

```rust
fn main() {
    let (i,j,k,l) = (0,0,0,0);
}
```
used to translate to (unoptimized only, of course):
```llvm
define internal void @_ZN4main20ha8deb085c47920d8eaaE() unnamed_addr #0 {
entry-block:
  %dropflag_hint_10 = alloca i8
  %dropflag_hint_11 = alloca i8
  %dropflag_hint_12 = alloca i8
  %dropflag_hint_13 = alloca i8
  %const = alloca { i32, i32, i32, i32 }
  %i = alloca i32
  %j = alloca i32
  %k = alloca i32
  %l = alloca i32
  store i8 61, i8* %dropflag_hint_10
  store i8 61, i8* %dropflag_hint_11
  store i8 61, i8* %dropflag_hint_12
  store i8 61, i8* %dropflag_hint_13
  %0 = bitcast { i32, i32, i32, i32 }* %const to i8*
  call void @llvm.memcpy.p0i8.p0i8.i64(i8* %0, i8* bitcast ({ i32, i32, i32, i32 }* @const2752 to i8*), i64 16, i32 4, i1 false)
  %1 = getelementptr inbounds { i32, i32, i32, i32 }, { i32, i32, i32, i32 }* %const, i32 0, i32 0
  %2 = load i32, i32* %1, align 4
  store i32 %2, i32* %i, align 4
  %3 = getelementptr inbounds { i32, i32, i32, i32 }, { i32, i32, i32, i32 }* %const, i32 0, i32 1
  %4 = load i32, i32* %3, align 4
  store i32 %4, i32* %j, align 4
  %5 = getelementptr inbounds { i32, i32, i32, i32 }, { i32, i32, i32, i32 }* %const, i32 0, i32 2
  %6 = load i32, i32* %5, align 4
  store i32 %6, i32* %k, align 4
  %7 = getelementptr inbounds { i32, i32, i32, i32 }, { i32, i32, i32, i32 }* %const, i32 0, i32 3
  %8 = load i32, i32* %7, align 4
  store i32 %8, i32* %l, align 4
  ret void
}
```

Now it gives:
```llvm
define internal void @_ZN4main20ha8deb085c47920d8eaaE() unnamed_addr #0 {
entry-block:
  %const = alloca { i32, i32, i32, i32 }
  %i = alloca i32
  %j = alloca i32
  %k = alloca i32
  %l = alloca i32
  %0 = bitcast { i32, i32, i32, i32 }* %const to i8*
  call void @llvm.memcpy.p0i8.p0i8.i64(i8* %0, i8* bitcast ({ i32, i32, i32, i32 }* @const2748 to i8*), i64 16, i32 4, i1 false)
  %1 = getelementptr inbounds { i32, i32, i32, i32 }, { i32, i32, i32, i32 }* %const, i32 0, i32 0
  %2 = load i32, i32* %1, align 4
  store i32 %2, i32* %i, align 4
  %3 = getelementptr inbounds { i32, i32, i32, i32 }, { i32, i32, i32, i32 }* %const, i32 0, i32 1
  %4 = load i32, i32* %3, align 4
  store i32 %4, i32* %j, align 4
  %5 = getelementptr inbounds { i32, i32, i32, i32 }, { i32, i32, i32, i32 }* %const, i32 0, i32 2
  %6 = load i32, i32* %5, align 4
  store i32 %6, i32* %k, align 4
  %7 = getelementptr inbounds { i32, i32, i32, i32 }, { i32, i32, i32, i32 }* %const, i32 0, i32 3
  %8 = load i32, i32* %7, align 4
  store i32 %8, i32* %l, align 4
  ret void
}
```

Let's hope I didn't break anything!
2016-01-14 11:04:43 +05:30
Manish Goregaokar 6ceaa2f77a Rollup merge of #30850 - ranma42:cleanup-io, r=alexcrichton
In 8d90d3f368 `BufStream`, the only
consumer of `InternalBufWriter`, was removed. As implied by the name,
this type is private, hence it is currently dead code.
2016-01-14 11:04:43 +05:30
Manish Goregaokar 24848846cc Rollup merge of #30839 - tomaka:debug-phantomdata, r=nikomatsakis
All the trait implementations of `PhantomData` use `impl<T: ?Sized>` except for `Debug`
https://doc.rust-lang.org/nightly/std/marker/struct.PhantomData.html#implementations

This PR fixes this.
2016-01-14 11:04:42 +05:30
Manish Goregaokar 837a8decb6 Rollup merge of #30837 - semarie:openbsd-libc, r=alexcrichton
The following PR updates libc version to latest commits for correctly support openbsd.
It corrects several points in rustc to be compatible with libc changes.

r? @alexcrichton
2016-01-14 11:04:42 +05:30
Manish Goregaokar 4ff1d20ad7 Rollup merge of #30835 - kraai:show-span, r=sanxiyn
I think this will fix #30656.
2016-01-14 11:04:41 +05:30
Manish Goregaokar 98c7519826 Rollup merge of #30828 - wheals:fix-dead-links, r=steveklabnik
See [the intrinsics page](https://doc.rust-lang.org/nightly/core/intrinsics/index.html) for example.
2016-01-14 11:04:41 +05:30
Manish Goregaokar 9036c82781 Rollup merge of #30823 - pnkfelix:put-back-alloca-zeroing-for-issue-30530, r=dotdash
Put back alloca zeroing for issues #29092, #30018, #30530; inject zeroing for #30822.

----

Background context: `fn alloca_zeroed` was removed in PR #22969, so we haven't been "zero'ing" (\*) the alloca's since at least that point, but the logic behind that PR seems sound, so its not entirely obvious how *long* the underlying bug has actually been present.  In other words, I have not yet done a survey to see when the new `alloc_ty` and `lvalue_scratch_datum` calls were introduced that should have had "zero'ing" the alloca's.

----

I first fixed #30018, then decided to do a survey of `alloc_ty` calls to see if they needed similar treatment, which quickly led to a rediscovery of #30530.

While making the regression test for the latter, I discovered #30822, which is a slightly different bug (in terms of where the "zero'ing" needs to go), but still relevant.

I haven't finished the aforementioned survey of `fn alloc_ty` calls, but I decided I wanted to get this up for review in its current state (namely to see if my attempt to force developers to include a justification for passing `Uninit` can possibly fly, or if I should abandon that path of action).

----

(*): I am putting quotation marks around "zero'ing" because we no longer use zero as our "dropped" marker value.

Fix #29092
Fix #30018
Fix #30530
Fix #30822
2016-01-14 11:04:41 +05:30
Manish Goregaokar 3e248aa09f Rollup merge of #30818 - sfackler:duration-hash, r=alexcrichton
tikue pointed out in IRC that this was missing.
2016-01-14 11:04:40 +05:30
Manish Goregaokar 6f4ede44de Rollup merge of #30801 - Amanieu:oom_print, r=alexcrichton
This adds the ability to override the default OOM behavior by setting a handler function. This is used by libstd to print a message when running out of memory instead of crashing with an obscure "illegal hardware instruction" error (at least on Linux).

Fixes #14674
2016-01-14 11:04:40 +05:30
Manish Goregaokar 6581563f7a Rollup merge of #30770 - steveklabnik:gh30345, r=brson
Fixes #30345

I'm not sure if there's anything else that belongs here. Thoughts?
2016-01-14 11:04:40 +05:30
Manish Goregaokar 40f06b4bb1 Rollup merge of #30626 - steveklabnik:gh30618, r=luqmana
Fixes #30618
2016-01-14 11:04:39 +05:30
bors e1f550ebc2 Auto merge of #30662 - simartin:issue_30592, r=alexcrichton
Fixes https://github.com/rust-lang/rust/issues/30592, a fallout of cd1848a1a6
2016-01-14 03:17:51 +00:00
bors 9f6917d426 Auto merge of #30466 - alexcrichton:move-wrapping-and-fill-out, r=aturon
This commit migrates all of the methods on `num::wrapping::OverflowingOps` onto
inherent methods of the integer types. This also fills out some missing gaps in
the saturating and checked departments such as:

* `saturating_mul`
* `checked_{neg,rem,shl,shr}`

This is done in preparation for stabilization,

cc #27755
2016-01-14 01:26:54 +00:00
bors 1447ce78fb Auto merge of #30870 - Eljay:issue-30477, r=alexcrichton
Fixes #30477, #30213.

The loop over reexports used to be a closure before #30043 but it's an iterator now so it should just continue instead of exiting the loop and skipping stuff.

r? @brson
2016-01-13 22:27:46 +00:00
Amanieu d'Antras 98bef2b818 Add missing newline character to callers of dumb_print 2016-01-13 20:40:25 +00:00
bors 6089ebaddb Auto merge of #30813 - fhahn:fix-ice-semicolon-in-lifetime, r=nrc
This PR fixes an ICE due to an DiagnosticsBuilder not being canceld or emitted.

Ideally it would use `Handler::cancel`, but I did not manage to get a `&mut` reference to the diagnostics handler.
2016-01-13 20:38:12 +00:00
Simon Martin c5da16012d Issue #30592: Restore build in --disable-jemalloc mode. 2016-01-13 21:15:00 +01:00
bors ac9be00ecc Auto merge of #30509 - michaelsproul:string-box-error, r=alexcrichton
Closes #30156.
2016-01-13 18:46:29 +00:00
bors b0eec55c3f Auto merge of #30794 - joerg-krause:fix-arm-unknown-linux-gnueabi-float-abi, r=alexcrichton
gnueabi indicates soft whereas gnueabihf indicates hard floating-point ABI.
2016-01-13 16:57:01 +00:00
bors 7aed245d69 Auto merge of #30779 - michaelwoerister:closure-mir-in-metadata, r=nikomatsakis 2016-01-13 15:08:07 +00:00
Felix S. Klock II decc286757 add doc for new `fn alloc_ty_init`.
(Note that it might be a good idea to replace *all* calls of
`alloc_ty` with calls to `alloc_ty_init`, to encourage programmers to
consider the appropriate value for the `init` flag when creating
temporary values.)
2016-01-13 14:29:50 +01:00
Felix S. Klock II 7706e2333e revise lifetime handling for alloca's that are initialized as "dropped."
(This can/should be revisited when drop flags are stored out of band.)
2016-01-13 14:29:50 +01:00
Felix S. Klock II 8168765d43 Factored out private routine for emitting LLVM lifetime intrinsic calls.
(The reason this is not factored as far as possible because a
subsequent commit is going to need to do construction without having
access to a `cx`.)
2016-01-13 14:29:50 +01:00
Felix S. Klock II df1283cd1a Unit/regression tests for issues #29092, #30018, #30530, #30822.
Note that the test for #30822 is folded into the test for #30530 (but
the file name mentions only 30530).
2016-01-13 14:29:25 +01:00
Felix S. Klock II f251ff4081 bug fixes for issues 30018 and 30822.
includes bugfixes pointed out during review:

 * Only `call_lifetime_start` for an alloca if the function entry does
   not itself initialize it to "dropped."

 * Remove `schedule_lifetime_end` after writing an *element* into a
   borrowed slice. (As explained by [dotdash][irc], "the lifetime end
   that is being removed was for an element in the slice, which is not
   an alloca of its own and has no lifetime start of its own")

[irc]: https://botbot.me/mozilla/rust-internals/2016-01-13/?msg=57844504&page=3
2016-01-13 14:02:06 +01:00
Lee Jeffery 42acf89e1f Fix rustdoc reexports. 2016-01-13 13:01:14 +00:00
bors d3c83fef24 Auto merge of #30684 - tshepang:rustfmt-lexer-part2, r=nrc 2016-01-13 12:22:51 +00:00
bors 8796e012cb Auto merge of #29498 - wthrowe:replace-pattern, r=alexcrichton
It appears this was left out of RFC rust-lang/rfcs#528 because it might be useful to
also generalize the second argument in some way.  That doesn't seem to
prevent generalizing the first argument now, however.

This is a [breaking-change] because it could cause type-inference to
fail where it previously succeeded.

Also update docs for a few other methods that still referred to `&str` instead of patterns.
2016-01-13 08:15:45 +00:00
bors f1bcfdd8e4 Auto merge of #30639 - rkruppe:dec2flt-fastpath-tables, r=alexcrichton
Add tables of small powers of ten used in the fast path. The tables are redundant: We could also use the big, more accurate table and round the value to the correct type (in fact we did just that before this commit). However, the rounding is extra work and slows down the fast path.

Because only very small exponents enter the fast path, the table and thus the space overhead is negligible. Speed-wise, this is a clear win on a [benchmark] comparing the fast path to a naive, hand-optimized, inaccurate algorithm. Specifically, this change narrows the gap from a roughly 5x difference to a roughly 3.4x difference.

[benchmark]: https://gist.github.com/Veedrac/dbb0c07994bc7882098e
2016-01-13 02:05:02 +00:00
Jeffrey Seyfried a8514d3ecc resolve: use arena allocation instead of reference counting for `Module`s to fix memory leaks from Rc cycles 2016-01-13 00:54:16 +00:00
Michael Sproul c1e527f11d Add an impl for Box<Error> from &str. 2016-01-13 10:38:44 +11:00
bors 49c3827790 Auto merge of #30601 - tamird:delegate-libc, r=alexcrichton
See: http://developer.android.com/ndk/downloads/revision_history.html

Also, use `libc`'s `posix_memalign`.
2016-01-12 22:49:02 +00:00
Robin Kruppe dad1df6c1a Speed up dec2flt fast path with additional tables.
Add tables of small powers of ten used in the fast path. The tables are redundant: We could also use the big, more accurate table and round the value to the correct type (in fact we did just that before this commit). However, the rounding is extra work and slows down the fast path.

Because only very small exponents enter the fast path, the table and thus the space overhead is negligible. Speed-wise, this is a clear win on a [benchmark] comparing the fast path to a naive, hand-optimized, inaccurate algorithm. Specifically, this change narrows the gap from a roughly 5x difference to a roughly 3.4x difference.

[benchmark]: https://gist.github.com/Veedrac/dbb0c07994bc7882098e
2016-01-12 22:25:16 +01:00
Tamir Duberstein 5657eefcd8 android has `posix_memalign` for API 16+ since NDK r10d
See: http://developer.android.com/ndk/downloads/revision_history.html

Also, use `libc`'s `posix_memalign`.
2016-01-12 15:04:59 -05:00
Steve Klabnik b6cc0995b0 Add some examples to std::string
Fixes #30345
2016-01-12 14:12:31 -05:00
Tshepang Lekhonkhobe aa3b4c668e re-instate comment that was mysteriously disappeared 2016-01-12 21:00:09 +02:00
Andrea Canciani fb82398b2a Remove dead `InternalBufWriter` implementation
In 8d90d3f368 `BufStream`, the only
consumer of `InternalBufWriter`, was removed. As implied by the name,
this type is private, hence it is currently dead code.
2016-01-12 18:10:43 +01:00
Jonas Schievink e3abc3cfe7 Don't use dropflag hints when the type is dropless 2016-01-12 18:04:21 +01:00
bors cf8b1ce250 Auto merge of #30719 - pyfisch:fix30657, r=alexcrichton 2016-01-12 16:30:20 +00:00
Felix S. Klock II cec7280bf3 debug instrumentation (can remove) 2016-01-12 15:24:52 +01:00
Felix S. Klock II 965b0bfefe Issue 30530: initialize allocas for `Datum::to_lvalue_datum_in_scope`.
In particular, bring back the `zero` flag for `lvalue_scratch_datum`,
which controls whether the alloca's created immediately at function
start are uninitialized at that point or have their embedded
drop-flags initialized to "dropped".

Then made `to_lvalue_datum_in_scope` pass "dropped" as `zero` flag.
2016-01-12 15:24:52 +01:00
Pierre Krieger 59df1d80f2 Fix the Debug impl of PhantomData requiring Sized on T 2016-01-12 11:23:18 +01:00
bors 7cffc9b195 Auto merge of #30695 - ranma42:cleanup-unicode, r=alexcrichton
and the associated update of tables.rs

The last commit is related to my comment to #29734.
2016-01-12 10:18:53 +00:00
bors 3246eaec90 Auto merge of #30678 - Amanieu:no_elf_tls, r=alexcrichton
I also re-enabled the use of `#[thread_local]` on AArch64. It was originally disabled in the PR that introduced AArch64 (#19790), but the reasons for this were not explained. `#[thread_local]` seems to work fine in my tests on AArch64, so I don't think this should be an issue.

cc @alexcrichton @akiss77
2016-01-12 08:30:56 +00:00
Sébastien Marie 667ee8a57b openbsd has dirent d_namlen field now 2016-01-12 08:43:53 +01:00
Sébastien Marie a545eac593 make siginfo_si_addr() returns a usize
`siginfo_si_addr()` function is used once, and the returned value is
casted to `usize`. So make the function returns a `usize`.

it simplifies OpenBSD case, where the return type wouldn't be a `*mut
libc::c_void` but a `*mut libc::c_char`.
2016-01-12 08:43:52 +01:00
Sébastien Marie 468959580a HW_AVAILCPU is unavailable under openbsd
define `num_cpus()` function for openbsd that use `HW_NCPU` for grabbing
the current number of cpus that could be used.
2016-01-12 08:43:52 +01:00