about summary refs log tree commit diff
path: root/compiler/rustc_metadata/src/rmeta
AgeCommit message (Collapse)AuthorLines
2023-12-24Remove `Session` methods that duplicate `DiagCtxt` methods.Nicholas Nethercote-3/+3
Also add some `dcx` methods to types that wrap `TyCtxt`, for easier access.
2023-12-23Remove metadata decoding DefPathHash cacheMark Rousskov-22/+8
This cache is largely useless. Decoding a DefPathHash from metadata is essentially a pair of memory loads - there's no heavyweight processing involved. Caching it behind a HashMap just adds extra cost and incurs hashing overheads.
2023-12-23Specialize DefPathHash table to skip crate IDsMark Rousskov-29/+19
Instead, we store just the local crate hash as a bare u64. On decoding, we recombine it with the crate's stable crate ID stored separately in metadata. The end result is that we save ~8 bytes/DefIndex in metadata size. One key detail here is that we no longer distinguish in encoded metadata between present and non-present DefPathHashes. It used to be highly likely we could distinguish as we used DefPathHash::default(), an all-zero representation. However in theory even that is fallible as nothing strictly prevents the StableCrateId from being zero.
2023-12-23Auto merge of #119225 - Mark-Simulacrum:remove-option, r=compiler-errorsbors-3/+3
Avoid redundant Option for cross_crate_inlinable
2023-12-22Split coroutine desugaring kind from sourceMichael Goulet-10/+10
2023-12-22Improve coding efficiency for RawDefIdMark Rousskov-23/+36
This copies the scheme already used for LazyArray, cutting a couple hundred kilobytes from libcore's metadata.
2023-12-22Avoid redundant Option for cross_crate_inlinableMark Rousskov-3/+3
2023-12-21Encode CoroutineKind directlyMichael Goulet-4/+19
2023-12-19Unify SourceFile::name_hash and StableSourceFileIdMichael Woerister-23/+25
2023-12-18Replace some instances of FxHashMap/FxHashSet with stable alternatives ↵Michael Woerister-2/+2
(mostly in rustc_hir and rustc_ast_lowering) Part of https://github.com/rust-lang/compiler-team/issues/533
2023-12-12Move some methods from `tcx.hir()` to `tcx`zetanumbers-3/+3
Renamings: - find -> opt_hir_node - get -> hir_node - find_by_def_id -> opt_hir_node_by_def_id - get_by_def_id -> hir_node_by_def_id Fix rebase changes using removed methods Use `tcx.hir_node_by_def_id()` whenever possible in compiler Fix clippy errors Fix compiler Apply suggestions from code review Co-authored-by: Vadim Petrochenkov <vadim.petrochenkov@gmail.com> Add FIXME for `tcx.hir()` returned type about its removal Simplify with with `tcx.hir_node_by_def_id`
2023-12-11Auto merge of #118344 - saethlin:rmeta-header-pos, r=WaffleLapkinbors-18/+15
Use a u64 for the rmeta root position Waffle noticed this in https://github.com/rust-lang/rust/pull/117301#discussion_r1405410174 We've upgraded the other file offsets to u64, and this one only costs 4 bytes per file. Also the way the truncation was being done before was extremely easy to miss, I sure missed it! It's not clear to me if not having this change effectively made the other upgrades from u32 to u64 ineffective, but we can have it now. r? `@WaffleLapkin`
2023-12-10Apply suggestions from code reviewBen Kimock-2/+1
Co-authored-by: Waffle Maybe <waffle.lapkin@gmail.com>
2023-12-10remove redundant importssurechen-47/+18
detects redundant imports that can be eliminated. for #117772 : In order to facilitate review and modification, split the checking code and removing redundant imports code into two PR.
2023-11-30Change prefetch to avoid deadlockAndreas Jonson-16/+7
2023-11-28Use a u64 for the rmeta root positionBen Kimock-17/+15
2023-11-26Auto merge of #118319 - GuillaumeGomez:rollup-vte50yq, r=GuillaumeGomezbors-22/+11
Rollup of 4 pull requests Successful merges: - #118296 (rustdoc: replace `elemIsInParent` with `Node.contains`) - #118302 (Clean dead codes) - #118311 (merge `DefKind::Coroutine` into `Defkind::Closure`) - #118318 (Remove myself from users on vacation) r? `@ghost` `@rustbot` modify labels: rollup
2023-11-26Rollup merge of #118311 - bvanjoi:merge_coroutinue_into_closure, r=petrochenkovGuillaume Gomez-22/+11
merge `DefKind::Coroutine` into `Defkind::Closure` Related to #118188 We no longer need to be concerned about the precise type whether it's `DefKind::Closure` or `DefKind::Coroutine`. Furthermore, thanks for the great work done by `@petrochenkov` on investigating https://rust-lang.zulipchat.com/#narrow/stream/182449-t-compiler.2Fhelp/topic/Why.20does.20it.20hang.20when.20querying.20.EF.BB.BF.60opt_def_kind.60.3F r? `@petrochenkov`
2023-11-26Auto merge of #117301 - saethlin:finish-rmeta-encoding, r=WaffleLapkinbors-12/+22
Call FileEncoder::finish in rmeta encoding Fixes https://github.com/rust-lang/rust/issues/117254 The bug here was that rmeta encoding never called FileEncoder::finish. Now it does. Most of the changes here are needed to support that, since rmeta encoding wants to finish _then_ access the File in the encoder, so finish can't move out. I tried adding a `cfg(debug_assertions)` exploding Drop impl to FileEncoder that checked for finish being called before dropping, but fatal errors cause unwinding so this isn't really possible. If we encounter a fatal error with a dirty FileEncoder, the Drop impl ICEs even though the implementation is correct. If we try to paper over that by wrapping FileEncoder in ManuallyDrop then that just erases the fact that Drop automatically checks that we call finish on all paths. I also changed the name of DepGraph::encode to DepGraph::finish_encoding, because that's what it does and it makes the fact that it is the path to FileEncoder::finish less confusing. r? `@WaffleLapkin`
2023-11-26merge `DefKind::Coroutine` into `DefKind::Closure`bohan-22/+11
2023-11-26rustc: `hir().local_def_id_to_hir_id()` -> `tcx.local_def_id_to_hir_id()` ↵Vadim Petrochenkov-1/+1
cleanup
2023-11-25rustc: Make `def_kind` mandatory for all `DefId`sVadim Petrochenkov-18/+20
2023-11-22Call FileEncoder::finish in rmeta encodingBen Kimock-12/+22
2023-11-22Rollup merge of #118147 - Nilstrieb:no-redundant-casts, r=WaffleLapkinMichael Goulet-6/+2
Fix some unnecessary casts `x clippy compiler -Aclippy::all -Wclippy::unnecessary_cast --fix` with some manual review to ensure every fix is correct.
2023-11-21Fix some unnecessary castsNilstrieb-6/+2
`x clippy compiler -Aclippy::all -Wclippy::unnecessary_cast --fix` with some manual review to ensure every fix is correct.
2023-11-21Fix `clippy::needless_borrow` in the compilerNilstrieb-15/+13
`x clippy compiler -Aclippy::all -Wclippy::needless_borrow --fix`. Then I had to remove a few unnecessary parens and muts that were exposed now.
2023-11-20Store feature stability un-splitMichael Goulet-13/+9
2023-11-20Unify defined_lib_features and lib_features queriesMichael Goulet-7/+21
2023-11-15Re-format code with new rustfmtMark Rousskov-6/+10
2023-11-07Rollup merge of #115485 - DaniPopes:rustdoc-macro-consts, r=jackh726,fmeaseMatthias Krüger-15/+16
Format macro const literals with pretty printer Fixes #115295
2023-10-20s/generator/coroutine/Oli Scherer-11/+11
2023-10-20s/Generator/Coroutine/Oli Scherer-19/+19
2023-10-19Auto merge of #115214 - Urgau:rfc-3127-trim-paths, r=compiler-errorsbors-3/+11
Implement rustc part of RFC 3127 trim-paths This PR implements (or at least tries to) [RFC 3127 trim-paths](https://github.com/rust-lang/rust/issues/111540), the rustc part. That is `-Zremap-path-scope` with all of it's components/scopes. `@rustbot` label: +F-trim-paths
2023-10-17Automatically enable cross-crate inlining for small functionsBen Kimock-1/+34
2023-10-17[RFC 3127 - Trim Paths]: Condition remapped filepath on remap scopesUrgau-3/+11
2023-10-15Format macro const literals with pretty printerDaniPopes-15/+16
2023-10-13Format all the let chains in compilerMichael Goulet-11/+23
2023-09-26Don't store lazyness in DefKindMichael Goulet-16/+19
2023-09-23Enable drop_tracking_mir by default.Camille GILLOT-34/+10
2023-09-22Merge `ExternProviders` into the general `Providers` structOli Scherer-7/+7
2023-09-22Auto merge of #115920 - Zoxc:depkind-u16, r=cjgillotbors-2/+2
Move `DepKind` to `rustc_query_system` and define it as `u16` This moves the `DepKind` type to `rustc_query_system` where it's defined with an inner `u16` field. This decouples it from `rustc_middle` and is a step towards letting other crates define dep kinds. It also allows some type parameters to be removed. The `DepKind` trait is replaced with a `Deps` trait. That's used when some operations or information about dep kinds which is unavailable in `rustc_query_system` are still needed. r? `@cjgillot`
2023-09-21Record asyncness span in HIRMichael Goulet-4/+4
2023-09-21Move `DepKind` to `rustc_query_system` and define it as `u16`John Kåre Alsaker-2/+2
2023-09-20Auto merge of #115542 - saethlin:fileencoder-is-bufwriter, r=WaffleLapkinbors-2/+4
Simplify/Optimize FileEncoder FileEncoder is basically a BufWriter except that it exposes access to the not-written-to-yet region of the buffer so that some users can write directly to the buffer. This strategy is awesome because it lets us avoid calling memcpy for small copies, but the previous strategy was based on the writer accessing a `&mut [MaybeUninit<u8>; N]` and returning a `&[u8]` which is an API which currently mandates the use of unsafe code, making that interface in general not that appealing. So this PR cleans up the FileEncoder implementation and builds on that general idea of direct buffer access in order to prevent `memcpy` calls in a few key places when encoding the dep graph and rmeta tables. The interface used here is now 100% safe, but with the caveat that internally we need to avoid trusting the number of bytes that the provided function claims to have written. The original primary objective of this PR was to clean up the FileEncoder implementation so that the fix for the following issues would be easy to implement. The fix for these issues is to correctly update self.buffered even when writes fail, which I think it's easy to verify manually is now done, because all the FileEncoder methods are small. Fixes https://github.com/rust-lang/rust/issues/115298 Fixes https://github.com/rust-lang/rust/issues/114671 Fixes https://github.com/rust-lang/rust/issues/114045 Fixes https://github.com/rust-lang/rust/issues/108100 Fixes https://github.com/rust-lang/rust/issues/106787
2023-09-13Auto merge of #115735 - bjorn3:better_list_crate_metadata, r=wesleywiserbors-17/+188
Extend rustc -Zls This makes it show a lot more things and thus a lot more useful.
2023-09-12Fix two typosbjorn3-1/+1
2023-09-10Reimplement FileEncoder with a small-write optimizationBen Kimock-2/+4
2023-09-10Auto merge of #115306 - tmiasko:encode-reachable-mir, r=cjgillotbors-12/+31
Encode only MIR reachable from other crates Only reachable items might participate in the code generation in the downstream crates. Omit redundant optimized MIR of unreachable items from a crate metadata. Additionally, include reachable closures in reachable set, so that unreachable closures can be omitted on the same basis.
2023-09-10Support listing all items in -Zlsbjorn3-10/+80
2023-09-10Show lib features in -Zls and allow configuring which things are shownbjorn3-69/+116