about summary refs log tree commit diff
path: root/compiler/rustc_metadata/src
AgeCommit message (Collapse)AuthorLines
2024-03-16Add `wasm_c_abi` `future-incompat` lintdaxpedda-1/+41
2024-03-14hir: Remove `opt_local_def_id_to_hir_id` and `opt_hir_node_by_def_id`Vadim Petrochenkov-2/+2
Also replace a few `hir_node()` calls with `hir_node_by_def_id()`
2024-03-12s/mt/mutability/Oli Scherer-4/+4
2024-03-12Ensure nested allocations in statics do not get deduplicatedOli Scherer-3/+6
2024-03-12Add `nested` bool to `DefKind::Static`.Oli Scherer-2/+4
Will be used in the next commit
2024-03-12Change `DefKind::Static` to a struct variantOli Scherer-14/+14
2024-03-11Rename `IntoDiagnostic` as `Diagnostic`.Nicholas Nethercote-7/+7
To match `derive(Diagnostic)`. Also rename `into_diagnostic` as `into_diag`.
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-09Rollup merge of #122187 - bjorn3:merge_header_version_checks, r=petrochenkovMatthias Krüger-45/+78
Move metadata header and version checks together This will make it easier to report rustc versions for older metadata formats. Split out of https://github.com/rust-lang/rust/pull/120855
2024-03-09Auto merge of #122010 - oli-obk:intrinsics3.0, r=pnkfelixbors-1/+1
Avoid invoking the `intrinsic` query for DefKinds other than `Fn` or `AssocFn` fixes the perf regression from https://github.com/rust-lang/rust/pull/120675 by only invoking (and thus inserting into the dep graph) the `intrinsic` query if the `DefKind` matches items that can actually be intrinsics
2024-03-08Move metadata header and version checks togetherbjorn3-45/+78
This will make it easier to report rustc versions for older metadata formats.
2024-03-07Rollup merge of #122114 - saethlin:cant-find-crate-spam, r=WaffleLapkinGuillaume Gomez-4/+18
Make not finding core a fatal error Similar to https://github.com/rust-lang/rust/pull/120472, this prevents terminal spam. In particular, it makes the good diagnostic visible when you try to use a target that's not installed.
2024-03-07Apply `EarlyBinder` only to `TraitRef` in `ImplTraitHeader`Yoshitomo Nakanishi-3/+2
2024-03-06Make not finding core a fatal errorBen Kimock-4/+18
2024-03-06Rollup merge of #121382 - nnethercote:rework-untranslatable_diagnostic-lint, ↵Matthias Krüger-0/+2
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-06Auto merge of #119455 - Mark-Simulacrum:relative-spans, r=cjgillotbors-6/+24
Embed length of offset/position into Span tag byte This cuts the average bytes/relative span from 3.5 to 3.2 on libcore, ultimately saving ~400kb of data.
2024-03-06Rewrite the `untranslatable_diagnostic` lint.Nicholas Nethercote-0/+2
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-05Avoid invoking the `intrinsic` query for DefKinds other than `Fn` or `AssocFn`Oli Scherer-1/+1
2024-03-05Auto merge of #120675 - oli-obk:intrinsics3.0, r=pnkfelixbors-6/+9
Add a scheme for moving away from `extern "rust-intrinsic"` entirely All `rust-intrinsic`s can become free functions now, either with a fallback body, or with a dummy body and an attribute, requiring backends to actually implement the intrinsic. This PR demonstrates the dummy-body scheme with the `vtable_size` intrinsic. cc https://github.com/rust-lang/rust/issues/63585 follow-up to #120500 MCP at https://github.com/rust-lang/compiler-team/issues/720
2024-03-05Rename all `ParseSess` variables/fields/lifetimes as `psess`.Nicholas Nethercote-3/+3
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-04make `intrinsic` query legal for any `DefId`Oli Scherer-8/+6
2024-03-04Add a scheme for moving away from `extern "rust-intrinsic"` entirelyOli Scherer-2/+7
2024-03-04Return a struct from `query intrinsic` to be able to add another field in ↵Oli Scherer-2/+2
the next commit
2024-03-04Fix duplicated path in the "not found dylib" errorGuillaume Gomez-1/+7
2024-02-28Rename `DiagnosticArg{,Map,Name,Value}` as `DiagArg{,Map,Name,Value}`.Nicholas Nethercote-5/+5
2024-02-28Rename `DiagnosticBuilder` as `Diag`.Nicholas Nethercote-9/+7
Much better! Note that this involves renaming (and updating the value of) `DIAGNOSTIC_BUILDER` in clippy.
2024-02-25remove platform-intrinsics ABI; make SIMD intrinsics be regular intrinsicsRalf Jung-1/+1
2024-02-21Rollup merge of #121392 - bjorn3:unify_dylib_loading, r=petrochenkovMatthias Krüger-19/+48
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-19/+48
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-20Rollup merge of #121167 - petrochenkov:unload2, r=wesleywiserNilstrieb-10/+10
resolve: Scale back unloading of speculatively loaded crates Fixes https://github.com/rust-lang/rust/issues/120830 and fixes https://github.com/rust-lang/rust/issues/120909 while still unblocking https://github.com/rust-lang/rust/pull/117772. I cannot reproduce https://github.com/parasyte/crash-rustc as an UI test for some reason, but I tested all the cases linked above manually.
2024-02-20Reduce capabilities of `Diagnostic`.Nicholas Nethercote-0/+4
Currently many diagnostic modifier methods are available on both `Diagnostic` and `DiagnosticBuilder`. This commit removes most of them from `Diagnostic`. To minimize the diff size, it keeps them within `diagnostic.rs` but changes the surrounding `impl Diagnostic` block to `impl DiagnosticBuilder`. (I intend to move things around later, to give a more sensible code layout.) `Diagnostic` keeps a few methods that it still needs, like `sub`, `arg`, and `replace_args`. The `forward!` macro, which defined two additional methods per call (e.g. `note` and `with_note`), is replaced by the `with_fn!` macro, which defines one additional method per call (e.g. `with_note`). It's now also only used when necessary -- not all modifier methods currently need a `with_*` form. (New ones can be easily added as necessary.) All this also requires changing `trait AddToDiagnostic` so its methods take `DiagnosticBuilder` instead of `Diagnostic`, which leads to many mechanical changes. `SubdiagnosticMessageOp` gains a type parameter `G`. There are three subdiagnostics -- `DelayedAtWithoutNewline`, `DelayedAtWithNewline`, and `InvalidFlushedDelayedDiagnosticLevel` -- that are created within the diagnostics machinery and appended to external diagnostics. These are handled at the `Diagnostic` level, which means it's now hard to construct them via `derive(Diagnostic)`, so instead we construct them by hand. This has no effect on what they look like when printed. There are lots of new `allow` markers for `untranslatable_diagnostics` and `diagnostics_outside_of_impl`. This is because `#[rustc_lint_diagnostics]` annotations were present on the `Diagnostic` modifier methods, but missing from the `DiagnosticBuilder` modifier methods. They're now present.
2024-02-18resolve: Scale back unloading of speculatively loaded cratesVadim Petrochenkov-10/+10
2024-02-18By tracking import use types to check whether it is scope uses or the other ↵surechen-1/+1
situations like module-relative uses, we can do more accurate redundant import checking. fixes #117448 For example unnecessary imports in std::prelude that can be eliminated: ```rust use std::option::Option::Some;//~ WARNING the item `Some` is imported redundantly use std::option::Option::None; //~ WARNING the item `None` is imported redundantly ```
2024-02-16Auto merge of #120500 - oli-obk:intrinsics2.0, r=WaffleLapkinbors-5/+7
Implement intrinsics with fallback bodies fixes #93145 (though we can port many more intrinsics) cc #63585 The way this works is that the backend logic for generating custom code for intrinsics has been made fallible. The only failure path is "this intrinsic is unknown". The `Instance` (that was `InstanceDef::Intrinsic`) then gets converted to `InstanceDef::Item`, which represents the fallback body. A regular function call to that body is then codegenned. This is currently implemented for * codegen_ssa (so llvm and gcc) * codegen_cranelift other backends will need to adjust, but they can just keep doing what they were doing if they prefer (though adding new intrinsics to the compiler will then require them to implement them, instead of getting the fallback body). cc `@scottmcm` `@WaffleLapkin` ### todo * [ ] miri support * [x] default intrinsic name to name of function instead of requiring it to be specified in attribute * [x] make sure that the bodies are always available (must be collected for metadata)
2024-02-16Auto merge of #120486 - reitermarkus:use-generic-nonzero, r=dtolnaybors-22/+23
Use generic `NonZero` internally. Tracking issue: https://github.com/rust-lang/rust/issues/120257
2024-02-15Return ConstAllocation from eval_static_initializer query directlyOli Scherer-6/+6
2024-02-15Store static initializers in metadata instead of the MIR of statics.Oli Scherer-5/+19
2024-02-15Replace `NonZero::<_>::new` with `NonZero::new`.Markus Reiter-13/+11
2024-02-15Use generic `NonZero` internally.Markus Reiter-23/+26
2024-02-13Auto merge of #120919 - oli-obk:impl_polarity, r=compiler-errorsbors-7/+5
Merge `impl_polarity` and `impl_trait_ref` queries Hopefully this is perf neutral. I want to finish https://github.com/rust-lang/rust/pull/120835 and stop using the HIR in `coherent_trait`, which should then give us a perf improvement.
2024-02-12Remove impl_polarity queryOli Scherer-3/+0
2024-02-12Implement intrinsics with fallback bodiesOli Scherer-5/+7
2024-02-12Use a struct instead of a tupleOli Scherer-2/+2
2024-02-12Make impl_trait_ref into a query also returning more information about the implOli Scherer-4/+5
2024-02-12Make `is_intrinsic` query return the intrinsic nameOli Scherer-5/+5
2024-02-12Lower anonymous structs or unions to HIRFrank King-0/+3
2024-02-10Encode coroutine_for_closure for foreign cratesMichael Goulet-0/+9
2024-02-09Rollup merge of #120693 - nnethercote:invert-diagnostic-lints, r=davidtwcoMatthias Krüger-2/+0
Invert diagnostic lints. That is, change `diagnostic_outside_of_impl` and `untranslatable_diagnostic` from `allow` to `deny`, because more than half of the compiler has been converted to use translated diagnostics. This commit removes more `deny` attributes than it adds `allow` attributes, which proves that this change is warranted. r? ````@davidtwco````