about summary refs log tree commit diff
path: root/compiler/rustc_mir_build/src
AgeCommit message (Collapse)AuthorLines
2024-01-31Auto merge of #120346 - petrochenkov:ownodes, r=oli-obkbors-1/+1
hir: Refactor getters for owner nodes
2024-01-30hir: Remove `hir::Map::{owner,expect_owner}`Vadim Petrochenkov-1/+1
2024-01-30Rollup merge of #120488 - nnethercote:diag-lifetimes, r=oli-obkGuillaume Gomez-30/+39
Diagnostic lifetimes cleanups Some diagnostic simplifications. r? `@oli-obk`
2024-01-30Remove lifetimes from some diagnostics.Nicholas Nethercote-18/+18
Because the `&'a str` fields can be trivially converted to `String` without causing any extra allocations.
2024-01-30Remove the lifetime from `DiagnosticArgValue`.Nicholas Nethercote-12/+21
Because it's almost always static. This makes `impl IntoDiagnosticArg for DiagnosticArgValue` trivial, which is nice. There are a few diagnostics constructed in `compiler/rustc_mir_build/src/check_unsafety.rs` and `compiler/rustc_mir_transform/src/errors.rs` that now need symbols converted to `String` with `to_string` instead of `&str` with `as_str`, but that' no big deal, and worth it for the simplifications elsewhere.
2024-01-29Rollup merge of #120390 - matthewjasper:inline-constant-pat-mir, r=davidtwcoDylan DPC-2/+35
Borrow check inline const patterns Add type annotations to MIR so that borrowck can pass constraints from inline constants in patterns to the containing function. Also enables some inline constant pattern tests that were fixed by the THIR unsafeck stabilization. cc #76001
2024-01-29Borrow check inline const patternsMatthew Jasper-2/+35
Add type annotations to MIR so that borrowck can pass constraints from inline constants in patterns to the containing function.
2024-01-29Stop using `String` for error codes.Nicholas Nethercote-35/+35
Error codes are integers, but `String` is used everywhere to represent them. Gross! This commit introduces `ErrCode`, an integral newtype for error codes, replacing `String`. It also introduces a constant for every error code, e.g. `E0123`, and removes the `error_code!` macro. The constants are imported wherever used with `use rustc_errors::codes::*`. With the old code, we have three different ways to specify an error code at a use point: ``` error_code!(E0123) // macro call struct_span_code_err!(dcx, span, E0123, "msg"); // bare ident arg to macro call \#[diag(name, code = "E0123")] // string struct Diag; ``` With the new code, they all use the `E0123` constant. ``` E0123 // constant struct_span_code_err!(dcx, span, E0123, "msg"); // constant \#[diag(name, code = E0123)] // constant struct Diag; ``` The commit also changes the structure of the error code definitions: - `rustc_error_codes` now just defines a higher-order macro listing the used error codes and nothing else. - Because that's now the only thing in the `rustc_error_codes` crate, I moved it into the `lib.rs` file and removed the `error_codes.rs` file. - `rustc_errors` uses that macro to define everything, e.g. the error code constants and the `DIAGNOSTIC_TABLES`. This is in its new `codes.rs` file.
2024-01-26remove illegal_floating_point_literal_pattern lintRalf Jung-13/+3
2024-01-26make matching on NaN a hard errorRalf Jung-11/+33
2024-01-26Classify closure arguments in refutable pattern in argument errorDeadbeef-1/+10
2024-01-25Remove unused featuresclubby789-1/+0
2024-01-25Clarify the new binding danceNadrieril-44/+20
2024-01-25Put new bindings first in refutable cases tooNadrieril-4/+4
2024-01-25Clarify the binding danceNadrieril-22/+41
2024-01-25Move `Or` test out of the loopNadrieril-22/+26
2024-01-23Rollup merge of #120171 - cjgillot:jump-threading-assume-assert, r=tmiaskoLeón Orell Valerian Liehr-0/+4
Fix assume and assert in jump threading r? ``@tmiasko``
2024-01-22Add Assume custom MIR.Camille GILLOT-0/+4
2024-01-23Rename `TyCtxt::emit_spanned_lint` as `TyCtxt::emit_node_span_lint`.Nicholas Nethercote-25/+25
2024-01-22Auto merge of #120242 - matthiaskrgr:rollup-a93yj3i, r=matthiaskrgrbors-39/+49
Rollup of 10 pull requests Successful merges: - #117910 (Refactor uses of `objc_msgSend` to no longer have clashing definitions) - #118639 (Undeprecate lint `unstable_features` and make use of it in the compiler) - #119801 (Fix deallocation with wrong allocator in (A)Rc::from_box_in) - #120058 (bootstrap: improvements for compiler builds) - #120059 (Make generic const type mismatches not hide trait impls from the trait solver) - #120097 (Report unreachable subpatterns consistently) - #120137 (Validate AggregateKind types in MIR) - #120164 (`maybe_lint_impl_trait`: separate `is_downgradable` from `is_object_safe`) - #120181 (Allow any `const` expression blocks in `thread_local!`) - #120218 (rustfmt: Check that a token can begin a nonterminal kind before parsing it as a macro arg) r? `@ghost` `@rustbot` modify labels: rollup
2024-01-22Rollup merge of #120097 - Nadrieril:consistent_unreachable_subpats, ↵Matthias Krüger-39/+49
r=compiler-errors Report unreachable subpatterns consistently We weren't reporting unreachable subpatterns in function arguments and `let` expressions. This wasn't very important, but never patterns make it more relevant: a user might write `let (Ok(x) | Err(!)) = ...` in a case where `let Ok(x) = ...` is accepted, so we should report the `Err(!)` as redundant. r? ```@compiler-errors```
2024-01-22Rollup merge of #119948 - asquared31415:unsafe_op_in_unsafe_fn_fix, r=TaKO8KiMatthias Krüger-1/+1
Make `unsafe_op_in_unsafe_fn` migrated in edition 2024 fixes rust-lang/rust#119823
2024-01-22Auto merge of #120080 - cuviper:128-align-packed, r=nikicbors-2/+2
Pack u128 in the compiler to mitigate new alignment This is based on #116672, adding a new `#[repr(packed(8))]` wrapper on `u128` to avoid changing any of the compiler's size assertions. This is needed in two places: * `SwitchTargets`, otherwise its `SmallVec<[u128; 1]>` gets padded up to 32 bytes. * `LitKind::Int`, so that entire `enum` can stay 24 bytes. * This change definitely has far-reaching effects though, since it's public.
2024-01-20Remove Ty: Copy boundNadrieril-1/+1
2024-01-19Pack the u128 in LitKind::IntJosh Stone-2/+2
2024-01-19Rollup merge of #120009 - Nadrieril:never_patterns_tyck, r=compiler-errorsMatthias Krüger-0/+26
never_patterns: typecheck never patterns This checks that a `!` pattern is only used on an uninhabited type (modulo match ergonomics, i.e. `!` is allowed on `&Void`). r? `@compiler-errors`
2024-01-19Rollup merge of #119835 - Nadrieril:simplify-empty-logic, r=compiler-errorsMatthias Krüger-1/+2
Exhaustiveness: simplify empty pattern logic The logic that handles empty patterns had gotten quite convoluted. This PR simplifies it a lot. I tried to make the logic as easy as possible to follow; this only does logically equivalent changes. The first commit is a drive-by comment clarification that was requested after another PR a while back. r? `@compiler-errors`
2024-01-18Typecheck never patternsNadrieril-0/+26
2024-01-18Consistently warn unreachable subpatternsNadrieril-31/+37
2024-01-18Consistently set `MatchVisitor.error` on errorNadrieril-12/+16
2024-01-17Add `PatKind::Err`Lieselotte-0/+2
2024-01-16Auto merge of #116520 - Enselic:large-copy-into-fn, r=oli-obkbors-10/+26
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-37/+19
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-15make unsafe_op_in_unsafe_fn MachineApplicable and add it to 2024 compatibilityasquared31415-1/+1
2024-01-15compiler: Lower fn call arg spans down to MIRMartin Nordholts-10/+26
To enable improved accuracy of diagnostics in upcoming commits.
2024-01-15Clarify that the status of `&!` is undecidedNadrieril-1/+2
2024-01-15Rollup merge of #119971 - compiler-errors:zip-eq, r=nnethercoteMatthias Krüger-3/+5
Use `zip_eq` to enforce that things being zipped have equal sizes Some `zip`s are best enforced to be equal, since size mismatches suggest deeper bugs in the compiler.
2024-01-14Use zip_eq to enforce that things being zipped have equal sizesMichael Goulet-2/+3
2024-01-14Closure body was being built incorrectly on error...Michael Goulet-1/+2
2024-01-14Simplify closure_env_ty and closure_env_paramMichael Goulet-37/+19
2024-01-11Rollup merge of #119715 - Nadrieril:graceful-type-error, r=compiler-errorsMatthias Krüger-2/+8
Exhaustiveness: abort on type error This adds an error path to exhaustiveness checking so that we abort instead of ICEing when encountering a stray `ty::Error`. Fixes https://github.com/rust-lang/rust/issues/119493 Fixes https://github.com/rust-lang/rust/issues/119778 r? `@compiler-errors`
2024-01-10Add `DiagCtxt::delayed_bug`.Nicholas Nethercote-34/+33
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-2/+4
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-09Don't mix combinators and `let else`Nadrieril-3/+6
Co-authored-by: Michael Goulet <michael@errs.io>
2024-01-07Add an error path to the algorithmNadrieril-2/+5
2024-01-06Don't populate yield and resume types after the factMichael Goulet-65/+65
2024-01-06Auto merge of #119329 - Nadrieril:reveal-opaques-early, r=compiler-errorsbors-4/+4
Exhaustiveness: Statically enforce revealing of opaques In https://github.com/rust-lang/rust/pull/116821 it was decided that exhaustiveness should operate on the hidden type of an opaque type when relevant. This PR makes sure we consistently reveal opaques within exhaustiveness. This makes it possible to remove `reveal_opaque_ty` from the `TypeCx` trait which was an unfortunate implementation detail. r? `@compiler-errors`
2024-01-05Rollup merge of #119563 - compiler-errors:coroutine-resume, r=oli-obkMatthias Krüger-10/+17
Check yield terminator's resume type in borrowck In borrowck, we didn't check that the lifetimes of the `TerminatorKind::Yield`'s `resume_place` were actually compatible with the coroutine's signature. That means that the lifetimes were totally going unchecked. Whoops! This PR implements this checking. Fixes #119564 r? types
2024-01-05Rollup merge of #119554 - matthewjasper:remove-guard-distinction, ↵Matthias Krüger-67/+69
r=compiler-errors Fix scoping for let chains in match guards If let guards were previously represented as a different type of guard in HIR and THIR. This meant that let chains in match guards were not handled correctly because they were treated exactly like normal guards. - Remove `hir::Guard` and `thir::Guard`. - Make the scoping different between normal guards and if let guards also check for let chains. closes #118593
2024-01-05Rollup merge of #119538 - nnethercote:cleanup-errors-5, r=compiler-errorsMichael Goulet-4/+4
Cleanup error handlers: round 5 More rustc_errors cleanups. A sequel to https://github.com/rust-lang/rust/pull/119171. r? ````@compiler-errors````