summary refs log tree commit diff
path: root/compiler/rustc_middle/src/mir/syntax.rs
AgeCommit message (Collapse)AuthorLines
2023-11-09rename `BorrowKind::Shallow` to `Fake`lcnr-2/+2
also adds some comments (cherry picked from commit 992d93f687c75f8f5ee69e0fb43bff509c7c9cb8)
2023-09-28Add a mir validation check to prevent OpaqueCast after analysis passes finishOli Scherer-0/+1
2023-09-24Add global value numbering pass.Camille GILLOT-1/+1
2023-09-21rename mir::Constant -> mir::ConstOperand, mir::ConstKind -> mir::ConstRalf Jung-15/+19
2023-09-19organize mir pretty.rs and move more things into it; move statement-related ↵Ralf Jung-1/+23
things out of mir/mod.rs
2023-08-24when terminating during unwinding, show the reason whyRalf Jung-3/+14
2023-08-20sync printing of MIR terminators with their new names (and dedup some to-str ↵Ralf Jung-2/+24
logic)
2023-08-20give some unwind-related terminators a more clear nameRalf Jung-4/+4
2023-07-14refactor(rustc_middle): Substs -> GenericArgMahdi Dibaiee-4/+4
2023-07-11update Operand::Move docsRalf Jung-4/+10
2023-07-07Rename `adjustment::PointerCast` and variants using it to `PointerCoercion`Nilstrieb-3/+3
It makes it sound like the `ExprKind` and `Rvalue` are supposed to represent all pointer related casts, when in reality their just used to share a some enum variants. Make it clear there these are only coercion to make it clear why only some pointer related "casts" are in the enum.
2023-06-20update comment on `MutBorrowKind::ClosureCapture`Ziru Niu-4/+7
2023-06-20merge `BorrowKind::Unique` into `BorrowKind::Mut`Ziru Niu-13/+11
2023-06-19Rollup merge of #112232 - fee1-dead-contrib:match-eq-const-msg, r=b-naberMichael Goulet-4/+28
Better error for non const `PartialEq` call generated by `match` Resolves #90237
2023-06-19Promote unchecked_add/sub/mul/shl/shr to mir::BinOpScott McMurray-0/+13
2023-06-19fix docDeadbeef-1/+1
2023-06-18Better error for non const `PartialEq` call generated by `match`Deadbeef-4/+28
2023-06-02Rollup merge of #112168 - scottmcm:lower-div-rem-unchecked-to-mir, r=oli-obkMichael Goulet-4/+9
Lower `unchecked_div`/`_rem` to MIR's `BinOp::Div`/`Rem` As described in <https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/mir/enum.BinOp.html#variant.Div>, the ordinary `BinOp`s for these are already UB for division by zero ([or overflow](https://llvm.org/docs/LangRef.html#sdiv-instruction), [demo](https://rust.godbolt.org/z/71e7P7Exh)), as MIR building is responsible for inserting code to panic for those cases regardless of whether the overflow checks are enabled. So we can lower these in the same arm that lowers `wrapping_add` to MIR `BinOp::Add` and such, as all these cases turn into ordinary `Rvalue::BinaryOp`s.
2023-06-01Clarify when MIR `Div`/`Rem` trigger UBScott McMurray-4/+9
2023-06-01Use translatable diagnostics in `rustc_const_eval`Deadbeef-1/+2
2023-05-29add FIXMElcnr-0/+5
2023-05-25Remove DesugaringKind::Replace.Camille GILLOT-1/+5
2023-05-17Drive-by cleanup: `debug::term_type` => `TerminatorKind::name`Maybe Waffle-0/+23
2023-05-01Box AssertKindBen Kimock-1/+1
2023-04-24Split `{Idx, IndexVec, IndexSlice}` into their own modulesMaybe Waffle-1/+1
2023-04-22Auto merge of #104844 - cjgillot:mention-eval-place, r=jackh726,RalfJungbors-3/+2
Evaluate place expression in `PlaceMention` https://github.com/rust-lang/rust/pull/102256 introduces a `PlaceMention(place)` MIR statement which keep trace of `let _ = place` statements from surface rust, but without semantics. This PR proposes to change the behaviour of `let _ =` patterns with respect to the borrow-checker to verify that the bound place is live. Specifically, consider this code: ```rust let _ = { let a = 5; &a }; ``` This passes borrowck without error on stable. Meanwhile, replacing `_` by `_: _` or `_p` errors with "error[E0597]: `a` does not live long enough", [see playground](https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=c448d25a7c205dc95a0967fe96bccce8). This PR *does not* change how `_` patterns behave with respect to initializedness: it remains ok to bind a moved-from place to `_`. The relevant test is `tests/ui/borrowck/let_underscore_temporary.rs`. Crater check found no regression. For consistency, this PR changes miri to evaluate the place found in `PlaceMention`, and report eventual dangling pointers found within it. r? `@RalfJung`
2023-04-21Actually keep `PlaceMention` if requested.Camille GILLOT-2/+0
2023-04-21Evaluate place expression in `PlaceMention`.Camille GILLOT-1/+2
2023-04-21intern offsetof fieldsDrMeepster-4/+4
2023-04-21offset_ofDrMeepster-2/+4
2023-04-17Spelling - compilerJosh Soref-2/+2
* account * achieved * advising * always * ambiguous * analysis * annotations * appropriate * build * candidates * cascading * category * character * clarification * compound * conceptually * constituent * consts * convenience * corresponds * debruijn * debug * debugable * debuggable * deterministic * discriminant * display * documentation * doesn't * ellipsis * erroneous * evaluability * evaluate * evaluation * explicitly * fallible * fulfill * getting * has * highlighting * illustrative * imported * incompatible * infringing * initialized * into * intrinsic * introduced * javascript * liveness * metadata * monomorphization * nonexistent * nontrivial * obligation * obligations * offset * opaque * opportunities * opt-in * outlive * overlapping * paragraph * parentheses * poisson * precisely * predecessors * predicates * preexisting * propagated * really * reentrant * referent * responsibility * rustonomicon * shortcircuit * simplifiable * simplifications * specify * stabilized * structurally * suggestibility * translatable * transmuting * two * unclosed * uninhabited * visibility * volatile * workaround Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>
2023-04-06Address review feedbackGary Guo-3/+1
2023-04-06Rename `Abort` terminator to `Terminate`Gary Guo-4/+4
Unify terminology used in unwind action and terminator, and reflect the fact that a nounwind panic is triggered instead of an immediate abort is triggered for this terminator.
2023-04-06Add `UnwindAction::Terminate`Gary Guo-0/+4
2023-04-06Add `UnwindAction::Unreachable`Gary Guo-3/+8
This also makes eval machine's `StackPopUnwind` redundant so that is replaced.
2023-04-06Refactor unwind from Option to a new enumGary Guo-15/+26
2023-04-01Use `FieldIdx` in various things related to aggregatesScott McMurray-3/+4
Shrank `AggregateKind` by 8 bytes on x64, since the active field of a union is tracked as an `Option<FieldIdx>` instead of `Option<usize>`.
2023-03-31Auto merge of #98112 - saethlin:mir-alignment-checks, r=oli-obkbors-0/+1
Insert alignment checks for pointer dereferences when debug assertions are enabled Closes https://github.com/rust-lang/rust/issues/54915 - [x] Jake tells me this sounds like a place to use `MirPatch`, but I can't figure out how to insert a new basic block with a new terminator in the middle of an existing basic block, using `MirPatch`. (if nobody else backs up this point I'm checking this as "not actually a good idea" because the code looks pretty clean to me after rearranging it a bit) - [x] Using `CastKind::PointerExposeAddress` is definitely wrong, we don't want to expose. Calling a function to get the pointer address seems quite excessive. ~I'll see if I can add a new `CastKind`.~ `CastKind::Transmute` to the rescue! - [x] Implement a more helpful panic message like slice bounds checking. r? `@oli-obk`
2023-03-28Move `mir::Field` → `abi::FieldIdx`Scott McMurray-3/+11
The first PR for https://github.com/rust-lang/compiler-team/issues/606 This is just the move-and-rename, because it's plenty big-and-bitrotty already. Future PRs will start using `FieldIdx` more broadly, and concomitantly removing `FieldIdx::new`s.
2023-03-23A MIR transform that checks pointers are alignedBen Kimock-0/+1
2023-03-22Add `CastKind::Transmute` to MIRScott McMurray-0/+7
Updates `interpret`, `codegen_ssa`, and `codegen_cranelift` to consume the new cast instead of the intrinsic. Includes `CastTransmute` for custom MIR building, to be able to test the extra UB.
2023-03-21Rollup merge of #109408 - RalfJung:retags, r=compiler-errorsnils-1/+2
not *all* retags might be explicit in Runtime MIR In https://github.com/rust-lang/rust/pull/105317 I made Miri treat `Rvalue::Ref/AddrOf` as implicit retagging sites. This updates the MIR docs accordingly. For `Rvalue::Ref` I think this makes a lot more sense: creating a new reference is their entire point, so we can avoid bloating the MIR with retags. Also this seems to be the best way to handle cases like `*ptr = &[mut] ...`, where doing a retag is somewhat questionable since maybe `*ptr` points to another place now? For `Rvalue::AddrOf`, Stacked Borrows needs this because even raw ptrs need some retagging, but Tree Borrows doesn't do ant retagging here and I hope we'll end up with a model where raw pointers don't get retagged.
2023-03-20not *all* retags might be explicit in Runtime MIRRalf Jung-1/+2
2023-03-20Fix off-by-one in mir syntax docAndy Wang-1/+1
2023-03-16Tweak implementation of overflow checking assertionsTomasz Miąsko-2/+1
Extract and reuse logic controlling behaviour of overflow checking assertions instead of duplicating it three times.
2023-03-16Rollup merge of #109180 - gimbles:master, r=compiler-errorsMatthias Krüger-1/+1
Unequal → Not equal Fixes #109168
2023-03-15Auto merge of #108282 - cjgillot:mir-checked-sh, r=tmiaskobors-4/+0
Implement checked Shl/Shr at MIR building. This does not require any special handling by codegen backends, as the overflow behaviour is entirely determined by the rhs (shift amount). This allows MIR ConstProp to remove the overflow check for constant shifts. ~There is an existing different behaviour between cg_llvm and cg_clif (cc `@bjorn3).` I took cg_llvm's one as reference: overflow if `rhs < 0 || rhs > number_of_bits_in_lhs_ty`.~ EDIT: `cg_llvm` and `cg_clif` implement the overflow check differently. This PR uses `cg_llvm`'s implementation based on a `BitAnd` instead of `cg_clif`'s one based on an unsigned comparison.
2023-03-15unequal → not equalgimbles-1/+1
2023-03-09Pacify tidy.Camille GILLOT-2/+2
2023-03-09Introduce a no-op PlaceMention statement for `let _ =`.Camille GILLOT-0/+9