Commit Graph

972 Commits

Author SHA1 Message Date
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
Manish Goregaokar 36c4c6d433 Rollup merge of #33544 - dotdash:baby_dont_break_me_no_more, r=Aatch
Only break critical edges where actually needed

Currently, to prepare for MIR trans, we break _all_ critical edges,
although we only actually need to do this for edges originating from a
call that gets translated to an invoke instruction in LLVM.

This has the unfortunate effect of undoing a bunch of the things that
SimplifyCfg has done. A particularly bad case arises when you have a
C-like enum with N variants and a derived PartialEq implementation.

In that case, the match on the (&lhs, &rhs) tuple gets translated into
nested matches with N arms each and a basic block each, resulting in N²
basic blocks. SimplifyCfg reduces that to roughly 2*N basic blocks, but
breaking the critical edges means that we go back to N².

In nickel.rs, there is such an enum with roughly N=800. So we get about
640K basic blocks or 2.5M lines of LLVM IR. LLVM takes a while to
reduce that to the final "disr_a == disr_b".

So before this patch, we had 2.5M lines of IR with 640K basic blocks,
which took about about 3.6s in LLVM to get optimized and translated.
After this patch, we get about 650K lines with about 1.6K basic blocks
and spent a little less than 0.2s in LLVM.

cc #33111

r? @Aatch
2016-05-14 11:57:47 +02:00
bors d3ec9d43cf Auto merge of #33538 - Ms2ger:LocalCrateReader, r=arielb1
Refactor code around LocalCrateReader.
2016-05-13 23:34:52 -07:00
bors dee865a56d Auto merge of #33532 - jseyfried:mutable_lowering_context, r=nrc
Clean up `hir::lowering`

Clean up `hir::lowering`:
 - give lowering functions mutable access to the lowering context
 - refactor the `lower_*` functions and other functions that take a lowering context into methods
 - simplify the API that `hir::lowering` exposes to `driver`
 - other miscellaneous cleanups

r? @nrc
2016-05-13 18:40:08 -07:00
bors 01ed700640 Auto merge of #33450 - SiegeLord:dep_info_no_analysis, r=nrc
Make --emit dep-info work correctly with -Z no-analysis again.

Previously, it would attempt to resolve some external crates that weren't necessary for dep-info output.

Fixes #33231.
2016-05-12 19:52:51 -07:00
Björn Steinbrink 00f6513259 Only break critical edges where actually needed
Currently, to prepare for MIR trans, we break _all_ critical edges,
although we only actually need to do this for edges originating from a
call that gets translated to an invoke instruction in LLVM.

This has the unfortunate effect of undoing a bunch of the things that
SimplifyCfg has done. A particularly bad case arises when you have a
C-like enum with N variants and a derived PartialEq implementation.

In that case, the match on the (&lhs, &rhs) tuple gets translated into
nested matches with N arms each and a basic block each, resulting in N²
basic blocks. SimplifyCfg reduces that to roughly 2*N basic blocks, but
breaking the critical edges means that we go back to N².

In nickel.rs, there is such an enum with roughly N=800. So we get about
640K basic blocks or 2.5M lines of LLVM IR. LLVM takes a while to
reduce that to the final "disr_a == disr_b".

So before this patch, we had 2.5M lines of IR with 640K basic blocks,
which took about about 3.6s in LLVM to get optimized and translated.
After this patch, we get about 650K lines with about 1.6K basic blocks
and spent a little less than 0.2s in LLVM.

cc #33111
2016-05-11 18:35:12 +02:00
Ms2ger c0e321abcb Make LocalCrateReader private to creader. 2016-05-11 09:32:05 +02:00
Ms2ger 5511e6568f Hand ownership of the Definitions to map_crate. 2016-05-11 09:32:05 +02:00
Pavel Sountsov ba04a52b96 Also rename the print_from_ast. 2016-05-10 19:21:44 -07:00
Eduard Burtescu a1c170fc35 rustc: Split local type contexts interners from the global one. 2016-05-11 04:14:58 +03:00
Eduard Burtescu 20652162ca rustc: More interning for data used in Ty<'tcx>. 2016-05-11 04:14:58 +03:00
Eduard Burtescu 12e56ea56b rustc: Wrap users of InferCtxt in an anonymous scope. 2016-05-11 04:14:58 +03:00
Eduard Burtescu 76affa5d6f rustc: Split 'tcx into 'gcx and 'tcx for InferCtxt and its users. 2016-05-11 04:14:58 +03:00
Eduard Burtescu 513d392f7e rustc: Replace &'a TyCtxt<'tcx> with a TyCtxt<'a, 'tcx> wrapper. 2016-05-11 04:14:58 +03:00
Eduard Burtescu f8ea24edc8 rustc: Avoid free functions taking &TyCtxt and &InferCtxt. 2016-05-11 04:14:58 +03:00
Eduard Burtescu 0907c198c4 infer: Use methods for creating an InferCtxt. 2016-05-11 04:14:58 +03:00
Ms2ger e919f25180 Delay wrapping Definitions into a RefCell around LocalCrateReader. 2016-05-10 19:36:08 +02:00
Pavel Sountsov 64cca3ab2d Rename after_ast to after_hir_lowering. 2016-05-10 08:22:55 -07:00
Pavel Sountsov 105aa8c30f Fix funky formatting. 2016-05-10 08:21:00 -07:00
Pavel Sountsov f16eac928a Make --emit dep-info work correctly with -Z no-analysis again.
Previously, it would attempt to resolve some external crates that weren't
necessary for dep-info output.

