Commit Graph

311 Commits

Author SHA1 Message Date
Alex Crichton
1210ebff43 Merge remote-tracking branch 'origin/master' into gen 2017-08-16 10:03:47 -07:00
Felix S. Klock II
018784afc9 MIR based borrow check (opt-in).
One can either use `-Z borrowck-mir` or add the `#[rustc_mir_borrowck]` attribute
to opt into MIR based borrow checking.

Note that regardless of whether one opts in or not, AST-based borrow
check will still run as well.  The errors emitted from AST-based
borrow check will include a "(Ast)" suffix in their error message,
while the errors emitted from MIR-based borrow check will include a
"(Mir)" suffix.

post-rebase: removed check for intra-statement mutual conflict;
replaced with assertion checking that at most one borrow is generated
per statement.

post-rebase: removed dead code: `IdxSet::pairs` and supporting stuff.
2017-08-16 16:08:28 +02:00
Felix S. Klock II
9b8b8c6aeb Move DataFlowState::{each_bit,interpret_set} method definitions to parent module.
Refactored `each_bit`, which traverses a `IdxSet`, so that the bulk of
its implementation lives in `rustc_data_structures`.
2017-08-16 15:53:27 +02:00
Zack M. Davis
1b6c9605e4 use field init shorthand EVERYWHERE
Like #43008 (f668999), but _much more aggressive_.
2017-08-15 15:29:17 -07:00
Fourchaux
c7104be1a3 Fix typos & us spellings 2017-08-15 21:56:30 +02:00
Alex Crichton
1413253a41 Merge remote-tracking branch 'origin/master' into gen 2017-08-14 19:36:13 -07:00
bors
0d12553320 Auto merge of #43740 - michaelwoerister:local-id-in-typecktables, r=arielb1
Use hir::ItemLocalId as keys in TypeckTables.

This PR makes `TypeckTables` use `ItemLocalId` instead of `NodeId` as key. This is needed for incremental compilation -- for stable hashing and for being able to persist and reload these tables. The PR implements the most important part of https://github.com/rust-lang/rust/issues/40303.

Some notes on the implementation:
* The PR adds the `HirId` to HIR nodes where needed (`Expr`, `Local`, `Block`, `Pat`) which obviates the need to store a `NodeId -> HirId` mapping in crate metadata. Thanks @eddyb for the suggestion! In the future the `HirId` should completely replace the `NodeId` in HIR nodes.
* Before something is read or stored in one of the various `TypeckTables` subtables, the entry's key is validated via the new `TypeckTables::validate_hir_id()` method. This makes sure that we are not mixing information from different items in a single table.

That last part could be made a bit nicer by either (a) new-typing the table-key and making `validate_hir_id()` the only way to convert a `HirId` to the new-typed key, or (b) just encapsulate sub-table access a little better. This PR, however, contents itself with not making things significantly worse.

Also, there's quite a bit of switching around between `NodeId`, `HirId`, and `DefIndex`. These conversions are cheap except for `HirId -> NodeId`, so if the valued reviewer finds such an instance in a performance critical place, please let me know.

Ideally we convert more and more code from `NodeId` to `HirId` in the future so that there are no more `NodeId`s after HIR lowering anywhere. Then the amount of switching should be minimal again.

r? @eddyb, maybe?
2017-08-14 14:15:06 +00:00
bors
bffc973da8 Auto merge of #43794 - Eijebong:fix_typos, r=lukaramu,steveklanik,imperio
Fix some typos

I wrote a really naive script and found those typos in the documentation.
2017-08-12 05:52:19 +00:00
Michael Woerister
783ccc443b Make TypeckTables::type_dependent_defs use ItemLocalId instead of NodeId. 2017-08-11 12:11:38 +02:00
Bastien Orivel
47cb3c5bc2 Fix some typos 2017-08-11 00:16:18 +02:00
Alex Crichton
b8aa595e6d Merge remote-tracking branch 'origin/master' into gen 2017-08-10 14:05:58 -07:00
bors
d21ec9b4ef Auto merge of #43582 - ivanbakel:unused_mut_ref, r=arielb1
Fixed mutable vars being marked used when they weren't

#### NB : bootstrapping is slow on my machine, even with `keep-stage` - fixes for occurances in the current codebase are <s>in the pipeline</s> done. This PR is being put up for review of the fix of the issue.

Fixes #43526, Fixes #30280, Fixes #25049

### Issue
Whenever the compiler detected a mutable deref being used mutably, it marked an associated value as being used mutably as well. In the case of derefencing local variables which were mutable references, this incorrectly marked the reference itself being used mutably, instead of its contents - with the consequence of making the following code emit no warnings
```
fn do_thing<T>(mut arg : &mut T) {
    ... // don't touch arg - just deref it to access the T
}
```

### Fix
Make dereferences not be counted as a mutable use, but only when they're on borrows on local variables.
#### Why not on things other than local variables?
  * Whenever you capture a variable in a closure, it gets turned into a hidden reference - when you use it in the closure, it gets dereferenced. If the closure uses the variable mutably, that is actually a mutable use of the thing being dereffed to, so it has to be counted.
  * If you deref a mutable `Box` to access the contents mutably, you are using the `Box` mutably - so it has to be counted.
2017-08-10 08:53:22 +00:00
Alex Crichton
f72724eeb4 Fix iterator over indexed sets 2017-08-09 14:02:45 -07:00
Alex Crichton
352577f4bb Initial pass review comments 2017-08-09 13:56:19 -07:00
Alex Crichton
c25ddf21f1 Merge remote-tracking branch 'origin/master' into gen 2017-08-09 11:44:21 -07:00
bors
2bb6d3dd89 Auto merge of #43713 - arielb1:legacy-dataflow, r=eddyb
rustc::middle::dataflow - visit the CFG in RPO

We used to propagate bits in node-id order, which sometimes caused an
excessive number of iterations, especially when macros were present. As
everyone knows, visiting the CFG in RPO bounds the number of iterators
by 1 plus the depth of the most deeply nested loop (times the height of
the lattice, which is 1).

