about summary refs log tree commit diff
path: root/compiler/rustc_middle/src/thir.rs
AgeCommit message (Collapse)AuthorLines
2024-04-23Rollup merge of #122598 - Nadrieril:full-derefpats, r=matthewjasperLeón Orell Valerian Liehr-2/+3
deref patterns: lower deref patterns to MIR This lowers deref patterns to MIR. This is a bit tricky because this is the first kind of pattern that requires storing a value in a temporary. Thanks to https://github.com/rust-lang/rust/pull/123324 false edges are no longer a problem. The thing I'm not confident about is the handling of fake borrows. This PR ignores any fake borrows inside a deref pattern. We are guaranteed to at least fake borrow the place of the first pointer value, which could be enough, but I'm not certain.
2024-04-20Track mutability of deref patternsNadrieril-2/+3
2024-04-20PatRangeBoundary::compare_with: als add a fast-path for signed integersRalf Jung-5/+8
2024-04-19Auto merge of #124113 - RalfJung:interpret-scalar-ops, r=oli-obkbors-10/+9
interpret: use ScalarInt for bin-ops; avoid PartialOrd for ScalarInt Best reviewed commit-by-commit r? `@oli-obk`
2024-04-19avoid PartialOrd on ScalarIntRalf Jung-10/+9
we don't know their sign so we cannot, in general, order them properly
2024-04-18Auto merge of #124008 - nnethercote:simpler-static_assert_size, r=Nilstriebbors-1/+1
Simplify `static_assert_size`s. We want to run them on all 64-bit platforms. r? `@ghost`
2024-04-18Simplify `static_assert_size`s.Nicholas Nethercote-1/+1
We want to run them on all 64-bit platforms.
2024-04-17Rename `BindingAnnotation` to `BindingMode`Jules Bertholet-6/+3
2024-04-16Avoid lots of `hir::HirId{,Map,Set}` qualifiers.Nicholas Nethercote-7/+7
Because they're a bit redundant.
2024-04-03Rollup merge of #123401 - Zalathar:assert-size-aarch64, r=fmeaseJacob Pratt-1/+1
Check `x86_64` size assertions on `aarch64`, too (Context: https://rust-lang.zulipchat.com/#narrow/stream/131828-t-compiler/topic/Checking.20size.20assertions.20on.20aarch64.3F) Currently the compiler has around 30 sets of `static_assert_size!` for various size-critical data structures (e.g. various IR nodes), guarded by `#[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))]`. (Presumably this cfg avoids having to maintain separate size values for 32-bit targets and unusual 64-bit targets. Apparently it may have been necessary before the i128/u128 alignment changes, too.) This is slightly incovenient for people on aarch64 workstations (e.g. Macs), because the assertions normally aren't checked until we push to a PR. So this PR adds `aarch64` to the `#[cfg(..)]` guarding all of those assertions in the compiler. --- Implemented with a simple find/replace. Verified by manually inspecting each `static_assert_size!` in `compiler/`, and checking that either the replacement succeeded, or adding aarch64 wouldn't have been appropriate.
2024-04-03Rollup merge of #123301 - Nadrieril:unions, r=compiler-errorsMatthias Krüger-1/+2
pattern analysis: fix union handling Little known fact: rust supports union patterns. Exhaustiveness handles them soundly but reports nonsensical missing patterns. This PR fixes the reported patterns and documents what we're doing. r? `@compiler-errors`
2024-04-03Check `x86_64` size assertions on `aarch64`, tooZalathar-1/+1
This makes it easier for contributors on aarch64 workstations (e.g. Macs) to notice when these assertions have been violated.
2024-04-02Fix suggestions for match non-exhaustivenessMichael Goulet-1/+2
2024-04-01Fix union handling in exhaustivenessNadrieril-1/+2
2024-03-29Auto merge of #123080 - Jules-Bertholet:mut-ref-mut, r=Nadrierilbors-26/+13
Match ergonomics 2024: implement mutable by-reference bindings Implements the mutable by-reference bindings portion of match ergonomics 2024 (#123076), with the `mut ref`/`mut ref mut` syntax, under feature gate `mut_ref`. r? `@Nadrieril` `@rustbot` label A-patterns A-edition-2024
2024-03-27Int constants must be valtrees in pattern loweringOli Scherer-5/+1
2024-03-27Remove `Ord` from `Ty`, `Const`, and `Region`Oli Scherer-1/+5
2024-03-27Implement `mut ref`/`mut ref mut`Jules Bertholet-26/+13
2024-03-21Implement macro-based deref!() syntax for deref patternsMichael Goulet-1/+1
Stop using `box PAT` syntax for deref patterns, as it's misleading and also causes their semantics being tangled up.
2024-03-20Add barest-bones deref patternsNadrieril-0/+9
Co-authored-by: Deadbeef <ent3rm4n@gmail.com>
2024-03-15Docs for `thir::ExprKind::Use` and `thir::ExprKind::Let`Zalathar-1/+12
2024-03-11Rename `IntoDiagnosticArg` as `IntoDiagArg`.Nicholas Nethercote-4/+4
Also rename `into_diagnostic_arg` as `into_diag_arg`, and `NotIntoDiagnosticArg` as `NotInotDiagArg`.
2024-03-08Rollup merge of #119365 - nbdd0121:asm-goto, r=AmanieuMatthias Krüger-0/+3
Add asm goto support to `asm!` Tracking issue: #119364 This PR implements asm-goto support, using the syntax described in "future possibilities" section of [RFC2873](https://rust-lang.github.io/rfcs/2873-inline-asm.html#asm-goto). Currently I have only implemented the `label` part, not the `fallthrough` part (i.e. fallthrough is implicit). This doesn't reduce the expressive though, since you can use label-break to get arbitrary control flow or simply set a value and rely on jump threading optimisation to get the desired control flow. I can add that later if deemed necessary. r? ``@Amanieu`` cc ``@ojeda``
2024-02-29Rollup merge of #121376 - Nadrieril:mir-half-ranges, r=pnkfelixGuillaume Gomez-16/+2
Skip unnecessary comparison with half-open range patterns This is the last remaining detail in the implementation of half-open range patterns. Until now, a half-open range pattern like `10..` was converted to `10..T::MAX` before lowering to MIR, which generated an extra pointless comparison. With this PR we don't generate it.
2024-02-28Rename `DiagnosticArg{,Map,Name,Value}` as `DiagArg{,Map,Name,Value}`.Nicholas Nethercote-2/+2
2024-02-27Document invariant in `thir::PatRange`Nadrieril-0/+2
2024-02-27Skip unnecessary comparison with half-open rangesNadrieril-16/+0
2024-02-24Add asm label support to THIRGary Guo-0/+3
2024-02-02Remove dead args from functionsMichael Goulet-1/+0
2024-01-30Remove the lifetime from `DiagnosticArgValue`.Nicholas Nethercote-1/+1
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-06Don't populate yield and resume types after the factMichael Goulet-2/+0
2024-01-05Remove `thir::Guard`Matthew Jasper-8/+1
Use Expr instead. Use `ExprKind::Let` to represent if let guards.
2023-12-04Don't include destruction scopes in THIRMatthew Jasper-4/+2
They are not used by anyone, and add memory/performance overhead.
2023-11-29Add `never_patterns` feature gateNadrieril-1/+10
2023-11-15Re-format code with new rustfmtMark Rousskov-1/+3
2023-11-01Auto merge of #114208 - GKFX:offset_of_enum, r=wesleywiserbors-1/+1
Support enum variants in offset_of! This MR implements support for navigating through enum variants in `offset_of!`, placing the enum variant name in the second argument to `offset_of!`. The RFC placed it in the first argument, but I think it interacts better with nested field access in the second, as you can then write things like ```rust offset_of!(Type, field.Variant.field) ``` Alternatively, a syntactic distinction could be made between variants and fields (e.g. `field::Variant.field`) but I'm not convinced this would be helpful. [RFC 3308 # Enum Support](https://rust-lang.github.io/rfcs/3308-offset_of.html#enum-support-offset_ofsomeenumstructvariant-field_on_variant) Tracking Issue #106655.
2023-10-31Update MIR tests for offset_ofGeorge Bateman-1/+0
2023-10-31Enums in offset_of: update based on est31, scottmcm & llogiq reviewGeorge Bateman-2/+2
2023-10-31Support enum variants in offset_of!George Bateman-2/+3
2023-10-27Propagate half-open ranges through THIRNadrieril-23/+49
2023-10-27Abstract over `PatRange` boundary valueNadrieril-10/+213
2023-10-25Auto merge of #116482 - matthewjasper:thir-unsafeck-inline-constants, r=b-naberbors-1/+21
Fix inline const pattern unsafety checking in THIR Fix THIR unsafety checking of inline constants. - Steal THIR in THIR unsafety checking (if enabled) instead of MIR lowering. - Represent inline constants in THIR patterns.
2023-10-20s/generator/coroutine/Oli Scherer-2/+2
2023-10-16Address review commentsMatthew Jasper-2/+13
Clean up code and add comments. Use InlineConstant to wrap range patterns.
2023-10-16Fix inline const pattern unsafety checking in THIRMatthew Jasper-1/+10
THIR unsafety checking was getting a cycle of function unsafety checking -> building THIR for the function -> evaluating pattern inline constants in the function -> building MIR for the inline constant -> checking unsafety of functions (so that THIR can be stolen) This is fixed by not stealing THIR when generating MIR but instead when unsafety checking. This leaves an issue with pattern inline constants not being unsafety checked because they are evaluated away when generating THIR. To fix that we now represent inline constants in THIR patterns and visit them in THIR unsafety checking.
2023-10-14Propagate pattern errors via a new `PatKind::Error` variantNadrieril-5/+26
Instead of via `Const::new_error`
2023-10-11Avoid emitting the non_exhaustive error if other errors already occurredOli Scherer-5/+8
2023-09-27Auto merge of #115887 - RalfJung:pat, r=oli-obkbors-6/+10
thir::pattern: update some comments and error type names Follow-up to [these comments](https://github.com/rust-lang/rust/pull/105750#pullrequestreview-1629697578). Please carefully fact-check, I'm new to this area of the compiler!
2023-09-21rename mir::Constant -> mir::ConstOperand, mir::ConstKind -> mir::ConstRalf Jung-5/+5
2023-09-16thir::pattern: update some comments and error type namesRalf Jung-6/+10