Fixes #33231.
2016-05-10 08:21:00 -07:00
Ms2ger 9ac468b841 Store a reference rather than a RefCell in LocalCrateReader. 2016-05-10 15:34:25 +02:00
Jeffrey Seyfried 33978b0728 Refactor `hir::lowering` API 2016-05-10 07:54:52 +00:00
Jeffrey Seyfried 946efcd4ca Refactor the `hir::lowering::lower_*` functions into methods of `LoweringContext` 2016-05-10 05:41:01 +00:00
Jeffrey Seyfried eed8d70ac5 Give lowering functions mutable access to the lowering context 2016-05-10 04:58:09 +00:00
Jeffrey Seyfried 805666a4d2 Fix fallout in `librustdoc` and in tests 2016-05-09 12:12:32 +00:00
Jeffrey Seyfried abec20b177 Refactor out `driver::lower_and_resolve` 2016-05-09 10:27:27 +00:00
Jeffrey Seyfried e6d6c37968 Reimplement pretty printing 2016-05-09 02:47:08 +00:00
Jeffrey Seyfried e5a0dd7c6e Resolve paths generated in the ast->hir lowerer 2016-05-09 02:31:06 +00:00
Jeffrey Seyfried 983b4d3925 Refactor the interface that `resolve` exposes to `driver` 2016-05-09 02:31:06 +00:00
Jeffrey Seyfried 8428447253 Move resolution to before lowering 2016-05-09 02:31:04 +00:00
Jeffrey Seyfried 16c8f2cca8 Temporarily unimplement pretty printing 2016-05-09 00:48:50 +00:00
bors 8e414e0e3f Auto merge of #33091 - sanxiyn:unused-trait-import-3, r=nrc
Warn unused trait imports, rebased

Rebase of #30021.

Fix #25730.
2016-05-08 04:50:27 -07:00
bors 1ec22171e6 Auto merge of #33130 - eddyb:mir-const, r=nikomatsakis
Implement constant support in MIR.

All of the intended features in `trans::consts` are now supported by `mir::constant`.
The implementation is considered a temporary measure until `miri` replaces it.

A `-Z orbit` bootstrap build will only translate LLVM IR from AST for `#[rustc_no_mir]` functions.

Furthermore, almost all checks of constant expressions have been moved to MIR.
In non-`const` functions, trees of temporaries are promoted, as per RFC 1414 (rvalue promotion).
Promotion before MIR borrowck would allow reasoning about promoted values' lifetimes.

The improved checking comes at the cost of four `[breaking-change]`s:
* repeat counts must contain a constant expression, e.g.:
`let arr = [0; { println!("foo"); 5 }];` used to be allowed (it behaved like `let arr = [0; 5];`)
* dereference of a reference to a `static` cannot be used in another `static`, e.g.:
`static X: [u8; 1] = [1]; static Y: u8 = (&X)[0];` was unintentionally allowed before
* the type of a `static` *must* be `Sync`, irrespective of the initializer, e.g.
`static FOO: *const T = &BAR;` worked as `&T` is `Sync`, but it shouldn't because `*const T` isn't
* a `static` cannot wrap `UnsafeCell` around a type that *may* need drop, e.g.
`static X: MakeSync<UnsafeCell<Option<String>>> = MakeSync(UnsafeCell::new(None));`
was previously allowed based on the fact `None` alone doesn't need drop, but in `UnsafeCell`
it can be later changed to `Some(String)` which *does* need dropping

