about summary refs log tree commit diff
path: root/compiler
AgeCommit message (Collapse)AuthorLines
2023-12-04Inline and remove more `DiagnosticBuilder::new_diagnostic_*` functions.Nicholas Nethercote-83/+28
They each have a single call site. Note: the `make_diagnostic_builder` calls in `lib.rs` will be replaced in a subsequent commit.
2023-12-04Auto merge of #118490 - Nadrieril:arena-alloc-matrix, r=nnethercotebors-31/+33
Exhaustiveness: allocate memory better Exhaustiveness is a recursive algorithm that allocates a bunch of slices at every step. Let's see if I can improve performance by improving allocations. Already just using `Vec::with_capacity` is showing impressive improvements on my local measurements. r? `@ghost`
2023-12-04Inline and remove `DiagnosticBuilder::new_diagnostic_*` functions.Nicholas Nethercote-24/+0
They each have a single call site.
2023-12-04Give `Handler::fatal` and `Session::fatal` the same return type.Nicholas Nethercote-8/+9
Currently, `Handler::fatal` returns `FatalError`. But `Session::fatal` returns `!`, because it calls `Handler::fatal` and then calls `raise` on the result. This inconsistency is unfortunate. This commit changes `Handler::fatal` to do the `raise` itself, changing its return type to `!`. This is safe because there are only two calls to `Handler::fatal`, one in `rustc_session` and one in `rustc_codegen_cranelift`, and they both call `raise` on the result. `HandlerInner::fatal` still returns `FatalError`, so I renamed it `fatal_no_raise` to emphasise the return type difference.
2023-12-04dedup for duplicate suggestionsbohan-4/+5
2023-12-04Document reentrancy in `*Arena::alloc_from_iter`Nadrieril-16/+25
2023-12-03Auto merge of #117840 - RalfJung:miri-promise-align, r=cjgillotbors-16/+22
miri: support 'promising' alignment for symbolic alignment check Then use that ability in `slice::align_to`, so that even with `-Zmiri-symbolic-alignment-check`, it no longer has to return spuriously empty "middle" parts. Fixes https://github.com/rust-lang/miri/issues/3068
2023-12-03Auto merge of #118579 - matthiaskrgr:rollup-22kn8sa, r=matthiaskrgrbors-6/+14
Rollup of 3 pull requests Successful merges: - #117869 ([rustdoc] Add highlighting for comments in items declaration) - #118525 (coverage: Skip spans that can't be un-expanded back to the function body) - #118574 (rustc_session: Address all `rustc::potential_query_instability` lints) r? `@ghost` `@rustbot` modify labels: rollup
2023-12-03miri: support 'promising' alignment for symbolic alignment checkRalf Jung-16/+22
2023-12-03Rollup merge of #118574 - Enselic:query-instability, r=cjgillotMatthias Krüger-1/+7
rustc_session: Address all `rustc::potential_query_instability` lints Instead of allowing `rustc::potential_query_instability` on the whole crate we go over each lint and allow it individually if it is safe to do. Turns out all instances were safe to allow in this crate. Part of #84447 which is **E-help-wanted**.
2023-12-03Rollup merge of #118525 - Zalathar:skip-spans, r=cjgillotMatthias Krüger-5/+7
coverage: Skip spans that can't be un-expanded back to the function body When we extract coverage spans from MIR, we try to "un-expand" them back to spans that are inside the function's body span. In cases where that doesn't succeed, the current code just swaps in the entire body span instead. But that tends to result in coverage spans that are completely unrelated to the control flow of the affected code, so it's better to just discard those spans. --- Extracted from #118305, since this is a general improvement that isn't specific to branch coverage. --- `@rustbot` label +A-code-coverage
2023-12-03Auto merge of #118072 - estebank:issue-98982, r=cjgillotbors-13/+86
Provide structured suggestion for type mismatch in loop We currently provide only a `help` message, this PR introduces the last two structured suggestions instead: ``` error[E0308]: mismatched types --> $DIR/issue-98982.rs:2:5 | LL | fn foo() -> i32 { | --- expected `i32` because of return type LL | / for i in 0..0 { LL | | return i; LL | | } | |_____^ expected `i32`, found `()` | note: the function expects a value to always be returned, but loops might run zero times --> $DIR/issue-98982.rs:2:5 | LL | for i in 0..0 { | ^^^^^^^^^^^^^ this might have zero elements to iterate on LL | return i; | -------- if the loop doesn't execute, this value would never get returned help: return a value for the case when the loop has zero elements to iterate on | LL ~ } LL ~ /* `i32` value */ | help: otherwise consider changing the return type to account for that possibility | LL ~ fn foo() -> Option<i32> { LL | for i in 0..0 { LL ~ return Some(i); LL ~ } LL ~ None | ``` Fix #98982.
2023-12-03Auto merge of #113730 - belovdv:jobserver-init-check, r=petrochenkovbors-32/+85
Report errors in jobserver inherited through environment variables This pr attempts to catch situations, when jobserver exists, but is not being inherited. r? `@petrochenkov`
2023-12-03Auto merge of #118526 - sjwang05:issue-118510, r=petrochenkovbors-2/+9
Fix ICE: `fn_arg_names: unexpected item DefId(..)` Fixes #118510
2023-12-03rustc_session: Address all `rustc::potential_query_instability` lintsMartin Nordholts-1/+7
Instead of allowing `rustc::potential_query_instability` on the whole crate we go over each lint and allow it individually if it is safe to do. Turns out all instances were safe to allow in this crate.
2023-12-03rustc: Harmonize `DefKind` and `DefPathData`Vadim Petrochenkov-132/+133
`DefPathData::(ClosureExpr,ImplTrait)` are renamed to match `DefKind::(Closure,OpaqueTy)`. `DefPathData::ImplTraitAssocTy` is replaced with `DefPathData::TypeNS(kw::Empty)` because both correspond to `DefKind::AssocTy`. It's possible that introducing `(DefKind,DefPathData)::AssocOpaqueTy` could be a better solution, but that would be a much more invasive change. Const generic parameters introduced for effects are moved from `DefPathData::TypeNS` to `DefPathData::ValueNS`, because constants are values. `DefPathData` is no longer passed to `create_def` functions to avoid redundancy.
2023-12-03compiler: replace cstr macro with c str literals in compiler and few other c ↵klensy-59/+42
str replacements
2023-12-03Disallow arm bodies on never patternsNadrieril-8/+27
2023-12-03Disallow guards on never patternsNadrieril-2/+17
2023-12-03Disallow an arm without a body (except for never patterns)Nadrieril-5/+42
Parsing now accepts a match arm without a body, so we must make sure to only accept that if the pattern is a never pattern.
2023-12-03Detect attempts to expand a macro to a match arm againNadrieril-29/+25
Because a macro invocation can expand to a never pattern, we can't rule out a `arm!(),` arm at parse time. Instead we detect that case at expansion time, if the macro tries to output a pattern followed by `=>`.
2023-12-03Parse a pattern with no armNadrieril-151/+221
2023-12-03interpret: make numeric_intrinsic accessible from MiriRalf Jung-46/+36
2023-12-03codegen, miri: fix computing the offset of an unsized field in a packed structRalf Jung-11/+23
2023-12-03more targeted errors when extern types end up in places they should notRalf Jung-0/+22
2023-12-03Auto merge of #118542 - chenyukang:yukang-fix-parser-ice-118531, r=cjgillotbors-12/+4
Fix parser ICE from attrs Fixes #118531, Fixes #118530.
2023-12-03coverage: Skip spans that can't be un-expanded back to the function bodyZalathar-5/+7
When we extract coverage spans from MIR, we try to "un-expand" them back to spans that are inside the function's body span. In cases where that doesn't succeed, the current code just swaps in the entire body span instead. But that tends to result in coverage spans that are completely unrelated to the control flow of the affected code, so it's better to just discard those spans.
2023-12-02Fix ICE when suggesting closures for non-fn-like defssjwang05-2/+9
2023-12-02Avoid per-register closure expansionsMark Rousskov-58/+63
2023-12-02Rollup merge of #118524 - celinval:smir-instance-def, r=ouz-aMatthias Krüger-19/+107
Add more information to StableMIR Instance Allow stable MIR users to retrieve an instance function signature, the index for a VTable instance and more information about its underlying definition. These are needed to properly interpret function calls, either via VTable or direct calls. The `CrateDef` implementation will also allow users to emit diagnostic messages. I also fixed a few issues that we had identified before with how we were retrieving body of things that may not have a body available.
2023-12-02Rollup merge of #118514 - Enselic:ice-probe, r=cjgillotMatthias Krüger-3/+4
rustc_hir_typeck: Fix ICE when probing for non-ASCII function alternative Closes #118499 Apparently triggered by https://github.com/rust-lang/rust/pull/118381
2023-12-02Implement repr(packed) for repr(simd)Caleb Zulawski-3/+24
2023-12-02Fix parser ICE from attrsyukang-12/+4
2023-12-02Add diagnostic item to PartialEq::{eq,ne}Urgau-0/+2
2023-12-02Auto merge of #117912 - GeorgeWort:master, r=petrochenkovbors-6/+27
Name explicit registers in conflict register errors for inline assembly
2023-12-02fix an ICE when a valtree failed to evaluateRalf Jung-2/+10
2023-12-02Auto merge of #117754 - matthewjasper:subtype-overflow, r=lcnrbors-5/+30
Handle recursion limit for subtype and well-formed predicates Adds a recursion limit check for subtype predicates and well-formed predicates. `-Ztrait-solver=next` currently panics with unimplemented for these cases. These cases are arguably bugs in the occurs check but: - I could not find a simple way to fix the occurs check - There should still be a recursion limit check to prevent hangs anyway. closes #117151 r? types
2023-12-02Auto merge of #118470 - nnethercote:cleanup-error-handlers, r=compiler-errorsbors-486/+464
Cleanup error handlers Mostly by making function naming more consistent. More to do after this, but this is enough for one PR. r? compiler-errors
2023-12-02Anticipate allocation sizesNadrieril-15/+8
2023-12-01Add more information to stable InstanceCelina G. Val-19/+107
- Retrieve `FnSig`. - Implement CrateDef for InstanceDef. - Add VTable index for Virtual instances.
2023-12-01Attempt to try to resolve blocking concernsCaio-32/+335
2023-12-02Auto merge of #118175 - lqd:unify-live-loans, r=matthewjasperbors-102/+98
Centralize live loans maintenance to fix scope differences due to liveness As found in the recent [polonius crater run](https://github.com/rust-lang/rust/pull/117593#issuecomment-1801398892), NLLs and the location-insensitive polonius computed different scopes on some specific CFG shapes, e.g. the following. ![image](https://github.com/rust-lang/rust/assets/247183/c3649f5e-3058-454e-854e-1a6b336bdd5e) I had missed that liveness data was pushed from different sources than just the liveness computation: there are a few places that do this -- and some of them may be unneeded or at the very least untested, as no tests changed when I tried removing some of them. Here, `_6` is e.g. dead on entry to `bb2[0]` during `liveness::trace`, but its regions will be marked as live later during "constraint generation" (which I plan to refactor away and put in the liveness module soon). This should cause the inflowing loans to be marked live, but they were only computed in `liveness::trace`. Therefore, this PR moves live loan maintenance to `LivenessValues`, so that the various places pushing liveness data will all also update live loans at the same time -- except for promoteds which I don't believe need them, and their liveness handling is already interesting/peculiar. All the regressions I saw in the initial crater run were related to this kind of shapes, and this change did fix all of them on the [next run](https://github.com/rust-lang/rust/pull/117593#issuecomment-1826132145). r? `@matthewjasper` (This will conflict with #117880 but whichever lands first is fine by me, the end goal is the same for both)
2023-12-02Inline and remove `LoweringContext::handler()`.Nicholas Nethercote-6/+2
It has a single call site.
2023-12-02Remove unnecessary qualifiers.Nicholas Nethercote-3/+3
2023-12-02Use `Session::diagnostic` in more places.Nicholas Nethercote-40/+33
2023-12-02Use `Session::diagnostic` in more places.Nicholas Nethercote-66/+51
2023-12-02`Handler` tweaks.Nicholas Nethercote-8/+6
- Avoid unnecessary `inner` local variables. - Use `borrow_mut` everywhere (instead of the synonym `lock`).
2023-12-02Rename `LayoutCalculator::delay_bug` as `LayoutCalculator::delayed_bug`.Nicholas Nethercote-4/+4
To match with the previous commits.
2023-12-02Rename `Handler::delay_good_path_bug` as `Handler::good_path_delayed_bug`.Nicholas Nethercote-25/+28
In line with the previous commits.
2023-12-02Rename `HandlerInner::delayed_span_bugs` as `HandlerInner::span_delayed_bugs`.Nicholas Nethercote-21/+21
For reasons similar to the previous commit.