]> git.lizzy.rs Git - rust.git/log
rust.git
6 years agorustc: Preallocate when building the dep graph
Alex Crichton [Fri, 15 Sep 2017 04:28:55 +0000 (21:28 -0700)]
rustc: Preallocate when building the dep graph

This commit alters the `query` function in the dep graph module to preallocate
memory using `with_capacity` instead of relying on automatic growth. Discovered
in #44576 it was found that for the syntex_syntax clean incremental benchmark
the peak memory usage was found when the dep graph was being saved, particularly
the `DepGraphQuery` data structure itself. PRs like #44142 which add more
queries end up just making this much larger!

I didn't see an immediately obvious way to reduce the size of the
`DepGraphQuery` object, but it turns out that `with_capacity` helps quite a bit!
Locally 831 MB was used [before] this commit, and 770 MB is in use at the peak
of the compiler [after] this commit. That's a nice 7.5% improvement! This won't
quite make up for the losses in #44142 but I figured it's a good start.

[before]: https://gist.github.com/alexcrichton/2d2b9c7a65503761925c5a0bcfeb0d1e
[before]: https://gist.github.com/alexcrichton/6da51f2a6184bfb81694cc44f06deb5b

6 years agoAuto merge of #44502 - alexcrichton:remove-session-dep-graph, r=michaelwoerister
bors [Thu, 14 Sep 2017 19:37:11 +0000 (19:37 +0000)]
Auto merge of #44502 - alexcrichton:remove-session-dep-graph, r=michaelwoerister

rustc: Remove `Session::dep_graph`

This commit removes the `dep_graph` field from the `Session` type according to
issue #44390. Most of the fallout here was relatively straightforward and the
`prepare_session_directory` function was rejiggered a bit to reuse the results
in the later-called `load_dep_graph` function.

Closes #44390

6 years agorustc: Remove `Session::dep_graph`
Alex Crichton [Sat, 9 Sep 2017 18:02:18 +0000 (11:02 -0700)]
rustc: Remove `Session::dep_graph`

This commit removes the `dep_graph` field from the `Session` type according to
issue #44390. Most of the fallout here was relatively straightforward and the
`prepare_session_directory` function was rejiggered a bit to reuse the results
in the later-called `load_dep_graph` function.

Closes #44390

6 years agoAuto merge of #44480 - Zoxc:gen-liveness, r=arielb1
bors [Thu, 14 Sep 2017 12:28:31 +0000 (12:28 +0000)]
Auto merge of #44480 - Zoxc:gen-liveness, r=arielb1

Analyse storage liveness and preserve it during generator transformation

This uses a dataflow analysis on `StorageLive` and `StorageDead` statements to infer where the storage of locals are live. The result of this analysis is intersected with the regular liveness analysis such that a local is can only be live when its storage is. This fixes https://github.com/rust-lang/rust/issues/44184. If the storage of a local is live across a suspension point, we'll insert a `StorageLive` statement for it after the suspension point so storage liveness is preserved. This fixes https://github.com/rust-lang/rust/issues/44179.

r? @arielb1

6 years agoAuto merge of #44526 - leodasvacas:remove-deprecated-lang-items, r=arielb1
bors [Thu, 14 Sep 2017 09:18:28 +0000 (09:18 +0000)]
Auto merge of #44526 - leodasvacas:remove-deprecated-lang-items, r=arielb1

Remove deprecated lang items

They have been deprecated for years and there is no trace left of them in the compiler. Also removed `require_owned_box` which is dead code and other small refactorings.

6 years agoAuto merge of #43972 - TobiasSchaffner:std_clean, r=alexcrichton
bors [Thu, 14 Sep 2017 03:02:58 +0000 (03:02 +0000)]
Auto merge of #43972 - TobiasSchaffner:std_clean, r=alexcrichton

 Add the libstd-modifications needed for the L4Re target

This commit adds the needed modifications to compile the std crate for the L4 Runtime environment (L4Re).

A target for the L4Re was introduced in commit: c151220a84e40b65e45308cc0f3bbea4466d3acf

In many aspects implementations for linux also apply for the L4Re microkernel.

Some uncommon characteristics had to be resolved:
 * L4Re has no network funktionality
 * L4Re has a maximum stacksize of 1Mb for threads
 * L4Re has no uid or gid

Co-authored-by: Sebastian Humenda <sebastian.humenda@tu-dresden.de>
6 years agoAuto merge of #44484 - tirr-c:issue-44332, r=petrochenkov
bors [Thu, 14 Sep 2017 00:28:27 +0000 (00:28 +0000)]
Auto merge of #44484 - tirr-c:issue-44332, r=petrochenkov

Parse nested closure with two consecutive parameter lists properly

This is a followup of #44332.

---

Currently, in nightly, this does not compile:

```rust
fn main() {
    let f = |_||x, y| x+y;
    println!("{}", f(())(1, 2)); // should print 3
}
```

`|_||x, y| x+y` should be parsed as `|_| (|x, y| x+y)`, but the parser didn't accept `||` between `_` and `x`. This patch fixes the problem.

r? @petrochenkov

6 years agoFix a bug where StorageIgnored had an incorrect buffer length
John Kåre Alsaker [Wed, 13 Sep 2017 21:27:40 +0000 (23:27 +0200)]
Fix a bug where StorageIgnored had an incorrect buffer length

