summary refs log tree commit diff
path: root/compiler/rustc_metadata/src/creader.rs
AgeCommit message (Collapse)AuthorLines
2024-03-06Rollup merge of #121382 - nnethercote:rework-untranslatable_diagnostic-lint, ↵Matthias Krüger-0/+1
r=davidtwco Rework `untranslatable_diagnostic` lint Currently it only checks calls to functions marked with `#[rustc_lint_diagnostics]`. This PR changes it to check calls to any function with an `impl Into<{D,Subd}iagnosticMessage>` parameter. This greatly improves its coverage and doesn't rely on people remembering to add `#[rustc_lint_diagnostics]`. It also lets us add `#[rustc_lint_diagnostics]` to a number of functions that don't have an `impl Into<{D,Subd}iagnosticMessage>`, such as `Diag::span`. r? ``@davidtwco``
2024-03-06Rewrite the `untranslatable_diagnostic` lint.Nicholas Nethercote-0/+1
Currently it only checks calls to functions marked with `#[rustc_lint_diagnostics]`. This commit changes it to check calls to any function with an `impl Into<{D,Subd}iagMessage>` parameter. This greatly improves its coverage and doesn't rely on people remembering to add `#[rustc_lint_diagnostics]`. The commit also adds `#[allow(rustc::untranslatable_diagnostic)`] attributes to places that need it that are caught by the improved lint. These places that might be easy to convert to translatable diagnostics. Finally, it also: - Expands and corrects some comments. - Does some minor formatting improvements. - Adds missing `DecorateLint` cases to `tests/ui-fulldeps/internal-lints/diagnostics.rs`.
2024-03-05Rollup merge of #121978 - GuillaumeGomez:dylib-duplicated-path, r=bjorn3Matthias Krüger-1/+7
Fix duplicated path in the "not found dylib" error While working on the gcc backend, I couldn't figure out why I had this error: ``` error: couldn't load codegen backend /checkout/compiler/rustc_codegen_gcc/target/release/librustc_codegen_gcc.so/checkout/compiler/rustc_codegen_gcc/target/release/librustc_codegen_gcc.so: cannot open shared object file: No such file or directory ``` As you can see, the path is duplicated for some reason. After investigating a bit more, I realized that `libloading::Error::LoadLibraryExW` starts with the path of the not found dylib, making it appear twice in our error afterward (because we do render it like this: `{path}{err}`, and since the `err` starts with the path...). Thanks to `````@bjorn3````` for linking me to https://github.com/rust-lang/rust/pull/121392. :)
2024-03-05Rename all `ParseSess` variables/fields/lifetimes as `psess`.Nicholas Nethercote-1/+1
Existing names for values of this type are `sess`, `parse_sess`, `parse_session`, and `ps`. `sess` is particularly annoying because that's also used for `Session` values, which are often co-located, and it can be difficult to know which type a value named `sess` refers to. (That annoyance is the main motivation for this change.) `psess` is nice and short, which is good for a name used this much. The commit also renames some `parse_sess_created` values as `psess_created`.
2024-03-04Fix duplicated path in the "not found dylib" errorGuillaume Gomez-1/+7
2024-02-21Rollup merge of #121392 - bjorn3:unify_dylib_loading, r=petrochenkovMatthias Krüger-15/+41
Unify dylib loading between proc macros and codegen backends 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-02-22Adjust the `has_errors*` methods.Nicholas Nethercote-1/+1
Currently `has_errors` excludes lint errors. This commit changes it to include lint errors. The motivation for this is that for most places it doesn't matter whether lint errors are included or not. But there are multiple places where they must be includes, and only one place where they must not be included. So it makes sense for `has_errors` to do the thing that fits the most situations, and the new `has_errors_excluding_lint_errors` method in the one exceptional place. The same change is made for `err_count`. Annoyingly, this requires the introduction of `err_count_excluding_lint_errs` for one place, to preserve existing error printing behaviour. But I still think the change is worthwhile overall.
2024-02-21Unify dylib loading between proc macros and codegen backendsbjorn3-15/+41
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-02-18resolve: Scale back unloading of speculatively loaded cratesVadim Petrochenkov-10/+0
2024-02-06resolve: Unload speculatively resolved crates before freezing cstoreVadim Petrochenkov-1/+14
2024-01-04cstore: Remove unnecessary locking from `CrateMetadata`Vadim Petrochenkov-20/+21
2023-12-24Remove more `Session` methods that duplicate `DiagCtxt` methods.Nicholas Nethercote-1/+1
2023-12-24Remove `Session` methods that duplicate `DiagCtxt` methods.Nicholas Nethercote-15/+18
Also add some `dcx` methods to types that wrap `TyCtxt`, for easier access.
2023-12-18Rename `Session::span_diagnostic` as `Session::dcx`.Nicholas Nethercote-1/+1
2023-12-02Use `Session::diagnostic` in more places.Nicholas Nethercote-1/+1
2023-11-30Move `MetadataLoader{,Dyn}` to `rustc_metadata`.Nicholas Nethercote-5/+15
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-21Fix `clippy::needless_borrow` in the compilerNilstrieb-3/+3
`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-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-09Use `FreezeLock` for `CStore`John Kåre Alsaker-5/+5
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-09rustc: Move `crate_types` from `Session` to `GlobalCtxt`Vadim Petrochenkov-3/+3
Removes a piece of mutable state. Follow up to #114578.
2023-08-07rustc_interface: Dismantle `register_plugins` queryVadim Petrochenkov-3/+5
2023-07-12Re-format let-else per rustfmt updateMark Rousskov-2/+6
2023-05-31Auto merge of #111076 - ↵bors-5/+15
notriddle:notriddle/silence-private-dep-trait-impl-suggestions, r=cjgillot diagnostics: exclude indirect private deps from trait impl suggest Fixes #88696
2023-05-25Auto merge of #86844 - bjorn3:global_alloc_improvements, r=pnkfelixbors-3/+3
Support #[global_allocator] without the allocator shim This makes it possible to use liballoc/libstd in combination with `--emit obj` if you use `#[global_allocator]`. This is what rust-for-linux uses right now and systemd may use in the future. Currently they have to depend on the exact implementation of the allocator shim to create one themself as `--emit obj` doesn't create an allocator shim. Note that currently the allocator shim also defines the oom error handler, which is normally required too. Once `#![feature(default_alloc_error_handler)]` becomes the only option, this can be avoided. In addition when using only fallible allocator methods and either `--cfg no_global_oom_handling` for liballoc (like rust-for-linux) or `--gc-sections` no references to the oom error handler will exist. To avoid this feature being insta-stable, you will have to define `__rust_no_alloc_shim_is_unstable` to avoid linker errors. (Labeling this with both T-compiler and T-lang as it originally involved both an implementation detail and had an insta-stable user facing change. As noted above, the `__rust_no_alloc_shim_is_unstable` symbol requirement should prevent unintended dependence on this unstable feature.)
2023-05-25rustc_metadata: specialize private_dep flag with `fetch_and`Michael Howell-1/+1
2023-05-25rustc_metadata: fix private_dep logic in `register_crate`Michael Howell-6/+13
2023-05-25Update compiler/rustc_metadata/src/creader.rsMichael Howell-1/+1
Co-authored-by: Camille Gillot <gillot.camille@gmail.com>
2023-05-25rustc_metadata: inherit dependency privacy flagMichael Howell-3/+6
2023-05-24Use `Option::is_some_and` and `Result::is_ok_and` in the compilerMaybe Waffle-1/+1
2023-05-23Fix symbol conflict diagnostic mistakenly being shown instead of missing ↵Oli Scherer-3/+7
crate diagnostic
2023-05-16Avoid `&format("...")` calls in error message code.Nicholas Nethercote-1/+1
Error message all end up passing into a function as an `impl Into<{D,Subd}iagnosticMessage>`. If an error message is creatd as `&format("...")` that means we allocate a string (in the `format!` call), then take a reference, and then clone (allocating again) the reference to produce the `{D,Subd}iagnosticMessage`, which is silly. This commit removes the leading `&` from a lot of these cases. This means the original `String` is moved into the `{D,Subd}iagnosticMessage`, avoiding the double allocations. This requires changing some function argument types from `&str` to `String` (when all arguments are `String`) or `impl Into<{D,Subd}iagnosticMessage>` (when some arguments are `String` and some are `&str`).
2023-05-11Split AllocatorKind::fn_name in global_fn_name and default_fn_namebjorn3-3/+3
2023-05-05add "force" option to --externMatt Hammerly-1/+13
2023-04-28include source error for LoadLibraryExWSameer Puri-1/+9
2023-04-25Revert "Remove #[alloc_error_handler] from the compiler and library"Matthias Krüger-0/+68
This reverts commit abc0660118cc95f47445fd33502a11dd448f5968.
2023-04-24Split `{Idx, IndexVec, IndexSlice}` into their own modulesMaybe Waffle-1/+1
2023-04-16Remove #[alloc_error_handler] from the compiler and libraryAmanieu d'Antras-68/+0
2023-04-04Another AppendOnlyVecOli Scherer-2/+2
2023-03-22Rollup merge of #109358 - petrochenkov:nosess, r=cjgillotMatthias Krüger-20/+17
rustc: Remove unused `Session` argument from some attribute functions (One auxiliary test file containing one of these functions was unused, so I removed it instead of updating.)
2023-03-22rustc: Remove unused `Session` argument from some attribute functionsVadim Petrochenkov-20/+17
2023-03-21Eagerly intern and check CrateNum/StableCrateId collisionsOli Scherer-54/+21
2023-03-13metadata/resolve: Minor refactoring to "tcx -> cstore" conversionsVadim Petrochenkov-6/+9
2023-02-20Stop passing in values that one can also get from the tcx lazilyOli Scherer-12/+17
2023-02-20Remove definitions field that is only needed for one methodOli Scherer-12/+4
2023-02-20Make untracked.cstore lockable so that resolution can still write to it when ↵Oli Scherer-6/+5
using TyCtxt
2023-02-13rustc_resolve: Remove `Resolver::clone_output`Vadim Petrochenkov-6/+5
And remove `Clone` impls and `Lrc`s that are no longer necessary
2023-02-06Add extended error message for E0523Matthew Kelly-1/+6
Adds the extended error documentation for E0523 to indicate that the error is no longer produced by the compiler. Update the E0464 documentation to include example code that produces the error. Remove the error message E0523 from the compiler and replace it with an internal compiler error.
2023-02-05rustc_metadata: remove huge error importsest31-15/+13
2023-02-02Retry opening proc-macro DLLs a few times on Windows.Michael Woerister-2/+40