about summary refs log tree commit diff
path: root/compiler/rustc_metadata/src
AgeCommit message (Collapse)AuthorLines
2024-03-27Move `CrateStore::expn_hash_to_expn_id` to a hookOli Scherer-11/+5
2024-03-27Start replacing `CStore` trait methods with hooks.Oli Scherer-4/+8
This also avoids the cyclic definition issues with CrateStore being defined after TyCtxt, but needing to be used in TyCtxt.
2024-03-24Rollup merge of #122757 - h1467792822:priv-dep, r=davidtwcoMatthias Krüger-11/+16
Fixed the `private-dependency` bug Fixed the private-dependency bug: If the directly dependent crate is loaded last and is not configured with `--extern`, it may be incorrectly set to `private-dependency` Fixes #122756
2024-03-22Always encode implied_predicates query for traitsMichael Goulet-12/+2
With associated type bounds enabled, the implied_predicates and super_predicates queries may differ for traits, since associated type bounds are also implied but are not counted as super predicates.
2024-03-21Auto merge of #121123 - compiler-errors:item-assumptions, r=oli-obkbors-0/+24
Split an item bounds and an item's super predicates This is the moral equivalent of #107614, but instead for predicates this applies to **item bounds**. This PR splits out the item bounds (i.e. *all* predicates that are assumed to hold for the alias) from the item *super predicates*, which are the subset of item bounds which share the same self type as the alias. ## Why? Much like #107614, there are places in the compiler where we *only* care about super-predicates, and considering predicates that possibly don't have anything to do with the alias is problematic. This includes things like closure signature inference (which is at its core searching for `Self: Fn(..)` style bounds), but also lints like `#[must_use]`, error reporting for aliases, computing type outlives predicates. Even in cases where considering all of the `item_bounds` doesn't lead to bugs, unnecessarily considering irrelevant bounds does lead to a regression (#121121) due to doing extra work in the solver. ## Example 1 - Trait Aliases This is best explored via an example: ``` type TAIT<T> = impl TraitAlias<T>; trait TraitAlias<T> = A + B where T: C; ``` The item bounds list for `Tait<T>` will include: * `Tait<T>: A` * `Tait<T>: B` * `T: C` While `item_super_predicates` query will include just the first two predicates. Side-note: You may wonder why `T: C` is included in the item bounds for `TAIT`? This is because when we elaborate `TraitAlias<T>`, we will also elaborate all the predicates on the trait. ## Example 2 - Associated Type Bounds ``` type TAIT<T> = impl Iterator<Item: A>; ``` The `item_bounds` list for `TAIT<T>` will include: * `Tait<T>: Iterator` * `<Tait<T> as Iterator>::Item: A` But the `item_super_predicates` will just include the first bound, since that's the only bound that is relevant to the *alias* itself. ## So what This leads to some diagnostics duplication just like #107614, but none of it will be user-facing. We only see it in the UI test suite because we explicitly disable diagnostic deduplication. Regarding naming, I went with `super_predicates` kind of arbitrarily; this can easily be changed, but I'd consider better names as long as we don't block this PR in perpetuity.
2024-03-20Split item bounds and item super predicatesMichael Goulet-0/+24
2024-03-20Auto merge of #122359 - Zoxc:missing-static-notes, r=wesleywiserbors-8/+29
Print the crates not available as static This prints out the crates not available to be statically linked when static linking is preferred and we run into an error with duplicated crates.
2024-03-20Fixed the `private-dependency` bug: If the directly dependent crate is ↵h1467792822-11/+16
loaded last and is not configured with `--extern`, it may be incorrectly set to `private-dependency`
2024-03-20Rollup merge of #121543 - onur-ozkan:clippy-args, r=oli-obkMatthias Krüger-1/+1
various clippy fixes We need to keep the order of the given clippy lint rules before passing them. Since clap doesn't offer any useful interface for this purpose out of the box, we have to handle it manually. Additionally, this PR makes `-D` rules work as expected. Previously, lint rules were limited to `-W`. By enabling `-D`, clippy began to complain numerous lines in the tree, all of which have been resolved in this PR as well. Fixes #121481 cc `@matthiaskrgr`
2024-03-20resolve clippy errorsonur-ozkan-1/+1
Signed-off-by: onur-ozkan <work@onurozkan.dev>
2024-03-19Rollup merge of #122695 - surechen:make_only_local_explict_argument, r=lcnrMatthias Krüger-2/+2
Change only_local to a enum type. Change only_local to enum type and change the macros to always require a variant of that enum. r? `@lcnr`
2024-03-19Change only_local to enum type and change the macros to always require a ↵surechen-2/+2
variant of that enum.
2024-03-19Remove all checks of `IntrinsicDef::must_be_overridden` except for the ↵Oli Scherer-8/+3
actual overrides in codegen
2024-03-19Make `const_eval_select` a rustc_intrinsicOli Scherer-2/+4
2024-03-18Rollup merge of #122588 - klensy:imported_source_file, r=michaelwoeristerMatthias Krüger-10/+10
less useless filter calls in imported_source_file This reduces calls to `filter` greatly, giving 0.3% instructions win on some tests.
2024-03-16Rollup merge of #122605 - ↵León Orell Valerian Liehr-1/+2
osiewicz:metadata-register-crate-store-crate-name-in-profile, r=Nadrieril rustc-metadata: Store crate name in self-profile of metadata_register_crate When profiling a build of Zed, I found myself in need of names of crates that take the longest to register in downstream crates.
2024-03-16Rollup merge of #117918 - daxpedda:wasm-c-abi-warning, r=workingjubileeLeón Orell Valerian Liehr-1/+41
Add `wasm_c_abi` `future-incompat` lint This is a warning that will tell users to update to `wasm-bindgen` v0.2.88, which supports spec-compliant C ABI. The idea is to prepare for a future where Rust will switch to the spec-compliant C ABI by default; so not to break everyone's world, this warning is introduced. Addresses #71871.
2024-03-16rustc-metadata: Store crate name in self-profile of metadata_register_cratePiotr Osiewicz-1/+2
When profiling a build of Zed, I found myself in need of names of crates that take the longest to register in downstream crates.
2024-03-16Print the crates not available as staticJohn Kåre Alsaker-8/+29
2024-03-16less useless array builds in imported_source_fileklensy-10/+10
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.