6 years agoFix nits and refactor creation of StorageLive blocks
John Kåre Alsaker [Mon, 11 Sep 2017 16:11:21 +0000 (18:11 +0200)]
Fix nits and refactor creation of StorageLive blocks

6 years agoMake sure we aren't using dead locals
John Kåre Alsaker [Mon, 11 Sep 2017 10:15:35 +0000 (12:15 +0200)]
Make sure we aren't using dead locals

6 years agoAnalyse storage liveness and preserve it during generator transformation
John Kåre Alsaker [Sun, 10 Sep 2017 20:34:56 +0000 (22:34 +0200)]
Analyse storage liveness and preserve it during generator transformation

6 years agoAuto merge of #44516 - gaurikholkar:fns, r=arielb1
bors [Wed, 13 Sep 2017 21:20:19 +0000 (21:20 +0000)]
Auto merge of #44516 - gaurikholkar:fns, r=arielb1

Extend E0623 for fn items

This fixes #44516
The below example now gives
```
error[E0623]: lifetime mismatch
 --> gg.rs:3:10
  |
2 | fn foo(x:fn(&u8, &u8), y: Vec<&u8>, z: &u8) {
  |                               ---      --- these two types are declared with different lifetimes...
3 |   y.push(z);
  |          ^ ...but data from `z` flows into `y` here

error: aborting due to previous error
```

r? @nikomatsakis
cc @arielb1

6 years agoFix initial review
leonardo.yvens [Wed, 13 Sep 2017 17:21:16 +0000 (14:21 -0300)]
Fix initial review

6 years agofix ui tests
gaurikholkar [Wed, 13 Sep 2017 15:26:27 +0000 (20:56 +0530)]
fix ui tests

6 years agoRefactor fn_trait_kind
leonardo.yvens [Wed, 13 Sep 2017 15:19:37 +0000 (12:19 -0300)]
Refactor fn_trait_kind

Short and sweet

6 years agoRefactor how to get a lang item's name
leonardo.yvens [Wed, 13 Sep 2017 15:00:40 +0000 (12:00 -0300)]
Refactor how to get a lang item's name

Small refactorings

6 years agoRemove require_owned_box
leonardo.yvens [Wed, 13 Sep 2017 14:16:45 +0000 (11:16 -0300)]
Remove require_owned_box

It's unused and unnecessary

6 years agoAuto merge of #44129 - pnkfelix:fix-end-region-emission-order, r=nmatsakis
bors [Wed, 13 Sep 2017 13:01:42 +0000 (13:01 +0000)]
Auto merge of #44129 - pnkfelix:fix-end-region-emission-order, r=nmatsakis

Fix end region emission order

Fix #43481

6 years agoTest case illustrating some destruction code extent stuff.
Felix S. Klock II [Thu, 31 Aug 2017 11:32:52 +0000 (13:32 +0200)]
Test case illustrating some destruction code extent stuff.

6 years agoUnit test for proper EndRegion emission on a cyclic reference.
Felix S. Klock II [Mon, 28 Aug 2017 11:39:06 +0000 (13:39 +0200)]
Unit test for proper EndRegion emission on a cyclic reference.

6 years agoUpdate mir-opt tests to reflect change to EndRegion emission order.
Felix S. Klock II [Mon, 28 Aug 2017 09:40:37 +0000 (11:40 +0200)]
Update mir-opt tests to reflect change to EndRegion emission order.

Driveby fix to end_region_9.rs; it was missing END marker and was
therefore always passing (regardless of output correctness).

6 years agoFix issue #43481: emit the EndRegion *before* StorageDeads for a scope.
Felix S. Klock II [Tue, 22 Aug 2017 13:54:57 +0000 (15:54 +0200)]
Fix issue #43481: emit the EndRegion *before* StorageDeads for a scope.

(The idea is that the StorageDead marks the point where the memory can
be deallocated, and the EndRegion is marking where borrows of that
memory can no longer legally exist.)

6 years agoAuto merge of #44386 - est31:master, r=pnkfelix
bors [Wed, 13 Sep 2017 10:28:33 +0000 (10:28 +0000)]
Auto merge of #44386 - est31:master, r=pnkfelix

Fix mispositioned error indicators

Fixes #38384

Most of the Rust community uses 4 spaces for indentation,
but there are also tab users of Rust (including myself!).

This patch fixes a bug in error printing which mispositions
error indicators when near code with tabs.

The code attempted to fix the issue by replacing spaces
with tabs, but it sadly wasn't enough, as sometimes
you may not print spaces but _ or ^ instead.

This patch employs the reverse strategy: it replaces each
tab with a space, so that the number of _ and ^ and spaces
in error indicators below the code snippet line up
perfectly.

In a study [1] preceeding this patch, we could see that
this strategy is also chosen by gcc version 6.3.0.

Its not perfect, as the output is not beautiful, but its
the easiest to implement. If anyone wants to improve on
this, be my guest! This patch is meant as improvement of
the status quo, not as perfect end status. It fixes the
actual issue of mispositioning error indicators.

[1]: https://github.com/rust-lang/rust/issues/38384#issuecomment-326813710

6 years agoMove default stack min size to thread implementations
Tobias Schaffner [Sat, 9 Sep 2017 09:09:34 +0000 (11:09 +0200)]
Move default stack min size to thread implementations

The default min stack size value is smaller on l4re and therefore
this value has to be different depending on the platform.