The drop restrictions are relaxed by RFC 1440 (#33156), which is implemented, but feature-gated.
However, creating `UnsafeCell` from constants is unstable, so users can just enable the feature gate.
2016-05-08 00:31:40 -07:00
Eduard Burtescu 78884b7659 mir: qualify and promote constants. 2016-05-07 19:14:28 +03:00
Seo Sanghyeon 84946b8ace Fix more tests 2016-05-03 18:51:19 +09:00
Seo Sanghyeon 24d86137f5 Warn unused trait imports 2016-05-03 18:51:19 +09:00
Seo Sanghyeon 7ad1900e1c Remove unused trait imports flagged by lint 2016-05-03 18:48:34 +09:00
bors 7d8100a068 Auto merge of #33119 - nrc:pretty, r=pnkfelix
Refactor pretty printing to use the compiler API
2016-05-02 23:56:48 -07:00
Nick Cameron c1c6e99bfd rebasing
Note that this whole PR is a [breaking-change] for clients of the Compiler API.
2016-05-03 11:15:09 +12:00
Nick Cameron aaf56d7086 Fix tests 2016-05-03 10:51:01 +12:00
Nick Cameron 52a2b33a4b Refactor pretty printing to use more of the driver 2016-05-03 10:51:01 +12:00
Nick Cameron 7ee02d9f4d Use the compiler API to run pretty printing.
This commit still does a lot of building in pretty because we always run after parsing.
2016-05-03 10:49:47 +12:00
Nick Cameron a4000cbbf8 Make pretty printer take Session by ref 2016-05-03 10:48:22 +12:00
Niko Matsakis 64e0819fc2 patch travis failure 2016-05-02 11:49:26 -04:00
Niko Matsakis 2ba5fac1a4 fix rebase flaws 2016-05-02 11:49:26 -04:00
Niko Matsakis 8013eebf2c fix error message in librustc_driver tests 2016-05-02 11:49:24 -04:00
Niko Matsakis 1067850e6a refactor the Emitter trait
There is now a CoreEmitter that everything desugars to, but without
losing any information. Also remove RenderSpan::FileLine. This lets the
rustc_driver tests build.
2016-05-02 11:49:24 -04:00
Niko Matsakis 11dc974a38 refactor to use new snippet code and model
Major changes:
- Remove old snippet rendering code and use the new stuff.
- Introduce `span_label` method to add a label
- Remove EndSpan mode and replace with a fn to get the last
  character of a span.
- Stop using `Option<MultiSpan>` and just use an empty `MultiSpan`
- and probably a bunch of other stuff :)
2016-05-02 11:47:10 -04:00
bors 855fb61922 Auto merge of #33296 - jseyfried:non_idempotent_lowering, r=nrc
Remove the requirement that ast->hir lowering be reproducible

This PR changes the ast->hir lowerer to be non-reproducible, and it removes the lowering context's id cache.

If the `hir` of an `ast` node needs to be reproduced, we can use the hir map instead of the lowerer -- for example, `tcx.map.expect_expr(expr.id)` instead of `lower_expr(lcx, expr)`.

r? @nrc
2016-05-01 18:28:24 -07:00
Jeffrey Seyfried 522b6ed8a7 Avoid keeping MTWT tables for save-analysis 2016-05-02 00:19:22 +00:00
Jeffrey Seyfried ca88c44a90 Avoid using the lowering context in `librustc_save_analysis` 2016-05-01 23:30:18 +00:00
Guillaume Gomez 47d9f49ebf Remove rust flags from doc block 2016-05-01 18:13:36 +02:00
bors b0aefff714 Auto merge of #32846 - jseyfried:allow_unconfigured_gated_expanded_items, r=nrc
Avoid gated feature checking unconfigured expanded items

