Commit Graph

972 Commits

Author SHA1 Message Date
Jeffrey Seyfried 641274f907 Resolve imports during expansion. 2016-11-17 08:07:44 +00:00
Niko Matsakis 3fd67eba87 fallout from separating impl-items from impls
Basically adding `visit_impl_item` in various places and so forth.
2016-11-16 13:57:43 -05:00
Niko Matsakis 36fbf8c53c refactor Visitor into ItemLikeVisitor and intravisit::Visitor
There are now three patterns (shallow, deep, and nested visit).  These
are described in detail on the docs in `itemlikevisit::ItemLikeVisitor`.
2016-11-16 13:51:36 -05:00
Alex Crichton 06242ff15d rustc: Implement #[link(cfg(..))] and crt-static
This commit is an implementation of [RFC 1721] which adds a new target feature
to the compiler, `crt-static`, which can be used to select how the C runtime for
a target is linked. Most targets dynamically linke the C runtime by default with
the notable exception of some of the musl targets.

[RFC 1721]: https://github.com/rust-lang/rfcs/blob/master/text/1721-crt-static.md

This commit first adds the new target-feature, `crt-static`. If enabled, then
the `cfg(target_feature = "crt-static")` will be available. Targets like musl
will have this enabled by default. This feature can be controlled through the
standard target-feature interface, `-C target-feature=+crt-static` or
`-C target-feature=-crt-static`.

Next this adds an gated and unstable `#[link(cfg(..))]` feature to enable the
`crt-static` semantics we want with libc. The exact behavior of this attribute
is a little squishy, but it's intended to be a forever-unstable
implementation detail of the liblibc crate.

Specifically the `#[link(cfg(..))]` annotation means that the `#[link]`
directive is only active in a compilation unit if that `cfg` value is satisfied.
For example when compiling an rlib, these directives are just encoded and
ignored for dylibs, and all staticlibs are continued to be put into the rlib as
usual. When placing that rlib into a staticlib, executable, or dylib, however,
the `cfg` is evaluated *as if it were defined in the final artifact* and the
library is decided to be linked or not.

Essentially, what'll happen is:

* On MSVC with `-C target-feature=-crt-static`, the `msvcrt.lib` library will be
  linked to.
* On MSVC with `-C target-feature=+crt-static`, the `libcmt.lib` library will be
  linked to.
* On musl with `-C target-feature=-crt-static`, the object files in liblibc.rlib
  are removed and `-lc` is passed instead.
* On musl with `-C target-feature=+crt-static`, the object files in liblibc.rlib
  are used and `-lc` is not passed.

This commit does **not** include an update to the liblibc module to implement
these changes. I plan to do that just after the 1.14.0 beta release is cut to
ensure we get ample time to test this feature.