6 years agoAuto merge of #44420 - alexcrichton:private-cstore, r=michaelwoerister
bors [Wed, 13 Sep 2017 05:32:00 +0000 (05:32 +0000)]
Auto merge of #44420 - alexcrichton:private-cstore, r=michaelwoerister

rustc: Make `CrateStore` private to `TyCtxt`

This commit makes the `CrateStore` object private to the `ty/context.rs` module and also absent on the `Session` itself.

cc #44390
cc #44341 (initial commit pulled and rebased from here)

6 years agorustc: Make `CrateStore` private to `TyCtxt`
Alex Crichton [Thu, 7 Sep 2017 20:21:46 +0000 (13:21 -0700)]
rustc: Make `CrateStore` private to `TyCtxt`

This commit removes the `cstore_untracked` method, making the `CrateStore` trait
object entirely private to the `ty/context.rs` module.

6 years agoAuto merge of #44456 - eddyb:stable-drop-const, r=nikomatsakis
bors [Wed, 13 Sep 2017 03:04:49 +0000 (03:04 +0000)]
Auto merge of #44456 - eddyb:stable-drop-const, r=nikomatsakis

Stabilize drop_types_in_const.

Closes #33156, stabilizing the new, revised, rules, and improving the error message.

r? @nikomatsakis cc @SergioBenitez

6 years agoAuto merge of #44015 - kennytm:hasher, r=alexcrichton
bors [Tue, 12 Sep 2017 21:39:08 +0000 (21:39 +0000)]
Auto merge of #44015 - kennytm:hasher, r=alexcrichton

 impl Hasher for {&mut Hasher, Box<Hasher>}

**Rationale:** The `Hash` trait has `fn hash<H: Hasher>(&self, state: &mut H)`, which can only accept a `Sized` hasher, even if the `Hasher` trait is object-safe. We cannot retroactively add the `?Sized` bound without breaking stability, thus implementing `Hasher` to a trait object reference is the next best solution.

**Warning:** These `impl` are insta-stable, and should need an FCP. I don't think a full RFC is necessary.

6 years agoRemove deprecated lang items
leonardo.yvens [Tue, 12 Sep 2017 20:04:26 +0000 (17:04 -0300)]
Remove deprecated lang items

They have been deprecated for years and there is no trace left of them
in the compiler.

6 years agoAuto merge of #44133 - vorner:allocator-kind-autodetect, r=alexcrichton
bors [Tue, 12 Sep 2017 18:12:21 +0000 (18:12 +0000)]
Auto merge of #44133 - vorner:allocator-kind-autodetect, r=alexcrichton

Autodetect the type of allocator crate used

Annotate the allocator crates (allocator_system, allocator_jemalloc) by the type of allocator they are. If one is requested as an exe allocator, detect its type by the flags.

This has the effect that using this (de jure wrong) configuration in the target spec works instead of producing a really unhelpful and arcane linker error:

"exe-allocation-crate": "alloc_system"

Fixes #43524.

There are two yet unsolved FIXME's, I'll be glad for some advice on what to do with them.

6 years agoRemove the `cstore` reference from Session in order to prepare encapsulating CrateSto...
Michael Woerister [Tue, 5 Sep 2017 14:48:24 +0000 (16:48 +0200)]
Remove the `cstore` reference from Session in order to prepare encapsulating CrateStore access in tcx.

6 years agoAdding changes for trait objects
gaurikholkar [Tue, 12 Sep 2017 12:52:22 +0000 (18:22 +0530)]
Adding changes for trait objects

6 years agoAuto merge of #44413 - est31:move_man, r=nikomatsakis
bors [Tue, 12 Sep 2017 12:41:23 +0000 (12:41 +0000)]
Auto merge of #44413 - est31:move_man, r=nikomatsakis

Move the man directory to a subdirectory

There is no reason it should be in the top directory.

6 years agoadd ui test for fn items, tidy fixes
gaurikholkar [Tue, 12 Sep 2017 11:18:01 +0000 (16:48 +0530)]
add ui test for fn items, tidy fixes

6 years agoAuto merge of #44344 - jonhoo:entry_or_default, r=BurntSushi
bors [Tue, 12 Sep 2017 09:54:59 +0000 (09:54 +0000)]
Auto merge of #44344 - jonhoo:entry_or_default, r=BurntSushi

Add or_default to Entry APIs

As argued for in #44324, this PR adds a new `or_default` method to the various `Entry` APIs (currently just for `BTreeMap` and `HashMap`) when `V: Default`. This method is effectively a shorthand for `or_insert_with(Default::default)`.

6 years agoDisable the new Hasher tests on Emscripten.
kennytm [Sun, 10 Sep 2017 16:13:19 +0000 (00:13 +0800)]
Disable the new Hasher tests on Emscripten.

6 years agoimpl Hasher for {&mut Hasher, Box<Hasher>}
kennytm [Mon, 21 Aug 2017 14:15:02 +0000 (22:15 +0800)]
impl Hasher for {&mut Hasher, Box<Hasher>}

6 years agoAuto merge of #44310 - ldr709:master, r=BurntSushi
bors [Tue, 12 Sep 2017 07:13:40 +0000 (07:13 +0000)]
Auto merge of #44310 - ldr709:master, r=BurntSushi

Additional traits for std::mem::ManuallyDrop

The first commit adds `Clone` and `Copy` trait implementations for `ManuallyDrop`. Although `Drop` and `Copy` cannot be used together, this may be useful for generics.

The second commit adds implementations common traits. I do not think this is necessary, as they could be implemented in a wrapper type outside the standard library, but it would make `ManuallyDrop` more convenient to use.