Avoid gated feature checking unconfigured macro-expanded items (fixes #32840).
Unconfigured items that are not macro-expanded are already not gated feature checked.
r? @nrc
2016-04-30 02:07:33 -07:00
bors 115c6c810c Auto merge of #33217 - aochagavia:fileloader, r=nrc
rustc_driver: Allow running the compiler with a FileLoader

cc @nrc. I chose to implement this in such a way that it doesn't break anything. Please let me know if you want me to change anything.
2016-04-28 12:27:27 -07:00
bors 4751e45521 Auto merge of #33208 - nrc:save-json, r=pnkfelix
save-analysis: dump in JSON format

cc #18582
2016-04-28 05:47:57 -07:00
bors 435095f32a Auto merge of #32791 - LeoTestard:feature-gate-clean, r=nikomatsakis
Feature gate clean

This PR does a bit of cleaning in the feature-gate-handling code of libsyntax. It also fixes two bugs (#32782 and #32648). Changes include:

* Change the way the existing features are declared in `feature_gate.rs`. The array of features and the `Features` struct are now defined together by a single macro. `featureck.py` has been updated accordingly. Note: there are now three different arrays for active, removed and accepted features instead of a single one with a `Status` item to tell wether a feature is active, removed, or accepted. This is mainly due to the way I implemented my macro in the first time and I can switch back to a single array if needed. But an advantage of the way it is now is that when an active feature is used, the parser only searches through the list of active features. It goes through the other arrays only if the feature is not found. I like to think that error checking (in this case, checking that an used feature is active) does not slow down compilation of valid code. :) But this is not very important...
* Feature-gate checking pass now use the `Features` structure instead of looking through a string vector. This should speed them up a bit. The construction of the `Features` struct should be faster too since it is build directly when parsing features instead of calling `has_feature` dozens of times.
* The MacroVisitor pass has been removed, it was mostly useless since the `#[cfg]-stripping` phase happens before (fixes #32648). The features that must actually be checked before expansion are now checked at the time they are used. This also allows us to check attributes that are generated by macro expansion and not visible to MacroVisitor, but are also removed by macro expansion and thus not visible to PostExpansionVisitor either. This fixes #32782. Note that in order for `#[derive_*]` to be feature-gated but still accepted when generated by `#[derive(Trait)]`, I had to do a little bit of trickery with spans that I'm not totally confident into. Please review that part carefully. (It's in `libsyntax_ext/deriving/mod.rs`.)::

Note: this is a [breaking change], since programs with feature-gated attributes on macro-generated macro invocations were not rejected before. For example:

```rust
macro_rules! bar (
    () => ()
);

macro_rules! foo (
    () => (
        #[allow_internal_unstable] //~ ERROR allow_internal_unstable side-steps
        bar!();
    );
);
```
foo!();
2016-04-27 18:35:29 -07:00
Adolfo Ochagavía 6c50c8877f rustc_driver: Allow running the compiler with a FileLoader 2016-04-27 10:51:55 +02:00
Nick Cameron 5065f0c2a2 save-analysis-json: thread through -z option
In fact, we make JSOn the default and add an option for save-analysis-csv for the legacy behaviour.

We also rename some bits and pieces `dxr` -> `save-analysis`
2016-04-26 10:14:44 +12:00
bors a264f5b7e8 Auto merge of #33089 - nrc:hir-name-res, r=eddyb
Move def id collection and extern crate handling to before AST->HIR lowering

r? @jseyfried, @eddyb, or @nikomatsakis
2016-04-22 03:41:29 -07:00
Leo Testard 03ab057f97 Remove the MacroVisitor pass.
This pass was supposed to check use of gated features before
`#[cfg]`-stripping but this was not the case since it in fact happens
after. Checks that are actually important and must be done before macro
expansion are now made where the features are actually used. Close #32648.
Also ensure that attributes on macro-generated macro invocations are
checked as well. Close #32782 and #32655.
2016-04-22 01:40:33 +02:00
bors 92e3fb3ebe Auto merge of #31709 - ranma42:target_feature-from-llvm, r=alexcrichton
Compute `target_feature` from LLVM

This is a work-in-progress fix for #31662.

The logic that computes the target features from the command line has been replaced with queries to the `TargetMachine`.
2016-04-20 09:57:57 -07:00
Andrea Canciani ce99a5e5d8 Check that the feature strings are well-formed
Assert that the feature strings are NUL terminated, so that they will
be well-formed as C strings.

This is a safety check to ease the maintaninace and update of the
feature lists.
2016-04-20 09:09:30 +02:00
Andrea Canciani deaa2fe753 Make the feature whitelists constants
This simplifies the code a bit and makes the types nicer, too.
2016-04-20 09:08:25 +02:00
Nick Cameron 0be3c8c569 rebasing 2016-04-20 10:16:10 +12:00
Nick Cameron 1d5a29cf0e debugging, misc fixes 2016-04-20 10:14:16 +12:00
Nick Cameron 84c3f898f9 def_collector and crate reader operate on AST instead of HIR
And move extern crate reading earlier in the driver
2016-04-20 10:13:35 +12:00
Nick Cameron 6af7acab1c Separate def collection and hir map making even further 2016-04-20 10:13:35 +12:00
Nick Cameron d6bcc04c52 Move DefCollector to its own module. 2016-04-20 10:13:35 +12:00
Nick Cameron f61b404467 Split up NodeCollector so that defs are collected separately from nodes for the HIR map. 2016-04-20 10:13:35 +12:00
Nick Cameron c99b73a767 Trivial refactoring 2016-04-20 10:13:35 +12:00
Andrea Canciani 5879ee1eca Distinguish different `vfp?` features
The different generations of ARM floating point VFP correspond to the
LLVM CPU features named `vfp2`, `vfp3`, and `vfp4`; they are now
exposed in Rust under the same names.

This commit fixes some crashes that would occour when checking if the
`vfp` feature exists (the crash occurs because the linear scan of the
LLVM feature goes past the end of the features whenever it searches
for a feature that does not exist in the LLVM tables).
2016-04-19 17:48:51 +02:00
Andrea Canciani f942c28900 Do not intern NUL terminators
The C representation needed by LLVM requires strings to be
NUL-terminated, but on the Rust side they should not contain unwanted
NULs.
2016-04-19 17:44:36 +02:00
bors 933000613b Auto merge of #32811 - alexcrichton:check-lints, r=nrc
rustdoc: Fix testing no_run code blocks

This was a regression introduced by #31250 where the compiler deferred returning
the results of compilation a little too late (after the `Stop` check was looked
at). This commit alters the stop point to first try to return an erroneous
`result` and only if it was successful return the sentinel `Err(0)`.

Closes #31576
2016-04-12 07:14:55 -07:00
Alex Crichton 42bcb4047d rustdoc: Fix testing no_run code blocks
This was a regression introduced by #31250 where the compiler deferred returning
the results of compilation a little too late (after the `Stop` check was looked
at). This commit alters the stop point to first try to return an erroneous
`result` and only if it was successful return the sentinel `Err(0)`.

Closes #31576
2016-04-11 09:26:59 -07:00
Jeffrey Seyfried 5eb775eedd Remove redundant gated feature checking pass 2016-04-09 00:16:57 +00:00
Jeffrey Seyfried 0ea66f35a9 Avoid gated feature checking unconfigured items 2016-04-08 22:47:55 +00:00
Andrea Canciani 92e24b9516 Expose the features computed from LLVM in `cfg!`
Instead of relying on the features explicitly passed through the
command line, compute them from the LLVM `TargetMachine`.
2016-04-09 00:41:23 +02:00
bors 7979dd6089 Auto merge of #32016 - nikomatsakis:incr-comp-save, r=mw
Save/load incremental compilation dep graph

Contains the code to serialize/deserialize the dep graph to disk between executions. We also hash the item contents and compare to the new hashes. Also includes a unit test harness. There are definitely some known limitations, such as https://github.com/rust-lang/rust/issues/32014 and https://github.com/rust-lang/rust/issues/32015, but I am leaving those for follow-up work.

Note that this PR builds on https://github.com/rust-lang/rust/pull/32007, so the overlapping commits can be excluded from review.

r? @michaelwoerister
2016-04-07 10:55:37 -07:00
bors a9f34c86a4 Auto merge of #32230 - GuillaumeGomez:extend_css, r=alexcrichton
Add --extend-css option to rustdoc

Fixes #32223

r? @brson
2016-04-06 17:11:44 -07:00
Niko Matsakis 3fb40c1d95 add code to persist graph and for unit-testing 2016-04-06 12:42:46 -04:00
Niko Matsakis b1e68b9e2d make an incremental crate
for now, this houses `svh` and the code to check `assert_dep_graph` is
sane
2016-04-06 12:42:02 -04:00
Niko Matsakis fe47ca0d0b restructure rustc options relating to incr. comp.
You can now pass `-Z incremental=dir` as well as saying `-Z
query-dep-graph` if you want to enable queries for some other
purpose. Accessor functions take the place of computed boolean flags.
2016-04-06 12:35:15 -04:00
Eduard Burtescu e8a8dfb056 rustc: retire hir::map's paths. 2016-04-06 13:51:55 +03:00
Eduard Burtescu 8b0937293b rustc: move rustc_front to rustc::hir. 2016-04-06 09:01:55 +03:00
Manish Goregaokar f6019760f9 Rollup merge of #32596 - soltanmm:lazy, r=nikomatsakis
Plumb obligations through librustc/infer

Like #32542, but more like #31867.

TODO before merge: make an issue for the propagation of obligations through... uh, everywhere... then replace the `#????`s with the actual issue number.

cc @jroesch
r? @nikomatsakis
2016-04-05 16:43:21 +05:30
Guillaume Gomez ded701bf64 Centralize nightly compiler flags handling 2016-04-05 04:13:30 +02:00
Masood Malekghassemi 86071aca3d Address nits 2016-04-04 12:41:05 -07:00
bors c0b8c43820 Auto merge of #32210 - Aatch:mir-traversal, r=nikomatsakis
rBreak Critical Edges and other MIR work

This PR is built on top of #32080.

This adds the basic depth-first traversals for MIR, preorder, postorder and reverse postorder. The MIR blocks are now translated using reverse postorder. There is also a transform for breaking critical edges, which includes the edges from `invoke`d calls (`Drop` and `Call`), to account for the fact that we can't add code after an `invoke`. It also stops generating the intermediate block (since the transform essentially does it if necessary already).

The kinds of cases this deals with are difficult to produce, so the test is the one I managed to get. However, it seems to bootstrap with `-Z orbit`, which it didn't before my changes.
2016-04-03 08:58:59 -07:00
bors f2285bdaf5 Auto merge of #32549 - respeccing:rust_backtrace_disabled, r=alexcrichton
allow RUST_BACKTRACE=0 to act as if unset

**UPDATE:** `RUST_BACKTRACE=0` to act as if the env. var is unset! (now `0` is what `disabled` was for, below)

When RUST_BACKTRACE is set to "disabled" then this acts as if the env. var is unset. So, either make sure `RUST_BACKTRACE` is not set OR set it to `disabled` to achieve the same effect.

Sample usage:

```bash
$ rustc -o /tmp/a.out -- <(echo 'fn main(){ panic!() }') && RUST_BACKTRACE=disabled /tmp/a.out
!! executing '/home/zazdxscf/build/1nonpkgs/rust/rust//x86_64-unknown-linux-gnu/stage2/bin//rustc' with args: '-o /tmp/a.out -- /dev/fd/63'
thread '<main>' panicked at 'explicit panic', /dev/fd/63:1
note: Run with `RUST_BACKTRACE=1` for a backtrace.

$ rustc -o /tmp/a.out -- <(echo 'fn main(){ panic!() }') && RUST_BACKTRACE=1 /tmp/a.out
!! executing '/home/zazdxscf/build/1nonpkgs/rust/rust//x86_64-unknown-linux-gnu/stage2/bin//rustc' with args: '-o /tmp/a.out -- /dev/fd/63'
thread '<main>' panicked at 'explicit panic', /dev/fd/63:1
stack backtrace:
   1:     0x55709e8148c0 - sys::backtrace::tracing:👿:write::h140f24a0cfc189b98Ru
   2:     0x55709e816a5b - panicking::default_hook::_$u7b$$u7b$closure$u7d$$u7d$::closure.45165
   3:     0x55709e8166e8 - panicking::default_hook::hed419823688cb82aXoA
   4:     0x55709e810fff - sys_common::unwind::begin_unwind_inner::hbb9642f6e212d56fmHt
   5:     0x55709e810513 - sys_common::unwind::begin_unwind::h16232867470678019594
   6:     0x55709e810489 - main::hb524f9576270962feaa
   7:     0x55709e816314 - sys_common::unwind::try::try_fn::h1274188004693518534
   8:     0x55709e813dfb - __rust_try
   9:     0x55709e815dab - rt::lang_start::h712b1cd650781872ahA
  10:     0x55709e810679 - main
  11:     0x7efd1026859f - __libc_start_main
  12:     0x55709e810348 - _start
  13:                0x0 - <unknown>
```

Some programs(eg. [vim's syntactic](https://github.com/scrooloose/syntastic) used by [rust.vim](https://github.com/rust-lang/rust.vim)) cannot unset the env. var RUST_BACKTRACE if it's already set(eg. in .bashrc) but [they can set it to some value](cb5533e159/system/Z575/OSes/gentoo/on_baremetal/filesystem_now/gentoo/home/zazdxscf/build/1nonpkgs/rust.vim/upd (L17)), and I needed to ensure the env. var is unset in order to avoid this issue: https://github.com/rust-lang/rust/issues/29293

**EDIT:** Sample usage 2:

```bash
$ export RUST_BACKTRACE=1

$ rustc -o /tmp/a.out -- <(echo 'fn main(){ panic!() }') && /tmp/a.out
!! executing '/home/zazdxscf/build/1nonpkgs/rust/rust//x86_64-unknown-linux-gnu/stage2/bin//rustc' with args: '-o /tmp/a.out -- /dev/fd/63'
thread '<main>' panicked at 'explicit panic', /dev/fd/63:1
stack backtrace:
   1:     0x55c2696738c0 - sys::backtrace::tracing:👿:write::h140f24a0cfc189b98Ru
   2:     0x55c269675a5b - panicking::default_hook::_$u7b$$u7b$closure$u7d$$u7d$::closure.45165
   3:     0x55c2696756e8 - panicking::default_hook::hed419823688cb82aXoA
   4:     0x55c26966ffff - sys_common::unwind::begin_unwind_inner::hbb9642f6e212d56fmHt
   5:     0x55c26966f513 - sys_common::unwind::begin_unwind::h16023941661074805588
   6:     0x55c26966f489 - main::hb524f9576270962feaa
   7:     0x55c269675314 - sys_common::unwind::try::try_fn::h1274188004693518534
   8:     0x55c269672dfb - __rust_try
   9:     0x55c269674dab - rt::lang_start::h712b1cd650781872ahA
  10:     0x55c26966f679 - main
  11:     0x7f593d58459f - __libc_start_main
  12:     0x55c26966f348 - _start
  13:                0x0 - <unknown>

$ rustc -o /tmp/a.out -- <(echo 'fn main(){ panic!() }') && RUST_BACKTRACE=disabled /tmp/a.out
!! executing '/home/zazdxscf/build/1nonpkgs/rust/rust//x86_64-unknown-linux-gnu/stage2/bin//rustc' with args: '-o /tmp/a.out -- /dev/fd/63'
thread '<main>' panicked at 'explicit panic', /dev/fd/63:1
note: Run with `RUST_BACKTRACE=1` for a backtrace.

```
2016-04-02 01:47:59 -07:00
bors c8b8eb1fda Auto merge of #32544 - alexcrichton:rustbuild-dist-libtest, r=brson
rustbuild: Fix dist for non-host targets

The `rust-std` package that we produce is expected to have not only the standard
library but also libtest for compiling unit tests. Unfortunately this does not
currently happen due to the way rustbuild is structured.

There are currently two main stages of compilation in rustbuild, one for the
standard library and one for the compiler. This is primarily done to allow us to
fill in the sysroot right after the standard library has finished compiling to
continue compiling the rest of the crates. Consequently the entire compiler does
not have to explicitly depend on the standard library, and this also should
allow us to pull in crates.io dependencies into the build in the future because
they'll just naturally build against the std we just produced.

These phases, however, do not represent a cross-compiled build. Target-only
builds also require libtest, and libtest is currently part of the
all-encompassing "compiler build". There's unfortunately no way to learn about
just libtest and its dependencies (in a great and robust fashion) so to ensure
that we can copy the right artifacts over this commit introduces a new build
step, libtest.

The new libtest build step has documentation, dist, and link steps as std/rustc
already do. The compiler now depends on libtest instead of libstd, and all
compiler crates can now assume that test and its dependencies are implicitly
part of the sysroot (hence explicit dependencies being removed). This makes the
build a tad less parallel as in theory many rustc crates can be compiled in
parallel with libtest, but this likely isn't where we really need parallelism
either (all the time is still spent in the compiler).

All in all this allows the `dist-std` step to depend on both libstd and libtest,
so `rust-std` packages produced by rustbuild should start having both the
standard library and libtest.

Closes #32523
2016-04-01 12:52:08 -07:00
Alex Crichton 3d6340ffe2 rustbuild: Fix dist for non-host targets
The `rust-std` package that we produce is expected to have not only the standard
library but also libtest for compiling unit tests. Unfortunately this does not
currently happen due to the way rustbuild is structured.

There are currently two main stages of compilation in rustbuild, one for the
standard library and one for the compiler. This is primarily done to allow us to
fill in the sysroot right after the standard library has finished compiling to
continue compiling the rest of the crates. Consequently the entire compiler does
not have to explicitly depend on the standard library, and this also should
allow us to pull in crates.io dependencies into the build in the future because
they'll just naturally build against the std we just produced.

These phases, however, do not represent a cross-compiled build. Target-only
builds also require libtest, and libtest is currently part of the
all-encompassing "compiler build". There's unfortunately no way to learn about
just libtest and its dependencies (in a great and robust fashion) so to ensure
that we can copy the right artifacts over this commit introduces a new build
step, libtest.

The new libtest build step has documentation, dist, and link steps as std/rustc
already do. The compiler now depends on libtest instead of libstd, and all
compiler crates can now assume that test and its dependencies are implicitly
part of the sysroot (hence explicit dependencies being removed). This makes the
build a tad less parallel as in theory many rustc crates can be compiled in
parallel with libtest, but this likely isn't where we really need parallelism
either (all the time is still spent in the compiler).

All in all this allows the `dist-std` step to depend on both libstd and libtest,
so `rust-std` packages produced by rustbuild should start having both the
standard library and libtest.

Closes #32523
2016-04-01 10:18:36 -07:00
Emanuel Czirai e1d2eda7f3 allow RUST_BACKTRACE=0 to act as if unset
/# This is a combination of 16 commits.
/# The first commit's message is:
allow RUST_BACKTRACE=disabled to act as if unset

When RUST_BACKTRACE is set to "disabled" then this acts as if the env.
var is unset.

/# This is the 2nd commit message:

case insensitive "DiSaBLeD" RUST_BACKTRACE value

previously it expected a lowercase "disabled" to treat the env. var as
unset

/# This is the 3rd commit message:

RUST_BACKTRACE=0 acts as if unset

previously RUST_BACKTRACE=disabled was doing the same thing

/# This is the 4th commit message:

RUST_BACKTRACE=0|n|no|off acts as if unset

previously only RUST_BACKTRACE=0 acted as if RUST_BACKTRACE was unset
Now added more options (case-insensitive): 'n','no' and 'off'
eg. RUST_BACKTRACE=oFF

/# This is the 5th commit message:

DRY on the value of 2

DRY=don't repeat yourself
Because having to remember to keep the two places of '2' in sync is not
ideal, even though this is a simple enough case.

/# This is the 6th commit message:

Revert "DRY on the value of 2"

This reverts commit 95a0479d5cf72a2b2d9d21ec0bed2823ed213fef.

Nevermind this DRY on 2, because we already have a RY on 1,
besides the code is less readable this way...

/# This is the 7th commit message:

attempt to document unsetting RUST_BACKTRACE

/# This is the 8th commit message:

curb allocations when checking for RUST_BACKTRACE

this means we don't check for case-insensitivity anymore

/# This is the 9th commit message:

as decided, RUST_BACKTRACE=0 turns off backtrace

/# This is the 10th commit message:

RUST_TEST_NOCAPTURE=0 acts as if unset

(that is, capture is on)

Any other value acts as if nocapture is enabled (that is, capture is off)

/# This is the 11th commit message:

update other RUST_TEST_NOCAPTURE occurrences

apparently only one place needs updating

/# This is the 12th commit message:

update RUST_BACKTRACE in man page

/# This is the 13th commit message:

handle an occurrence of RUST_BACKTRACE

/# This is the 14th commit message:

ensure consistency with new rules for backtrace

/# This is the 15th commit message:

a more concise comment for RUST_TEST_NOCAPTURE

/# This is the 16th commit message:

update RUST_TEST_NOCAPTURE in man page
2016-03-31 23:02:59 +02:00
James Miller 63321ca193 Turn break critical edges into a MIR pass
Also adds a new set of passes to run just before translation that
"prepare" the MIR for codegen. Removal of landing pads, region erasure
and break critical edges are run in this pass.

Also fixes some merge/rebase errors.
2016-03-31 15:13:24 +13:00
Manish Goregaokar 74546e8ab7 Rollup merge of #32494 - pnkfelix:gate-parser-recovery-via-debugflag, r=nrc
Gate parser recovery via debugflag

Gate parser recovery via debugflag

Put in `-Z continue_parse_after_error`

This works by adding a method, `fn abort_if_no_parse_recovery`, to the
diagnostic handler in `syntax::errors`, and calling it after each
error is emitted in the parser.

(We might consider adding a debugflag to do such aborts in other
places where we are currently attempting recovery, such as resolve,
but I think the parser is the really important case to handle in the
face of #31994 and the parser bugs of varying degrees that were
injected by parse error recovery.)

r? @nikomatsakis
2016-03-31 05:04:59 +05:30
Felix S. Klock II 2646663b5a Put in `-Z continue-parse-after-error`
This works by adding a boolean flag, `continue_after_error`, to
`syntax::errors::Handler` that can be imperatively set to `true` or
`false` via a new `fn set_continue_after_error`.

The flag starts off true (since we generally try to recover from
compiler errors, and `Handler` is shared across all phases).

Then, during the `phase_1_parse_input`, we consult the setting of the
`-Z continue-parse-after-error` debug flag to determine whether we
should leave the flag set to `true` or should change it to `false`.

----

(We might consider adding a debugflag to do such aborts in other
places where we are currently attempting recovery, such as resolve,
but I think the parser is the really important case to handle in the
face of #31994 and the parser bugs of varying degrees that were
injected by parse error recovery.)
2016-03-30 22:23:48 +02:00
Oliver Schneider 3eac64747f move `const_eval` and `check_match` out of `librustc` 2016-03-30 13:43:36 +02:00
Masood Malekghassemi dcdf3d62c1 Plumb obligations through librustc/infer 2016-03-29 20:06:42 -07:00
James Miller eee7f3c732 Add and use a break critical edges transform
This is a fairly standard transform that inserts blocks along critical
edges so code can be inserted along the edge without it affecting other
edges. The main difference is that it considers a Drop or Call
terminator that would require an `invoke` instruction in LLVM a critical
edge. This is because we can't actually insert code after an invoke, so
it ends up looking similar to a critical edge anyway.

The transform is run just before translation right now.
2016-03-30 12:59:57 +13:00
bors ec666a5977 Auto merge of #32571 - eddyb:llvm-back-to-back, r=alexcrichton
Weed out dependencies on librustc_llvm and librustc.

Found while working on #32570. cc @nikomatsakis
2016-03-29 14:43:51 -07:00
Eduard Burtescu 352b44d1fa Remove unnecessary dependencies on rustc_llvm. 2016-03-29 19:36:01 +03:00
Masood Malekghassemi 8cd0f0cc3a Refactor s.t. TypeRelation implementors don't escape InferCtxt 2016-03-28 22:10:26 -07:00