about summary refs log tree commit diff
path: root/compiler/rustc_metadata/src/locator.rs
AgeCommit message (Collapse)AuthorLines
2025-07-28use let chains in hir, lint, mirKivooeo-5/+4
2025-07-03Rollup merge of #143369 - bjorn3:cleanup_metadata_loading, r=lcnrGuillaume Gomez-48/+72
Various refactorings to the metadata loader
2025-07-03Make most CrateLocator fields privatebjorn3-6/+22
This ensures they don't get out of sync
2025-07-03Pass CrateRejections separately from CrateLocatorbjorn3-38/+48
This allows all CrateLocator methods to take &self.
2025-07-03Deduplicate getting the path of a lib candidatebjorn3-6/+4
2025-07-03setup CI and tidy to use typos for spellchecking and fix few typosklensy-2/+2
2025-06-24rustc_session: Add a structure for keeping both explicit and default sysrootsVadim Petrochenkov-1/+1
Also avoid creating and cloning sysroot unnecessarily.
2025-06-17apply clippy::or_fun_callklensy-2/+6
2025-05-29creader: Remove extraenous String::clonePiotr Osiewicz-1/+1
2025-05-04Initial support for dynamically linked cratesBryanskiy-34/+113
2025-04-16Don't canonicalize crate pathsChris Denton-6/+15
2025-03-31Add an error when full metadata was not foundJakub Beránek-1/+22
2025-03-31Simplify find_commandline_librarybjorn3-28/+16
2025-02-25Teach structured errors to display short `Ty`Esteban Küber-1/+1
Make it so that every structured error annotated with `#[derive(Diagnostic)]` that has a field of type `Ty<'_>`, the printing of that value into a `String` will look at the thread-local storage `TyCtxt` in order to shorten to a length appropriate with the terminal width. When this happen, the resulting error will have a note with the file where the full type name was written to. ``` error[E0618]: expected function, found `((..., ..., ..., ...), ..., ..., ...)`` --> long.rs:7:5 | 6 | fn foo(x: D) { //~ `x` has type `(... | - `x` has type `((..., ..., ..., ...), ..., ..., ...)` 7 | x(); //~ ERROR expected function, found `(... | ^-- | | | call expression requires function | = note: the full name for the type has been written to 'long.long-type-14182675702747116984.txt' = note: consider using `--verbose` to print the full type name to the console ```
2025-02-20Improve debugging for metadata structuresTrevor Gross-4/+6
I had to do a lot of debug by printing; having these `Debug` traits in place made it easier. Additionally, add some more information to existing `info!` statements.
2025-01-14rustc_metadata: Rename `root` to `dep_root`Trevor Gross-6/+6
Currently `root` or `crate_root` is used to refer to an instance of `CrateRoot` (representation of a crate's serialized metadata), but the name `root` sometimes also refers to a `CratePath` representing a "root" node in the dependency graph. In order to disambiguate, rename all instances of the latter to `dep_root`.
2024-12-18Re-export more `rustc_span::symbol` things from `rustc_span`.Nicholas Nethercote-2/+1
`rustc_span::symbol` defines some things that are re-exported from `rustc_span`, such as `Symbol` and `sym`. But it doesn't re-export some closely related things such as `Ident` and `kw`. So you can do `use rustc_span::{Symbol, sym}` but you have to do `use rustc_span::symbol::{Ident, kw}`, which is inconsistent for no good reason. This commit re-exports `Ident`, `kw`, and `MacroRulesNormalizedIdent`, and changes many `rustc_span::symbol::` qualifiers in `compiler/` to `rustc_span::`. This is a 200+ net line of code reduction, mostly because many files with two `use rustc_span` items can be reduced to one.
2024-11-21aix: fix archive formatHenry Jiang-1/+4
fmt fix cfg for windows remove unused imports address comments update libc to 0.2.164 fmt remove unused imports
2024-11-15rustc_metadata: Preprocess search paths for better performancePiotr Osiewicz-40/+44
Over in Zed we've noticed that loading crates for a large-ish workspace can take almost 200ms. We've pinned it down to how rustc searches for paths, as it performs a linear search over the list of candidate paths. In our case the candidate list had about 20k entries which we had to iterate over for each dependency being loaded. This commit introduces a simple FilesIndex that's just a sorted Vec under the hood. Since crates are looked up by both prefix and suffix, we perform a range search on said Vec (which constraints the search space based on prefix) and follow up with a linear scan of entries with matching suffixes. FilesIndex is also pre-filtered before any queries are performed using available target information; query prefixes/sufixes are based on the target we are compiling for, so we can remove entries that can never match up front. Overall, this commit brings down build time for us in dev scenarios by about 6%. 100ms might not seem like much, but this is a constant cost that each of our workspace crates has to pay, even when said crate is miniscule.
2024-11-02Rename target triple to target tuple in many places in the compilerNoratrieb-8/+8
This changes the naming to the new naming, used by `--print target-tuple`. It does not change all locations, but many.
2024-10-31Remove support for decompressing dylib metadatabjorn3-25/+4
We haven't been compressing dylib metadata for a while now. Removing decompression support will regress error messages about an incompatible rustc version being used, but dylibs are pretty rare anyway.
2024-10-17rustc_metadata: reduce repetitionTamir Duberstein-15/+29
2024-10-16rustc_metadata: reduce repetitionTamir Duberstein-27/+18
2024-10-15rustc_metadata: replace `?` in expression with mapTamir Duberstein-1/+1
2024-10-15rustc_metadata: move comment closer to codeTamir Duberstein-3/+5
This was added in cc3c8bbfaf5af19caf3deb131a995a65ca4674f9 when it was closer to the `extract_one` call. Move it back near that call.
2024-10-03Handle `rustc_metadata` cases of `rustc::potential_query_instability` lintismailarilik-10/+10
2024-09-22Reformat using the new identifier sorting from rustfmtMichael Goulet-3/+3
2024-08-21Simplify some redundant field namesMichael Goulet-6/+2
2024-07-29Reformat `use` declarations.Nicholas Nethercote-9/+9
The previous commit updated `rustfmt.toml` appropriately. This commit is the outcome of running `x fmt --all` with the new formatting options.
2024-06-06Simplify string operations in crate loaderNilstrieb-6/+12
2024-06-06Remove constant parameter from `CrateLocator::new`Nilstrieb-13/+3
2024-05-23Remove `#[macro_use] extern crate tracing` from `rustc_metadata`.Nicholas Nethercote-0/+1
2024-05-21PR feedbackBen Kimock-1/+1
2024-05-21Add a footer in FileEncoder and check for it in MemDecoderBen Kimock-1/+6
2024-03-11Rename `IntoDiagnosticArg` as `IntoDiagArg`.Nicholas Nethercote-3/+3
Also rename `into_diagnostic_arg` as `into_diag_arg`, and `NotIntoDiagnosticArg` as `NotInotDiagArg`.
2024-03-08Move metadata header and version checks togetherbjorn3-39/+60
This will make it easier to report rustc versions for older metadata formats.
2024-03-06Make not finding core a fatal errorBen Kimock-4/+18
2024-02-28Rename `DiagnosticArg{,Map,Name,Value}` as `DiagArg{,Map,Name,Value}`.Nicholas Nethercote-5/+5
2024-02-21Unify dylib loading between proc macros and codegen backendsbjorn3-4/+4
As bonus this makes the errors when failing to load a proc macro more informative to match the backend loading errors. In addition it makes it slightly easier to patch rustc to work on platforms that don't support dynamic linking like wasm.
2024-01-30Remove the lifetime from `DiagnosticArgValue`.Nicholas Nethercote-1/+1
Because it's almost always static. This makes `impl IntoDiagnosticArg for DiagnosticArgValue` trivial, which is nice. There are a few diagnostics constructed in `compiler/rustc_mir_build/src/check_unsafety.rs` and `compiler/rustc_mir_transform/src/errors.rs` that now need symbols converted to `String` with `to_string` instead of `&str` with `as_str`, but that' no big deal, and worth it for the simplifications elsewhere.
2023-12-24Remove `Session` methods that duplicate `DiagCtxt` methods.Nicholas Nethercote-16/+17
Also add some `dcx` methods to types that wrap `TyCtxt`, for easier access.
2023-12-11Auto merge of #118344 - saethlin:rmeta-header-pos, r=WaffleLapkinbors-4/+4
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-11-30Move `MetadataLoader{,Dyn}` to `rustc_metadata`.Nicholas Nethercote-2/+2
They're not used in `rustc_session`, and `rustc_metadata` is a more obvious location. `MetadataLoader` was originally put into `rustc_session` in #41565 to avoid a dependency on LLVM, but things have changed a lot since then and that's no longer relevant, e.g. `rustc_codegen_llvm` depends on `rustc_metadata`.
2023-11-28Use a u64 for the rmeta root positionBen Kimock-4/+4
2023-11-21Fix `clippy::needless_borrow` in the compilerNilstrieb-1/+1
`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-04Remove support for compiler plugins.Nicholas Nethercote-45/+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-09-10Show lib features in -Zls and allow configuring which things are shownbjorn3-1/+2
2023-08-07rustc_interface: Dismantle `register_plugins` queryVadim Petrochenkov-7/+6
2023-08-03Auto merge of #113292 - MU001999:fix/issue-113222, r=Nilstriebbors-0/+2
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-07-30inline format!() args up to and including rustc_codegen_llvmMatthias Krüger-1/+1