6 years agofixes
gaurikholkar [Mon, 11 Sep 2017 19:04:52 +0000 (00:34 +0530)]
fixes

6 years agocorrect depth initialisation
gaurikholkar [Mon, 11 Sep 2017 18:28:29 +0000 (23:58 +0530)]
correct depth initialisation

6 years agoadd logs
gaurikholkar [Tue, 15 Aug 2017 16:46:29 +0000 (22:16 +0530)]
add logs

6 years agoextend E0623 for fns
gaurikholkar [Tue, 15 Aug 2017 04:51:31 +0000 (10:21 +0530)]
extend E0623 for fns

6 years agoAdding E0623 for structs
gaurikholkar [Sat, 5 Aug 2017 22:39:43 +0000 (04:09 +0530)]
Adding E0623 for structs

6 years agoAuto merge of #44275 - eddyb:deferred-ctfe, r=nikomatsakis
bors [Tue, 12 Sep 2017 04:14:07 +0000 (04:14 +0000)]
Auto merge of #44275 - eddyb:deferred-ctfe, r=nikomatsakis

Evaluate fixed-length array length expressions lazily.

This is in preparation for polymorphic array lengths (aka `[T; T::A]`) and const generics.
We need deferred const-evaluation to break cycles when array types show up in positions which require knowing the array type to typeck the array length, e.g. the array type is in a `where` clause.

The final step - actually passing bounds in scope to array length expressions from the parent - is not done because it still produces cycles when *normalizing* `ParamEnv`s, and @nikomatsakis' in-progress lazy normalization work is needed to deal with that uniformly.

However, the changes here are still useful to unlock work on const generics, which @EpicatSupercell manifested interest in, and I might be mentoring them for that, but we need this baseline first.

r? @nikomatsakis cc @oli-obk

6 years agoAuto merge of #43716 - MaloJaffre:_-in-literals, r=petrochenkov
bors [Tue, 12 Sep 2017 01:25:23 +0000 (01:25 +0000)]
Auto merge of #43716 - MaloJaffre:_-in-literals, r=petrochenkov

Accept underscores in unicode escapes

Fixes #43692.

I don't know if this need an RFC, but at least the impl is here!

6 years agoAuto merge of #44498 - alexcrichton:fix-nightlies, r=alexcrichton
bors [Mon, 11 Sep 2017 22:49:20 +0000 (22:49 +0000)]
Auto merge of #44498 - alexcrichton:fix-nightlies, r=alexcrichton

rustbuild: Fix a distribution bug with rustdoc

Apparently `File::create` was called when there was an existing hard link or the
like, causing an existing file to get accidentally truncated!

Closes #44487

6 years agoAuto merge of #44442 - Aaron1011:promote-static-ref, r=eddyb
bors [Mon, 11 Sep 2017 20:02:19 +0000 (20:02 +0000)]
Auto merge of #44442 - Aaron1011:promote-static-ref, r=eddyb

Fix regression in promotion of rvalues referencing a static

This commit makes librustc_passes::consts::CheckCrateVisitor properly
mark expressions as promotable if they reference a static, as it's
perfectly fine for one static to reference another. It fixes a
regression that prevented a temporary rvalue from referencing a static
if it was itself declared within a static.

Prior to commit https://github.com/rust-lang/rust/commit/b8c05fe90bc,
`region::ScopeTree` would only register a 'terminating scope' for function
bodies. Thus, while rvalues in a static that referenced a static would be marked
unpromotable, the lack of enclosing scope would cause
mem_categorization::MemCategorizationContext::cat_rvalue_node
to compute a 'temporary scope' of `ReStatic`. Since this had the same
effect as explicitly selecting a scope of `ReStatic`
due to the rvalue being marked by CheckCrateVisitor as promotable,
no issue occurred.

However, commit https://github.com/rust-lang/rust/commit/b8c05fe90bc
made ScopeTree unconditionally register a 'terminating scope'
Since mem_categorization would now compute a non-static 'temporary scope', the
aforementioned rvalues would be erroneously marked as living for too
short a time.

By fixing the behavior of CheckCrateVisitor, this commit avoids changing
mem_categorization's behavior, while ensuring that temporary values in
statics are still allowed to reference other statics.

Fixes issue #44373

6 years agorustbuild: Fix a distribution bug with rustdoc
Alex Crichton [Mon, 11 Sep 2017 18:01:48 +0000 (11:01 -0700)]
rustbuild: Fix a distribution bug with rustdoc

Apparently `File::create` was called when there was an existing hard link or the
like, causing an existing file to get accidentally truncated!

Closes #44487

6 years agoAuto merge of #44435 - alexcrichton:in-scope, r=michaelwoerister
bors [Mon, 11 Sep 2017 15:35:35 +0000 (15:35 +0000)]
Auto merge of #44435 - alexcrichton:in-scope, r=michaelwoerister

rustc: Remove HirId from queries

This'll allow us to reconstruct query parameters purely from the `DepNode`
they're associated with.

Closes #44414

6 years agorustc: Remove HirId from queries
Alex Crichton [Fri, 8 Sep 2017 20:51:57 +0000 (13:51 -0700)]
rustc: Remove HirId from queries

This'll allow us to reconstruct query parameters purely from the `DepNode`
they're associated with. Some queries could move straight to `HirId` but others
that don't always have a correspondance between `HirId` and `DefId` moved to
two-level maps where the query operates over a `DefIndex`, returning a map,
which is then keyed off `ItemLocalId`.

