about summary refs log tree commit diff
path: root/src/librustc_metadata
AgeCommit message (Collapse)AuthorLines
2020-08-30mv compiler to compiler/mark-8210/+0
2020-08-30Auto merge of #75176 - jyn514:impl-link, r=GuillaumeGomez,petrochenkovbors-1/+10
Fix intra-doc links for cross-crate re-exports of default trait methods The original fix for this was very simple: https://github.com/rust-lang/rust/pull/58972 ignored `extern_traits` because before https://github.com/rust-lang/rust/issues/65983 was fixed, they would always fail to resolve, giving spurious warnings. So the first commit just undoes that change, so extern traits are now seen by the `collect_intra_doc_links` pass. There are also some minor changes in `librustdoc/fold.rs` to avoid borrowing the `extern_traits` RefCell more than once at a time. However, that brought up a much more thorny problem. `rustc_resolve` started giving 'error: cannot find a built-in macro with name `cfg`' when documenting `libproc_macro` (I still haven't been able to reproduce on anything smaller than the full standard library). The chain of events looked like this (thanks @eddyb for the help debugging!): 0. `x.py build --stage 1` builds the standard library and creates a sysroot 1. `cargo doc` does something like `cargo check` to create `rmeta`s for all the crates (unrelated to what was built above) 2. the `cargo check`-like `libcore-*.rmeta` is loaded as a transitive dependency *and claims ownership* of builtin macros 3. `rustdoc` later tries to resolve some path in a doc link 4. suggestion logic fires and loads "extern prelude" crates by name 5. the sysroot `libcore-*.rlib` is loaded and *fails to claim ownership* of builtin macros `rustc_resolve` gives the error after step 5. However, `rustdoc` doesn't need suggestions at all - `resolve_str_path_error` completely discards the `ResolutionError`! The fix implemented in this PR is to skip the suggestion logic for `resolve_ast_path`: pass `record_used: false` and skip `lookup_import_candidates` when `record_used` isn't set. It's possible that if/when https://github.com/rust-lang/rust/issues/74207 is implemented this will need a more in-depth fix which returns a `ResolutionError` from `compile_macro`, to allow rustdoc to reuse the suggestions from rustc_resolve. However, that's a much larger change and there's no need for it yet, so I haven't implemented it here. Fixes https://github.com/rust-lang/rust/issues/73829. r? @GuillaumeGomez
2020-08-30rustdoc,metadata: DebuggingJoshua Nelson-1/+10
2020-08-29Auto merge of #75754 - joshtriplett:wip-perf-snappy, r=Mark-Simulacrumbors-3/+3
Switch to Snappy compression for metadata
2020-08-26Auto merge of #75811 - ecstatic-morse:better-dlerror, r=nagisabors-34/+74
Refactor dynamic library error checking on *nix The old code was checking `dlerror` more often than necessary, since (unlike `dlsym`) checking the return value of [`dlopen`](https://www.man7.org/linux/man-pages/man3/dlopen.3.html) is enough to indicate whether an error occurred. In the first commit, I've refactored the code to minimize the number of system calls needed. It should be strictly better than the old version. The second commit is an optional addendum which fixes the issue observed on illumos in #74469, a PR I reviewed that was ultimately closed due to inactivity. I'm not sure how hard we try to work around platform-specific bugs like this, and I believe that, due to the way that `dlerror` is specified in the POSIX standard, libc implementations that want to run on conforming systems cannot call `dlsym` in multi-threaded programs.
2020-08-25Explicitly pass `RTLD_LOCAL` to `dlopen`Dylan MacKenzie-4/+4
This happens to be the default on Linux, but the default is unspecified in the POSIX standard. Also switches to `cast` to keep line lengths in check.
2020-08-25Always treat `dlsym` returning NULL as an errorDylan MacKenzie-31/+24
This simplifies the code somewhat. Also updates comments to reflect notes from reviw about thread-safety of `dlerror`.
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-22Treat a NULL return from `dlsym` as an error on illumosDylan MacKenzie-4/+24
This works around behavior observed on illumos in #74469, in which foreign code (libc according to the OP) was racing with rustc to check `dlerror`.
2020-08-22Refactor dynamic library error checking on *nixDylan MacKenzie-34/+61
The old code was checking `dlerror` more often than necessary, since the return value of `dlopen` indicates whether an error occurred.
2020-08-20Switch to Snappy compression for metadataJosh Triplett-3/+3
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.