summary refs log tree commit diff
path: root/src/librustc_metadata/encoder.rs
AgeCommit message (Collapse)AuthorLines
2018-07-18Implement existential typesOliver Schneider-0/+5
2018-07-16ItemKindcsmoe-79/+79
2018-07-16ForeignItemKindcsmoe-5/+5
2018-07-16TyKindcsmoe-1/+1
2018-07-16ExprKindcsmoe-1/+1
2018-07-10Upgrade to LLVM's master branch (LLVM 7)Alex Crichton-12/+0
This commit upgrades the main LLVM submodule to LLVM's current master branch. The LLD submodule is updated in tandem as well as compiler-builtins. Along the way support was also added for LLVM 7's new features. This primarily includes the support for custom section concatenation natively in LLD so we now add wasm custom sections in LLVM IR rather than having custom support in rustc itself for doing so. Some other miscellaneous changes are: * We now pass `--gc-sections` to `wasm-ld` * The optimization level is now passed to `wasm-ld` * A `--stack-first` option is passed to LLD to have stack overflow always cause a trap instead of corrupting static data * The wasm target for LLVM switched to `wasm32-unknown-unknown`. * The syntax for aligned pointers has changed in LLVM IR and tests are updated to reflect this. * The `thumbv6m-none-eabi` target is disabled due to an [LLVM bug][llbug] Nowadays we've been mostly only upgrading whenever there's a major release of LLVM but enough changes have been happening on the wasm target that there's been growing motivation for quite some time now to upgrade out version of LLD. To upgrade LLD, however, we need to upgrade LLVM to avoid needing to build yet another version of LLVM on the builders. The revision of LLVM in use here is arbitrarily chosen. We will likely need to continue to update it over time if and when we discover bugs. Once LLVM 7 is fully released we can switch to that channel as well. [llbug]: https://bugs.llvm.org/show_bug.cgi?id=37382
2018-07-04Auto merge of #51895 - nikomatsakis:move-self-trait-predicate-to-items, ↵bors-0/+27
r=scalexm Move self trait predicate to items This is a "reimagination" of @tmandry's PR #50183. The main effect is described in this comment from one of the commits: --- Before we had the following results for `predicates_of`: ```rust trait Foo { // predicates_of: Self: Foo fn bar(); // predicates_of: Self: Foo (inherited from trait) } ``` Now we have removed the `Self: Foo` from the trait. However, we still add it to the trait ITEM. This is because when people do things like `<T as Foo>::bar()`, they still need to prove that `T: Foo`, and having it in the `predicates_of` seems to be the cleanest way to ensure that happens right now (otherwise, we'd need special case code in various places): ```rust trait Foo { // predicates_of: [] fn bar(); // predicates_of: Self: Foo } ``` However, we sometimes want to get the list of *just* the predicates truly defined on a trait item (e.g., for chalk, but also for a few other bits of code). For that, we define `predicates_defined_on`, which does not contain the `Self: Foo` predicate yet, and we plumb that through metadata and so forth. --- I'm assigning @eddyb as the main reviewer, but I thought I might delegate to scalexm for this one in any case. I also want to post an alternative that I'll leave in the comments; it occurred to me as I was writing. =) r? @eddyb cc @scalexm @tmandry @leodasvacas
2018-07-02introduce `predicates_defined_on` for traitsNiko Matsakis-0/+27
This new query returns only the predicates *directly defined* on an item (in contrast to the more common `predicates_of`, which returns the predicates that must be proven to reference an item). These two sets are almost always identical except for traits, where `predicates_of` includes an artificial `Self: Trait<...>` predicate (basically saying that you cannot use a trait item without proving that the trait is implemented for the type parameters). This new query is only used in chalk lowering, where this artificial `Self: Trait` predicate is problematic. We encode it in metadata but only where needed since it is kind of repetitive with existing information. Co-authored-by: Tyler Mandry <tmandry@gmail.com>
2018-07-01call it `hir::VisibilityKind` instead of `hir::Visibility_:*`Zack M. Davis-1/+1
It was pointed out in review that the glob-exported underscore-suffixed convention for `Spanned` HIR nodes is no longer preferred: see February 2016's #31487 for AST's migration away from this style towards properly namespaced NodeKind enums. This concerns #51968.
2018-06-30in which hir::Visibility recalls whence it came (i.e., becomes Spanned)Zack M. Davis-1/+3
There are at least a couple (and plausibly even three) diagnostics that could use the spans of visibility modifiers in order to be reliably correct (rather than hacking and munging surrounding spans to try to infer where the visibility keyword must have been). We follow the naming convention established by the other `Spanned` HIR nodes: the "outer" type alias gets the "prime" node-type name, the "inner" enum gets the name suffixed with an underscore, and the variant names are prefixed with the prime name and `pub use` exported from here (from HIR). Thanks to veteran reviewer Vadim Petrochenkov for suggesting this uniform approach. (A previous draft, based on the reasoning that `Visibility::Inherited` should not have a span, tried to hack in a named `span` field on `Visibility::Restricted` and a positional field on `Public` and `Crate`. This was ... not so uniform.)
2018-06-30Fortify dummy span checkingVadim Petrochenkov-2/+2
2018-06-28Use `Ident`s in a number of structures in HIRVadim Petrochenkov-7/+5
Namely: labels, type parameters, bindings in patterns, parameter names in functions without body. All of these do not need hygiene after lowering to HIR, only span locations.
2018-06-27Make opaque::Encoder append-only and make it infallibleJohn Kåre Alsaker-13/+11
2018-06-21async await desugaring and testsTaylor Cramer-1/+4
2018-06-21Parse async fn header.Without Boats-6/+6
This is gated on edition 2018 & the `async_await` feature gate. The parser will accept `async fn` and `async unsafe fn` as fn items. Along the same lines as `const fn`, only `async unsafe fn` is permitted, not `unsafe async fn`.The parser will not accept `async` functions as trait methods. To do a little code clean up, four fields of the function type struct have been merged into the new `FnHeader` struct: constness, asyncness, unsafety, and ABI. Also, a small bug in HIR printing is fixed: it previously printed `const unsafe fn` as `unsafe const fn`, which is grammatically incorrect.
2018-06-20Use ty::Generics instead of hir::Generics for various checksvarkor-2/+3
2018-06-20Refactor generic parameters in rustdoc/cleanvarkor-11/+8
2018-06-20Remove all traces of lifetimes() and types() methodsvarkor-6/+4
2018-06-20Remove specific parameter iterators from hir::Genericsvarkor-2/+7
2018-06-20Refactor hir::GenericParam as a structvarkor-4/+11
2018-06-07Add existential type definitonsOliver Schneider-26/+5
2018-05-23Auto merge of #50528 - whitfin:issue-50508, r=michaelwoeristerbors-2/+10
Remove attribute_cache from CrateMetadata This PR will fix #50508 by removing the `attribute_cache` from the `CrateMetadata` struct. Seeing as performance was referenced in the original issue, I also cleaned up a `self.entry(node_id);` call which might have occasionally happened redundantly. r? @michaelwoerister
2018-05-19rustc: introduce {ast,hir}::AnonConst to consolidate so-called "embedded ↵Eduard-Mihai Burtescu-8/+8
constants".
2018-05-18Serialize attributes into the CrateRootIsaac Whitfield-2/+10
2018-05-17Keep crate edition in metadataVadim Petrochenkov-1/+2
2018-05-17Rename trans to codegen everywhere.Irina Popa-4/+5
2018-05-15Rename `has_type_parameters` to `requires_monomorphization`varkor-1/+1
2018-05-15Reduce parent_params to parent_countvarkor-4/+3
2018-05-15Consolidate ty::Genericsvarkor-1/+1
2018-04-20Clean up `IsolatedEncoder::encode_info_for_impl_item()` a bitWesley Wiser-12/+13
2018-04-20Fix bad merge in #49991Wesley Wiser-1/+1
When I rebased #49991 on `master`, I messed up the merge for this line. I'm reverting this back to the way it was in f15e5c1.
2018-04-19Remove HIR inliningWesley Wiser-44/+59
Fixes #49690
2018-04-16Auto merge of #49433 - varkor:metadata-skip-mir-opt, r=michaelwoeristerbors-2/+9
Skip MIR encoding for cargo check Resolves #48662. r? @michaelwoerister
2018-04-14Get rid of redundant `HashSet`Oliver Schneider-13/+12
2018-04-14Encode items before encoding the list of AllocIdsOliver Schneider-10/+13
2018-04-14Use `LazySeq` instead of `Vec`Oliver Schneider-17/+22
2018-04-14Don't recurse into allocations, use a global table insteadOliver Schneider-22/+46
2018-04-12Auto merge of #49558 - Zoxc:sync-misc, r=michaelwoeristerbors-1/+1
Even more thread-safety changes r? @michaelwoerister
2018-04-10Make Session.has_global_allocator thread-safeJohn Kåre Alsaker-1/+1
2018-04-09Take OutputType::DepInfo into account for metadata_output_onlyvarkor-3/+2
2018-04-09Convert sort_unstable_by_key to sort_by_cached_keyvarkor-2/+2
2018-04-06Allow for representing exported monomorphizations in crate metadata.Michael Woerister-4/+8
2018-04-04Add len() method to OutputTypesvarkor-1/+1
2018-03-28Take the original extra-filename passed to a crate into account whenChris Manchester-0/+2
resolving it as a dependency. Fixes #46816
2018-03-27Skip MIR optimisation for cargo checkvarkor-3/+11
2018-03-22rustc: Add a `#[wasm_import_module]` attributeAlex Crichton-1/+11
This commit adds a new attribute to the Rust compiler specific to the wasm target (and no other targets). The `#[wasm_import_module]` attribute is used to specify the module that a name is imported from, and is used like so: #[wasm_import_module = "./foo.js"] extern { fn some_js_function(); } Here the import of the symbol `some_js_function` is tagged with the `./foo.js` module in the wasm output file. Wasm-the-format includes two fields on all imports, a module and a field. The field is the symbol name (`some_js_function` above) and the module has historically unconditionally been `"env"`. I'm not sure if this `"env"` convention has asm.js or LLVM roots, but regardless we'd like the ability to configure it! The proposed ES module integration with wasm (aka a wasm module is "just another ES module") requires that the import module of wasm imports is interpreted as an ES module import, meaning that you'll need to encode paths, NPM packages, etc. As a result, we'll need this to be something other than `"env"`! Unfortunately neither our version of LLVM nor LLD supports custom import modules (aka anything not `"env"`). My hope is that by the time LLVM 7 is released both will have support, but in the meantime this commit adds some primitive encoding/decoding of wasm files to the compiler. This way rustc postprocesses the wasm module that LLVM emits to ensure it's got all the imports we'd like to have in it. Eventually I'd ideally like to unconditionally require this attribute to be placed on all `extern { ... }` blocks. For now though it seemed prudent to add it as an unstable attribute, so for now it's not required (as that'd force usage of a feature gate). Hopefully it doesn't take too long to "stabilize" this! cc rust-lang-nursery/rust-wasm#29
2018-03-22rustc: Add a `#[wasm_custom_section]` attributeAlex Crichton-0/+12
This commit is an implementation of adding custom sections to wasm artifacts in rustc. The intention here is to expose the ability of the wasm binary format to contain custom sections with arbitrary user-defined data. Currently neither our version of LLVM nor LLD supports this so the implementation is currently custom to rustc itself. The implementation here is to attach a `#[wasm_custom_section = "foo"]` attribute to any `const` which has a type like `[u8; N]`. Other types of constants aren't supported yet but may be added one day! This should hopefully be enough to get off the ground with *some* custom section support. The current semantics are that any constant tagged with `#[wasm_custom_section]` section will be *appended* to the corresponding section in the final output wasm artifact (and this affects dependencies linked in as well, not just the final crate). This means that whatever is interpreting the contents must be able to interpret binary-concatenated sections (or each constant needs to be in its own custom section). To test this change the existing `run-make` test suite was moved to a `run-make-fulldeps` folder and a new `run-make` test suite was added which applies to all targets by default. This test suite currently only has one test which only runs for the wasm target (using a node.js script to use `WebAssembly` in JS to parse the wasm output).
2018-03-20Encode/decode extern statics in metadata and incremental cacheOliver Schneider-2/+2
2018-03-16Cleanup metadata and incremental cache processing of constantsOliver Schneider-24/+20
2018-03-08Hide the RefCell inside InterpretInternerOliver Schneider-3/+3
It was too easy to get this wrong