Closes #44414

6 years agoUpdate comment to properly describe static promotion restrictions
Aaron Hill [Mon, 11 Sep 2017 14:51:28 +0000 (10:51 -0400)]
Update comment to properly describe static promotion restrictions

6 years agoAuto merge of #44440 - cuviper:min_global_align, r=japaric
bors [Mon, 11 Sep 2017 12:53:21 +0000 (12:53 +0000)]
Auto merge of #44440 - cuviper:min_global_align, r=japaric

Add `TargetOptions::min_global_align`, with s390x at 16-bit

The SystemZ `LALR` instruction provides PC-relative addressing for globals,
but only to *even* addresses, so other compilers make sure that such
globals are always 2-byte aligned.  In Clang, this is modeled with
`TargetInfo::MinGlobalAlign`, and `TargetOptions::min_global_align` now
serves the same purpose for rustc.

In Clang, the only targets that set this are SystemZ, Lanai, and NVPTX, and
the latter two don't have targets in rust master.

Fixes #44411.
r? @eddyb

6 years agoAuto merge of #44410 - alexcrichton:fix-travis, r=Mark-Simulacrum
bors [Mon, 11 Sep 2017 09:47:06 +0000 (09:47 +0000)]
Auto merge of #44410 - alexcrichton:fix-travis, r=Mark-Simulacrum

Fix sanitizer tests on buggy kernels

Travis recently pushed an update to the Linux environments, namely the kernels
that we're running on. This in turn caused some of the sanitizer tests we run to
fail. We also apparently weren't the first to hit these failures! Detailed in
google/sanitizers#837 these tests were failing due to a specific commit in the
kernel which has since been backed out, but for now work around the buggy kernel
that's deployed on Travis and eventually we should be able to remove these
flags.

6 years agoAuto merge of #44385 - alexcrichton:new-sccache-keys, r=alexcrichton
bors [Mon, 11 Sep 2017 07:18:27 +0000 (07:18 +0000)]
Auto merge of #44385 - alexcrichton:new-sccache-keys, r=alexcrichton

Rotate Travis/AppVeyor S3 keys

Haven't done this in awhile so seems like a good idea!

6 years agorustc: use ConstVal::Unevaluated instead of mir::Literal::Item.
Eduard-Mihai Burtescu [Sun, 3 Sep 2017 17:34:48 +0000 (20:34 +0300)]
rustc: use ConstVal::Unevaluated instead of mir::Literal::Item.

6 years agorustc: evaluate fixed-length array length expressions lazily.
Eduard-Mihai Burtescu [Mon, 7 Aug 2017 05:08:53 +0000 (08:08 +0300)]
rustc: evaluate fixed-length array length expressions lazily.

6 years agorustc: remove obsolete const_val::ErrKind::{Negate,Not}On.
Eduard-Mihai Burtescu [Tue, 15 Aug 2017 15:35:31 +0000 (18:35 +0300)]
rustc: remove obsolete const_val::ErrKind::{Negate,Not}On.

6 years agorustc: use ty::Const for the length of TyArray.
Eduard-Mihai Burtescu [Sat, 5 Aug 2017 13:11:24 +0000 (16:11 +0300)]
rustc: use ty::Const for the length of TyArray.

6 years agorustc: replace usize with u64 and ConstUsize.
Eduard-Mihai Burtescu [Sat, 5 Aug 2017 09:27:28 +0000 (12:27 +0300)]
rustc: replace usize with u64 and ConstUsize.

6 years agorustc: introduce ty::Const { ConstVal, Ty }.
Eduard-Mihai Burtescu [Fri, 4 Aug 2017 08:25:13 +0000 (11:25 +0300)]
rustc: introduce ty::Const { ConstVal, Ty }.

6 years agorustc: intern ConstVal's in TyCtxt.
Eduard-Mihai Burtescu [Thu, 3 Aug 2017 21:41:44 +0000 (00:41 +0300)]
rustc: intern ConstVal's in TyCtxt.

6 years agoAuto merge of #44383 - qmx:gh/40473/no-inline-trait-method, r=nikomatsakis
bors [Mon, 11 Sep 2017 04:59:28 +0000 (04:59 +0000)]
Auto merge of #44383 - qmx:gh/40473/no-inline-trait-method, r=nikomatsakis

MIR: should not inline trait method

Fixes #40473.

The idea here is bailing out of inlining if we're talking about a trait method.

6 years agoAuto merge of #44375 - topecongiro:macrodef-span, r=petrochenkov
bors [Mon, 11 Sep 2017 02:23:24 +0000 (02:23 +0000)]
Auto merge of #44375 - topecongiro:macrodef-span, r=petrochenkov

Add visibility to span for macros 2.0

cc https://github.com/rust-lang-nursery/rustfmt/issues/1949.
r? @nrc

6 years agoAuto merge of #44316 - eddyb:no-local-var-def-id, r=michaelwoerister
bors [Sun, 10 Sep 2017 21:55:43 +0000 (21:55 +0000)]
Auto merge of #44316 - eddyb:no-local-var-def-id, r=michaelwoerister

Use NodeId/HirId instead of DefId for local variables.

r? @michaelwoerister

6 years agoAuto merge of #44220 - kennytm:fix-44216-instance-plus-max-duration-should-panic...
bors [Sun, 10 Sep 2017 18:37:27 +0000 (18:37 +0000)]
Auto merge of #44220 - kennytm:fix-44216-instance-plus-max-duration-should-panic, r=alexcrichton

