about summary refs log tree commit diff
path: root/compiler/rustc_metadata
AgeCommit message (Collapse)AuthorLines
2023-11-07Rollup merge of #115485 - DaniPopes:rustdoc-macro-consts, r=jackh726,fmeaseMatthias Krüger-15/+17
Format macro const literals with pretty printer Fixes #115295
2023-11-04Remove support for compiler plugins.Nicholas Nethercote-56/+1
They've been deprecated for four years. This commit includes the following changes. - It eliminates the `rustc_plugin_impl` crate. - It changes the language used for lints in `compiler/rustc_driver_impl/src/lib.rs` and `compiler/rustc_lint/src/context.rs`. External lints are now called "loaded" lints, rather than "plugins" to avoid confusion with the old plugins. This only has a tiny effect on the output of `-W help`. - E0457 and E0498 are no longer used. - E0463 is narrowed, now only relating to unfound crates, not plugins. - The `plugin` feature was moved from "active" to "removed". - It removes the entire plugins chapter from the unstable book. - It removes quite a few tests, mostly all of those in `tests/ui-fulldeps/plugin/`. Closes #29597.
2023-10-30Clean up `rustc_*/Cargo.toml`.Nicholas Nethercote-10/+10
- Sort dependencies and features sections. - Add `tidy` markers to the sorted sections so they stay sorted. - Remove empty `[lib`] sections. - Remove "See more keys..." comments. Excluded files: - rustc_codegen_{cranelift,gcc}, because they're external. - rustc_lexer, because it has external use. - stable_mir, because it has external use.
2023-10-20s/generator/coroutine/Oli Scherer-13/+14
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/+17
2023-10-13Format all the let chains in compilerMichael Goulet-15/+34
2023-10-08rustdoc: remove rust logo from non-Rust cratesMichael Howell-0/+3
2023-10-06rustc_metadata: use try_canonicalizeTamir Duberstein-2/+3
This is simpler and avoids unnecessary calls to `env::current_dir`. rustc_plugin is left unchanged to avoid conflicts with #116412. Updates #116426.
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-8/+8
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-17Auto merge of #114750 - Enselic:metadata-dep-info, r=compiler-errorsbors-3/+1
Make `.rmeta` file in `dep-info` have correct name (`lib` prefix) Since `filename_for_metadata()` and `OutputFilenames::path(OutputType::Metadata)` had different logic for the name of the metadata file, the `.d` file contained a file name different from the actual name used. Share the logic to fix the out-of-sync name. Without this fix, the `.d` file contained dash-separated_something-extra.rmeta: dash-separated.rs instead of libdash_separated_something-extra.rmeta: dash-separated.rs which is the name of the file that is actually written by the compiler. Worth noting: It took me several iterations to get all tests to pass, so I am relatively confident that this PR does not break anything. Closes #68839
2023-09-13Auto merge of #115735 - bjorn3:better_list_crate_metadata, r=wesleywiserbors-18/+190
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-12cleanup on messagesyukang-3/+0
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-70/+118
2023-09-10List all defined and required lang items in -Zlsbjorn3-0/+20
2023-09-10List more crate metadata in -Zlsbjorn3-4/+38
2023-09-10Encode only MIR that can be used by other cratesTomasz Miąsko-12/+31
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-09Use `FreezeLock` for `CStore`John Kåre Alsaker-7/+7
2023-09-07Use `Freeze` for `SourceFile.external_src`John Kåre Alsaker-2/+2
2023-09-03Register the file while computing its start position.Camille GILLOT-1/+1
2023-09-03Use relative positions inside a SourceFile.Camille GILLOT-13/+11
2023-09-03Make `.rmeta` file in `dep-info` have correct name (`lib` prefix)Martin Nordholts-3/+1
Since `filename_for_metadata()` and `OutputFilenames::path(OutputType::Metadata)` had different logic for the name of the metadata file, the `.d` file contained a file name different from the actual name used. Share the logic to fix the out-of-sync name. Closes 68839.
2023-09-02Auto merge of #115286 - saethlin:detangler, r=petrochenkovbors-12/+98
Skip rendering metadata strings from include_str!/include_bytes! The const rendering code in rustdoc completely ignores consts from expansions, but the compiler was rendering all consts. So some consts (namely those from `include_bytes!`) were rendered then ignored. Most of the diff here is from moving `print_const_expr` from rustdoc into `rustc_hir_pretty` so that it can be used in rustdoc and when building rmeta files.
2023-09-01Reuse const rendering from rustdoc in rmeta encodingBen Kimock-12/+98
2023-09-01Use `OnceLock` for `SingleCache`John Kåre Alsaker-2/+2
2023-08-30Auto merge of #113542 - saethlin:adaptive-tables, r=b-naberbors-47/+125
Adapt table sizes to the contents This is an implementation of https://github.com/rust-lang/compiler-team/issues/666 The objective of this PR is to permit the rmeta format to accommodate larger crates that need offsets larger than a `u32` can store without compromising performance for crates that do not need such range. The second commit is a number of tiny optimization opportunities I noticed while looking at perf recordings of the first commit. The rmeta tables need to have fixed-size elements to permit lazy random access. But the size only needs to be fixed _per table_, not per element type. This PR adds another `usize` to the table header which indicates the table element size. As each element of a table is set, we keep track of the widest encoded table value, then don't bother encoding all the unused trailing bytes on each value. When decoding table elements, we copy them to a full-width array if they are not already full-width. `LazyArray` needs some special treatment. Most other values that are encoded in tables are indexes or offsets, and those tend to be small so we get to drop a lot of zero bytes off the end. But `LazyArray` encodes _two_ small values in a fixed-width table element: A position of the table and the length of the table. The treatment described above could trim zero bytes off the table length, but any nonzero length shields the position bytes from the optimization. To improve this, we interleave the bytes of position and length. This change is responsible for about half of the crate metadata win on many crates. Fixes https://github.com/rust-lang/rust/issues/112934 (probably) Fixes https://github.com/rust-lang/rust/issues/103607
2023-08-29Document in the code how this scheme worksBen Kimock-14/+25
2023-08-27Add a specialization for encoding byte arrays in rmetaBen Kimock-0/+7
2023-08-13Remove metadata_loader querybjorn3-5/+11
It is only used by CrateLoader. We can store the metadata loader in CStore instead which CrateLoader has access to.
2023-08-11rustc: Move `features` from `Session` to `GlobalCtxt`Vadim Petrochenkov-4/+7
Removes two pieces of mutable state. Follow up to #114622.
2023-08-09rustc: Move `crate_types` from `Session` to `GlobalCtxt`Vadim Petrochenkov-14/+18
Removes a piece of mutable state. Follow up to #114578.
2023-08-08Auto merge of #114578 - petrochenkov:noplugin, r=cjgillotbors-10/+11
rustc_interface: Dismantle `register_plugins` query It did three independent things: - Constructed `LintStore` - Prepared incremental directories and dep graph - Initialized some fields in `Session` The `LintStore` construction (now `passes::create_lint_store`) is more or less left in place. The incremental stuff is now moved into `fn dep_graph_future`. This helps us to start loading the dep graph a bit earlier. The `Session` field initialization is moved to tcx construction point. Now that tcx is constructed early these fields don't even need to live in `Session`, they can live in tcx instead and be initialized at its creation (see the FIXME). Three previously existing `rustc_interface` queries are de-querified (`register_plugins`, `dep_graph_future`, `dep_graph`) because they are only used locally in `fn global_ctxt` and their results don't need to be saved elsewhere. On the other hand, `crate_types` and `stable_crate_id` are querified. They are used from different places and their use is very similar to the existing `crate_name` query in this regard.
2023-08-07Store the laziness of type aliases in the DefKindLeón Orell Valerian Liehr-14/+14
2023-08-07rustc_interface: Dismantle `register_plugins` queryVadim Petrochenkov-10/+11
2023-08-04Rollup merge of #114253 - fmease:compute-variances-for-lazy-ty-aliases, ↵Matthias Krüger-3/+7
r=oli-obk Compute variances for lazy type aliases Fixes #114221. CC ``@oli-obk`` r? types
2023-08-03Auto merge of #113292 - MU001999:fix/issue-113222, r=Nilstriebbors-4/+17
Suggest `x build library` for a custom toolchain that fails to load `core` Fixes #113222 The nicer suggestion for dev-channel won't be emitted if `-Z ui-testing` enabled. IMO, this is acceptable for now.
2023-08-03Compute variances for lazy type aliasesLeón Orell Valerian Liehr-3/+7