I have no idea how this affects borrowck perf in the non-worst-case, so it's probably a good idea to not roll this up so we can see the effects.

Fixes #43704.

r? @eddyb
2017-08-07 15:42:35 +00:00
Ariel Ben-Yehuda
4e3a0b636f rustc::middle::dataflow - visit the CFG in RPO
We used to propagate bits in node-id order, which sometimes caused an
excessive number of iterations, especially when macros were present. As
everyone knows, visiting the CFG in RPO bounds the number of iterators
by 1 plus the depth of the most deeply nested loop (times the height of
the lattice, which is 1).

Fixes #43704.
2017-08-07 16:00:31 +03:00
Matt Brubeck
daa764461d Remove unused fnv hash code 2017-08-02 10:42:12 -07:00
Isaac van Bakel
400075d9d9 Fixed all unnecessary muts in language core 2017-08-01 23:01:24 +01:00
Alex Crichton
dd371a2069 rustc: Inline bitwise modification operators
These need to be inlined across crates to avoid showing up as one-instruction
functions in profiles! In the benchmark from #43578 this decreased the
translation item collection step from 30s to 23s, and looks like it also allowed
vectorization elsewhere of the operations!
2017-07-31 18:39:25 -07:00
John Kåre Alsaker
d861982ca6 Generator literal support 2017-07-28 15:46:23 +02:00
bors
ddaab61101 Auto merge of #43373 - alexcrichton:stabilize-1.20.0, r=aturon
Stabilize more APIs for the 1.20.0 release

In addition to the few stabilizations that have already landed, this cleans up the remaining APIs that are in `final-comment-period` right now to be stable by the 1.20.0 release
2017-07-26 23:40:48 +00:00
Mark Simulacrum
959ebd6785 Rollup merge of #43480 - dhduvall:sparc-blake2b, r=eddyb
Constrain the layout of Blake2bCtx for proper SPARC compilation

On SPARC, optimization fuel ends up emitting incorrect load and store
instructions for the transmute() call in blake2b_compress().  If we
force Blake2bCtx to be repr(C), the problem disappears.

Fixes #43346
2017-07-26 06:15:09 -06:00
Mark Simulacrum
b5b7266b78 Rollup merge of #42959 - SimonSapin:nonzero-checked, r=sfackler
Make the "main" constructors of NonZero/Shared/Unique return Option

Per discussion in https://github.com/rust-lang/rust/issues/27730#issuecomment-303939441.

This is a breaking change to unstable APIs.

The old behavior is still available under the name `new_unchecked`. Note that only that one can be `const fn`, since `if` is currently not allowed in constant contexts.

In the case of `NonZero` this requires adding a new `is_zero` method to the `Zeroable` trait. I mildly dislike this, but it’s not much worse than having a `Zeroable` trait in the first place. `Zeroable` and `NonZero` are both unstable, this can be reworked later.
2017-07-26 06:15:01 -06:00
Danek Duvall
f0fda53cc1 Constrain the layout of Blake2bCtx for proper SPARC compilation
On SPARC, optimization fuel ends up emitting incorrect load and store
instructions for the transmute() call in blake2b_compress().  If we
force Blake2bCtx to be repr(C), the problem disappears.

Fixes #43346
2017-07-25 14:32:08 -07:00
Alex Crichton
daeb6077c8 std: Stabilize manually_drop feature
Stabilizes

* `core::mem::ManuallyDrop`
* `std::mem::ManuallyDrop`
* `ManuallyDrop::new`
* `ManuallyDrop::into_inner`
* `ManuallyDrop::drop`
* `Deref for ManuallyDrop`
* `DerefMut for ManuallyDrop`

Closes #40673
2017-07-25 07:09:31 -07:00
Alex Crichton
9010567dcc Bump master to 1.21.0
This commit bumps the master branch's version to 1.21.0 and also updates the
bootstrap compiler from the freshly minted beta release.
2017-07-25 07:03:19 -07:00
Bruce Mitchener
539df8121b Fix some doc/comment typos. 2017-07-23 22:48:01 +07:00
Simon Sapin
13d17adf60 Use checked NonZero constructor in obligation forest NodeIndex
… to remove an `unsafe` block.
2017-07-22 20:38:40 +02:00
Simon Sapin
a4edae95ad Add conversions from references to NonZero pointers, Unique, and Shared 2017-07-22 20:38:40 +02:00
Simon Sapin
0a08ad0443 Rename {NonZero,Shared,Unique}::new to new_unchecked 2017-07-22 20:38:16 +02:00
Sean McArthur
74b2d69358 remove associated_consts feature gate 2017-07-06 11:52:25 -07:00
Steven Fackler
0a9c13624d Revert "Stabilize RangeArgument"
This reverts commit 143206d54d.
2017-06-30 08:34:53 -10:00
Steven Fackler
143206d54d Stabilize RangeArgument
Move it and Bound to core::ops while we're at it.

Closes #30877
2017-06-24 19:20:57 -07:00
Alex Crichton
be7ebdd512 Bump version and stage0 compiler 2017-06-19 22:25:05 -07:00
bors
28cc0c5a7b Auto merge of #42593 - ibabushkin:on-demand-external-source, r=eddyb
Implement lazy loading of external crates' sources. Fixes #38875

Fixes #38875. This is a follow-up to #42507. When a (now correctly translated) span from an external crate is referenced in a error, warning or info message, we still don't have the source code being referenced.
Since stuffing the source in the serialized metadata of an rlib is extremely wasteful, the following scheme has been implemented:

* File maps now contain a source hash that gets serialized as well.
* When a span is rendered in a message, the source hash in the corresponding file map(s) is used to try and load the source from the corresponding file on disk. If the file is not found or the hashes don't match, the failed attempt is recorded (and not retried).
* The machinery fetching source lines from file maps is augmented to use the lazily loaded external source as a secondary fallback for file maps belonging to external crates.