Properly detect overflow in Instance ± Duration.

Fix #44216.
Fix #42622

The computation `Instant::now() + Duration::from_secs(u64::max_value())` now panics. The call `receiver.recv_timeout(Duration::from_secs(u64::max_value()))`, which involves such time addition, will also panic.

The reason #44216 arises is because of an unchecked cast from `u64` to `i64`, making the duration equivalent to -1 second.

Note that the current implementation is over-conservative, since e.g. (-2⁶²) + (2⁶³) is perfectly fine for an `i64`, yet this is rejected because (2⁶³) overflows the `i64`.

6 years agoAutodetect the type of allocator crate used
Michal 'vorner' Vaner [Sun, 10 Sep 2017 17:59:42 +0000 (19:59 +0200)]
Autodetect the type of allocator crate used

Annotate the allocator crates (allocator_system, allocator_jemalloc) by
the type of allocator they are. If one is requested as an exe allocator,
detect its type by the flags.

This has the effect that using this (de jure wrong) configuration in the
target spec works instead of producing a really unhelpful and arcane
linker error:

"exe-allocation-crate": "alloc_system"

Fixes #43524.

6 years agoParse nested closure with two consecutive parameter lists properly
Wonwoo Choi [Thu, 7 Sep 2017 06:07:49 +0000 (15:07 +0900)]
Parse nested closure with two consecutive parameter lists properly

6 years agoAuto merge of #44079 - gaurikholkar:named_conf, r=nikomatsakis
bors [Sun, 10 Sep 2017 15:32:20 +0000 (15:32 +0000)]
Auto merge of #44079 - gaurikholkar:named_conf, r=nikomatsakis

Extend E0623 for LateBound and EarlyBound Regions

This is a fix for #43882
```
fn foo<'a,'b>(x: &mut Vec<&'a u8>, y: &'b u8) {
    x.push(y);
}
```
now gives

```
error[E0623]: lifetime mismatch
  --> $DIR/ex3-both-anon-regions-latebound-regions.rs:12:12
   |
11 | fn foo<'a,'b>(x: &mut Vec<&'a u8>, y: &'b u8) {
   |                           ------      ------ these two types are declared with different lifetimes...
12 |     x.push(y);
   |            ^ ...but data from `y` flows into `x` here
```
cc @nikomatsakis @arielb1

Please ignore the second commit. It will be merged in a separate PR.

6 years agoAuto merge of #44474 - GuillaumeGomez:rollup, r=GuillaumeGomez
bors [Sun, 10 Sep 2017 12:48:55 +0000 (12:48 +0000)]
Auto merge of #44474 - GuillaumeGomez:rollup, r=GuillaumeGomez

Rollup of 13 pull requests

- Successful merges: #44262, #44329, #44332, #44347, #44372, #44384, #44387, #44396, #44449, #44451, #44457, #44464, #44467
- Failed merges:

6 years agoRollup merge of #44467 - toidiu:ak-44382, r=frewsxcv
Guillaume Gomez [Sun, 10 Sep 2017 12:03:32 +0000 (14:03 +0200)]
Rollup merge of #44467 - toidiu:ak-44382, r=frewsxcv

documentation update to demonstrate mutability

#44467

- demonstrate correct implementation returns `Some`
- demonstrate out of bounds returns `None`
- demonstrate mutability

6 years agoRollup merge of #44464 - Dushistov:master, r=alexcrichton
Guillaume Gomez [Sun, 10 Sep 2017 12:03:31 +0000 (14:03 +0200)]
Rollup merge of #44464 - Dushistov:master, r=alexcrichton

add test for #41229

Closes #41229

6 years agoRollup merge of #44457 - napen123:master, r=frewsxcv
Guillaume Gomez [Sun, 10 Sep 2017 12:03:30 +0000 (14:03 +0200)]
Rollup merge of #44457 - napen123:master, r=frewsxcv

Add doc examples for str::as_bytes_mut

Fixes #44427

6 years agoRollup merge of #44451 - Zoxc:gen-panic, r=eddyb
Guillaume Gomez [Sun, 10 Sep 2017 12:03:29 +0000 (14:03 +0200)]
Rollup merge of #44451 - Zoxc:gen-panic, r=eddyb

Fix bitrotted generator panic emission

r? @eddyb

6 years agoRollup merge of #44449 - tommyip:doc_string_as_str, r=frewsxcv
Guillaume Gomez [Sun, 10 Sep 2017 12:03:28 +0000 (14:03 +0200)]
Rollup merge of #44449 - tommyip:doc_string_as_str, r=frewsxcv

Add doc example to String::as_str

Fixes #44428.

6 years agoRollup merge of #44396 - joshlf:tls-comment, r=alexcrichton
Guillaume Gomez [Sun, 10 Sep 2017 12:03:27 +0000 (14:03 +0200)]
Rollup merge of #44396 - joshlf:tls-comment, r=alexcrichton

std::thread::LocalKey: Document limitation with initializers

Document that if a `LocalKey`'s initializer recursively depends on itself, initialization will result in infinite recursion.

6 years agoRollup merge of #44387 - est31:update_compiler_builtins, r=Mark-Simulacrum
Guillaume Gomez [Sun, 10 Sep 2017 12:03:26 +0000 (14:03 +0200)]
Rollup merge of #44387 - est31:update_compiler_builtins, r=Mark-Simulacrum