cc #37406
2016-11-16 07:00:09 -08:00
Niko Matsakis 19c1a47713 remove TypeOrigin and use ObligationCause instead
In general having all these different structs for "origins" is not
great, since equating types can cause obligations and vice-versa.  I
think we should gradually collapse these things. We almost certainly
also need to invest a big more energy into the `error_reporting` code to
rationalize it: this PR does kind of the minimal effort in that
direction.
2016-11-15 16:12:41 -05:00
Jorge Aparicio 80ca1e1251 don't build an object file for emit=asm,llvm-ir 2016-11-14 03:37:46 -05:00
Jorge Aparicio a6a2477986 use write::run_assembler 2016-11-12 17:45:15 -05:00
Eduard Burtescu 6b3cc0b8c8 rustc_typeck: correctly track "always-diverges" and "has-type-errors". 2016-11-10 01:44:53 +02:00
Eduard Burtescu ff0830d749 rustc: use an Expr instead of a Block for function bodies. 2016-11-10 01:44:45 +02:00
Eduard-Mihai Burtescu 3292f407e7 Rollup merge of #37636 - karpinski:issue-34915, r=nikomatsakis
Marking the 'no-stack-check' codegen option as deprecated (Issue #34915)

Attempts to finish resolving issue #34915. Based on pull request #35156, which was closed due to inactivity.
2016-11-09 20:51:19 +02:00
karpinski c670293630 Adding a deprecation warning for no-stack-check codegen option. 2016-11-08 13:45:07 +01:00
bors 38a959a543 Auto merge of #36843 - petrochenkov:dotstab, r=nikomatsakis
Stabilize `..` in tuple (struct) patterns

I'd like to nominate `..` in tuple and tuple struct patterns for stabilization.
This feature is a relatively small extension to existing stable functionality and doesn't have known blockers.
The feature first appeared in Rust 1.10 6 months ago.
An example of use: https://github.com/rust-lang/rust/pull/36203

Closes https://github.com/rust-lang/rust/issues/33627
r? @nikomatsakis
2016-11-08 02:06:45 -08:00
Alex Crichton 0670d4b7f3 Rollup merge of #37583 - michaelwoerister:hir-stats, r=alexcrichton
Add `-Z hir-stats` for collecting statistics on HIR and AST

The data collected will be printed to the commandline and looks like the following:

```
// stats for libcore

PRE EXPANSION AST STATS

Name                Accumulated Size         Count     Item Size
----------------------------------------------------------------
TypeBinding                    2_280            57            40
Mod                            3_560            89            40
PathListItem                   6_516           181            36
Variant                        7_872            82            96
LifetimeDef                   21_280           380            56
StructField                   22_880           260            88
Lifetime                      23_800         1_190            20
Local                         30_192           629            48
ForeignItem                   31_504           179           176
Arm                           42_880           670            64
Mac                           46_960           587            80
FnDecl                        57_792         1_204            48
TraitItem                     69_504           362           192
TyParamBound                  98_280           945           104
Block                        108_384         2_258            48
Stmt                         144_720         3_618            40
ImplItem                     230_272         1_028           224
Item                         467_456         1_826           256
Pat                          517_776         4_623           112
Attribute                    745_680        15_535            48
Ty                         1_114_848         9_954           112
PathSegment                1_218_528        16_924            72
Expr                       3_082_408        20_279           152
----------------------------------------------------------------
Total                      8_095_372

POST EXPANSION AST STATS

Name                Accumulated Size         Count     Item Size
----------------------------------------------------------------
MacroDef                       1_056            12            88
Mod                            3_400            85            40
TypeBinding                    4_280           107            40
PathListItem                   6_516           181            36
Variant                        7_872            82            96
StructField                   24_904           283            88
ForeignItem                   31_504           179           176
TraitItem                     69_504           362           192
Local                         85_008         1_771            48
Arm                          100_288         1_567            64
Lifetime                     123_980         6_199            20
LifetimeDef                  126_728         2_263            56
TyParamBound                 297_128         2_857           104
FnDecl                       305_856         6_372            48
Block                        481_104        10_023            48
Stmt                         535_120        13_378            40
Item                       1_469_952         5_742           256
Attribute                  1_629_840        33_955            48
ImplItem                   1_732_864         7_736           224
Pat                        2_360_176        21_073           112
PathSegment                5_888_448        81_784            72
Ty                         6_237_168        55_689           112
Expr                      12_013_320        79_035           152
----------------------------------------------------------------
Total                     33_536_016

HIR STATS

Name                Accumulated Size         Count     Item Size
----------------------------------------------------------------
MacroDef                         864            12            72
Mod                            2_720            85            32
TypeBinding                    3_424           107            32
PathListItem                   5_068           181            28
Variant                        6_560            82            80
StructField                   20_376           283            72
ForeignItem                   27_208           179           152
WherePredicate                43_776           684            64
TraitItem                     52_128           362           144
Decl                          68_992         2_156            32
Local                         89_184         1_858            48
Arm                           94_368         1_966            48
LifetimeDef                  108_624         2_263            48
Lifetime                     123_980         6_199            20
Stmt                         168_000         4_200            40
TyParamBound                 251_416         2_857            88
FnDecl                       254_880         6_372            40
Block                        583_968        12_166            48
Item                       1_240_272         5_742           216
ImplItem                   1_361_536         7_736           176
Attribute                  1_620_480        33_760            48
Pat                        2_073_120        21_595            96
Path                       2_385_856        74_558            32
Ty                         4_455_040        55_688            80
PathSegment                5_587_904        87_311            64
Expr                       7_588_992        79_052            96
----------------------------------------------------------------
Total                     28_218_736
```
2016-11-05 10:50:25 -07:00
Alex Crichton 1a0963292a Rollup merge of #37408 - eddyb:lazy-5, r=nikomatsakis
[5/n] rustc: record the target type of every adjustment.

_This is part of a series ([prev](https://github.com/rust-lang/rust/pull/37404) | [next](https://github.com/rust-lang/rust/pull/37412)) of patches designed to rework rustc into an out-of-order on-demand pipeline model for both better feature support (e.g. [MIR-based](https://github.com/solson/miri) early constant evaluation) and incremental execution of compiler passes (e.g. type-checking), with beneficial consequences to IDE support as well.
If any motivation is unclear, please ask for additional PR description clarifications or code comments._

<hr>

The first commit rearranges `tcx.tables` so that all users go through `tcx.tables()`. This in preparation for per-body `Tables` where they will be requested for a specific `DefId`. Included to minimize churn.

The rest of the changes focus on adjustments, there are some renamings, but the main addition is the target type, always available in all cases (as opposed to just for unsizing where it was previously needed).

Possibly the most significant effect of this change is that figuring out the final type of an expression is now _always_ just one successful `HashMap` lookup (either the adjustment or, if that doesn't exist, the node type).
2016-11-04 16:49:28 -07:00
Michael Woerister 94e655eca6 Add -Zhir-stats for collecting statistics on HIR and AST 2016-11-04 11:37:39 -04: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
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
Vadim Petrochenkov 74bb594563 Stabilize `..` in tuple (struct) patterns 2016-11-03 01:38:15 +03:00
Eduard Burtescu 6a8d131e5d rustc: make all read access to tcx.tables go through a method. 2016-11-02 03:50:32 +02:00
Guillaume Gomez ed96e4fd2e Rollup merge of #37296 - srinivasreddy:librustc_driver, r=nikomatsakis
run rustfmt on librustc_driver folder
2016-11-01 16:15:51 +01:00
Michael Woerister 9ef9194528 Make the crate disambiguator 128 bits instead of 256 bits. 2016-10-30 19:14:18 -04:00
Michael Woerister bd1ce91249 Add rustc_data_structures to rustc_driver dependencies. 2016-10-30 19:14:18 -04:00
Michael Woerister a2a2763e6d Replace all uses of SHA-256 with BLAKE2b. 2016-10-30 19:14:18 -04:00
bors 6062e7ed3d Auto merge of #37431 - jseyfried:refactor_crate_config, r=eddyb
Move `CrateConfig` from `Crate` to `ParseSess`

This is a syntax-[breaking-change]. Most breakage can be fixed by removing a `CrateConfig` argument.
r? @eddyb
2016-10-30 06:51:30 -07:00
Srinivas Reddy Thatiparthy f32ce9c142
run rustfmt on librustc_driver folder 2016-10-30 18:26:51 +05:30
Jeffrey Seyfried cbd24757eb Move `CrateConfig` from `Crate` to `ParseSess`. 2016-10-29 07:52:58 +00:00
Eduard Burtescu e34792b181 rustc: move the MIR map into TyCtxt. 2016-10-28 13:55:49 +03: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 982a48575b Utilize AccumulateVec to avoid heap allocations in mk_{substs, type_list, tup} calls. 2016-10-25 20:06:17 -06:00
Jeffrey Seyfried f3993d1a7f Rename `loader.rs` -> `locator.rs`. 2016-10-22 20:01:50 +00:00
Jeffrey Seyfried 2b43fac2b9 Remove `CrateReader`, use `CrateLoader` instead. 2016-10-22 20:01:38 +00:00
Mark-Simulacrum 83b198249f Use TypedArena::alloc_slice in rustc. 2016-10-19 07:53:56 -06:00
Zack M. Davis 06123d3afe include LLVM version in `--version --verbose`
This is in the matter of #28405.
2016-10-15 15:57:28 -07:00
Alex Crichton 20991829e2 Rollup merge of #37084 - jseyfried:cleanup_expanded_macro_use_scopes, r=nrc
macros: clean up scopes of expanded `#[macro_use]` imports

This PR changes the scope of macro-expanded `#[macro_use]` imports to match that of unexpanded `#[macro_use]` imports. For example, this would be allowed:
```rust
example!();
macro_rules! m { () => { #[macro_use(example)] extern crate example_crate; } }
m!();
```

This PR also enforces the full shadowing restrictions from RFC 1560 on `#[macro_use]` imports (currently, we only enforce the weakened restrictions from #36767).

This is a [breaking-change], but I believe it is highly unlikely to cause breakage in practice.
r? @nrc
2016-10-12 14:07:56 -07:00
Alex Crichton 920f10950a Rollup merge of #37066 - nrc:stderr, r=alexcrichton
Error monitor should emit error to stderr instead of stdout

We are pretty consistent about emitting to stderr, except for when there is actually an error, in which case we emit to stdout. This seems a bit backwards. This PR just changes that exception to emit to stderr. This is useful for the RLS since the LS protocol uses stdout (grrr).

r? @alexcrichton
2016-10-12 14:07:56 -07:00
Nick Cameron 9bc6d26092 Stabilise `?`
cc [`?` tracking issue](https://github.com/rust-lang/rust/issues/31436)
2016-10-12 08:40:22 +13:00
Jeffrey Seyfried d5281ef681 Merge branch 'persistent_macro_scopes' into cleanup_expanded_macro_use_scopes 2016-10-11 03:41:18 +00:00
Nick Cameron 4df0f3f6a6 Error monitor should emit error to stderr instead of stdout 2016-10-10 18:14:45 +13:00
Jeffrey Seyfried 21b4369322 Refactor away `ext::expand::{expand_crate, expand_crate_with_expander}`. 2016-10-07 21:54:04 +00:00
Jeffrey Seyfried 09e41b6784 Add macros from plugins in `libsyntax_ext::register_builtins`. 2016-10-07 21:54:03 +00:00
Alex Crichton 2148bdfcc7 rustc: Rename rustc_macro to proc_macro
This commit blanket renames the `rustc_macro` infrastructure to `proc_macro`,
which reflects the general consensus of #35900. A follow up PR to Cargo will be
required to purge the `rustc-macro` name as well.
2016-10-06 11:07:23 -07:00
bors ff713464e6 Auto merge of #36847 - alexcrichton:rustc-macro-doc, r=nrc
rustdoc: Fix documenting rustc-macro crates

This commit adds a "hack" to the session to track whether we're a rustdoc
session or not. If we're rustdoc then we skip the expansion to add the
rustc-macro infrastructure.

Closes #36820
2016-10-03 07:40:22 -07:00
Brian Anderson a4c3288129 Change the sigs of set_print/set_panic to allow restoring the default objects 2016-09-30 14:02:53 -07:00
Alex Crichton 7724a04b0f rustdoc: Fix documenting rustc-macro crates
This commit adds a "hack" to the session to track whether we're a rustdoc
session or not. If we're rustdoc then we skip the expansion to add the
rustc-macro infrastructure.

Closes #36820
2016-09-30 10:49:30 -07:00
Jonathan Turner 45fd0626a4 Rollup merge of #36760 - nrc:input2, r=alexcrichton
Allow supplying an error destination via the compiler driver

Allows replacing stderr with a buffer from the client.

Also, some refactoring around run_compiler.
2016-09-28 20:21:51 -07:00
Nick Cameron e8a4db25ac Allow supplying an error destination via the compiler driver
Allows replacing stderr with a buffer from the client.

Also, some refactoring around run_compiler.
2016-09-28 16:20:30 +13:00
Jeffrey Seyfried b3a81ee844 Build the reduced graph during expansion. 2016-09-27 06:42:10 +00:00
Jeffrey Seyfried ebaaafcd5d Peform def id assignment during expansion. 2016-09-27 06:42:09 +00:00
Tim Neumann cf1fc2ce13 appease tidy 2016-09-26 07:07:41 +02:00
Tim Neumann ad81f11b01 deduplicate inline is_nightly_build implementations 2016-09-26 07:07:41 +02:00
Tim Neumann 3f287efc82 refactor away get_unstable_features_setting 2016-09-26 07:07:41 +02:00
Jeffrey Seyfried b4906a93a0 Load macros from `#[macro_use]` extern crates in `resolve`. 2016-09-24 20:22:25 +00:00
Jeffrey Seyfried 7b5c59ea65 Load extern crates in `resolve`. 2016-09-23 06:35:33 +00:00
Jeffrey Seyfried 272cf4e61d Refactor `no_implicit_prelude: Cell<bool>` -> `no_implicit_prelude: bool`. 2016-09-22 07:45:11 +00:00
bors 1cf592fa40 Auto merge of #36551 - eddyb:meta-games, r=nikomatsakis
Refactor away RBML from rustc_metadata.

RBML and `ty{en,de}code` have had their long-overdue purge. Summary of changes:
* Metadata is now a tree encoded in post-order and with relative backward references pointing to children nodes. With auto-deriving and type safety, this makes maintenance and adding new information to metadata painless and bug-free by default. It's also more compact and cache-friendly (cache misses should be proportional to the depth of the node being accessed, not the number of siblings as in EBML/RBML).
* Metadata sizes have been reduced, for `libcore` it went down 16% (`8.38MB` -> `7.05MB`) and for `libstd` 14% (`3.53MB` -> `3.03MB`), while encoding more or less the same information
* Specialization is used in the bundled `libserialize` (crates.io `rustc_serialize` remains unaffected) to customize the encoding (and more importantly, decoding) of various types, most notably those interned in the `TyCtxt`. Some of this abuses a soundness hole pending a fix (cc @aturon), but when that fix arrives, we'll move to macros 1.1 `#[derive]` and custom `TyCtxt`-aware serialization traits.
* Enumerating children of modules from other crates is now orthogonal to describing those items via `Def` - this is a step towards bridging crate-local HIR and cross-crate metadata
* `CrateNum` has been moved to `rustc` and both it and `NodeId` are now newtypes instead of `u32` aliases, for specializing their decoding. This is `[syntax-breaking]` (cc @Manishearth ).

cc @rust-lang/compiler
2016-09-21 19:17:24 -07:00
Eduard Burtescu fc363cb482 rustc_metadata: go only through rustc_serialize in astencode. 2016-09-20 20:07:54 +03:00
bors c772948b68 Auto merge of #36388 - pcwalton:copy-propagation, r=nikomatsakis
librustc_mir: Implement def-use chains and trivial copy propagation on MIR.

This only supports trivial cases in which there is exactly one def and
one use.

Currently, some random unrelated MIR tests are failing, probably just because they haven't been updated.

r? @eddyb
2016-09-20 08:01:01 -07:00
Patrick Walton 480287ec3b librustc: Implement def-use chains and trivial copy propagation on MIR.
This only supports trivial cases in which there is exactly one def and
one use.
2016-09-19 19:18:38 -07:00
bors e0547019eb Auto merge of #36102 - GuillaumeGomez:rustc_metadata_diagnostics, r=jonathandturner
Rustc metadata diagnostics

r? @jonathandturner
2016-09-19 13:23:12 -07:00
bors d37e54b419 Auto merge of #36504 - pcwalton:and-star, r=eddyb
librustc_mir: Remove `&*x` when `x` has a reference type.

This introduces a new `InstCombine` pass for us to place such peephole
optimizations.

r? @eddyb
2016-09-17 17:30:22 -07:00
bors d4037fc476 Auto merge of #36444 - jseyfried:macro_rules_ext, r=nrc
Remove variant `MacroRulesTT` of `SyntaxExtension`

r? @nrc
2016-09-16 14:15:13 -07:00
Patrick Walton e8a44d29b6 librustc_mir: Remove `&*x` when `x` has a reference type.
This introduces a new `InstCombine` pass for us to place such peephole
optimizations.
2016-09-16 09:30:51 -07:00
Jeffrey Seyfried 21ba8160f2 Move fields `single_step` and `keep_macs` from `MacroExpander` to `ExpansionConfig`. 2016-09-15 20:57:38 +00:00
Simonas Kazlauskas ffaebadc99 Default RUST_MIN_STACK to 16MiB for now 2016-09-15 23:40:48 +03:00
Jeffrey Seyfried 78c0039878 Expand generated test harnesses and macro registries. 2016-09-13 09:40:28 +00:00
Jeffrey Seyfried c86c8d41a2 Perform node id assignment and `macros_at_scope` construction during
the `InvocationCollector` and `PlaceholderExpander` folds.
2016-09-13 09:40:28 +00:00
Jeffrey Seyfried 72a636975f Move macro resolution into `librustc_resolve`. 2016-09-13 09:40:26 +00:00
Jeffrey Seyfried a9821e1658 Refactor `ExtCtxt` to use a `Resolver` instead of a `MacroLoader`. 2016-09-13 05:31:16 +00:00
bors 4a26286216 Auto merge of #36214 - jseyfried:stackless_expansion, r=nrc
macros: stackless expansion

After this PR, macro expansion cannot overflow the stack unless the expanded crate is too deep to fold.
Everything but the stackless placeholder expansion commit is also groundwork for macro modularization.

r? @nrc or @eddyb
2016-09-07 19:02:51 -07:00
bors 923bac4596 Auto merge of #36025 - michaelwoerister:incr-comp-hash-spans, r=nikomatsakis
incr. comp.: Take spans into account for ICH

This PR makes the ICH (incr. comp. hash) take spans into account when debuginfo is enabled.

A side-effect of this is that the SVH (which is based on the ICHs of all items in the crate) becomes sensitive to the tiniest change in a code base if debuginfo is enabled. Since we are not trying to model ABI compatibility via the SVH anymore (this is done via the crate disambiguator now), this should be not be a problem.

Fixes #33888.
Fixes #32753.
2016-09-06 13:22:35 -07:00
Jeffrey Seyfried 9b3bc7a9e9 Remove `syntax::config::strip_unconfigured`, add `syntax::config::features`. 2016-09-05 04:53:16 +00:00
bors 86995dc8c5 Auto merge of #36240 - leeopop:master, r=jseyfried
Allow CompilerControllers to access rustc_plugin::registry::Registry

fixes #36064

I chose to put ructc_plugin::registry::Registry structure
into CompilerState structure, instead of Session structure.
This will preserve dependencies among librustc, libructc_driver, and libructc_plugin.

@jseyfried @sanxiyn
2016-09-04 18:36:42 -07:00
bors 91f057de35 Auto merge of #36203 - petrochenkov:uvsdot, r=nrc
Replace `_, _` with `..` in patterns

This is how https://github.com/rust-lang/rust/issues/33627 looks in action.

Looks especially nice in leftmost/rightmost positions `(first, ..)`/`(.., last)`.
I haven't touched libsyntax intentionally because the feature is still unstable.
2016-09-04 14:03:01 -07:00
bors e77d86c142 Auto merge of #36132 - nrc:save-std, r=@eddyb
Add --Zsave-analysis-api

This is a save-analysis variation which can be used with libraries distributed without their source (e.g., libstd). It will allow IDEs and other tools to get info about types and create URLs to docs and source, without the unnecessary clutter of internal-only save-analysis info. I'm sure we'll iterate somewhat on the design, but this is a first draft.
2016-09-04 02:40:31 -07:00
Vadim Petrochenkov e05e74ac83 Replace `_, _` with `..` 2016-09-04 12:30:33 +03:00
Keunhong Lee ca5dfd0c97 Allow CompilerControllers to access rustc_plugin::registry::Registry structure. 2016-09-04 03:22:56 +00:00
ggomez 7c53eb97df Add librustc metadata error codes to global check 2016-09-04 01:32:30 +02:00
Vadim Petrochenkov 641d8e9e4c Some better support for unions through the compiler 2016-09-03 13:39:34 +03:00
Alex Crichton ecc6c39e87 rustc: Implement custom derive (macros 1.1)
This commit is an implementation of [RFC 1681] which adds support to the
compiler for first-class user-define custom `#[derive]` modes with a far more
stable API than plugins have today.

[RFC 1681]: https://github.com/rust-lang/rfcs/blob/master/text/1681-macros-1.1.md

The main features added by this commit are:

* A new `rustc-macro` crate-type. This crate type represents one which will
  provide custom `derive` implementations and perhaps eventually flower into the
  implementation of macros 2.0 as well.

* A new `rustc_macro` crate in the standard distribution. This crate will
  provide the runtime interface between macro crates and the compiler. The API
  here is particularly conservative right now but has quite a bit of room to
  expand into any manner of APIs required by macro authors.

* The ability to load new derive modes through the `#[macro_use]` annotations on
  other crates.

All support added here is gated behind the `rustc_macro` feature gate, both for
the library support (the `rustc_macro` crate) as well as the language features.

There are a few minor differences from the implementation outlined in the RFC,
such as the `rustc_macro` crate being available as a dylib and all symbols are
`dlsym`'d directly instead of having a shim compiled. These should only affect
the implementation, however, not the public interface.

This commit also ended up touching a lot of code related to `#[derive]`, making
a few notable changes:

* Recognized derive attributes are no longer desugared to `derive_Foo`. Wasn't
  sure how to keep this behavior and *not* expose it to custom derive.

* Derive attributes no longer have access to unstable features by default, they
  have to opt in on a granular level.

* The `derive(Copy,Clone)` optimization is now done through another "obscure
  attribute" which is just intended to ferry along in the compiler that such an
  optimization is possible. The `derive(PartialEq,Eq)` optimization was also
  updated to do something similar.

---

One part of this PR which needs to be improved before stabilizing are the errors
and exact interfaces here. The error messages are relatively poor quality and
there are surprising spects of this such as `#[derive(PartialEq, Eq, MyTrait)]`
not working by default. The custom attributes added by the compiler end up
becoming unstable again when going through a custom impl.

Hopefully though this is enough to start allowing experimentation on crates.io!

syntax-[breaking-change]
2016-09-02 12:52:56 -07:00
Michael Woerister dd65cb223a Add some infrastructure for timing things where time_passes can't be used. 2016-09-01 09:43:18 -04:00
Nick Cameron 4dc7b585a2 save-analysis: add parent info to api dumps
The parent id is used for constructing rustdoc URLs by clients
2016-09-01 14:55:27 +12:00
Nick Cameron cbafc5758b save-analsysis: add save-analysis-api CLI flag 2016-09-01 14:55:27 +12:00
bors 2c01bb8851 Auto merge of #35718 - michaelwoerister:incr-comp-dir-locking, r=alexcrichton
Implement synchronization scheme for incr. comp. directory

This PR implements a copy-on-write-based synchronization scheme for the incremental compilation cache directory. For technical details, see the documentation at the beginning of `rustc_incremental/persist/fs.rs`.

The PR contains unit tests for some functions but for testing whether the scheme properly handles races, a more elaborate test setup would be needed. It would probably involve a small tool that allows to manipulate the incremental compilation directory in a controlled way and then letting a compiler instance run against directories in different states. I don't know if it's worth the trouble of adding another test category to `compiletest`, but I'd be happy to do so.

Fixes #32754
Fixes #34957
2016-08-31 12:56:15 -07:00
Michael Woerister 3e9bed92da Implement copy-on-write scheme for managing the incremental compilation cache. 2016-08-29 14:27:40 -04:00
Jeffrey Seyfried c14ff2884d Rollup merge of #35917 - jseyfried:remove_attr_ext_traits, r=nrc
syntax: Remove traits `AttrMetaMethods`, `AttributeMethods`, and `AttrNestedMetaItemMethods`
2016-08-28 10:40:04 +00:00
Jeffrey Seyfried 6303640e85 Rollup merge of #35850 - SergioBenitez:master, r=nrc
Implement RFC#1559: allow all literals in attributes

Implemented rust-lang/rfcs#1559, tracked by #34981.
2016-08-28 10:38:19 +00:00
Eduard Burtescu 7a8d4822d8 rustc: use Vec<Kind> in Substs, where Kind is a &TyS | &Region tagged pointer. 2016-08-27 01:15:07 +03:00
Eduard Burtescu dffd238f8b rustc: pass ty::Region behind an interned 'tcx reference. 2016-08-27 01:15:06 +03:00
Jeffrey Seyfried bfb01bbb26 Refactor away `AttrMetaMethods`. 2016-08-25 20:41:40 +00:00
Sergio Benitez 8250a26b5b Implement RFC#1559: allow all literals in attributes. 2016-08-25 13:25:22 -07:00
Manish Goregaokar cf597ab2ba Rollup merge of #35955 - frewsxcv:idiomatic-methods, r=eddyb
Use idiomatic names for string-related methods names.

None
2016-08-25 17:08:01 +05:30
Corey Farwell 2655c89549 Use idiomatic names for string-related methods names. 2016-08-23 21:28:26 -04:00
Niko Matsakis c21fa64dbb pacify the mercilous tidy 2016-08-23 13:28:55 -04:00
Niko Matsakis 484da37845 rename HashesMap to IncrementalHashesMap 2016-08-23 07:47:14 -04:00
Niko Matsakis 6bd80d1116 compute and cache HIR hashes at beginning
This avoids the compile-time overhead of computing them twice.  It also fixes
an issue where the hash computed after typeck is differen than the hash before,
because typeck mutates the def-map in place.

Fixes #35549.
Fixes #35593.
2016-08-20 07:26:14 -04:00
Eduard Burtescu 9453d9b8ad rustc: remove ParamSpace from Substs. 2016-08-17 06:32:00 +03:00
Eduard Burtescu 4158673ad7 rustc: reduce Substs and Generics to a simple immutable API. 2016-08-17 05:50:57 +03:00
bors 1bf5fa3269 Auto merge of #35538 - cgswords:libproc_macro, r=nrc
Kicking off libproc_macro

This PR introduces `libproc_macro`, which is currently quite bare-bones (just a few macro construction tools and an initial `quote!` macro).

This PR also introduces a few test cases for it, and an additional `shim` file (at `src/libsyntax/ext/proc_macro_shim.rs` to allow a facsimile usage of Macros 2.0 *today*!
2016-08-16 16:35:10 -07:00
cgswords 98c8e0a05d Proc_macro is alive 2016-08-16 13:17:36 -07:00
bors e25542cb02 Auto merge of #35162 - canndrew:bang_type_coerced, r=nikomatsakis
Implement the `!` type

This implements the never type (`!`) and hides it behind the feature gate `#[feature(never_type)]`. With the feature gate off, things should build as normal (although some error messages may be different). With the gate on, `!` is usable as a type and diverging type variables (ie. types that are unconstrained by anything in the code) will default to `!` instead of `()`.
2016-08-16 00:12:12 -07:00
bors f65d96fe3f Auto merge of #35340 - michaelwoerister:incr-comp-cli-args, r=nikomatsakis
Take commandline arguments into account for incr. comp.

Implements the conservative strategy described in https://github.com/rust-lang/rust/issues/33727.

From now one, every time a new commandline option is added, one has to specify if it influences the incremental compilation cache. I've tried to implement this as automatic as possible: One just has to added either the `[TRACKED]` or the `[UNTRACKED]` marker next to the field. The `Options`, `CodegenOptions`, and `DebuggingOptions` definitions in `session::config` show plenty of examples.

The PR removes some cruft from `session::config::Options`, mostly unnecessary copies of flags also present in `DebuggingOptions` or `CodeGenOptions` in the same struct.

One notable removal is the `cfg` field that contained the values passed via `--cfg` commandline arguments. I chose to remove it because (1) its content is only a subset of what later is stored in `hir::Crate::config` and it's pretty likely that reading the cfgs from `Options` would not be what you wanted, and (2) we could not incorporate it into the dep-tracking hash of the `Options` struct because of how the test framework works, leaving us with a piece of untracked but vital data.

It is now recommended (just as before) to access the crate config via the `krate()` method in the HIR map.

Because the `cfg` field is not present in the `Options` struct any more, some methods in the `CompilerCalls` trait now take the crate config as an explicit parameter -- which might constitute a breaking change for plugin authors.
2016-08-15 08:35:18 -07:00
Andrew Cann ed02344fbc Remove obsolete divergence related stuff
Replace FnOutput with Ty
Replace FnConverging(ty) with ty
Purge FnDiverging, FunctionRetTy::NoReturn and FunctionRetTy::None
2016-08-13 21:37:09 +08:00
bors f55ac6944a Auto merge of #35091 - eddyb:impl-trait, r=nikomatsakis
Implement `impl Trait` in return type position by anonymization.

This is the first step towards implementing `impl Trait` (cc #34511).
`impl Trait` types are only allowed in function and inherent method return types, and capture all named lifetime and type parameters, being invariant over them.
No lifetimes that are not explicitly named lifetime parameters are allowed to escape from the function body.
The exposed traits are only those listed explicitly, i.e. `Foo` and `Clone` in `impl Foo + Clone`, with the exception of "auto traits" (like `Send` or `Sync`) which "leak" the actual contents.

The implementation strategy is anonymization, i.e.:
```rust
fn foo<T>(xs: Vec<T>) -> impl Iterator<Item=impl FnOnce() -> T> {
    xs.into_iter().map(|x| || x)
}

// is represented as:
type A</*invariant over*/ T> where A<T>: Iterator<Item=B<T>>;
type B</*invariant over*/ T> where B<T>: FnOnce() -> T;
fn foo<T>(xs: Vec<T>) -> A<T> {
    xs.into_iter().map(|x| || x): $0 where $0: Iterator<Item=$1>, $1: FnOnce() -> T
}
```
`$0` and `$1` are resolved (to `iter::Map<vec::Iter<T>, closure>` and the closure, respectively) and assigned to `A` and `B`, after checking the body of `foo`. `A` and `B` are *never* resolved for user-facing type equality (typeck), but always for the low-level representation and specialization (trans).

The "auto traits" exception is implemented by collecting bounds like `impl Trait: Send` that have failed for the obscure `impl Trait` type (i.e. `A` or `B` above), pretending they succeeded within the function and trying them again after type-checking the whole crate, by replacing `impl Trait` with the real type.

While passing around values which have explicit lifetime parameters (of the function with `-> impl Trait`) in their type *should* work, regionck appears to assign inference variables in *way* too many cases, and never properly resolving them to either explicit lifetime parameters, or `'static`.
We might not be able to handle lifetime parameters in `impl Trait` without changes to lifetime inference, but type parameters can have arbitrary lifetimes in them from the caller, so most type-generic usecases (or not generic at all) should not run into this problem.

cc @rust-lang/lang
2016-08-12 01:26:12 -07:00
bors 68d9284a9b Auto merge of #34811 - DanielJCampbell:Expander, r=jseyfried
Extended expand.rs to support alternate expansion behaviours (eg. stepwise expansion)

r? nrc
2016-08-11 22:10:16 -07:00
Eduard Burtescu d1d16c94c5 rustc: rename ProjectionMode and its variant to be more memorable. 2016-08-12 06:43:34 +03:00
Michael Woerister 65eb024542 Remove the 'cfg' field from session::config::Options.
The 'cfg' in the Options struct is only the commandline-specified
subset of the crate configuration and it's almost always wrong to
read that instead of the CrateConfig in HIR crate node.
2016-08-11 09:56:00 -04:00
Michael Woerister 32414310b7 Add the notion of a dependency tracking status to commandline arguments.
Commandline arguments influence whether incremental compilation
can use its compilation cache and thus their changes relative to
previous compilation sessions need to be taking into account. This
commit makes sure that one has to specify for every commandline
argument whether it influences incremental compilation or not.
2016-08-11 09:56:00 -04:00
bors 1222f5d52b Auto merge of #34845 - bitshifter:issue-30961, r=alexcrichton
Add help for target CPUs, features, relocation and code models.

Fix for https://github.com/rust-lang/rust/issues/30961. Requires PR https://github.com/rust-lang/llvm/pull/45 to be accepted first, and the .gitmodules for llvm to be updated before this can be merged.
2016-08-10 21:42:48 -07:00
Daniel Campbell 61c7569d4a Extended expand.rs to support alternate expansion behaviours
Added single_step & keep_macs flags and functionality to expander
2016-08-10 18:35:15 +12:00
bors 561c4e1dd3 Auto merge of #35079 - nikomatsakis:incr-comp-ich-32753, r=mw
Various improvements to the SVH

This fixes a few points for the SVH:

- incorporate resolve results into the SVH;
- don't include nested items.

r? @michaelwoerister

cc #32753 (not fully fixed I don't think)
2016-08-09 21:00:21 -07:00
Niko Matsakis c7f15aa178 incorporate resolve results into hashing
We now incorporate the `def_map` and `trait_map`
results into the SVH.
2016-08-09 20:28:46 -04:00
bors 576f766594 Auto merge of #35401 - jonathandturner:enable_json_and_new_errors, r=jonathandturner
Turn on new errors and json mode

This PR is a big-switch, but on a well-worn path:

* Turns on new errors by default (and removes old skool)
* Moves json output from behind a flag

The RFC for new errors [landed](https://github.com/rust-lang/rfcs/pull/1644) and as part of that we wanted some bake time.  It's now had a few weeks + all the time leading up to the RFC of people banging on it.  We've also had [editors updating to the new format](https://github.com/saviorisdead/RustyCode/pull/159) and expect more to follow.

We also have an [issue on old skool](https://github.com/rust-lang/rust/issues/35330) that needs to be fixed as more errors are switched to the new style, but it seems silly to fix old skool errors when we fully intend to throw the switch in the near future.

This makes it lean towards "why not just throw the switch now, rather than waiting a couple more weeks?"  I only know of vim that wanted to try to parse the new format but were not sure how, and I think we can reach out to them and work out something in the 8 weeks before this would appear in a stable release.

We've [hashed out](https://github.com/rust-lang/rust/issues/35330) stabilizing JSON output, and it seems like people are relatively happy making what we have v1 and then likely adding to it in the future.  The idea is that we'd maintain backward compatibility and just add new fields as needed.  We'll also work on a separate output format that'd be better suited for interactive tools like IDES (since JSON message can get a little long depending on the error).

This PR stabilizes JSON mode, allowing its use without `-Z unstable-options`

Combined, this gives editors two ways to support errors going forward: parsing the new error format or using the JSON mode.  By moving JSON to stable, we can also add support to Cargo, which plugin authors tell us does help simplify their support story.

r? @nikomatsakis
cc @rust-lang/tools

Closes https://github.com/rust-lang/rust/issues/34826
2016-08-09 14:04:54 -07:00
bors e1d2bc2916 Auto merge of #35166 - nikomatsakis:incr-comp-ice-34991-2, r=mw
Address ICEs running w/ incremental compilation and building glium

Fixes for various ICEs I encountered trying to build glium with incremental compilation enabled. Building glium now works. Of the 4 ICEs, I have test cases for 3 of them -- I didn't isolate a test for the last commit and kind of want to go do other things -- most notably, figuring out why incremental isn't saving much *effort*.

But if it seems worthwhile and I can come back and try to narrow down the problem.

r? @michaelwoerister

Fixes #34991
Fixes #32015
2016-08-09 10:00:54 -07:00
Niko Matsakis 8fdc72f830 track MIR through the dep-graph
Per the discussion on #34765, we make one `DepNode::Mir` variant and use
it to represent both the MIR tracking map as well as passes that operate
on MIR. We also track loads of cached MIR (which naturally comes from
metadata).

Note that the "HAIR" pass adds a read of TypeckItemBody because it uses
a myriad of tables that are not individually tracked.
2016-08-08 18:44:24 -04:00
Jonathan Turner fad4f32c31 Turn on new errors, json mode. Remove duplicate unicode test 2016-08-07 07:46:49 -07:00
Cameron Hart cbb88faad7 Merge branch 'master' into issue-30961 2016-08-06 15:50:48 +10:00
bors e804a3cf25 Auto merge of #35168 - scottcarr:deaggregation, r=nikomatsakis
[MIR] Deaggregate structs to enable further optimizations

Currently, we generate MIR like:

```
tmp0 = ...;
tmp1 = ...;
tmp3 = Foo { a: ..., b: ... };
```

This PR implements "deaggregation," i.e.:

```
tmp3.0 = ...
tmp3.1 = ...
```

Currently, the code only deaggregates structs, not enums.  My understanding is that we do not have MIR to set the discriminant of an enum.
2016-08-04 03:01:37 -07:00
Ariel Ben-Yehuda d091ef802f begin auditing the C++ types in RustWrapper 2016-08-03 15:08:47 +03:00
Scott A Carr 62cdbea8c9 deaggregate structs to enable further optimization 2016-08-01 15:57:10 -07:00
Vadim Petrochenkov a80d329b68 Don't gate methods `Fn(Mut,Once)::call(mut,once)` with feature `unboxed_closures`
They are already gated with feature `fn_traits`
2016-07-31 17:48:20 +03:00
bors f164cf5d64 Auto merge of #34842 - cgswords:attr_enc, r=nrc
Better attribute and metaitem encapsulation throughout the compiler

This PR refactors most (hopefully all?) of the `MetaItem` interactions outside of `libsyntax` (and a few inside) to interact with MetaItems through the provided traits instead of directly creating / destruct / matching against them. This is a necessary first step to eventually converting `MetaItem`s to internally use `TokenStream` representations (which will make `MetaItem` interactions much nicer for macro writers once the new macro system is in place).

r? @nrc
2016-07-29 16:26:38 -07:00
bors 1523a5480a Auto merge of #34980 - cardoe:expose-target-options, r=alexcrichton
Convert built-in targets to JSON

Convert the built-in targets to JSON to ensure that the JSON parser is always fully featured. This follows on #32988 and #32847. The PR includes a number of extra commits that are just intermediate changes necessary for bisectibility and the ability to prove correctness of the change.
2016-07-28 23:18:52 -07:00
Niko Matsakis ceeb158e0a Address mw nits 2016-07-28 12:05:45 -04:00
Niko Matsakis cca4804251 Code to save/load the work-products map from disk
Work products are deleted if any of their inputs are dirty.
2016-07-28 12:05:04 -04:00
Niko Matsakis ffc13b2f80 Store `crate_disambiguator` as an `InternedString`
We used to use `Name`, but the session outlives the tokenizer, which
means that attempts to read this field after trans has complete
otherwise panic. All reads want an `InternedString` anyhow.
2016-07-28 12:05:04 -04:00
Jonathan Creekmore 54c61ff959 librustc_back: filter targets for only valid ones
Since we can know which targets are instantiable on a particular host,
it does not make sense to list invalid targets in the target print code.
Filter the list of targets to only include the targets that can be
instantiated.
2016-07-27 10:29:43 -07:00
cgswords 5553901146 Adressed PR comments. 2016-07-25 14:27:10 -07:00
cgswords a5e5ea1646 General MetaItem encapsulation rewrites. 2016-07-25 14:27:10 -07:00
Cameron Hart 6aee1e2a67 Tidy ups for code gen options help
Remove duplication code gen options and updated help to reflect
changes.
2016-07-24 18:44:08 +10:00
Cameron Hart 79358aa523 Merge branch 'master' into issue-30961 2016-07-19 20:57:49 +10:00
Jeffrey Seyfried 0042c1a620 Add `librustc_driver::driver::reset_thread_local_state` and
remove the thread local state reset at the beginning of `phase_1_parse_input`.
2016-07-18 10:10:11 +00:00
bors 6cc49e51de Auto merge of #34860 - jseyfried:encapsulate_hygiene, r=nrc
Clean up and encapsulate `syntax::ext::mtwt`, rename `mtwt` to `hygiene`

r? @nrc
2016-07-17 22:12:59 -07:00
Jeffrey Seyfried 44575f708a Rename `mtwt` to `hygiene` 2016-07-17 17:12:35 +00:00
Jeffrey Seyfried 76ed445622 Clean up and encapsulate `syntax::ext::mtwt` 2016-07-17 17:12:32 +00:00
bors 7ed6068d3e Auto merge of #34789 - jonathandturner:simplify_liberror, r=alexcrichton
Simplify librustc_errors

This is part 2 of the error crate refactor, starting with #34403.

In this refactor, I focused on slimming down the error crate to fewer moving parts.  As such, I've removed quite a few parts and replaced the with simpler, straight-line code.  Specifically, this PR:

* Removes BasicEmitter
* Remove emit from emitter, leaving emit_struct
* Renames emit_struct to emit
* Removes CoreEmitter and focuses on a single Emitter
* Implements the latest changes to error format RFC (#1644)
* Removes (now-unused) code in emitter.rs and snippet.rs
* Moves more tests to the UI tester, removing some duplicate tests in the process

There is probably more that could be done with some additional refactoring, but this felt like it was getting to a good state.

r? @alexcrichton   cc: @Manishearth (as there may be breaking changes in stuff I removed/changed)
2016-07-17 00:06:29 -07:00
Cameron Hart 5c4d621a96 Merge branch 'master' into issue-30961 2016-07-16 15:21:00 +10:00
bors 4db1874f4c Auto merge of #34570 - jseyfried:no_rename, r=nrc
Simplify the macro hygiene algorithm

This PR removes renaming from the hygiene algorithm and treats differently marked identifiers as unequal.

This change makes the scope of identifiers in `macro_rules!` items empty. That is, identifiers in `macro_rules!` definitions do not inherit any semantics from the `macro_rules!`'s scope.

Since `macro_rules!` macros are items, the scope of their identifiers "should" be the same as that of other items; in particular, the scope should contain only items. Since all items are unhygienic today, this would mean the scope should be empty.

However, the scope of an identifier in a `macro_rules!` statement today is the scope that the identifier would have if it replaced the `macro_rules!` (excluding anything unhygienic, i.e. locals only).

To continue to support this, this PR tracks the scope of each `macro_rules!` and uses it in `resolve` to ensure that an identifier expanded from a `macro_rules!` gets a chance to resolve to the locals in the `macro_rules!`'s scope.

This PR is a pure refactoring. After this PR,
 - `syntax::ext::expand` is much simpler.
 - We can expand macros in any order without causing problems for hygiene (needed for macro modularization).
 - We can deprecate or remove today's `macro_rules!` scope easily.
 - Expansion performance improves by 25%, post-expansion memory usage decreases by ~5%.
 - Expanding a block is no longer quadratic in the number of `let` statements (fixes #10607).

r? @nrc
2016-07-15 08:48:41 -07:00
Jonathan Turner c7158a143a Remove unused import 2016-07-15 08:47:12 -04:00
Jonathan Turner bf66a4840b Fix up more tests that I missed 2016-07-14 15:43:53 -04:00
Jonathan Turner a019c2c6ba Remove CoreEmitter and focus on Emitter 2016-07-14 07:57:46 -04:00
Jonathan Turner 55f06883b8 Remove emit from emitter, leaving emit_struct 2016-07-14 07:57:46 -04:00
Jonathan Turner 8f044fae36 Remove BasicEmitter 2016-07-14 07:57:46 -04:00
Jeffrey Seyfried 195a27faab Move node id assigning into `resolve` 2016-07-14 01:30:19 +00:00
Jeffrey Seyfried 752d4419a0 Refactor `get_ident_interner` -> `with_ident_interner`. 2016-07-11 22:25:04 +00:00
Jeffrey Seyfried 70e2845230 Avoid passing around the thread-local interner in `librustc_metadata`. 2016-07-11 22:23:35 +00:00
Cameron Hart e1efa324ec Add help for target CPUs, features, relocation and code models. 2016-07-11 00:22:13 +10:00
Michael Woerister 65e8a13441 Adapt backend to trans::partitioning dictating the codegen-unit setup. 2016-07-08 10:42:46 -04:00
bors ec58d0c997 Auto merge of #34412 - gnzlbg:document_platform_intrinsics_generate, r=alexcrichton
Add x86 intrinsics for bit manipulation (BMI 1.0, BMI 2.0, and TBM).

This PR adds the LLVM x86 intrinsics for the bit manipulation instruction sets (BMI 1.0, BMI 2.0, and TBM).

The objective of this pull-request is to allow building a library that implements all the algorithms offered by those instruction sets, using compiler intrinsics for the targets that support them (by means of `target_feature`).

The target features added are:

- `bmi`: Bit Manipulation Instruction Set 1.0, available in Intel >= Haswell and AMD's >= Jaguar/Piledriver,
- `bmi2`: Bit Manipulation Instruction Set 2.0, available in Intel >= Haswell and AMD's >= Excavator,
- `tbm`: Trailing Bit Manipulation, available only in AMD's Piledriver (won't be available in newer CPUs).

The intrinsics added are:

- BMI 1.0:
  - `bextr`: Bit field extract (with register).
- BMI 2.0:
  - `bzhi`: Zero high bits starting with specified bit position.
  - `pdep`: Parallel bits deposit.
  - `pext`: Parallel bits extract.
- TBM:
 - `bextri`: Bit field extract (with immediate).
2016-07-05 08:25:37 -07:00
Will Crichton 5b0f334c6b Renamed phase to compilation_done 2016-07-04 02:47:53 -04:00
Will Crichton eaf31099ed Added new compilation phase and test 2016-07-04 02:47:19 -04:00
Will Crichton ce1146ac5f Moved LLVM cleanup to after `after_llvm` phase 2016-07-04 02:47:19 -04:00
Jeffrey Seyfried d1e3d6272e Add the `after_expand` entry point between import resolution and the rest of name resolution 2016-07-01 00:07:32 +00:00
Jeffrey Seyfried 9eec73820c Remove `after_expand` and `after_write_deps` CompileController entry points 2016-06-30 04:55:21 +00:00
Jeffrey Seyfried e58963d3e4 groundwork: create the `Resolver` earlier in phase 2 2016-06-28 05:28:27 +00:00
Jeffrey Seyfried ec0c150152 groundwork: refactor the interface that `resolve` exposes to `driver` 2016-06-28 05:28:26 +00:00
Jeffrey Seyfried 36a4eb9940 cleanup: refactor away `ast::NodeIdAssigner` 2016-06-28 05:28:25 +00:00
Jeffrey Seyfried 9bb3ea0feb Rollup merge of #34436 - jseyfried:no_block_expr, r=eddyb
To allow these braced macro invocation, this PR removes the optional expression from `ast::Block` and instead uses a `StmtKind::Expr` at the end of the statement list.

Currently, braced macro invocations in blocks can expand into statements (and items) except when they are last in a block, in which case they can only expand into expressions.

For example,
```rust
macro_rules! make_stmt {
    () => { let x = 0; }
}

fn f() {
    make_stmt! {} //< This is OK...
    let x = 0; //< ... unless this line is commented out.
}
```

Fixes #34418.
2016-06-26 02:20:14 +00:00
Jeffrey Seyfried 8eddf02800 Rollup merge of #34339 - jseyfried:thin_vec, r=petrochenkov,Manishearth
Generalize and abstract `ThinAttributes` to `ThinVec<Attribute>`.
2016-06-26 02:18:43 +00:00
Jeffrey Seyfried a48a4f5c7a Avoid wasting node ids 2016-06-23 17:42:10 +00:00
Jeffrey Seyfried b7da35a5aa Remove field `expr` of `ast::Block` 2016-06-23 17:42:08 +00:00
Jonathan Turner 6ae3502134 Move errors from libsyntax to its own crate 2016-06-23 08:07:35 -04:00
gnzlbg 483bec790b Add target_features for the bit manipulation instruction sets: BMI 1.0, BMI 2.0, and TBM. 2016-06-22 17:11:17 +02:00
Paul Jarrett bd477503e2 Improves organization of driver includes. 2016-06-20 22:11:45 -04:00
Jeffrey Seyfried 5033eca65f Generalize and abstract `ThinAttributes` 2016-06-19 00:01:55 +00:00
Jeffrey Seyfried 2cd6ccf0b1 Simplify gated cfg checking 2016-06-16 19:24:44 +00:00
Jeffrey Seyfried 66b9ade341 Strip `#[test]` nodes during `cfg` processing on non-test builds. 2016-06-11 03:13:44 +00:00
bors ee00760a14 Auto merge of #34149 - arielb1:remove-remove-dead-blocks, r=nikomatsakis
MIR cleanups and predecessor cache

This PR cleans up a few things in MIR and adds a predecessor cache to allow graph algorithms to be run easily.

r? @nikomatsakis
2016-06-09 12:07:38 -07:00
Ariel Ben-Yehuda ce4fdefbd8 fix issues 2016-06-09 21:47:58 +03:00
Ariel Ben-Yehuda f5b1ba6e90 use the type name as the pass name 2016-06-09 15:24:46 +03:00
Ariel Ben-Yehuda 065a264976 refactor simplify_cfg and split off simplify_branches 2016-06-09 15:24:43 +03:00
Ariel Ben-Yehuda 2ee00e6d9d add hook infrastructure for automatically dumping MIR on every pass 2016-06-09 15:21:43 +03:00
Ariel Ben-Yehuda e9003c5574 merge the RemoveDeadBlocks pass into the SimplifyCfg pass 2016-06-09 13:23:00 +03:00
bors 24526cc3cc Auto merge of #34108 - jseyfried:refactor_prelude_injection, r=nrc
Refactor away the prelude injection fold

Instead, just inject `#[prelude_import] use [core|std]::prelude::v1::*;` at the crate root while injecting `extern crate [core|std];` and process `#[no_implicit_prelude]` attributes in `resolve`.

r? @nrc
2016-06-09 01:35:26 -07:00
Jeffrey Seyfried 51499b6e1f Load macros from `extern crate`s during expansion. 2016-06-09 00:44:17 +00:00
bors 4b240fe96a Auto merge of #34083 - alexcrichton:dumb-hack, r=nrc
rustc: Try to contain prepends to PATH

This commit attempts to bring our prepends to PATH on Windows when loading
plugins because we've been seeing quite a few issues with failing to spawn a
process on Windows, the leading theory of which is that PATH is too large as a
result of this. Currently this is mostly a stab in the dark as it's not
confirmed to actually fix the problem, but it's probably not a bad change to
have anyway!

cc #33844
Closes #17360
2016-06-08 07:43:29 -07:00
Jeffrey Seyfried 49de80d7ea Refactor away the prelude injection pass 2016-06-07 00:31:42 +00:00
Alex Crichton 1564e92940 rustc: Try to contain prepends to PATH
This commit attempts to bring our prepends to PATH on Windows when loading
plugins because we've been seeing quite a few issues with failing to spawn a
process on Windows, the leading theory of which is that PATH is too large as a
result of this. Currently this is mostly a stab in the dark as it's not
confirmed to actually fix the problem, but it's probably not a bad change to
have anyway!

cc #33844
Closes #17360
2016-06-05 00:08:35 -07:00
bors f97c411548 Auto merge of #33622 - arielb1:elaborate-drops, r=nikomatsakis
[MIR] non-zeroing drop

This enables non-zeroing drop through stack flags for MIR.

Fixes #30380.
Fixes #5016.
2016-06-04 23:49:29 -07:00
Ariel Ben-Yehuda 4106ab24d7 break critical edges only when needed
the *only* place where critical edges need to be broken is on Call
instructions, so only break them there.
2016-06-05 09:27:26 +03:00
Ariel Ben-Yehuda a091cfd4f3 implement drop elaboration
Fixes #30380
2016-06-03 16:11:18 +03:00
Jeffrey Seyfried 3fc0407fb3 Remove the `dep-info-no-analysis` test and fix other fallout. 2016-06-01 19:20:42 +00:00
Jeffrey Seyfried c52968af8c Move name resolution to phase 2 2016-06-01 19:20:39 +00:00
Jeffrey Seyfried 58d7e1bf70 Remove redundant `check_for_macros` AST pass. 2016-06-01 18:51:35 +00:00
bors c2cab1fd58 Auto merge of #33794 - petrochenkov:sanity, r=nrc
Add AST validation pass and move some checks to it

The purpose of this pass is to catch constructions that fit into AST data structures, but not permitted by the language. As an example, `impl`s don't have visibilities, but for convenience and uniformity with other items they are represented with a structure `Item` which has `Visibility` field.

This pass is intended to run after expansion of macros and syntax extensions (and before lowering to HIR), so it can catch erroneous constructions that were generated by them. This pass allows to remove ad hoc semantic checks from the parser, which can be overruled by syntax extensions and occasionally macros.

The checks can be put here if they are simple, local, don't require results of any complex analysis like name resolution or type checking and maybe don't logically fall into other passes. I expect most of errors generated by this pass to be non-fatal and allowing the compilation to proceed.

I intend to move some more checks to this pass later and maybe extend it with new checks, like, for example, identifier validity. Given that syntax extensions are going to be stabilized in the measurable future, it's important that they would not be able to subvert usual language rules.

In this patch I've added two new checks - a check for labels named `'static` and a check for lifetimes and labels named `'_`. The first one gives a hard error, the second one - a future compatibility warning.
Fixes https://github.com/rust-lang/rust/issues/33059 ([breaking-change])
cc https://github.com/rust-lang/rfcs/pull/1177

r? @nrc
2016-06-01 06:21:53 -07:00
Ms2ger 7463c95183 Take the def_map argument to TyCtxt::create_and_enter out of its RefCell. 2016-05-31 09:21:49 +02:00
Ms2ger 989a3034db Move driver::Resolutions::def_map out of its RefCell. 2016-05-30 15:17:16 +02:00
Vadim Petrochenkov 731144b95a sanity -> validation
Add test for `::super` in import prefix
2016-05-28 20:52:49 +03:00
Vadim Petrochenkov 2abdf96344 Add an AST sanity checking pass and use it to catch some illegal lifetime/label names 2016-05-28 20:27:57 +03:00
bors 623af22b9a Auto merge of #33821 - sanxiyn:cfg-test, r=nikomatsakis
Do not inject test harness for --cfg test

Fix #33670.
2016-05-28 10:24:01 -07:00
bors 8b012ed142 Auto merge of #33706 - jseyfried:refactor_cfg, r=nrc
Perform `cfg` attribute processing during macro expansion and fix bugs

This PR refactors `cfg` attribute processing and fixes bugs. More specifically:
 - It merges gated feature checking for stmt/expr attributes, `cfg_attr` processing, and `cfg` processing into a single fold.
  - This allows feature gated `cfg` variables to be used in `cfg_attr` on unconfigured items. All other feature gated attributes can already be used on unconfigured items.
 - It performs `cfg` attribute processing during macro expansion instead of after expansion so that macro-expanded items are configured the same as ordinary items. In particular, to match their non-expanded counterparts,
  - macro-expanded unconfigured macro invocations are no longer expanded,
  - macro-expanded unconfigured macro definitions are no longer usable, and
  - feature gated `cfg` variables on macro-expanded macro definitions/invocations are now errors.

This is a [breaking-change]. For example, the following would break:
```rust
macro_rules! m {
    () => {
        #[cfg(attr)]
        macro_rules! foo { () => {} }
        foo!(); // This will be an error

        macro_rules! bar { () => { fn f() {} } }
        #[cfg(attr)] bar!(); // This will no longer be expanded ...
        fn g() { f(); } // ... so that `f` will be unresolved.

        #[cfg(target_thread_local)] // This will be a gated feature error
        macro_rules! baz { () => {} }
    }
}

m!();
```

r? @nrc
2016-05-27 17:46:14 -07:00
Manish Goregaokar 63dfbdbc1b Rollup merge of #33839 - kamalmarhubi:codemape-get-filemap-option, r=nmatsakis
This is more idiomatic, putting the caller in charge of whether or not
to panic.
2016-05-27 10:02:45 +05:30
Jeffrey Seyfried 1aa34e0b5f Strip unconfigured items during macro expansion 2016-05-27 00:01:04 +00:00
Eduard Burtescu a619901e3d trans: save metadata even with -Z no-trans. 2016-05-25 08:46:36 +03:00
Kamal Marhubi 3bef085ea8 syntax: Make codemap::get_filemap() return an Option
This is more idiomatic, putting the caller in charge of whether or not
to panic.
2016-05-24 16:08:01 +02:00
Seo Sanghyeon 3c4eb01482 Remove unused field and argument 2016-05-24 02:00:39 +09:00
Seo Sanghyeon f27fbf9a4a Do not inject test harness for --cfg test 2016-05-24 00:44:44 +09:00
bors d27bdafc3e Auto merge of #33553 - alexcrichton:cdylibs, r=brson
rustc: Add a new crate type, cdylib

This commit is an implementation of [RFC 1510] which adds a new crate type,
`cdylib`, to the compiler. This new crate type differs from the existing `dylib`
crate type in a few key ways:

* No metadata is present in the final artifact
* Symbol visibility rules are the same as executables, that is only reachable
  `extern` functions are visible symbols
* LTO is allowed
* All libraries are always linked statically

This commit is relatively simple by just plubming the compiler with another
crate type which takes different branches here and there. The only major change
is an implementation of the `Linker::export_symbols` function on Unix which now
actually does something. This helps restrict the public symbols from a cdylib on
Unix.

With this PR a "hello world" `cdylib` is 7.2K while the same `dylib` is 2.4MB,
which is some nice size savings!

[RFC 1510]: https://github.com/rust-lang/rfcs/pull/1510

Closes #33132
2016-05-20 00:34:50 -07:00
Alex Crichton 07d373f3d6 rustc: Add a new crate type, cdylib
This commit is an implementation of [RFC 1510] which adds a new crate type,
`cdylib`, to the compiler. This new crate type differs from the existing `dylib`
crate type in a few key ways:

* No metadata is present in the final artifact
* Symbol visibility rules are the same as executables, that is only reachable
  `extern` functions are visible symbols
* LTO is allowed
* All libraries are always linked statically

This commit is relatively simple by just plubming the compiler with another
crate type which takes different branches here and there. The only major change
is an implementation of the `Linker::export_symbols` function on Unix which now
actually does something. This helps restrict the public symbols from a cdylib on
Unix.

With this PR a "hello world" `cdylib` is 7.2K while the same `dylib` is 2.4MB,
which is some nice size savings!

[RFC 1510]: https://github.com/rust-lang/rfcs/pull/1510

Closes #33132
2016-05-19 15:32:03 -07:00
Niko Matsakis 7734308f89 ignore dep-graph in resolve and lower_crate
This got removed at some point, it seems.
2016-05-18 10:11:35 -04:00
Niko Matsakis b711734a5f thread the DepGraph to session/crate-store
This is a [breaking-change] for plugin authors.
You must now create a dep-graph earlier.
2016-05-18 10:10:45 -04:00