This required a small change to the expected stderr of one UI test (it now renders a span, where previously was none).

Further work can be done based on this - some of the machinery previously used to hide external spans is possibly obsolete and the hashing code can be reused in different places as well.

r? @eddyb
2017-06-18 10:41:05 +00:00
Corey Farwell
999f3ad60d Rollup merge of #42656 - VBChunguk:struct-field-attributes, r=nikomatsakis
Remove struct_field_attributes feature gate

Part of #41681. ~This PR only removes the feature gate; this *does not* update any documentations.~ This PR removes the feature gate and the corresponding chapter of the Unstable Book.

I'm not very sure about the changes I made though... Just followed the stabilization guideline.

r? @nikomatsakis
2017-06-16 00:32:45 -04:00
Wonwoo Choi
79f173ad21 Remove struct_field_attributes feature gate 2017-06-15 02:24:05 +09:00
Murarth
eadda7665e Merge crate collections into alloc 2017-06-13 23:37:34 -07:00
Inokentiy Babushkin
afe841587d
External spans: fixed unit tests and addressed review. 2017-06-11 16:45:51 +02:00
Inokentiy Babushkin
70fa1fbea7
Added a StableHasherResult impl for u128. 2017-06-10 12:21:24 +02:00
Michael Woerister
7fc84907dc ICH: Add some HashStable implementations. 2017-06-06 13:50:13 +02:00
Ariel Ben-Yehuda
ee982d4355 fix translation of MSVC funclets that loop to their own start 2017-05-28 12:00:03 +03:00
Vadim Petrochenkov
73c73e4a95 Stabilize unions with Copy fields and no destructor 2017-05-27 00:52:20 +03:00
Alex Crichton
ab54f4b226 rustc: Remove #![unstable] annotation
These are now no longer necessary with `-Z force-unstable-if-unmarked`
2017-05-11 16:03:05 -07:00
Michael Woerister
6a5e2a5a9e incr.comp.: Hash more pieces of crate metadata to detect changes there. 2017-05-08 12:31:26 +02:00
Joshua Sheard
db8be04e49 Fix definitions of ULONG_PTR 2017-05-06 15:46:16 +01:00
Corey Farwell
26e067b058 Rollup merge of #41734 - nikomatsakis:incr-comp-refactor-variance, r=pnkfelix
Refactor variance and remove last `[pub]` map

This PR refactors variance to work in a more red-green friendly way. Because red-green doesn't exist yet, it has to be a bit hacky. The basic idea is this:

- We compute a big map with the variance for all items in the crate; when you request variances for a particular item, we read it from the crate
- We now hard-code that traits are invariant (which they are, for deep reasons, not gonna' change)
- When building constraints, we compute the transitive closure of all things within the crate that depend on what using `TransitiveRelation`
    - this lets us gin up the correct dependencies when requesting variance of a single item

Ah damn, just remembered, one TODO:

- [x] Update the variance README -- ah, I guess the README updates I did are sufficient

r? @michaelwoerister
2017-05-05 17:35:29 -04:00
Alexis Beingessner
4ff583b116 fallout from NonZero/Unique/Shared changes 2017-05-04 23:54:54 -04:00
Niko Matsakis
4824a199ca factor variances into a proper query
There are now two queries: crate and item. The crate one computes the
variance of all items in the crate; it is sort of an implementation
detail, and not meant to be used. The item one reads from the crate one,
synthesizing correct deps in lieu of the red-green algorithm.

At the same time, remove the `variance_computed` flag, which was a
horrible hack used to force invariance early on (e.g. when type-checking
constants). This is only needed because of trait applications, and
traits are always invariant anyway. Therefore, we now change to take
advantage of the query system:

- When asked to compute variances for a trait, just return a vector
  saying 'all invariant'.
- Remove the corresponding "inferreds" from traits, and tweak the
  constraint generation code to understand that traits are always
  inferred.
2017-05-03 16:42:07 -04:00
Niko Matsakis
b175aef0c4 make transitive relation use a hash map 2017-05-03 15:28:16 -04:00
Corey Farwell
e0bfd19add Rollup merge of #41693 - est31:anon_params_removal, r=eddyb
Removal pass for anonymous parameters

Removes occurences of anonymous parameters from the
rustc codebase, as they are to be deprecated.

See issue #41686 and RFC 1685.

r? @frewsxcv
2017-05-02 09:09:59 -04:00
est31
d290849a23 Removal pass for anonymous parameters
Removes occurences of anonymous parameters from the
rustc codebase, as they are to be deprecated.

See issue #41686 and RFC 1685.
2017-05-02 05:55:20 +02:00
Niko Matsakis
c7dc39dbf0 intern CodeExtents
Make a `CodeExtent<'tcx>` be something allocated in an arena
instead of an index into the `RegionMaps`.
2017-04-30 17:02:59 -04:00
Jessica Hamilton
e1afddc29c Haiku: fix initial platform support 2017-04-22 13:47:36 +12:00
bors
d2e2ad559e Auto merge of #40570 - nikomatsakis:inference-subtype-through-obligation, r=arielb1
Handle subtyping in inference through obligations

We currently store subtyping relations in the `TypeVariables` structure as a kind of special case. This branch uses normal obligations to propagate subtyping, thus converting our inference variables into normal fallback. It also does a few other things:

- Removes the (unstable, outdated) support for custom type inference fallback.
    - It's not clear how we want this to work, but we know that we don't want it to work the way it currently does.
    - The existing support was also just getting in my way.
- Fixes #30225, which was caused by the trait caching code pretending type variables were normal unification variables, when indeed they were not (but now are).

There is one fishy part of these changes: when computing the LUB/GLB of a "bivariant" type parameter, I currently return the `a` value. Bivariant type parameters are only allowed in a very particular situation, where the type parameter is only used as an associated type output, like this:

```rust
pub struct Foo<A, B>
    where A: Fn() -> B
{
    data: A
}
```

In principle, if one had `T=Foo<A, &'a u32>` and `U=Foo<A, &'b u32>` and (e.g.) `A: for<'a> Fn() -> &'a u32`, then I think that computing the LUB of `T` and `U` might do the wrong thing. Probably the right behavior is just to create a fresh type variable. However, that particular example would not compile (because the where-clause is illegal; `'a` does not appear in any input type). I was not able to make an example that *would* compile and demonstrate this shortcoming, and handling the LUB/GLB was mildly inconvenient, so I left it as is. I am considering whether to revisit this or what.

I have started a crater run to test the impact of these changes.
2017-04-13 00:28:11 +00:00
Michael Woerister
ca2dce9b48 ICH: Replace old, transitive metadata hashing with direct hashing approach.
Instead of collecting all potential inputs to some metadata entry and
hashing those, we directly hash the values we are storing in metadata.
This is more accurate and doesn't suffer from quadratic blow-up when
many entries have the same dependencies.
2017-04-12 11:47:26 +02:00
Michael Woerister
bc7af816f3 ICH: Hash everything that gets encoded into crate metadata. 2017-04-12 11:42:15 +02:00
Niko Matsakis
59babd80bd add some comments and debug! calls to "obligation forest" 2017-04-11 20:32:48 -04:00
Simonas Kazlauskas
38713126dd Move away from the ad-hoc NoDrop unions 2017-04-09 18:55:47 +03:00
Michael Woerister
c47cdc0d93 Introduce HashStable trait and base ICH implementations on it.
This initial commit provides implementations for HIR, MIR, and
everything that also needs to be supported for those two.
2017-04-06 16:01:51 +02:00
bors
5c94997b6b Auto merge of #40524 - alexcrichton:update-bootstrap, r=alexcrichton
rustbuild: Update bootstrap compiler

Now that we've also updated cargo's release process this commit also changes the
download location of Cargo from Cargos archives back to the static.r-l.o
archives. This should ensure that the Cargo download is the exact Cargo paired
with the rustc that we release.
2017-03-30 17:10:11 +00:00
Alex Crichton
c033942925 rustbuild: Update bootstrap compiler
Now that we've also updated cargo's release process this commit also changes the
download location of Cargo from Cargos archives back to the static.r-l.o
archives. This should ensure that the Cargo download is the exact Cargo paired
with the rustc that we release.
2017-03-29 08:55:15 -07:00
Oliver Schneider
eb447f4ef4
Fix various useless derefs and slicings 2017-03-27 08:58:00 +02:00
Alex Crichton
e341d603fe Remove internal liblog
This commit deletes the internal liblog in favor of the implementation that
lives on crates.io. Similarly it's also setting a convention for adding crates
to the compiler. The main restriction right now is that we want compiler
implementation details to be unreachable from normal Rust code (e.g. requires a
feature), and by default everything in the sysroot is reachable via `extern
crate`.

The proposal here is to require that crates pulled in have these lines in their
`src/lib.rs`:

    #![cfg_attr(rustbuild, feature(staged_api, rustc_private))]
    #![cfg_attr(rustbuild, unstable(feature = "rustc_private", issue = "27812"))]

This'll mean that by default they're not using these attributes but when
compiled as part of the compiler they do a few things:

* Mark themselves as entirely unstable via the `staged_api` feature and the
  `#![unstable]` attribute.
* Allow usage of other unstable crates via `feature(rustc_private)` which is
  required if the crate relies on any other crates to compile (other than std).
2017-03-23 11:28:00 -07:00
Michael Woerister
9e0589a52b Add resize() method to IndexVec. 2017-03-22 16:11:18 +01:00
Aaron Turon
a8f4a1bd98 Stabilize rc_raw feature, closes #37197 2017-03-17 13:28:53 -07:00
James Miller
d708a4072a Add extra methods to IndexVec and implement TypeFoldable for it
Adds `get`/`get_mut` accessors and `drain`/`drain_enumerated` iterators
to IndexVec.

Implements TypeFoldable for IndexVec.
2017-03-10 02:55:39 +02:00
Niko Matsakis
b3a482ca9b move the FreeRegionMap into TypeckTables 2017-02-28 08:43:47 -05:00
bors
05a7f25cc4 Auto merge of #39456 - nagisa:mir-switchint-everywhere, r=nikomatsakis
[MIR] SwitchInt Everywhere

Something I've been meaning to do for a very long while. This PR essentially gets rid of 3 kinds of conditional branching and only keeps the most general one - `SwitchInt`. Primary benefits are such that dealing with MIR now does not involve dealing with 3 different ways to do conditional control flow. On the other hand, constructing a `SwitchInt` currently requires more code than what previously was necessary to build an equivalent `If` terminator. Something trivially "fixable" with some constructor methods somewhere (MIR needs stuff like that badly in general).

Some timings (tl;dr: slightly faster^1 (unexpected), but also uses slightly more memory at peak (expected)):

^1: Not sure if the speed benefits are because of LLVM liking the generated code better or the compiler itself getting compiled better. Either way, its a net benefit. The CORE and SYNTAX timings done for compilation without optimisation.

```
AFTER:
Building stage1 std artifacts (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
    Finished release [optimized] target(s) in 31.50 secs
    Finished release [optimized] target(s) in 31.42 secs
Building stage1 compiler artifacts (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
    Finished release [optimized] target(s) in 439.56 secs
    Finished release [optimized] target(s) in 435.15 secs

CORE: 99% (24.81 real, 0.13 kernel, 24.57 user); 358536k resident
CORE: 99% (24.56 real, 0.15 kernel, 24.36 user); 359168k resident
SYNTAX: 99% (49.98 real, 0.48 kernel, 49.42 user); 653416k resident
SYNTAX: 99% (50.07 real, 0.58 kernel, 49.43 user); 653604k resident

BEFORE:
Building stage1 std artifacts (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
    Finished release [optimized] target(s) in 31.84 secs
Building stage1 compiler artifacts (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
    Finished release [optimized] target(s) in 451.17 secs

CORE: 99% (24.66 real, 0.20 kernel, 24.38 user); 351096k resident
CORE: 99% (24.36 real, 0.17 kernel, 24.18 user); 352284k resident
SYNTAX: 99% (52.24 real, 0.56 kernel, 51.66 user); 645544k resident
SYNTAX: 99% (51.55 real, 0.48 kernel, 50.99 user); 646428k resident
```

cc @nikomatsakis @eddyb
2017-02-13 02:32:09 +00:00
Marco A L Barbosa
a8364acafb Allow rustc data structures compile to android
flock structure is defined in asm*/fcntl.h. This file on android is
generated from the linux kernel source, so they are the same.
2017-02-10 16:34:10 -02:00
Simonas Kazlauskas
aac82d9b13 SwitchInt over Switch
This removes another special case of Switch by replacing it with the more general SwitchInt. While
this is more clunky currently, there’s no reason we can’t make it nice (and efficient) to use.
2017-02-10 19:42:41 +02:00
Alex Crichton
626e754473 Bump version, upgrade bootstrap
This commit updates the version number to 1.17.0 as we're not on that version of
the nightly compiler, and at the same time this updates src/stage0.txt to
bootstrap from freshly minted beta compiler and beta Cargo.
2017-02-03 13:25:46 -08:00
est31
7ed78fcbdf Remove dead recursive partial eq impl
Its nowhere used (if it had been used used, the rust stack would have overflown
due to the recursion). Its presence was confusing for mrustc.
2017-01-29 06:07:45 +01:00
bors
0ef85a6b1c Auto merge of #38610 - djzin:master, r=sfackler
Implementation of plan in issue #27787 for btree_range

Still some ergonomics to be worked on, the ::<str,_> is particularly unsightly
2017-01-15 21:44:51 +00:00
Djzin
bd04c30df7 add required imports & feature 2017-01-14 17:40:52 +00:00
djzin
93e6c26dcf update array_vec to use new rangeargument 2017-01-14 17:06:00 +00:00
Michael Woerister
71274ac9ad Mark some BitVector methods with #[inline] 2017-01-12 15:13:02 -05:00
Ariel Ben-Yehuda
a89475d7ec Use little-endian encoding for Blake2 hashing on all architectures
Like many hash functions, the blake2 hash is mathematically defined on
a sequence of 64-bit words. As Rust's hash interface operates on
sequences of octets, some encoding must be used to bridge that
difference.

The Blake2 RFC (RFC 7693) specifies that:
   Byte (octet) streams are interpreted as words in little-endian order,
   with the least-significant byte first.

So use that encoding consistently.

Fixes #38891.
2017-01-10 20:43:32 +02:00
bors
7ac9d337dc Auto merge of #38679 - alexcrichton:always-deny-warnings, r=nrc
Remove not(stage0) from deny(warnings)

Historically this was done to accommodate bugs in lints, but there hasn't been a
bug in a lint since this feature was added which the warnings affected. Let's
completely purge warnings from all our stages by denying warnings in all stages.
This will also assist in tracking down `stage0` code to be removed whenever
we're updating the bootstrap compiler.
2017-01-08 08:22:06 +00:00
Andrew Cann
9482492ab6 Add drain method to AccumulateVec/ArrayVec
You can now call .drain(..) on SmallVec, AccumulateVec and ArrayVec
2017-01-03 15:48:29 +08:00
est31
0a481fe5d2 Fix rebase fallout and compilation fixes 2016-12-30 15:17:30 +01:00
Alex Crichton
9b0b5b45db Remove not(stage0) from deny(warnings)
Historically this was done to accommodate bugs in lints, but there hasn't been a
bug in a lint since this feature was added which the warnings affected. Let's
completely purge warnings from all our stages by denying warnings in all stages.
This will also assist in tracking down `stage0` code to be removed whenever
we're updating the bootstrap compiler.
2016-12-29 21:07:20 -08:00
bors
71c06a56a1 Auto merge of #38051 - sanxiyn:unused-type-alias-3, r=eddyb
Warn unused type aliases, reimplemented

Reimplementation of #37631. Fix #37455.
2016-12-18 22:06:34 +00:00
bors
8327b5afaf Auto merge of #37429 - camlorn:univariant_layout_optimization, r=eddyb
struct field reordering and optimization

This is work in progress.  The goal is to divorce the order of fields in source code from the order of fields in the LLVM IR, then optimize structs (and tuples/enum variants)by always ordering fields from least to most aligned.  It does not work yet.  I intend to check compiler memory usage as a benchmark, and a crater run will probably be required.

I don't know enough of the compiler to complete this work unaided.  If you see places that still need updating, please mention them.  The only one I know of currently is debuginfo, which I'm putting off intentionally until a bit later.

r? @eddyb
2016-12-18 07:59:32 +00:00
Austin Hicks
ff59474ed3 flock needs repr(C) 2016-12-16 15:50:14 -05:00
Ariel Ben-Yehuda
e1d4b8fc8c Use StableHasher everywhere
The standard implementations of Hasher have architecture-dependent
results when hashing integers. This causes problems when the hashes are
stored within metadata - metadata written by one host architecture can't
be read by another.

To fix that, implement an architecture-independent StableHasher and use
it in all places an architecture-independent hasher is needed.

Fixes #38177.
2016-12-15 20:48:59 +02:00
Seo Sanghyeon
75cd69cf95 Warn unused type aliases 2016-12-15 18:35:20 +09:00
Vadzim Dambrouski
9d764fc3c1 Do not generate '@' character in symbol names.
MSP430 assembler does not like '@' character in symbol names, so we should
only use alphanumerics when we generate a new name.

Fixes #38116
2016-12-12 21:56:52 +03:00
Nicholas Nethercote
f72685f2ff Use SmallVec for TypeWalker's stack.
The change also adds the missing `SmallVec::truncate` method.
2016-11-22 10:02:04 +11:00
Nicholas Nethercote
f0c9a9f474 Don't clone in UnificationTable::probe().
This speeds up compilation of rustc-benchmarks/inflate-0.1.0 by 1%.
2016-11-18 14:26:22 +11:00
Michael Woerister
5b093ebab2 Make names of types used in LLVM IR stable.
Before this PR, type names could depend on the cratenum being used
for a given crate and also on the source location of closures.
Both are undesirable for incremental compilation where we cache
LLVM IR and don't want it to depend on formatting or in which
order crates are loaded.
2016-11-13 19:49:46 -05:00
Eduard-Mihai Burtescu
f19f939994 Rollup merge of #37551 - Mark-Simulacrum:upgrade-accvec, r=eddyb
Replace syntax's SmallVector with AccumulateVec

This adds a new type to data_structures, `SmallVec`, which wraps `AccumulateVec` with support for re-allocating onto the heap (`SmallVec::reserve`). `SmallVec` is then used to replace the implementation of `SmallVector` in libsyntax.

r? @eddyb

Fixes #37371. Using `SmallVec` instead of libsyntax's `SmallVector` will provide the `N = 2/4` case easily (just needs a few more `Array` impls).

cc @nnethercote, probably interested in this area
2016-11-12 10:38:38 +02:00
Eduard-Mihai Burtescu
c3ab57c99e Rollup merge of #37535 - Havvy:graph, r=eddyb
Graph Changes

General cleanup and adding a few methods that I want to use in Clippy.

Need somebody to bikeshed names.
2016-11-12 10:38:38 +02:00
Mark-Simulacrum
7bbebb1f54 Change implementation of syntax::util::SmallVector to use data_structures::SmallVec. 2016-11-11 07:38:48 -07:00
Nicholas Nethercote
00e48affde Replace FnvHasher use with FxHasher.
This speeds up compilation by 3--6% across most of rustc-benchmarks.
2016-11-08 15:14:59 +11:00
Nicholas Nethercote
eca1cc957f Add FxHasher, a faster alternative to FnvHasher. 2016-11-08 15:14:00 +11:00
bors
49c36bf16f Auto merge of #36306 - nagisa:mir-local-cleanup, r=eddyb
A way to remove otherwise unused locals from MIR

There is a certain amount of desire for a pass which cleans up the provably unused variables (no assignments or reads). There has been an implementation of such pass by @scottcarr, and another (two!) implementations by me in my own dataflow efforts.

PR like https://github.com/rust-lang/rust/pull/35916 proves that this pass is useful even on its own, which is why I cherry-picked it out from my dataflow effort.

@nikomatsakis previously expressed concerns over this pass not seeming to be very cheap to run and therefore unsuitable for regular cleanup duties. Turns out, regular cleanup of local declarations is not at all necessary, at least now, because majority of passes simply do not (or should not) care about them. That’s why it is viable to only run this pass once (perhaps a few more times in the future?) per function, right before translation.

r? @eddyb or @nikomatsakis
2016-11-03 22:58:55 -07:00
Havvy
9ddbb9133c Added Graph::is_cyclicic_node algorithm 2016-11-02 21:57:36 -07:00
Simonas Kazlauskas
475236770f A way to remove otherwise unused locals from MIR
Replaces the hack where a similar thing is done within trans.
2016-11-03 06:17:01 +02:00
Havvy
7d91581cca Change Make comment into doc comment on Graph::iterate_until_fixed_point 2016-11-02 01:48:11 -07:00
Havvy
fcf02623ee Added general iterators for graph nodes and edges
Also used those general iterators in other methods.
2016-11-02 01:47:54 -07:00
Havvy
3d1ecc50ed Normalize generic bounds in graph iterators
Use where clasues and only where clauses for bounds in the
iterators for Graph.

The rest of the code uses bounds on the generic declarations for
Debug, and we may want to change those to for consistency. I did
not do that here because I don't know whether or not that's a good
idea. But for the iterators, they were inconsistent causing
confusion, at least for me.
2016-11-01 20:32:02 -07:00
Nicholas Nethercote
7b33f7e3e7 Optimize ObligationForest's NodeState handling.
This commit partially inlines two functions, `find_cycles_from_node` and
`mark_as_waiting_from`, at two call sites in order to avoid function
unnecessary function calls on hot paths.

It also fully inlines and removes `is_popped`.

These changes speeds up rustc-benchmarks/inflate-0.1.0 by about 2% when
doing debug builds with a stage1 compiler.
2016-11-02 13:37:10 +11:00
Michael Woerister
a2a2763e6d Replace all uses of SHA-256 with BLAKE2b. 2016-10-30 19:14:18 -04:00
bors
a6b3b01b5f Auto merge of #37270 - Mark-Simulacrum:smallvec-optimized-arenas, r=eddyb
Add ArrayVec and AccumulateVec to reduce heap allocations during interning of slices

Updates `mk_tup`, `mk_type_list`, and `mk_substs` to allow interning directly from iterators. The previous PR, #37220, changed some of the calls to pass a borrowed slice from `Vec` instead of directly passing the iterator, and these changes further optimize that to avoid the allocation entirely.

This change yields 50% less malloc calls in [some cases](https://pastebin.mozilla.org/8921686). It also yields decent, though not amazing, performance improvements:
```
futures-rs-test  4.091s vs  4.021s --> 1.017x faster (variance: 1.004x, 1.004x)
helloworld       0.219s vs  0.220s --> 0.993x faster (variance: 1.010x, 1.018x)
html5ever-2016-  3.805s vs  3.736s --> 1.018x faster (variance: 1.003x, 1.009x)
hyper.0.5.0      4.609s vs  4.571s --> 1.008x faster (variance: 1.015x, 1.017x)
inflate-0.1.0    3.864s vs  3.883s --> 0.995x faster (variance: 1.232x, 1.005x)
issue-32062-equ  0.309s vs  0.299s --> 1.033x faster (variance: 1.014x, 1.003x)
issue-32278-big  1.614s vs  1.594s --> 1.013x faster (variance: 1.007x, 1.004x)
jld-day15-parse  1.390s vs  1.326s --> 1.049x faster (variance: 1.006x, 1.009x)
piston-image-0. 10.930s vs 10.675s --> 1.024x faster (variance: 1.006x, 1.010x)
reddit-stress    2.302s vs  2.261s --> 1.019x faster (variance: 1.010x, 1.026x)
regex.0.1.30     2.250s vs  2.240s --> 1.005x faster (variance: 1.087x, 1.011x)
rust-encoding-0  1.895s vs  1.887s --> 1.005x faster (variance: 1.005x, 1.018x)
syntex-0.42.2   29.045s vs 28.663s --> 1.013x faster (variance: 1.004x, 1.006x)
syntex-0.42.2-i 13.925s vs 13.868s --> 1.004x faster (variance: 1.022x, 1.007x)
```

We implement a small-size optimized vector, intended to be used primarily for collection of presumed to be short iterators. This vector cannot be "upsized/reallocated" into a heap-allocated vector, since that would require (slow) branching logic, but during the initial collection from an iterator heap-allocation is possible.

We make the new `AccumulateVec` and `ArrayVec` generic over implementors of the `Array` trait, of which there is currently one, `[T; 8]`. In the future, this is likely to expand to other values of N.

Huge thanks to @nnethercote for collecting the performance and other statistics mentioned above.
2016-10-26 03:47:55 -07:00
Mark-Simulacrum
a4f7ba376e Add AccumulateVec, a potentially stack-allocated vector.
AccumulateVec is generic over the Array trait, which is currently only
implemented for [T; 8].
2016-10-25 20:06:17 -06:00
bors
4879166194 Auto merge of #37294 - nikomatsakis:issue-37154, r=nikomatsakis
remove keys w/ skolemized regions from proj cache when popping skolemized regions

This addresses #37154 (a regression). The projection cache was incorrectly caching the results for skolemized regions -- when we pop skolemized regions, we are supposed to drop cache keys for them (just as we remove those skolemized regions from the region inference graph). This is because those skolemized region numbers will be reused later with different meaning (and we have determined that the old ones don't leak out in any meaningful way).

I did a *somewhat* aggressive fix here of only removing keys that mention the skolemized regions. One could imagine just removing all keys added since we started the skolemization (as indeed I did in my initial commit). This more aggressive fix required fixing a latent bug in `TypeFlags`, as an aside.

I believe the more aggressive fix is correct; clearly there can be entries that are unrelated to the skoelemized region, and it's a shame to remove them. My one concern was that it *is* possible I believe to have some region variables that are created and related to skolemized regions, and maybe some of them could end up in the cache. However, that seems harmless enough to me-- those relations will be removed, and couldn't have impacted how trait resolution proceeded anyway (iow, the cache entry is not wrong, though it is kind of useless).

r? @pnkfelix
cc @arielb1
2016-10-22 03:30:23 -07:00
Guillaume Gomez
59faa20156 Rollup merge of #37286 - srinivasreddy:graph, r=nrc
run rustfmt on graph folder
2016-10-22 01:21:59 +02:00
Niko Matsakis
567b11fc3a only remove keys that mention skolemized regions 2016-10-21 11:13:36 -04:00
Niko Matsakis
974817d493 when pop skol, also remove from proj cache 2016-10-21 11:13:34 -04:00
Guillaume Gomez
dd3a014ed9 Rollup merge of #37288 - srinivasreddy:snapshot_map, r=eddyb
run rustfmt on snapshot_map
2016-10-19 23:15:01 +02:00
Guillaume Gomez
655ecd89ed Rollup merge of #37287 - srinivasreddy:unify, r=eddyb
run rustfmt on unify folder
2016-10-19 23:15:01 +02:00
Srinivas Reddy Thatiparthy
4e89811690
run rustfmt on snapshot_map 2016-10-20 00:40:05 +05:30
Srinivas Reddy Thatiparthy
c2d0d4fea6
run rustfmt on unify folder 2016-10-20 00:38:55 +05:30
Srinivas Reddy Thatiparthy
20bda8d5f4
run rustfmt on graph folder 2016-10-20 00:37:24 +05:30
Srinivas Reddy Thatiparthy
f1e4ae17b1
run rustfmt on control_flow_graph folder 2016-10-20 00:25:19 +05:30
Eduard-Mihai Burtescu
7343291ac3 Rollup merge of #37233 - michaelwoerister:blake2-for-ich, r=nikomatsakis
ICH: Use 128-bit Blake2b hash instead of 64-bit SipHash for incr. comp. fingerprints

This PR makes incr. comp. hashes 128 bits wide in order to push collision probability below a threshold that we need to worry about. It also replaces SipHash, which has been mentioned multiple times as not being built for fingerprinting, with the [BLAKE2b hash function](https://blake2.net/), an improved version of the BLAKE sha-3 finalist.

I was worried that using a cryptographic hash function would make ICH computation noticeably slower, but after doing some performance tests, I'm not any more. Most of the time BLAKE2b is actually faster than using two SipHashes (in order to get 128 bits):

```
SipHash
libcore: 0.199 seconds
libstd:  0.090 seconds

BLAKE2b
libcore: 0.162 seconds
libstd:  0.078 seconds
```

If someone can prove that something like MetroHash128 provides a comparably low collision probability as BLAKE2, I'm happy to switch. But for now we are at least not taking a performance hit.

I also suggest that we throw out the sha-256 implementation in the compiler and replace it with BLAKE2, since our sha-256 implementation is two to three times slower than the BLAKE2 implementation in this PR (cc @alexcrichton @eddyb @brson)

r? @nikomatsakis (although there's not much incr. comp. specific in here, so feel free to re-assign)
2016-10-19 08:00:03 +03:00
Jonas Schievink
0c844d2304 Set stalled=false when encountering an error 2016-10-17 21:53:27 +02:00
Michael Woerister
d07523c716 ICH: Use 128-bit Blake2b hash instead of 64-bit SipHash for incr. comp. fingerprints. 2016-10-17 12:40:25 -04:00
Jonas Schievink
88fde7f728 Don't process cycles when stalled
This improves the `inflate-0.1.0` benchmark by about 10% for me.
2016-10-17 02:28:31 +02:00
Wesley Wiser
5e91c073f2 Move IdxSetBuf and BitSlice to rustc_data_structures
Resolves a FIXME
2016-10-10 20:26:26 -04:00
Niels Sascha Reedijk
1a6fc8b7b8 Add support for the Haiku operating system on x86 and x86_64 machines
* Hand rebased from Niels original work on 1.9.0
2016-09-25 11:12:23 -05:00
athulappadan
49e77dbf25 Documentation of what does for each type 2016-09-11 17:00:09 +05:30
Michael Woerister
7310a8ffea ICH: Adapt to changes in the MetaItem AST representation. 2016-09-01 14:39:31 -04:00
Michael Woerister
794fd315ad incr.comp.: Move lock files out of directory being locked 2016-08-29 14:27:40 -04:00
Michael Woerister
3e9bed92da Implement copy-on-write scheme for managing the incremental compilation cache. 2016-08-29 14:27:40 -04:00
Michael Woerister
206e7b6fc7 Add some features to flock. 2016-08-29 14:27:40 -04:00
Michael Woerister
6ef8198406 Move flock.rs from librustdoc to librustc_data_structures. 2016-08-29 14:27:40 -04:00
Niko Matsakis
9978cbc8f4 generalize BitMatrix to be NxM and not just NxN 2016-08-09 08:26:06 -04:00
Niko Matsakis
0e97240f98 isolate predecessor computation
The new `Predecessors` type computes a set of interesting targets and
their HIR predecessors, and discards everything in between.
2016-08-09 08:26:05 -04:00
bors
1ab87b65a2 Auto merge of #34605 - arielb1:bug-in-the-jungle, r=eddyb
fail obligations that depend on erroring obligations

Fix a bug where an obligation that depend on an erroring obligation would
be regarded as successful, leading to global cache pollution and random
lossage.

Fixes #33723.
Fixes #34503.

r? @eddyb since @nikomatsakis is on vacation

beta-nominating because of the massive lossage potential (e.g. with `Copy` this could lead to random memory leaks), plus this is a regression.
2016-07-02 12:25:29 -07:00
Ariel Ben-Yehuda
201cdd33df fail obligations that depend on erroring obligations
Fix a bug where an obligation that depend on an erroring obligation would
be regarded as successful, leading to global cache pollution and random
lossage.

Fixes #33723.
Fixes #34503.
2016-07-02 02:20:45 +03:00
Ariel Ben-Yehuda
bff28ec468 refactor rustc_metadata to use CamelCase names and IndexVec 2016-06-28 23:41:09 +03:00
Scott A Carr
66d60c78b3 add control flow graph and algorithms. add dominator to mir 2016-06-23 14:00:00 -07:00
bors
6b4511755c Auto merge of #34221 - srinivasreddy:rm_redundant, r=alexcrichton
remove redundant test case in bitvector.rs

`bitvec_iter_works_2` does exactly same as `bitvec_iter_works_1`, so i removed it.
2016-06-14 13:42:28 -07:00
Srinivas Reddy Thatiparthy
fa91c14bc0 Add additional test cases to test all arities of tuple; And remove type suffix - i32 on integers 2016-06-11 22:31:24 +05:30
Srinivas Reddy Thatiparthy
99e9f2ddc1 remove redundant test case 2016-06-11 20:59:58 +05:30
Ariel Ben-Yehuda
e3af9fa490 make the basic_blocks field private 2016-06-09 14:55:19 +03:00
Ariel Ben-Yehuda
bc1eb67721 introduce the type-safe IdxVec and use it instead of loose indexes 2016-06-09 14:26:08 +03:00
bors
22b36c70f9 Auto merge of #33999 - scottcarr:master, r=nikomatsakis
generate fewer basic blocks for variant switches

CC #33567
Adds a new field to TestKind::Switch that tracks the variants that are actually matched against.  The other candidates target a common "otherwise" block.
2016-06-05 03:12:38 -07:00
Scott A Carr
79bf586d4b switch to BitVector, simplify target_block logic
clarify comments and panic message
2016-06-01 10:23:56 -07:00
Niko Matsakis
d042ce2ed3 add a snapshottable hashmap 2016-05-31 19:44:05 -04:00
Niko Matsakis
f89041bbe3 identify inputs of MetaData(X) nodes
Generate a second hash file that contains the metadata for an X node.
2016-05-18 10:11:35 -04:00
bors
786b26d7b4 Auto merge of #33491 - arielb1:obligation-jungle, r=nikomatsakis
Replace the obligation forest with a graph

In the presence of caching, arbitrary nodes in the obligation forest can be merged, which makes it a general graph. Handle it as such, using cycle-detection algorithms in the processing.

I should do performance measurements sometime.

This was pretty much written as a proof-of-concept. Please help me write this in a less-ugly way. I should also add comments explaining what is going on.

r? @nikomatsakis
2016-05-16 18:39:59 -07:00
Ariel Ben-Yehuda
f0f5ef51bf address review comments 2016-05-13 21:23:02 -07:00
Ariel Ben-Yehuda
5c39a2ae44 add cycle-reporting logic
Fixes #33344
2016-05-13 21:23:02 -07:00
Ariel Ben-Yehuda
957500b793 rewrite obligation forest. cycles still handled incorrectly. 2016-05-13 21:23:02 -07:00
Masood Malekghassemi
f52b655621 Plumb inference obligations through selection 2016-05-11 17:29:23 -07:00
Michael Woerister
0fc9f9a200 Make the codegen unit partitioner also emit item declarations. 2016-04-28 16:53:00 -04:00