Update the libcompiler_builins submodule

Pulls in https://github.com/rust-lang-nursery/compiler-builtins/pull/187 for nicer build output :)

6 years agoRollup merge of #44384 - alexcrichton:osx-segfault, r=estebank
Guillaume Gomez [Sun, 10 Sep 2017 12:03:25 +0000 (14:03 +0200)]
Rollup merge of #44384 - alexcrichton:osx-segfault, r=estebank

std: Fix a segfault on OSX with backtraces

Apparently `dladdr` can succeed but still give you NULL pointers!

Closes #44379

6 years agoRollup merge of #44372 - bgermann:master, r=alexcrichton
Guillaume Gomez [Sun, 10 Sep 2017 12:03:24 +0000 (14:03 +0200)]
Rollup merge of #44372 - bgermann:master, r=alexcrichton

Use memalign instead of posix_memalign for Solaris

As pointed out in https://github.com/rust-lang/libc/commit/deb61c8,
Solaris 10 does not support posix_memalign.
Use memalign for all Solaris versions instead.
With this change applied I am able to cross-build rustc for Solaris 10.

6 years agoRollup merge of #44347 - GuillaumeGomez:rustdoc-false-positive, r=QuietMisdreavus
Guillaume Gomez [Sun, 10 Sep 2017 12:03:23 +0000 (14:03 +0200)]
Rollup merge of #44347 - GuillaumeGomez:rustdoc-false-positive, r=QuietMisdreavus

Reduce false positives number in rustdoc html diff

cc @rust-lang/dev-tools
r? @nrc

Very simple trick but should lighten html diff a bit

6 years agoRollup merge of #44332 - tirr-c:issue-44021, r=petrochenkov
Guillaume Gomez [Sun, 10 Sep 2017 12:03:22 +0000 (14:03 +0200)]
Rollup merge of #44332 - tirr-c:issue-44021, r=petrochenkov

Expect pipe symbol after closure parameter list

Fixes #44021.

---

Originally, the parser just called `bump` to discard following token after parsing closure parameter list, because it assumes `|` is following. However, the following code breaks the assumption:

```rust
struct MyStruct;
impl MyStruct {
   fn f() {|x, y}
}
```

Here, the parameter list is `x, y` and the following token is `}`. The parser discards `}`, and then we have a curly bracket mismatch.

Indeed, this code has a syntax error. On current nightly, the compiler emits an syntax error, but with incorrect message and span, followed by an ICE.

```
error: expected expression, found `}`
 --> 44021.rs:4:1
  |
4 | }
  | ^

error: internal compiler error: unexpected panic
```

Even worse, on current stable(1.20.0), the compiler falls into an infinite loop.

This pull request fixes this problem. Now the compiler emits correct error message and span, and does not ICE.

```
error: expected one of `:`, `@`, or `|`, found `}`
 --> 44021.rs:3:20
  |
3 |     fn foo() {|x, y}
  |                    ^ expected one of `:`, `@`, or `|` here
```

6 years agoRollup merge of #44329 - nrc:pulldown-warn-fix, r=ollie27
Guillaume Gomez [Sun, 10 Sep 2017 12:03:21 +0000 (14:03 +0200)]
Rollup merge of #44329 - nrc:pulldown-warn-fix, r=ollie27

Fixup some nits from #44238

r? @ollie27

6 years agoRollup merge of #44262 - alexcrichton:repr-128-gate, r=nikomatsakis
Guillaume Gomez [Sun, 10 Sep 2017 12:03:20 +0000 (14:03 +0200)]
Rollup merge of #44262 - alexcrichton:repr-128-gate, r=nikomatsakis

rustc: Separately feature gate repr(i128)

Brought up during the discussion of #35118, the support for this is still
somewhat buggy and so stabilization likely wants to be considered independently
of the type itself.

6 years agoAuto merge of #44312 - eddyb:static-by-any-other-name, r=alexcrichton
bors [Sun, 10 Sep 2017 10:09:47 +0000 (10:09 +0000)]
Auto merge of #44312 - eddyb:static-by-any-other-name, r=alexcrichton

Use rvalue promotion to 'static instead of static items.

Fixes #44240. Among other things, in crates that do a lot of formatting, this could reduce the number of items, although I haven't measured the performance benefits. If there's a codegen slowdown, that should IMO be solved by caching the output of miri, *not* by using `static`.

r? @alexcrichton

6 years agofix "correct" case in diagnostic error message
Niko Matsakis [Sun, 10 Sep 2017 10:08:29 +0000 (06:08 -0400)]
fix "correct" case in diagnostic error message

6 years agoUse rvalue promotion to 'static instead of static items.
Eduard-Mihai Burtescu [Mon, 4 Sep 2017 10:23:49 +0000 (13:23 +0300)]
Use rvalue promotion to 'static instead of static items.

6 years agoAuto merge of #44418 - alexcrichton:remove-dep-graph, r=michaelwoerister
bors [Sun, 10 Sep 2017 07:33:46 +0000 (07:33 +0000)]
Auto merge of #44418 - alexcrichton:remove-dep-graph, r=michaelwoerister

rustc: Remove `DepGraph` handling from rustc_metadata

This should now be entirely tracked through queries, so no need to have a
`DepGraph` in the `CStore` object any more!

cc #44390

