summary refs log tree commit diff
path: root/src/librustc_metadata/decoder.rs
AgeCommit message (Collapse)AuthorLines
2018-10-02Use full name to identify a macro in a `FileName`.Diogo Sousa-2/+2
Before this two macros with same name would be indistinguishable inside a `FileName`. This caused a bug in incremental compilation (see #53097) since two different macros would map out to the same `StableFilemapId`. Fixes #53097.
2018-09-22avoid leaking host details in proc macro metadata decodingAriel Ben-Yehuda-18/+53
proc macro crates are essentially implemented as dynamic libraries using a dlopen-based ABI. They are also Rust crates, so they have 2 worlds - the "host" world in which they are defined, and the "target" world in which they are used. For all the "target" world knows, the proc macro crate might not even be implemented in Rust, so leaks of details from the host to the target must be avoided for correctness. Because the "host" DefId space is different from the "target" DefId space, any leak involving a DefId will have a nonsensical or out-of-bounds DefKey, and will cause all sorts of crashes. This PR fixes all leaks I have found in `decoder`. In particular, #54059 was caused by host native libraries leaking into the target, which feels like it might even be a correctness issue if it doesn't cause an ICE. Fixes #54059
2018-09-06Auto merge of #53721 - arielb1:exhaustively-unpun, r=nikomatsakisbors-10/+18
fix `is_non_exhaustive` confusion between structs and enums Structs and enums can both be non-exhaustive, with a very different meaning. This PR splits `is_non_exhaustive` to 2 separate functions - 1 for structs, and another for enums, and fixes the places that got the usage confused. Fixes #53549. r? @eddyb
2018-09-01move the is_field_list_non_exhaustive flag to VariantDefAriel Ben-Yehuda-10/+18
This completely splits the IS_NON_EXHAUSTIVE flag. No functional changes intended.
2018-08-26create a valid DefIdTable for proc macro cratesAriel Ben-Yehuda-22/+45
At least the incremental compilation code, and a few other places in the compiler, require the CrateMetadata for a loaded target crate to contain a valid DefIdTable for the DefIds in the target. Previously, the CrateMetadata for a proc macro contained the crate's "host" DefIdTable, which is of course incompatible with the "target" DefIdTable, causing ICEs. This creates a DefIdTable that properly refers to the "proc macro" DefIds. Fixes #49482.
2018-08-22Replace TyForeign with ForeignTyvarkor-1/+1
2018-08-22Rename Def::{Param, Foreign} to Def::{TyParam, TyForeign}varkor-1/+1
2018-08-22Remove Ty prefix from Ty{Foreign|Param}varkor-1/+1
2018-08-19fix tidy errorsDonato Sciarra-2/+4
2018-08-19mv codemap source_mapDonato Sciarra-19/+19
2018-08-19mv codemap() source_map()Donato Sciarra-1/+1
2018-08-19mv (mod) codemap source_mapDonato Sciarra-2/+2
2018-08-19mv filemap source_fileDonato Sciarra-32/+32
2018-08-19mv FileMap SourceFileDonato Sciarra-11/+11
2018-08-19mv CodeMap SourceMapDonato Sciarra-2/+2
2018-08-09Move Fingerprint to data structuresMark Rousskov-1/+1
2018-08-07Rollup merge of #52886 - petrochenkov:noga, r=alexcrichtonkennytm-1/+1
cleanup: Remove `Def::GlobalAsm` Global asm is not something that needs to have a `Def` or `DefId`.
2018-08-05Improve query efficiencyvarkor-4/+2
2018-08-05Fix incremental testsvarkor-2/+4
2018-08-05Add lint for unknown feature attributesvarkor-0/+8
2018-08-04cleanup: Remove `Def::GlobalAsm`Vadim Petrochenkov-1/+1
2018-07-18Implement existential typesOliver Schneider-0/+1
2018-07-11Deny bare trait objects in in src/librustc_metadataljedrz-1/+1
2018-07-10Upgrade to LLVM's master branch (LLVM 7)Alex Crichton-10/+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-02introduce `predicates_defined_on` for traitsNiko Matsakis-0/+7
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-06-28Auto merge of #50997 - michaelwoerister:pre-analyze-filemaps, r=Mark-Simulacrumbors-6/+3
Make FileMap::{lines, multibyte_chars, non_narrow_chars} non-mutable. This PR removes most of the interior mutability from `FileMap`, which should be beneficial, especially in a multithreaded setting. This is achieved by initializing the state in question when the filemap is constructed instead of during lexing. Hopefully this doesn't degrade performance. cc @wesleywiser
2018-06-28Use `Ident`s for associated item definitions in HIRVadim Petrochenkov-1/+1
Remove emulation of hygiene with gensyms
2018-06-27Make FileMap::{lines, multibyte_chars, non_narrow_chars} non-mutable.Michael Woerister-6/+3
2018-06-07Add existential type definitonsOliver Schneider-0/+1
2018-06-03Remove is_import fieldMark Simulacrum-6/+3
2018-06-01Make metadata decoding use AllocDecodingState/Session.Michael Woerister-34/+10
2018-05-26Use `Ident`s for fields in HIRVadim Petrochenkov-1/+1
2018-05-18Serialize attributes into the CrateRootIsaac Whitfield-10/+6
2018-05-18Remove attribute_cache from CrateMetadataIsaac Whitfield-20/+8
2018-05-08Don't use Lock for heavily accessed CrateMetadata::cnum_map.Michael Woerister-3/+3
2018-04-29Auto merge of #50271 - sinkuu:fix_ice, r=eddybbors-1/+7
Fix ICE #48984 * ~~fbf6423 The tail type was not normalized.~~ * https://github.com/rust-lang/rust/commit/d0839d5680d2a51785eeb0811cf3e2beba90eacb The method had a wrong assumption that something whose parent is a trait is an associated item. Fixes #48984.
2018-04-28Make `trait_of_item` return None for non associated itemsShotaro Yamada-1/+7
It have returned `Some` for constants in a trait definition, and `Instance::resolve` called `tcx.associated_item` for them, causing ICE.
2018-04-27Rename InternedString to LocalInternedString and introduce a new thread-safe ↵John Kåre Alsaker-8/+8
InternedString
2018-04-19Remove HIR inliningWesley Wiser-56/+20
Fixes #49690
2018-04-14Reduce the number of calls to `cdata`Oliver Schneider-2/+2
2018-04-14Use `LazySeq` instead of `Vec`Oliver Schneider-5/+17
2018-04-14Don't recurse into allocations, use a global table insteadOliver Schneider-31/+18
2018-04-10Auto merge of #49386 - GuillaumeGomez:fix-path-attribute, r=eddybbors-3/+6
Add tcx in item_body_nested_bodies Fixes #47391. r? @eddyb
2018-04-06Allow for representing exported monomorphizations in crate metadata.Michael Woerister-5/+7
2018-03-26Fix path attribute in rustdocGuillaume Gomez-3/+6
2018-03-25Rollup merge of #49273 - michaelwoerister:fix-extern-proc-macro-defkey, r=eddybkennytm-2/+19
Fix DefKey lookup for proc-macro crates. Add a special case for proc-macro crates for `def_key()` in the metadata decoder (like we already have for many other methods in there). In the long run, it would be preferable to get rid of the need for special casing proc-macro crates (see #49271). Fixes https://github.com/rust-lang/rust/issues/48739 (though I wasn't able to come up with a regression test, unfortunately) r? @eddyb
2018-03-22rustc: Add a `#[wasm_import_module]` attributeAlex Crichton-5/+5
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/+10
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-22Fix DefKey lookup for proc-macro crates.Michael Woerister-2/+19
2018-03-21work around fallout from these changes in rustcNiko Matsakis-1/+5