about summary refs log tree commit diff
path: root/src/librustc_driver
AgeCommit message (Collapse)AuthorLines
2017-01-20Rollup merge of #38842 - abonander:proc_macro_attribute, r=jseyfriedAlex Crichton-11/+12
Implement `#[proc_macro_attribute]` This implements `#[proc_macro_attribute]` as described in https://github.com/rust-lang/rfcs/pull/1566 The following major (hopefully non-breaking) changes are included: * Refactor `proc_macro::TokenStream` to use `syntax::tokenstream::TokenStream`. * `proc_macro::tokenstream::TokenStream` no longer emits newlines between items, this can be trivially restored if desired * `proc_macro::TokenStream::from_str` does not try to parse an item anymore, moved to `impl MultiItemModifier for CustomDerive` with more informative error message * Implement `#[proc_macro_attribute]`, which expects functions of the kind `fn(TokenStream, TokenStream) -> TokenStream` * Reactivated `#![feature(proc_macro)]` and gated `#[proc_macro_attribute]` under it * `#![feature(proc_macro)]` and `#![feature(custom_attribute)]` are mutually exclusive * adding `#![feature(proc_macro)]` makes the expansion pass assume that any attributes that are not built-in, or introduced by existing syntax extensions, are proc-macro attributes * Fix `feature_gate::find_lang_feature_issue()` to not use `unwrap()` * This change wasn't necessary for this PR, but it helped debugging a problem where I was using the wrong feature string. * Move "completed feature gate checking" pass to after "name resolution" pass * This was necessary for proper feature-gating of `#[proc_macro_attribute]` invocations when the `proc_macro` feature flag isn't set. Prototype/Litmus Test: [Implementation](https://github.com/abonander/anterofit/blob/proc_macro/service-attr/src/lib.rs#L13) -- [Usage](https://github.com/abonander/anterofit/blob/proc_macro/service-attr/examples/post_service.rs#L35)
2017-01-17run rustdoc tests in the same sort of thread rustc runs inNiko Matsakis-16/+28
2017-01-17Teach Diagnostics to highlight textEsteban Küber-2/+2
2017-01-17Give the `StringReader` a `sess: &ParseSess`.Jeffrey Seyfried-4/+4
2017-01-16Move "completed feature gate checking" pass to after "name resolution" pass ↵Austin Bonander-11/+11
so proc-macro-attribute feature gate check can use resolve
2017-01-16Implement `#[proc_macro_attribute]`Austin Bonander-0/+1
* Add support for `#[proc_macro]` * Reactivate `proc_macro` feature and gate `#[proc_macro_attribute]` under it * Have `#![feature(proc_macro)]` imply `#![feature(use_extern_macros)]`, error on legacy import of proc macros via `#[macro_use]`
2017-01-12Fix linker failureGuillaume Gomez-1/+5
2017-01-09Auto merge of #38840 - kjaleshire:multiple-targets-error-fix, r=nrcbors-3/+4
Warn that the link target ignores the given name Hi, new contributor here. This is my stab at #20130, any feedback welcome!
2017-01-08Auto merge of #38813 - eddyb:lazy-11, r=nikomatsakisbors-5/+17
[11/n] Separate ty::Tables into one per each body. _This is part of a series ([prev](https://github.com/rust-lang/rust/pull/38449) | [next]()) 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> In order to track the results of type-checking and inference for incremental recompilation, they must be stored separately for each function or constant value, instead of lumped together. These side-`Tables` also have to be tracked by various passes, as they visit through bodies (all of which have `Tables`, even if closures share the ones from their parent functions). This is usually done by switching a `tables` field in an override of `visit_nested_body` before recursing through `visit_body`, to the relevant one and then restoring it - however, in many cases the nesting is unnecessary and creating the visitor for each body in the crate and then visiting that body, would be a much cleaner solution. To simplify handling of inlined HIR & its side-tables, their `NodeId` remapping and entries HIR map were fully stripped out, which means that `NodeId`s from inlined HIR must not be used where a local `NodeId` is expected. It might be possible to make the nodes (`Expr`, `Block`, `Pat`, etc.) that only show up within a `Body` have IDs that are scoped to that `Body`, which would also allow `Tables` to use `Vec`s. That last part also fixes #38790 which was accidentally introduced in a previous refactor.
2017-01-08Auto merge of #38679 - alexcrichton:always-deny-warnings, r=nrcbors-1/+1
Remove not(stage0) from deny(warnings) Historically this was done to accommodate bugs in lints, but there hasn't been a bug in a lint since this feature was added which the warnings affected. Let's completely purge warnings from all our stages by denying warnings in all stages. This will also assist in tracking down `stage0` code to be removed whenever we're updating the bootstrap compiler.
2017-01-06Error message more like originalKyle Aleshire-2/+2
2017-01-06rustc: keep track of tables everywhere as if they were per-body.Eduard-Mihai Burtescu-5/+17
2017-01-04Warn that the name is ignored if a link target is emittedKyle Aleshire-3/+4
2017-01-02rustc: Stabilize the `proc_macro` featureAlex Crichton-2/+1
This commit stabilizes the `proc_macro` and `proc_macro_lib` features in the compiler to stabilize the "Macros 1.1" feature of the language. Many more details can be found on the tracking issue, #35900. Closes #35900
2016-12-31Split CtxtArenas into GlobalArenas and CtxtInterners.Mark Simulacrum-10/+34
CtxtInterners contains a single DroplessArena, while GlobalArenas contains the TypedArenas still required for the remaining Drop-containing types.
2016-12-29Remove not(stage0) from deny(warnings)Alex Crichton-1/+1
Historically this was done to accommodate bugs in lints, but there hasn't been a bug in a lint since this feature was added which the warnings affected. Let's completely purge warnings from all our stages by denying warnings in all stages. This will also assist in tracking down `stage0` code to be removed whenever we're updating the bootstrap compiler.
2016-12-29Change --crate-type metadata to --emit=metadataNick Cameron-4/+2
2016-12-28rustc: always print nested nodes where a HIR map is available.Eduard-Mihai Burtescu-5/+25
2016-12-28rustc: separate bodies for static/(associated)const and embedded constants.Eduard-Mihai Burtescu-2/+2
2016-12-28rustc: separate TraitItem from their parent Item, just like ImplItem.Eduard-Mihai Burtescu-0/+3
2016-12-23Allow legacy custom derive authors to disable warnings in downstream crates.Jeffrey Seyfried-0/+2
2016-12-22Add intrinsics & target features for rd{rand,seed}Simonas Kazlauskas-1/+1
2016-12-19Simplify `TyCtxt::create_and_enter`.Jeffrey Seyfried-19/+6
2016-12-15Use StableHasher everywhereAriel Ben-Yehuda-8/+4
The standard implementations of Hasher have architecture-dependent results when hashing integers. This causes problems when the hashes are stored within metadata - metadata written by one host architecture can't be read by another. To fix that, implement an architecture-independent StableHasher and use it in all places an architecture-independent hasher is needed. Fixes #38177.
2016-12-12Auto merge of #38057 - KiChjang:display-formal-type-param, r=nikomatsakisbors-3/+5
Display better error messages for E0282 Fixes #36554.
2016-12-05Refactor FnSig to contain a Slice for its inputs and outputs.Mark-Simulacrum-6/+1
2016-12-04Auto merge of #38092 - pnkfelix:mir-stats, r=nikomatsakisbors-1/+13
Adds `-Z mir-stats`, which is similar to `-Z hir-stats`. Adds `-Z mir-stats`, which is similar to `-Z hir-stats`. Some notes: * This code attempts to present the breakdown of each variant for every enum in the MIR. This is meant to guide decisions about how to revise representations e.g. when to box payloads for rare variants to shrink the size of the enum overall. * I left out the "Total:" line that hir-stats presents, because this implementation uses the MIR Visitor infrastructure, and the memory usage of structures directly embedded in other structures (e.g. the `func: Operand` in a `TerminatorKind:Call`) is not distinguished from similar structures allocated in a `Vec` (e.g. the `args: Vec<Operand>` in a `TerminatorKind::Call`). This means that a naive summation of all the accumulated sizes is misleading, because it will double-count the contribution of the `Operand` of the `func` as well as the size of the whole `TerminatorKind`. * I did consider abandoning the MIR Visitor and instead hand-coding a traversal that distinguished embedded storage from indirect storage. But such code would be fragile; better to just require people to take care when interpreting the presented results. * This traverses the `mir.promoted` rvalues to capture stats for MIR stored there, even though the MIR visitor super_mir method does not do so. (I did not observe any promoted mir being newly traversed when compiling the rustc crate, however.) * It might be nice to try to unify this code with hir-stats. Then again, the reporting portion is the only common code (I think), and it is small compared to the visitors in hir-stats and mir-stats.
2016-12-03Add TypeVariableOrigin enumKeith Yeung-3/+5
2016-12-03Auto merge of #38079 - BurntSushi:attrtarget, r=alexcrichtonbors-1/+2
Add new #[target_feature = "..."] attribute. This commit adds a new attribute that instructs the compiler to emit target specific code for a single function. For example, the following function is permitted to use instructions that are part of SSE 4.2: #[target_feature = "+sse4.2"] fn foo() { ... } In particular, use of this attribute does not require setting the -C target-feature or -C target-cpu options on rustc. This attribute does not have any protections built into it. For example, nothing stops one from calling the above `foo` function on hosts without SSE 4.2 support. Doing so may result in a SIGILL. I've also expanded the x86 target feature whitelist.
2016-12-03Auto merge of #38061 - cardoe:target-spec, r=alexcrichtonbors-0/+3
print option to dump target spec as JSON This lets the user dump out the target spec that the compiler is using. This is useful to people defining their own target.json to compare it against existing targets or understand how different targets change internal settings. It is also potentially useful for Cargo to determine if something has changed with a target and it needs to rebuild things.
2016-12-02rustc: add --print target-spec optionDoug Goldstein-0/+3
This option provides the user the ability to dump the configuration that is in use by rustc for the target they are building for. Signed-off-by: Doug Goldstein <cardoe@cardoe.com>
2016-12-02limit the length of types in monomorphizationAriel Ben-Yehuda-1/+1
This adds the new insta-stable `#![type_size_limit]` crate attribute to control the limit, and is obviously a [breaking-change] fixable by that.
2016-11-30Adds `-Z mir-stats`, which is similar to `-Z hir-stats`.Felix S. Klock II-1/+13
Some notes: * This code attempts to present the breakdown of each variant for every enum in the MIR. This is meant to guide decisions about how to revise representations e.g. when to box payloads for rare variants to shrink the size of the enum overall. * I left out the "Total:" line that hir-stats presents, because this implementation uses the MIR Visitor infrastructure, and the memory usage of structures directly embedded in other structures (e.g. the `func: Operand` in a `TerminatorKind:Call`) is not distinguished from similar structures allocated in a `Vec` (e.g. the `args: Vec<Operand>` in a `TerminatorKind::Call`). This means that a naive summation of all the accumulated sizes is misleading, because it will double-count the contribution of the `Operand` of the `func` as well as the size of the whole `TerminatorKind`. * I did consider abandoning the MIR Visitor and instead hand-coding a traversal that distinguished embedded storage from indirect storage. But such code would be fragile; better to just require people to take care when interpreting the presented results. * This traverses the `mir.promoted` rvalues to capture stats for MIR stored there, even though the MIR visitor super_mir method does not do so. (I did not observe any new mir being traversed when compiling the rustc crate, however.) * It might be nice to try to unify this code with hir-stats. Then again, the reporting portion is the only common code (I think), and it is small compared to the visitors in hir-stats and mir-stats.
2016-11-30Auto merge of #37800 - alexcrichton:new-bootstrap, r=eddybbors-2/+0
Update the bootstrap compiler Now that we've got a beta build, let's use it!
2016-11-30Update the bootstrap compilerAlex Crichton-2/+0
Now that we've got a beta build, let's use it!
2016-11-30Auto merge of #38014 - jseyfried:refactor_path_resolution, r=nrcbors-3/+0
resolve: refactor path resolution This is a pure refactoring, modulo minor diagnostics improvements. r? @nrc
2016-11-30rustc: track the Span's of definitions across crates.Eduard-Mihai Burtescu-5/+1
2016-11-29Add new #[target_feature = "..."] attribute.Andrew Gallant-1/+2
This commit adds a new attribute that instructs the compiler to emit target specific code for a single function. For example, the following function is permitted to use instructions that are part of SSE 4.2: #[target_feature = "+sse4.2"] fn foo() { ... } In particular, use of this attribute does not require setting the -C target-feature or -C target-cpu options on rustc. This attribute does not have any protections built into it. For example, nothing stops one from calling the above `foo` function on hosts without SSE 4.2 support. Doing so may result in a SIGILL. This commit also expands the target feature whitelist to include lzcnt, popcnt and sse4a. Namely, lzcnt and popcnt have their own CPUID bits, but were introduced with SSE4.
2016-11-29rustc_driver: fix compilationFlorian Diebold-2/+5
2016-11-29Remove `resolver.record_resolution()`.Jeffrey Seyfried-3/+0
2016-11-28rustc: rework stability to be on-demand for type-directed lookup.Eduard Burtescu-12/+9
2016-11-28rustc_typeck: save the type cache for rustdoc and save-analysis.Eduard Burtescu-45/+47
2016-11-28rustc: embed path resolutions into the HIR instead of keeping DefMap.Eduard-Mihai Burtescu-8/+4
2016-11-24Revisions from review comments, squashed.Felix S. Klock II-6/+0
Biggest change: Revised print-type-sizes output to include breakdown of layout. Includes info about field sizes (and alignment + padding when padding is injected; the injected padding is derived from the offsets computed by layout module). Output format is illustrated in commit that has the ui tests. Note: there exists (at least) one case of variant w/o name: empty enums. Namely, empty enums use anonymous univariant repr. So for such cases, print the number of the variant instead of the name. ---- Also, eddyb suggested of reading from `layout_cache` post-trans. (For casual readers: the compiler source often uses the word "cache" for tables that are in fact not periodically purged, and thus are useful as the basis for data like this.) Some types that were previously not printed are now included in the output. (See e.g. the tests `print_type_sizes/generics.rs` and `print_type_sizes/variants.rs`) ---- Other review feedback: switch to an exhaustive match when filtering in just structural types. switch to hashset for layout info and move sort into print method. ---- Driveby change: Factored session::code_stats into its own module ---- incorporate njn feedback re output formatting.
2016-11-24Add `-Z print-type-sizes`, a tool for digging into how variants are laid out.Felix S. Klock II-0/+10
2016-11-22Auto merge of #37681 - nrc:crate-metadata, r=@alexcrichtonbors-0/+3
add --crate-type metadata r? @alexcrichton
2016-11-21Implement the `loop_break_value` feature.Geoffry Song-1/+1
This implements RFC 1624, tracking issue #37339. - `FnCtxt` (in typeck) gets a stack of `LoopCtxt`s, which store the currently deduced type of that loop, the desired type, and a list of break expressions currently seen. `loop` loops get a fresh type variable as their initial type (this logic is stolen from that for arrays). `while` loops get `()`. - `break {expr}` looks up the broken loop, and unifies the type of `expr` with the type of the loop. - `break` with no expr unifies the loop's type with `()`. - When building MIR, `loop` loops no longer construct a `()` value at termination of the loop; rather, the `break` expression assigns the result of the loop. `while` loops are unchanged. - `break` respects contexts in which expressions may not end with braced blocks. That is, `while break { break-value } { while-body }` is illegal; this preserves backwards compatibility. - The RFC did not make it clear, but I chose to make `break ()` inside of a `while` loop illegal, just in case we wanted to do anything with that design space in the future. This is my first time dealing with this part of rustc so I'm sure there's plenty of problems to pick on here ^_^
2016-11-21Fix fallout in `rustdoc` and tests.Jeffrey Seyfried-4/+4
2016-11-21Remove `Rc` from the interner.Jeffrey Seyfried-8/+0
2016-11-21Use `Symbol` instead of `InternedString` in the AST, HIR, and various other ↵Jeffrey Seyfried-6/+5
places.