6 years agoAuto merge of #44260 - alexcrichton:hardlink-no-copy, r=Mark-Simulacrum
bors [Sun, 10 Sep 2017 04:36:15 +0000 (04:36 +0000)]
Auto merge of #44260 - alexcrichton:hardlink-no-copy, r=Mark-Simulacrum

rustbuild: Switch back to using hard links

The `copy` function historically in rustbuild used hard links to speed up the
copy operations that it does. This logic was backed out, however, in #39518 due
to a bug that only showed up on Windows, described in #39504. The cause
described in #39504 happened because Cargo, on a fresh build, would overwrite
the previous artifacts with new hard links that Cargo itself manages.

This behavior in Cargo was fixed in rust-lang/cargo#4390 where it no longer
should overwrite files on fresh builds, opportunistically leaving the filesystem
intact and not touching it.

Hopefully this can help speed up local builds by doing fewer copies all over the
place!

6 years agoRelaxed error pattern, and add test for SystemTime as well.
kennytm [Sat, 9 Sep 2017 17:48:43 +0000 (01:48 +0800)]
Relaxed error pattern, and add test for SystemTime as well.

6 years agorustbuild: Switch back to using hard links
Alex Crichton [Sat, 2 Sep 2017 03:46:51 +0000 (20:46 -0700)]
rustbuild: Switch back to using hard links

The `copy` function historically in rustbuild used hard links to speed up the
copy operations that it does. This logic was backed out, however, in #39518 due
to a bug that only showed up on Windows, described in #39504. The cause
described in #39504 happened because Cargo, on a fresh build, would overwrite
the previous artifacts with new hard links that Cargo itself manages.

This behavior in Cargo was fixed in rust-lang/cargo#4390 where it no longer
should overwrite files on fresh builds, opportunistically leaving the filesystem
intact and not touching it.

Hopefully this can help speed up local builds by doing fewer copies all over the
place!

6 years agorustc: Remove `DepGraph` handling from rustc_metadata
Alex Crichton [Thu, 7 Sep 2017 19:35:21 +0000 (12:35 -0700)]
rustc: Remove `DepGraph` handling from rustc_metadata

This should now be entirely tracked through queries, so no need to have a
`DepGraph` in the `CStore` object any more!

6 years agoAuto merge of #44274 - Mark-Simulacrum:rustdoc-tests, r=alexcrichton
bors [Sun, 10 Sep 2017 01:24:14 +0000 (01:24 +0000)]
Auto merge of #44274 - Mark-Simulacrum:rustdoc-tests, r=alexcrichton

Test rustdoc.

Also fixes the broken tests.

r? @alexcrichton

6 years agodocumentation update to demonstrate mutability
toidiu [Sat, 9 Sep 2017 20:56:12 +0000 (16:56 -0400)]
documentation update to demonstrate mutability

6 years agoadd test for #41229
Evgeniy A. Dushistov [Sat, 9 Sep 2017 20:12:41 +0000 (23:12 +0300)]
add test for #41229

Closes #41229

6 years agoDon't promote references to statics that occur in non-static locations
Aaron Hill [Sat, 9 Sep 2017 20:01:45 +0000 (16:01 -0400)]
Don't promote references to statics that occur in non-static locations

6 years agoRotate Travis/AppVeyor S3 keys
Alex Crichton [Thu, 7 Sep 2017 05:47:56 +0000 (22:47 -0700)]
Rotate Travis/AppVeyor S3 keys

Haven't done this in awhile so seems like a good idea!

6 years agoAuto merge of #44251 - kennytm:osx-backtrace, r=alexcrichton
bors [Sat, 9 Sep 2017 17:32:13 +0000 (17:32 +0000)]
Auto merge of #44251 - kennytm:osx-backtrace, r=alexcrichton

Add libbacktrace support for Apple platforms (resubmitted)

Resubmitting #43422 rebased on the current master (cc @JohnColanduoni).

I have added an additional commit to fallback to `dladdr`-based `resolve_symbol` if `libbacktrace` returns `None`, otherwise the stack trace will be full of `<unknown>` when you forget to pass the `-g` flag (actually it seems — at least on macOS — the `dladdr` symbol is more accurate than the `libbacktrace` one).

6 years agoAdd doc examples for str::as_bytes_mut
Ethan Dagner [Sat, 9 Sep 2017 16:27:47 +0000 (10:27 -0600)]
Add doc examples for str::as_bytes_mut

Fixes #44427

6 years agoStabilize drop_types_in_const.
Eduard-Mihai Burtescu [Sat, 2 Sep 2017 07:35:01 +0000 (10:35 +0300)]
Stabilize drop_types_in_const.

6 years agoAuto merge of #44212 - eddyb:drop-const, r=nikomatsakis
bors [Sat, 9 Sep 2017 11:48:57 +0000 (11:48 +0000)]
Auto merge of #44212 - eddyb:drop-const, r=nikomatsakis

Allow Drop types in const's too, with #![feature(drop_types_in_const)].

Implements the remaining amendment, see #33156. cc @SergioBenitez

r? @nikomatsakis

6 years agoAuto merge of #44438 - Xaeroxe:clamp, r=Mark-Simulacrum
bors [Sat, 9 Sep 2017 09:13:03 +0000 (09:13 +0000)]
Auto merge of #44438 - Xaeroxe:clamp, r=Mark-Simulacrum

Revert clamp

Revert clamp per https://github.com/rust-lang/rust/issues/44095#issuecomment-328218316 while we take time to assess the potential backwards compatibility damage done by it.