about summary refs log tree commit diff
path: root/src/librustc_metadata
AgeCommit message (Collapse)AuthorLines
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
2020-07-15const generics work!Bastian Kauschke-1/+1
2020-07-15optimized_mirBastian Kauschke-1/+1
2020-07-15Change `SymbolName::name` to a `&str`.Nicholas Nethercote-3/+3
This eliminates a bunch of `Symbol::intern()` and `Symbol::as_str()` calls, which is good, because they require locking the interner. Note that the unsafety in `from_cycle_error()` is identical to the unsafety on other adjacent impls.
2020-07-15Remove lots of `Symbol::as_str()` calls.Nicholas Nethercote-5/+5
In various ways, such as changing functions to take a `Symbol` instead of a `&str`.
2020-07-15Add and use more static symbols.Nicholas Nethercote-3/+3
Note that the output of `unpretty-debug.stdout` has changed. In that test the hash values are normalized from a symbol numbers to small numbers like "0#0" and "0#1". The increase in the number of static symbols must have caused the original numbers to contain more digits, resulting in different pretty-printing prior to normalization.
2020-07-10Avoid "whitelist"Tamir Duberstein-3/+0
Other terms are more inclusive and precise.
2020-07-05Use for<'tcx> fn pointers in Providers, instead of having Providers<'tcx>.Eduard-Mihai Burtescu-2/+2
2020-07-05Replace early-bound normalization hack with per-query key/value type aliases.Eduard-Mihai Burtescu-6/+3
2020-07-01Rollup merge of #73449 - ehuss:duplicate-lang-item, r=matthewjasperManish Goregaokar-0/+2
Provide more information on duplicate lang item error. This gives some notes on the location of the files where the lang items were loaded from. Some duplicate lang item errors can be a little confusing, and this might help in diagnosing what has happened. Here's an example when hitting a bug with Cargo's build-std: ``` error: duplicate lang item in crate `core` (which `rustc_std_workspace_core` depends on): `try`. | = note: the lang item is first defined in crate `core` (which `z10` depends on) = note: first definition in `core` loaded from /Users/eric/Proj/rust/cargo/scratch/z10/target/target/debug/deps/libcore-a764da499c7385f4.rmeta = note: second definition in `core` loaded from /Users/eric/Proj/rust/cargo/scratch/z10/target/target/debug/deps/libcore-5b082675aea34986.rmeta ```
2020-06-30Switch crate_extern_paths to a query, and tweak wording.Eric Huss-5/+2
2020-06-30Provide more information on duplicate lang item error.Eric Huss-0/+5
2020-06-29Serialize all foreign `SourceFile`s into proc-macro crate metadataAaron Hill-37/+94
Normally, we encode a `Span` that references a foreign `SourceFile` by encoding information about the foreign crate. When we decode this `Span`, we lookup the foreign crate in order to decode the `SourceFile`. However, this approach does not work for proc-macro crates. When we load a proc-macro crate, we do not deserialzie any of its dependencies (since a proc-macro crate can only export proc-macros). This means that we cannot serialize a reference to an upstream crate, since the associated metadata will not be available when we try to deserialize it. This commit modifies foreign span handling so that we treat all foreign `SourceFile`s as local `SourceFile`s when serializing a proc-macro. All `SourceFile`s will be stored into the metadata of a proc-macro crate, allowing us to cotinue to deserialize a proc-macro crate without needing to load any of its dependencies. Since the number of foreign `SourceFile`s that we load during a compilation session may be very large, we only serialize a `SourceFile` if we have also serialized a `Span` which requires it.
2020-06-26Make `fn_arg_names` return `Ident` instead of symbolAaron Hill-15/+9
Also, implement this query for the local crate, not just foreign crates.
2020-06-23Rollup merge of #73587 - marmeladema:hir-id-ification-final, r=petrochenkovManish Goregaokar-2/+2
Move remaining `NodeId` APIs from `Definitions` to `Resolver` Implements https://github.com/rust-lang/rust/pull/73291#issuecomment-643515557 TL;DR: it moves all fields that are only needed during name resolution passes into the `Resolver` and keep the rest in `Definitions`. This effectively enforces that all references to `NodeId`s are gone once HIR lowering is completed. After this, the only remaining work for #50928 should be to adjust the dev guide. r? @petrochenkov
2020-06-23Rollup merge of #73488 - richkadel:llvm-coverage-map-gen, r=tmandryManish Goregaokar-0/+2
code coverage foundation for hash and num_counters This PR is the next iteration after PR #73011 (which is still waiting on bors to merge). @wesleywiser - PTAL r? @tmandry (FYI, I'm also working on injecting the coverage maps, in another branch, while waiting for these to merge.) Thanks!
2020-06-22Address remaining feedback itemsRich Kadel-1/+1
2020-06-22Revert "Rollup merge of #72389 - Aaron1011:feature/move-fn-self-msg, ↵Aaron Hill-9/+15
r=nikomatsakis" This reverts commit 372cb9b69c76a042d0b9d4b48ff6084f64c84a2c, reversing changes made to 5c61a8dc34c3e2fc6d7f02cb288c350f0233f944.
2020-06-21Move remaining `NodeId` APIs from `Definitions` to `Resolver`marmeladema-2/+2
2020-06-21Cache decoded predicate shorthandsMatthew Jasper-18/+34
2020-06-20Rollup merge of #72600 - Aaron1011:fix/anon-const-encoding, r=varkorRalf Jung-3/+8
Properly encode AnonConst into crate metadata Fixes #68104 Previous, we were encoding AnonConst as a regular Const, causing us to treat them differently after being deserialized in another compilation session.
2020-06-19code coverage foundation for hash and num_countersRich Kadel-0/+2
Replaced dummy values for hash and num_counters with computed values, and refactored InstrumentCoverage pass to simplify injecting more counters per function in upcoming versions. Improved usage documentation and error messaging.
2020-06-19Rollup merge of #73011 - richkadel:llvm-count-from-mir-pass, r=tmandryRalf Jung-1/+3
first stage of implementing LLVM code coverage This PR replaces #70680 (WIP toward LLVM Code Coverage for Rust) since I am re-implementing the Rust LLVM code coverage feature in a different part of the compiler (in MIR pass(es) vs AST). This PR updates rustc with `-Zinstrument-coverage` option that injects the llvm intrinsic `instrprof.increment()` for code generation. This initial version only injects counters at the top of each function, and does not yet implement the required coverage map. Upcoming PRs will add the coverage map, and add more counters and/or counter expressions for each conditional code branch. Rust compiler MCP https://github.com/rust-lang/compiler-team/issues/278 Relevant issue: #34701 - Implement support for LLVMs code coverage instrumentation ***[I put together some development notes here, under a separate branch.](https://github.com/richkadel/rust/blob/cfa0b21d34ee64e4ebee226101bd2ef0c6757865/src/test/codegen/coverage-experiments/README-THIS-IS-TEMPORARY.md)***
2020-06-19Rollup merge of #73305 - crlf0710:disallow_loading_monsters, r=petrochenkovRalf Jung-0/+8
Disallow loading crates with non-ascii identifier name. This turns off external crate loading with non-ascii identifier names. cc #55467.
2020-06-16Ensure profiling runtime for -Zinstrument-coverageRich Kadel-1/+3
If config.toml `profiler = false`, the test/mir-opt/instrument_coverage test is ignored. Otherwise, this patch ensures the profiler_runtime is loaded when -Zinstrument-coverage is enabled. Confirmed that this works for MacOS.
2020-06-16Disallow loading crates with non-ascii identifier name.Charles Lew-0/+8
2020-06-15Auto merge of #73369 - RalfJung:rollup-hl8g9zf, r=RalfJungbors-19/+35
Rollup of 10 pull requests Successful merges: - #72707 (Use min_specialization in the remaining rustc crates) - #72740 (On recursive ADT, provide indirection structured suggestion) - #72879 (Miri: avoid tracking current location three times) - #72938 (Stabilize Option::zip) - #73086 (Rename "cyclone" to "apple-a7" per changes in upstream LLVM) - #73104 (Example about explicit mutex dropping) - #73139 (Add methods to go from a nul-terminated Vec<u8> to a CString) - #73296 (Remove vestigial CI job msvc-aux.) - #73304 (Revert heterogeneous SocketAddr PartialEq impls) - #73331 (extend network support for HermitCore) Failed merges: r? @ghost
2020-06-15Rollup merge of #72707 - matthewjasper:rustc_min_spec, r=oli-obkRalf Jung-19/+35
Use min_specialization in the remaining rustc crates This adds a lot of `transmute` calls to replace the unsound uses of specialization. It's ugly, but at least it's honest about what's going on. cc #71420, @RalfJung
2020-06-15Auto merge of #73367 - RalfJung:rollup-4ewvk9b, r=RalfJungbors-15/+9
Rollup of 10 pull requests Successful merges: - #71824 (Check for live drops in constants after drop elaboration) - #72389 (Explain move errors that occur due to method calls involving `self`) - #72556 (Fix trait alias inherent impl resolution) - #72584 (Stabilize vec::Drain::as_slice) - #72598 (Display information about captured variable in `FnMut` error) - #73336 (Group `Pattern::strip_*` method together) - #73341 (_match.rs: fix module doc comment) - #73342 (Fix iterator copied() documentation example code) - #73351 (Update E0446.md) - #73353 (structural_match: non-structural-match ty closures) Failed merges: r? @ghost
2020-06-15Rollup merge of #72389 - Aaron1011:feature/move-fn-self-msg, r=nikomatsakisRalf Jung-15/+9
Explain move errors that occur due to method calls involving `self` When calling a method that takes `self` (e.g. `vec.into_iter()`), the method receiver is moved out of. If the method receiver is used again, a move error will be emitted:: ```rust fn main() { let a = vec![true]; a.into_iter(); a; } ``` emits ``` error[E0382]: use of moved value: `a` --> src/main.rs:4:5 | 2 | let a = vec![true]; | - move occurs because `a` has type `std::vec::Vec<bool>`, which does not implement the `Copy` trait 3 | a.into_iter(); | - value moved here 4 | a; | ^ value used here after move ``` However, the error message doesn't make it clear that the move is caused by the call to `into_iter`. This PR adds additional messages to move errors when the move is caused by using a value as the receiver of a `self` method:: ``` error[E0382]: use of moved value: `a` --> vec.rs:4:5 | 2 | let a = vec![true]; | - move occurs because `a` has type `std::vec::Vec<bool>`, which does not implement the `Copy` trait 3 | a.into_iter(); | ------------- value moved due to this method call 4 | a; | ^ value used here after move | note: this function takes `self`, which moves the receiver --> /home/aaron/repos/rust/src/libcore/iter/traits/collect.rs:239:5 | 239 | fn into_iter(self) -> Self::IntoIter; ``` TODO: - [x] Add special handling for `FnOnce/FnMut/Fn` - we probably don't want to point at the unstable trait methods - [x] Consider adding additional context for operations (e.g. `Shr::shr`) when the call was generated using the operator syntax (e.g. `a >> b`) - [x] Consider pointing to the method parent (impl or trait block) in addition to the method itself.
2020-06-15Auto merge of #72080 - matthewjasper:uniform-impl-trait, r=nikomatsakisbors-8/+2
Clean up type alias impl trait implementation - Removes special case for top-level impl trait - Removes associated opaque types - Forbid lifetime elision in let position impl trait. This is consistent with the behavior for inferred types. - Handle lifetimes in type alias impl trait more uniformly with other parameters cc #69323 cc #63063 Closes #57188 Closes #62988 Closes #69136 Closes #73061
2020-06-11Make `fn_arg_names` return `Ident` instead of symbolAaron Hill-15/+9
Also, implement this query for the local crate, not just foreign crates.
2020-06-11Remove associated opaque typesMatthew Jasper-8/+2
They're unused now.
2020-06-10Use min_specialization in the remaining rustc cratesMatthew Jasper-19/+35
2020-06-10Migrate to numeric associated constsLzu Tao-1/+1
2020-06-07Use `LocalDefId` directly in `Resolver::export_map` and `module_exports` querymarmeladema-2/+11
This is to avoid the final conversion from `NodeId` to `HirId` during call to `Resolver::(clone|into)_outputs`.
2020-06-06Auto merge of #72927 - petrochenkov:rustc, r=Mark-Simulacrumbors-1/+1
Rename all remaining compiler crates to use the `rustc_foo` pattern libarena -> librustc_arena libfmt_macros -> librustc_parse_format libgraphviz -> librustc_graphviz libserialize -> librustc_serialize Closes https://github.com/rust-lang/rust/issues/71177 in particular.
2020-06-02Make things build againVadim Petrochenkov-1/+1
2020-06-01Don't count pathless --extern options for unused-crate-dependencies warningsJeremy Fitzhardinge-2/+6
`--extern proc_macro` is used to add the proc_macro crate to the extern prelude for all procmacros. In general pathless `--extern` only references sysroot/standard libraries and so should be exempt from unused-crate-dependencies warnings.
2020-05-29Use the virtual name for libstd files in StableSourceFileId and also in theFelix S. Klock II-1/+1
encoded build artifacts. Fix #70924.
2020-05-29Split payload of FileName::Real to track both real and virutalized paths.Felix S. Klock II-9/+17
Such splits arise from metadata refs into libstd. This way, we can (in a follow on commit) continue to emit the virtual name into things like the like the StableSourceFileId that ends up in incremetnal build artifacts, while still using the devirtualized file path when we want to access the file. Note that this commit is intended to be a refactoring; the actual fix to the bug in question is in a follow-on commit.