about summary refs log tree commit diff
path: root/compiler/rustc_middle/src
AgeCommit message (Collapse)AuthorLines
2024-01-17Auto merge of #119922 - nnethercote:fix-Diag-code-is_lint, r=oli-obkbors-5/+2
Rework how diagnostic lints are stored. `Diagnostic::code` has the type `DiagnosticId`, which has `Error` and `Lint` variants. Plus `Diagnostic::is_lint` is a bool, which should be redundant w.r.t. `Diagnostic::code`. Seems simple. Except it's possible for a lint to have an error code, in which case its `code` field is recorded as `Error`, and `is_lint` is required to indicate that it's a lint. This is what happens with `derive(LintDiagnostic)` lints. Which means those lints don't have a lint name or a `has_future_breakage` field because those are stored in the `DiagnosticId::Lint`. It's all a bit messy and confused and seems unintentional. This commit: - removes `DiagnosticId`; - changes `Diagnostic::code` to `Option<String>`, which means both errors and lints can straightforwardly have an error code; - changes `Diagnostic::is_lint` to `Option<IsLint>`, where `IsLint` is a new type containing a lint name and a `has_future_breakage` bool, so all lints can have those, error code or not. r? `@oli-obk`
2024-01-17Inline `dump_file_basename` into `dump_path`Zalathar-19/+10
2024-01-17Inline `create_dump_file_with_basename`Zalathar-22/+13
2024-01-16Get rid of the hir_owner query.Camille GILLOT-71/+35
2024-01-16Auto merge of #119977 - Mark-Simulacrum:defid-cache, r=cjgillotbors-1/+2
Cache local DefId-keyed queries without hashing This caches local DefId-keyed queries using just an IndexVec. This costs ~5% extra max-rss at most but brings significant runtime improvement, up to 13% cycle counts (mean: 4%) on primary benchmarks. It's possible that further tweaks could reduce the memory overhead further but this win seems worth landing despite the increased memory, particularly with regards to eliminating the present set in non-incr or storing it inline (skip list?) with the main data. We tried applying this scheme to all keys in the [first perf run] but found that it carried a significant memory hit (50%). instructions/cycle counts were also much more mixed, though that may have been due to the lack of the present set optimization (needed for fast iter() calls in incremental scenarios). Closes https://github.com/rust-lang/rust/issues/45275 [first perf run]: https://perf.rust-lang.org/compare.html?start=30dfb9e046aeb878db04332c74de76e52fb7db10&end=6235575300d8e6e2cc6f449cb9048722ef43f9c7&stat=instructions:u
2024-01-16Auto merge of #116520 - Enselic:large-copy-into-fn, r=oli-obkbors-4/+51
large_assignments: Lint on specific large args passed to functions Requires lowering function call arg spans down to MIR, which is done in the second commit. Part of #83518 Also see * https://rust-lang.zulipchat.com/#narrow/stream/182449-t-compiler.2Fhelp/topic/arg.20Spans.20for.20TerminatorKind.3A.3ACall.3F * https://rust-lang.zulipchat.com/#narrow/stream/122651-general/topic/move_size_limit.20lint r? `@oli-obk` (E-mentor)
2024-01-16Rollup merge of #119969 - compiler-errors:simplify-closure-env-ty, r=oli-obkMatthias Krüger-9/+5
Simplify `closure_env_ty` and `closure_env_param` Random cleanup that I found when working on async closures. This makes it easier to separate the latter into a new tykind.
2024-01-16don't store const var origins for known varslcnr-19/+10
2024-01-15Cache local DefId-keyed queries without hashingMark Rousskov-1/+2
Foreign maps are used to cache external DefIds, typically backed by metadata decoding. In the future we might skip caching `V` there (since loading from metadata usually is already cheap enough), but for now this cuts down on the impact to memory usage and time to None-init a bunch of memory. Foreign data is usually much sparser, since we're not usually loading *all* entries from the foreign crate(s).
2024-01-15large_assignments: Lint on specific large args passed to functionsMartin Nordholts-0/+12
2024-01-15compiler: Lower fn call arg spans down to MIRMartin Nordholts-4/+14
To enable improved accuracy of diagnostics in upcoming commits.
2024-01-15Implement TypeVisitable and TypeFoldable for SpannedMartin Nordholts-0/+25
The traits are already implemented for Span, so it makes sense to also have them for Spanned (upcoming commits will make use of this).
2024-01-15Rollup merge of #119974 - nnethercote:trimmed_def_paths-improvements, ↵Matthias Krüger-31/+26
r=compiler-errors Minor `trimmed_def_paths` improvements r? `@compiler-errors`
2024-01-15Rollup merge of #119897 - compiler-errors:fulfillment-errors, r=lcnrMatthias Krüger-2/+2
`OutputTypeParameterMismatch` -> `SignatureMismatch` I'm probably missing something that made this rename more complicated. What did you end up getting stuck on when renaming this selection error, `@lcnr?` **also** I renamed the `FulfillmentErrorCode` variants. This is just churn but I wanted to do it forever. I can move it out of this PR if desired. r? lcnr
2024-01-15Replace `TrimmedDefPaths` with a bool.Nicholas Nethercote-13/+11
It's a tri-state enum but the `Always` variant is never used, so a bool is simpler.
2024-01-15Refactor `try_print_trimmed_def_path`.Nicholas Nethercote-18/+11
Inverting the condition lets us merge the two `Ok(false)` paths. I also find the inverted condition easier to read: "all the things that must be true for trimming to occur", instead of "any of the things that must be true for trimming to not occur".
2024-01-15Add some helpful comments in `trimmed_def_paths`.Nicholas Nethercote-1/+5
To explain things that took me a minute to work out.
2024-01-14Simplify closure_env_ty and closure_env_paramMichael Goulet-9/+5
2024-01-14Rework how diagnostic lints are stored.Nicholas Nethercote-5/+2
`Diagnostic::code` has the type `DiagnosticId`, which has `Error` and `Lint` variants. Plus `Diagnostic::is_lint` is a bool, which should be redundant w.r.t. `Diagnostic::code`. Seems simple. Except it's possible for a lint to have an error code, in which case its `code` field is recorded as `Error`, and `is_lint` is required to indicate that it's a lint. This is what happens with `derive(LintDiagnostic)` lints. Which means those lints don't have a lint name or a `has_future_breakage` field because those are stored in the `DiagnosticId::Lint`. It's all a bit messy and confused and seems unintentional. This commit: - removes `DiagnosticId`; - changes `Diagnostic::code` to `Option<String>`, which means both errors and lints can straightforwardly have an error code; - changes `Diagnostic::is_lint` to `Option<IsLint>`, where `IsLint` is a new type containing a lint name and a `has_future_breakage` bool, so all lints can have those, error code or not.
2024-01-13Auto merge of #119088 - George-lewis:glewis/suggest-upgrading-compiler, ↵bors-2/+1
r=Nilstrieb Suggest Upgrading Compiler for Gated Features This PR addresses #117318 I have a few questions: 1. Do we want to specify the current version and release date of the compiler? I have added this in via environment variables, which I found in the code for the rustc cli where it handles the `--version` flag a. How can I handle the changing message in the tests? 3. Do we want to only show this message when the compiler is old? a. How can we determine when the compiler is old? I'll wait until we figure out the message to bless the tests
2024-01-13Add check for ui_testing via promoting parameters from `ParseSess` to `Session`George-lewis-2/+1
2024-01-13Rollup merge of #119898 - compiler-errors:error-reporting, r=oli-obkMatthias Krüger-5/+0
Remove unused `ErrorReporting` variant from overflow handling r? oli-obk
2024-01-13Auto merge of #118947 - Bryanskiy:delegStep1, r=petrochenkov,lcnrbors-1/+5
Delegation implementation: step 1 See https://github.com/rust-lang/rust/issues/118212 for more details. r? `@petrochenkov`
2024-01-12Remove unused ErrorReporting variant from overflow handlingMichael Goulet-5/+0
2024-01-12OutputTypeParameterMismatch -> SignatureMismatchMichael Goulet-2/+2
2024-01-12Rollup merge of #119885 - DianQK:revert-pr-113923, r=petrochenkovGuillaume Gomez-5/+0
Revert #113923 Per [#t-compiler/meetings > [weekly] 2024-01-11](https://rust-lang.zulipchat.com/#narrow/stream/238009-t-compiler.2Fmeetings/topic/.5Bweekly.5D.202024-01-11) discussion, revert #113923. Also revert associated #118568. The PR #113923 causes the regression issue #118609. We need more time to find a proper solution. Discussions start at [412365838](https://rust-lang.zulipchat.com/#narrow/stream/238009-t-compiler.2Fmeetings/topic/.5Bweekly.5D.202024-01-11/near/412365838) and continue to [412369643](https://rust-lang.zulipchat.com/#narrow/stream/238009-t-compiler.2Fmeetings/topic/.5Bweekly.5D.202024-01-11/near/412369643). Fixes #118609. r? compiler
2024-01-12Delegation implementation: step 1Bryanskiy-1/+5
2024-01-12Revert "Auto merge of #118568 - DianQK:no-builtins-symbols, r=pnkfelix"DianQK-5/+0
This reverts commit 503e129328080e924c0ddfca6abf4c2812580102, reversing changes made to 0e7f91b75e7484a713e2f644212cfc1aa7478a28.
2024-01-12Auto merge of #119879 - matthiaskrgr:rollup-y710der, r=matthiaskrgrbors-17/+18
Rollup of 4 pull requests Successful merges: - #119781 (fix typo) - #119865 (Set `c_str_literals` stabilization version back to `CURRENT_RUSTC_VERSION`) - #119866 (Convert `effects` description to doc comment) - #119868 (Register even erroneous impls) r? `@ghost` `@rustbot` modify labels: rollup
2024-01-12Rollup merge of #119868 - oli-obk:unknown_lifetime_ice, r=compiler-errorsMatthias Krüger-17/+18
Register even erroneous impls Otherwise the specialization graph fails to pick it up, even though other code assumes that all impl blocks have an entry in the specialization graph. also includes an unrelated cleanup of the specialization graph query fixes #119827
2024-01-12Auto merge of #119735 - lcnr:provisional-cache-readd, r=compiler-errorsbors-0/+4
next solver: provisional cache this adds the cache removed in #115843. However, it should now correctly track whether a provisional result depends on an inductive or coinductive stack. While working on this, I was using the following doc: https://hackmd.io/VsQPjW3wSTGUSlmgwrDKOA. I don't think it's too helpful to understanding this, but am somewhat hopeful that the inline comments are more useful. There are quite a few future perf improvements here. Given that this is already very involved I don't believe it is worth it (for now). While working on this PR one of my few attempts to significantly improve perf ended up being unsound again because I was not careful enough :sparkles: r? `@compiler-errors`
2024-01-11Register even erroneous implsOli Scherer-5/+3
Otherwise the specialization graph fails to pick it up, even though other code assumes that all impl blocks have an entry in the specialization graph.
2024-01-11`specialization_graph_of`'s `errored` field is used in the only call site, ↵Oli Scherer-12/+15
and used to immediately throw away the rest of the value. Let's use `Result` to statically signal that this is happening
2024-01-11coverage: Add enums to accommodate other kinds of coverage mappingsZalathar-10/+28
2024-01-11Rollup merge of #119763 - nnethercote:cleanup-Diagnostic, r=oli-obkMatthias Krüger-8/+6
Cleanup things in and around `Diagnostic` These changes all arose when I was looking closely at how to simplify `DiagCtxtInner::emit_diagnostic`. r? `@compiler-errors`
2024-01-11Rollup merge of #118915 - compiler-errors:alias-nits, r=lcnrMatthias Krüger-3/+3
Add some comments, add `can_define_opaque_ty` check to `try_normalize_ty_recur` Follow-up from #117278, since I was recently re-reviewing this code.
2024-01-11Change how `force-warn` lint diagnostics are recorded.Nicholas Nethercote-8/+6
`is_force_warn` is only possible for diagnostics with `Level::Warning`, but it is currently stored in `Diagnostic::code`, which every diagnostic has. This commit: - removes the boolean `DiagnosticId::Lint::is_force_warn` field; - adds a `ForceWarning` variant to `Level`. Benefits: - The common `Level::Warning` case now has no arguments, replacing lots of `Warning(None)` occurrences. - `rustc_session::lint::Level` and `rustc_errors::Level` are more similar, both having `ForceWarning` and `Warning`.
2024-01-10Simplify some redundant namesMichael Goulet-3/+3
2024-01-10Rename consuming chaining methods on `DiagnosticBuilder`.Nicholas Nethercote-3/+3
In #119606 I added them and used a `_mv` suffix, but that wasn't great. A `with_` prefix has three different existing uses. - Constructors, e.g. `Vec::with_capacity`. - Wrappers that provide an environment to execute some code, e.g. `with_session_globals`. - Consuming chaining methods, e.g. `Span::with_{lo,hi,ctxt}`. The third case is exactly what we want, so this commit changes `DiagnosticBuilder::foo_mv` to `DiagnosticBuilder::with_foo`. Thanks to @compiler-errors for the suggestion.
2024-01-10Add `DiagCtxt::delayed_bug`.Nicholas Nethercote-6/+3
We have `span_delayed_bug` and often pass it a `DUMMY_SP`. This commit adds `delayed_bug`, which matches pairs like `err`/`span_err` and `warn`/`span_warn`.
2024-01-10Rename `struct_span_err!` as `struct_span_code_err!`.Nicholas Nethercote-3/+3
Because it takes an error code after the span. This avoids the confusing overlap with the `DiagCtxt::struct_span_err` method, which doesn't take an error code.
2024-01-09Rollup merge of #119699 - cjgillot:simplify-unreachable, r=oli-obkGuillaume Gomez-0/+1
Merge dead bb pruning and unreachable bb deduplication. Both routines share the same basic structure: iterate on all bbs to identify work, and then renumber bbs. We can do both at once.
2024-01-09readd the provisional cachelcnr-0/+4
2024-01-09Auto merge of #117703 - compiler-errors:recursive-async, r=lcnrbors-32/+197
Support async recursive calls (as long as they have indirection) Before #101692, we stored coroutine witness types directly inside of the coroutine. That means that a coroutine could not contain itself (as a witness field) without creating a cycle in the type representation of the coroutine, which we detected with the `OpaqueTypeExpander`, which is used to detect cycles when expanding opaque types after that are inferred to contain themselves. After `-Zdrop-tracking-mir` was stabilized, we no longer store these generator witness fields directly, but instead behind a def-id based query. That means there is no technical obstacle in the compiler preventing coroutines from containing themselves per se, other than the fact that for a coroutine to have a non-infinite layout, it must contain itself wrapped in a layer of allocation indirection (like a `Box`). This means that it should be valid for this code to work: ``` async fn async_fibonacci(i: u32) -> u32 { if i == 0 || i == 1 { i } else { Box::pin(async_fibonacci(i - 1)).await + Box::pin(async_fibonacci(i - 2)).await } } ``` Whereas previously, you'd need to coerce the future to `Pin<Box<dyn Future<Output = ...>>` before `await`ing it, to prevent the async's desugared coroutine from containing itself across as await point. This PR does two things: 1. Only report an error if an opaque expansion cycle is detected *not* through coroutine witness fields. * Instead, if we find an opaque cycle through coroutine witness fields, we compute the layout of the coroutine. If that results in a cycle error, we report it as a recursive async fn. 4. Reworks the way we report layout errors having to do with coroutines, to make up for the diagnostic regressions introduced by (1.). We actually do even better now, pointing out the call sites of the recursion!
2024-01-09Rollup merge of #119725 - compiler-errors:has_effect_param, r=fmeaseMatthias Krüger-1/+8
Add helper for when we want to know if an item has a host param r? ````@fmease```` since you're a good reviewer and no good deed goes unpunished This helper will see far more usages as built-in traits get constified.
2024-01-09Rollup merge of #118903 - azhogin:azhogin/skip_second_stmt_debuginfo.rs, ↵Matthias Krüger-11/+11
r=petrochenkov Improved support of collapse_debuginfo attribute for macros. Added walk_chain_collapsed function to consider collapse_debuginfo attribute in parent macros in call chain. Fixed collapse_debuginfo attribute processing for cranelift (there was if/else branches error swap). cc https://github.com/rust-lang/rust/issues/100758
2024-01-08Last nitsMichael Goulet-9/+31
2024-01-08Make cycle error more resilient to where it startsMichael Goulet-62/+69
Also don't recomment recursive_async crate anymore Co-authored-by: lcnr <rust@lcnr.de>
2024-01-08Only compute layout of opaque if coroutine is the cause of an opaque cycleMichael Goulet-1/+24
2024-01-08Point out source of recursionMichael Goulet-16/+87