summary refs log tree commit diff
path: root/src/librustc_metadata
AgeCommit message (Collapse)AuthorLines
2020-08-22rustc_metadata: Move some code around to merge impls of `CrateMetadataRef`Vadim Petrochenkov-53/+51
2020-08-22Do not forget capacity when collecting def path hashesVadim Petrochenkov-7/+6
2020-08-22Lazy decoding of DefPathTable from crate metadata (non-incremental case)Aaron Hill-32/+73
2020-08-18Auto merge of #75635 - Aaron1011:fix/incr-fn-param-names, r=eddybbors-5/+1
Don't use `dep_graph.with_ignore` when encoding fn param names The call to `with_ignore` was added years ago, and should no longer be necessary with the modern incremental query infrastructure. I also removed a related FIXME comment for issue #38501, which was closed months ago.
2020-08-17Rollup merge of #75548 - dancrossnyc:master, r=tmandryTyler Mandry-4/+10
librustc_metadata::locator: Properly detect file type. Make sure to test file types against the non-canonicalized name to avoid detecting the wrong type. Some systems save build artifacts into associate file stores that do not preserve extensions, and then link to those using conventionally-named symbolic links, that are the arguments to `rustc` et al. If we canonicalize before testing the type, we resolve the symlink, the extension is lost and we might treat rlibs and rmetas as dylibs. The fix is to tntroduce a temporary to hold the canonicalized name, compare against the non-canonical name, and add a comment explaining what's going on for the would-be mainter who sees a potential cleanup. Signed-off-by: Dan Cross <dcross@google.com>
2020-08-17rust_ast::ast => rustc_astUjjwal Sharma-5/+5
2020-08-17librustc_metadata::locator: Properly detect file type.Dan Cross-4/+10
Make sure to test for file types against the non-canonicalized name to avoid detecting the wrong type. Some systems save build artifacts into associative file stores that do not preserve extensions, and then link to those using conventionally-named symbolic links that are the arguments to `rustc` et al. If we canonicalize before testing the type, we resolve the symlink, the extension is lost and we might treat rlibs and rmetas as dylibs. The fix is to introduce a temporary to hold the canonicalized name, compare against the non-canonical name, and add a comment explaining what's going on for the would-be maintainer who sees a potential cleanup. Signed-off-by: Dan Cross <dcross@google.com>
2020-08-16Don't use `dep_graph.with_ignore` when encoding fn param namesAaron Hill-5/+1
The call to `with_ignore` was added years ago, and should no longer be necessary with the modern incremental query infrastructure. I also removed a related FIXME comment for issue #38501, which was closed months ago.
2020-08-15replaced log with tracingGurpreet Singh-9/+9
2020-08-14Rollup merge of #75448 - lcnr:rn-as_local_hir_id, r=davidtwcoTyler Mandry-10/+10
merge `as_local_hir_id` with `local_def_id_to_hir_id` `as_local_hir_id` was defined as just calling `local_def_id_to_hir_id` and I think that having two different ways to call the same method is somewhat confusing. Don't really care about which of these 2 methods we want to keep. Does this require an MCP, considering that these methods are fairly frequently used?
2020-08-14Rework `rustc_serialize`Matthew Jasper-261/+227
- Move the type parameter from `encode` and `decode` methods to the trait. - Remove `UseSpecialized(En|De)codable` traits. - Remove blanket impls for references. - Add `RefDecodable` trait to allow deserializing to arena-allocated references safely. - Remove ability to (de)serialize HIR. - Create proc-macros `(Ty)?(En|De)codable` to help implement these new traits.
2020-08-13merge `as_local_hir_id` with `local_def_id_to_hir_id`Bastian Kauschke-10/+10
2020-08-09Auto merge of #75278 - cuviper:indexmap, r=Mark-Simulacrumbors-17/+5
Upgrade indexmap and use it more First this upgrades `indexmap` to 1.5.1, which is now based on `hashbrown::raw::RawTable`. This means it shares a lot of the same performance characteristics for insert, lookup, etc., while keeping items in insertion order. Then across various rustc crates, this replaces a lot of `Vec`+`HashMap` pairs with a single `IndexMap` or `IndexSet`. Closes #60608. r? @eddyb
2020-08-09rustc_metadata: use IndexSet in EncodeContextJosh Stone-17/+5
2020-08-09Auto merge of #75137 - Aaron1011:fix/hygiene-skip-expndata, r=petrochenkovbors-0/+4
Don't serialize ExpnData for foreign crates When we encode an ExpnId into the crate metadata, we write out the CrateNum of the crate that 'owns' the corresponding `ExpnData`, which is later used to decode the `ExpnData` from its owning crate. However, we current serialize the `ExpnData` for all `ExpnIds` that we serialize, even if the `ExpnData` was already serialized into a foreign crate. This commit skips encoding this kind of `ExpnData`, which should hopefully speed up metadata encoding and reduce the total metadata size.
2020-08-09Add comment about the lack of `ExpnData` serialization for proc-macro cratesAaron Hill-0/+4
2020-08-08Auto merge of #74932 - nnethercote:rm-ast-session-globals, r=petrochenkovbors-40/+59
Remove `librustc_ast` session globals By moving the data onto `Session`. r? @petrochenkov
2020-08-08Eliminate the `SessionGlobals` from `librustc_ast`.Nicholas Nethercote-39/+58
By moving `{known,used}_attrs` from `SessionGlobals` to `Session`. This means they are accessed via the `Session`, rather than via TLS. A few `Attr` methods and `librustc_ast` functions are now methods of `Session`. All of this required passing a `Session` to lots of functions that didn't already have one. Some of these functions also had arguments removed, because those arguments could be accessed directly via the `Session` argument. `contains_feature_attr()` was dead, and is removed. Some functions were moved from `librustc_ast` elsewhere because they now need to access `Session`, which isn't available in that crate. - `entry_point_type()` --> `librustc_builtin_macros` - `global_allocator_spans()` --> `librustc_metadata` - `is_proc_macro_attr()` --> `Session`
2020-08-08Remove some unnecessary uses of `Option`.Nicholas Nethercote-1/+1
These arguments are never `None`.
2020-08-07fix clippy::unnecessary_mut_passed: function arg is not required to be mutableMatthias Krüger-1/+1
2020-08-06Record query name when profiling "metadata_decode_entry"Aaron Hill-1/+1
2020-08-06Auto merge of #75008 - eddyb:rmeta-indexed-trait-impls, r=nikomatsakisbors-12/+23
rustc_metadata: track the simplified Self type for every trait impl. For the `traits_impls_of` query, we index the impls by `fast_reject::SimplifiedType` (a "shallow type"), which allows some simple cases like `impl Trait<..> for Foo<..>` to be efficiently iterated over, by e.g. `for_each_relevant_impl`. This PR encodes the `fast_reject::SimplifiedType` cross-crate to avoid needing to deserialize the `Self` type of every `impl` in order to simplify it - the simplification itself should be cheap, but the deserialization is less so. We could go further from here and make loading the list of impls lazy, for a given simplified `Self` type, but that would have more complicated implications for performance, and this PR doesn't do anything in that regard. r? @nikomatsakis cc @Mark-Simulacrum
2020-08-04metadata: skip empty polymorphization bitsetDavid Wood-2/+5
This commit skips encoding empty polymorphization results - while polymorphization is disabled, this should be every polymorphization result; but when polymorphization is re-enabled, this would help with non-generic functions and those which do use all their parameters (most functions). Signed-off-by: David Wood <david@davidtw.co>
2020-08-04mir: use `FiniteBitSet<u32>` in polymorphizationDavid Wood-2/+2
This commit changes polymorphization to return a `FiniteBitSet<u32>` rather than a `FiniteBitSet<u64>` because most functions do not use anywhere near sixty-four generic parameters so keeping a `u64` around is unnecessary in most cases. Signed-off-by: David Wood <david@davidtw.co>
2020-08-04rustc_ast: `(Nested)MetaItem::check_name` -> `has_name`Vadim Petrochenkov-4/+4
For consistency with `Attribute::has_name` which doesn't mark the attribute as used either. Replace all uses of `check_name` with `has_name` outside of rustc
2020-08-02Rollup merge of #75059 - shengsheng:typos, r=Dylan-DPCManish Goregaokar-1/+1
fix typos Fix common misspellings with https://en.wikipedia.org/wiki/Wikipedia:Lists_of_common_misspellings/For_machines
2020-08-03Rollup merge of #75054 - cjgillot:rename-depkind, r=petrochenkovYuki Okushi-24/+24
Rename rustc_middle::cstore::DepKind to CrateDepKind It is ambiguous with DepGraph's own DepKind.
2020-08-02fix typosliuzhenyu-1/+1
2020-08-02Rename rustc_middle::cstore::DepKind to DependencyKind.Camille GILLOT-24/+24
2020-08-01rustc_metadata: track the simplified Self type for every trait impl.Eduard-Mihai Burtescu-12/+23
2020-07-31Move from `log` to `tracing`Oliver Scherer-1/+1
2020-07-30Rollup merge of #74915 - alexcrichton:allow-failing-canonicalize, ↵Manish Goregaokar-20/+18
r=Mark-Simulacrum rustc: Ignore fs::canonicalize errors in metadata This commit updates the metadata location logic to ignore errors when calling `fs::canonicalize`. Canonicalization was added historically so multiple `-L` paths to the same directory don't print errors about multiple candidates (since rustc can deduplicate same-named paths), but canonicalization doesn't work on all filesystems. Cargo, for example, always uses this sort of fallback where it will opportunitistically try to canonicalize but fall back to using the input path if it otherwise doesn't work. If rustc is run on a filesystem that doesn't support canonicalization then the effect of this change will be that `-L` paths which logically point to the same directory will cause errors, but that's a rare enough occurrence it shouldn't cause much issue in practice. Otherwise rustc doesn't work at all today on those sorts of filesystem where canonicalization isn't supported!
2020-07-30rustc: Ignore fs::canonicalize errors in metadataAlex Crichton-20/+18
This commit updates the metadata location logic to ignore errors when calling `fs::canonicalize`. Canonicalization was added historically so multiple `-L` paths to the same directory don't print errors about multiple candidates (since rustc can deduplicate same-named paths), but canonicalization doesn't work on all filesystems. Cargo, for example, always uses this sort of fallback where it will opportunitistically try to canonicalize but fall back to using the input path if it otherwise doesn't work. If rustc is run on a filesystem that doesn't support canonicalization then the effect of this change will be that `-L` paths which logically point to the same directory will cause errors, but that's a rare enough occurrence it shouldn't cause much issue in practice. Otherwise rustc doesn't work at all today on those sorts of filesystem where canonicalization isn't supported!
2020-07-30Auto merge of #74876 - oli-obk:lumberjack_disable, r=RalfJungbors-22/+33
Replace all uses of `log::log_enabled` with `Debug` printers cc @RalfJung this touches a bunch of logging in the miri engine. There are some visual changes, mainly that in several cases we stop prepending lines with the module path and just have a newline.
2020-07-29Address review commentsOliver Scherer-5/+3
2020-07-28Cache non-exhaustive separately from attributesMark Rousskov-4/+9
2020-07-28Replace all uses of `log::log_enabled` with `Debug` printersOliver Scherer-22/+35
2020-07-27mv std libs to library/mark-1/+33
2020-07-26Share serialization optimization between incr and metadataAaron Hill-114/+54
2020-07-26Add test for serializing hygiene *into* a proc-macro crateAaron Hill-4/+27
This is a very obscure corner case, and should never be hit in practice.
2020-07-26Hygiene serialization implementationAaron Hill-37/+250
2020-07-22build: Remove unnecessary `cargo:rerun-if-env-changed` annotationsVadim Petrochenkov-5/+0
2020-07-20index: introduce and use `FiniteBitSet`David Wood-3/+3
This commit introduces a `FiniteBitSet` type which replaces the manual bit manipulation which was being performed in polymorphization. Signed-off-by: David Wood <david@davidtw.co>
2020-07-20metadata: record `unused_generic_params`David Wood-0/+14
This commit records the results of `unused_generic_params` in crate metadata, hopefully improving performance. Signed-off-by: David Wood <david@davidtw.co>
2020-07-18rustc_metadata: Make crate loading fully speculativeVadim Petrochenkov-421/+435
2020-07-18rustc_metadata: Refactor away `CrateLocator::(dy,static)libname`Vadim Petrochenkov-27/+19
2020-07-18rustc_metadata: Remove some extra diagnostics for legacy pluginsVadim Petrochenkov-31/+2
They are deprecated so doing extra work for error recovery doesn't make sense
2020-07-18rustc_metadata: Remove a bit of ancient profilingVadim Petrochenkov-15/+1
2020-07-17Rename TypeckTables to TypeckResults.Valentin Lazureanu-2/+2
2020-07-15Auto merge of #74113 - lcnr:type-dependent-consts-2, r=eddybbors-2/+2
Support const args in type dependent paths (Take 2) once more, except it is sound this time :smiling_face_with_three_hearts: previously #71154 ----- ```rust #![feature(const_generics)] struct A; impl A { fn foo<const N: usize>(&self) -> usize { N } } struct B; impl B { fn foo<const N: usize>(&self) -> usize { 42 } } fn main() { let a = A; a.foo::<7>(); } ``` When calling `type_of` for generic const arguments, we now use the `TypeckTables` of the surrounding body to get the expected type. This alone causes cycle errors though, as we now have `typeck_tables_of(main)` -> `...` -> `type_of(main_ANON0 := 7)` -> `typeck_tables_of(main)` :zap: (see https://github.com/rust-lang/rust/issues/68400#issuecomment-611760290) To prevent this we must not call `type_of(const_arg)` during `typeck_tables_of`. This is achieved by calling `type_of(param_def_id)` instead. We have to somehow remember the `DefId` of the param through all of typeck, which is done using the struct `ty::WithOptConstParam<DefId>`, which replaces `DefId` where needed and contains an `Option<DefId>` to be able to store the const parameter in case it exists. Queries which are currently cached on disk are split into two variants: `query_name`(cached) and `query_name_(of|for)_const_arg`(not cached), with `query_name_of_const_arg` taking a pair `(did, param_did): (LocalDefId, DefId)`. For some queries a method `query_name_of_opt_const_arg` is added to `TyCtxt` which takes a `ty::WithOptConstParam` and either calls `query_name` or `query_name_of_const_arg` depending on the value of `const_param_did`. r? @eddyb @varkor