summary refs log tree commit diff
path: root/compiler/rustc_metadata/src/rmeta/decoder.rs
AgeCommit message (Collapse)AuthorLines
2021-01-23Encode DefKind directly.Camille GILLOT-54/+24
2021-01-15Auto merge of #80602 - tgnottingham:cratemetadata_you_aint_special, ↵bors-33/+1
r=michaelwoerister Remove DepKind::CrateMetadata and pre-allocation of DepNodes Remove much of the special-case handling around crate metadata dependency tracking by replacing `DepKind::CrateMetadata` and the pre-allocation of corresponding `DepNodes` with on-demand invocation of the `crate_hash` query.
2021-01-13Auto merge of #77524 - Patryk27:fixes/66228, r=estebankbors-5/+9
Rework diagnostics for wrong number of generic args (fixes #66228 and #71924) This PR reworks the `wrong number of {} arguments` message, so that it provides more details and contextual hints.
2021-01-12Remove DepKind::CrateMetadata and pre-allocation of DepNodesTyson Nottingham-33/+1
Remove much of the special-case handling around crate metadata dependency tracking by replacing `DepKind::CrateMetadata` and the pre-allocation of corresponding `DepNodes` with on-demand invocation of the `crate_hash` query.
2021-01-12Auto merge of #78407 - oli-obk:ub_checkable_ctfe, r=RalfJung,pnkfelixbors-0/+15
Make CTFE able to check for UB... ... by not doing any optimizations on the `const fn` MIR used in CTFE. This means we duplicate all `const fn`'s MIR now, once for CTFE, once for runtime. This PR is for checking the perf effect, so we have some data when talking about https://github.com/rust-lang/const-eval/blob/master/rfcs/0000-const-ub.md To do this, we now have two queries for obtaining mir: `optimized_mir` and `mir_for_ctfe`. It is now illegal to invoke `optimized_mir` to obtain the MIR of a const/static item's initializer, an array length, an inline const expression or an enum discriminant initializer. For `const fn`, both `optimized_mir` and `mir_for_ctfe` work, the former returning the MIR that LLVM should use if the function is called at runtime. Similarly it is illegal to invoke `mir_for_ctfe` on regular functions. This is all checked via appropriate assertions and I don't think it is easy to get wrong, as there should be no `mir_for_ctfe` calls outside the const evaluator or metadata encoding. Almost all rustc devs should keep using `optimized_mir` (or `instance_mir` for that matter).
2021-01-10Rework diagnostics for wrong number of generic argsPatryk Wychowaniec-5/+9
2021-01-05Rollup merge of #80643 - LingMan:unwrap, r=oli-obkYuki Okushi-8/+7
Move variable into the only branch where it is relevant At the `if` branch `filter` (the `let` binding) is `None` iff `filter` (the parameter) was `None`. We can branch on the parameter, move the binding into the `if`, and the complexity of handling `Option<Option<_>` largely dissolves. `@rustbot` modify labels +C-cleanup +T-compiler Note: I have no idea how hot this code is. If this method frequently gets called with a `None` filter, there might be a small perf improvement.
2021-01-04Differentiate between the availability of ctfe MIR and runtime MIRoli-1/+4
2021-01-04Keep an unoptimized duplicate of `const fn` aroundoli-0/+12
This allows CTFE to reliably detect UB, as otherwise optimizations may hide UB.
2021-01-04Auto merge of #80610 - Aaron1011:unhash-def-path-hash, r=varkorbors-2/+3
Use `UnhashMap` whenever we have a key of `DefPathHash`
2021-01-03Move variable into condition where it's usedDániel Buga-1/+1
2021-01-03No need to collect result of get_item_attrsDániel Buga-3/+2
2021-01-03Clean up convoluted macros_only logicDániel Buga-13/+9
2021-01-03Move variable into the only branch where it is relevantLingMan-8/+7
At the `if` branch `filter` (the `let` binding) is `None` iff `filter` (the parameter) was `None`. We can branch on the parameter, move the binding into the `if`, and the complexity of handling `Option<Option<_>` largely dissolves.
2021-01-01Use `UnhashMap` whenever we have a key of `DefPathHash`Aaron Hill-2/+3
2020-12-08Account for gaps in def path table during decodingAaron Hill-3/+8
When encoding a proc-macro crate, there may be gaps in the table (since we only encode the crate root and proc-macro items). Account for this by checking if the entry is present, rather than using `unwrap()`
2020-12-03rustc_metadata: Remove some dead codeVadim Petrochenkov-17/+0
2020-12-01Auto merge of #74967 - Aaron1011:feature/incr-def-path-table, r=pnkfelixbors-0/+52
Implement lazy decoding of DefPathTable during incremental compilation PR https://github.com/rust-lang/rust/pull/75813 implemented lazy decoding of the `DefPathTable` from crate metadata. However, it requires decoding the entire `DefPathTable` when incremental compilation is active, so that we can map a decoded `DefPathHash` to a `DefId` from an arbitrary crate. This PR adds support for lazy decoding of dependency `DefPathTable`s when incremental compilation si active. When we load the incremental cache and dep graph, we need the ability to map a `DefPathHash` to a `DefId` in the current compilation session (if the corresponding definition still exists). This is accomplished by storing the old `DefId` (that is, the `DefId` from the previous compilation session) for each `DefPathHash` we need to remap. Since a `DefPathHash` includes the owning crate, the old crate is guaranteed to be the right one (if the definition still exists). We then use the old `DefIndex` as an initial guess, which we validate by comparing the expected and actual `DefPathHash`es. In most cases, foreign crates will be completely unchanged, which means that we our guess will be correct. If our guess is wrong, we fall back to decoding the entire `DefPathTable` for the foreign crate. This still represents an improvement over the status quo, since we can skip decoding the entire `DefPathTable` for other crates (where all of our guesses were correct).
2020-11-27Encode proc_macro directly.Camille GILLOT-62/+25
Encode proc_macro name directly. Do not store None values.
2020-11-25Lazy DefPath decoding for incremental compilationAaron Hill-0/+52
2020-11-18Improve error message when we try to get_type on something that does not ↵Hannah McLaughlin-1/+6
have a type
2020-11-13Eliminate some temporary vectors & Remove unnecessary mark_attr_usedDániel Buga-6/+11
2020-11-10Changed unwrap_or to unwrap_or_else in some places.Nicholas-Baron-8/+8
The discussion seems to have resolved that this lint is a bit "noisy" in that applying it in all places would result in a reduction in readability. A few of the trivial functions (like `Path::new`) are fine to leave outside of closures. The general rule seems to be that anything that is obviously an allocation (`Box`, `Vec`, `vec![]`) should be in a closure, even if it is a 0-sized allocation.
2020-10-27Cache foreign_modules queryRyan Levick-3/+5
2020-10-14Remove unused code from remaining compiler cratesest31-21/+0
2020-10-06Split bounds from predicatesMatthew Jasper-1/+14
2020-10-05Record `expansion_that_defined` into crate metadataAaron Hill-0/+4
Fixes #77523 Now that hygiene serialization is implemented, we also need to record `expansion_that_defined` so that we properly handle a foreign `SyntaxContext`.
2020-09-26Encode less metadata for proc-macro cratesAaron Hill-18/+38
Currently, we serialize the same crate metadata for proc-macro crates as we do for normal crates. This is quite wasteful - almost none of this metadata is ever used, and much of it can't even be deserialized (if it contains a foreign `CrateNum`). This PR changes metadata encoding to skip encoding the majority of crate metadata for proc-macro crates. Most of the `Lazy<[T]>` fields are left completetly empty, while the non-lazy fields are left as-is. Additionally, proc-macros now have a def span that does not include their body. This was done for normal functions in #75465, but was missed for proc-macros. As a result of this PR, we should only ever encode local `CrateNum`s when encoding proc-macro crates. I've added a specialized serialization impl for `CrateNum` to assert this.
2020-09-19wip emit errors during AbstractConst buildingBastian Kauschke-2/+3
2020-09-18support const_evaluatable_checked across crate boundariesBastian Kauschke-0/+19
2020-08-30mv compiler to compiler/mark-0/+1907