Skip to content

Commit 593615a

Browse files
authored
Rollup merge of #110190 - cbeuw:mir-offset, r=oli-obk
Custom MIR: Support `BinOp::Offset` Since offset doesn't have an infix operator, a new function `Offset` is added which is lowered to `Rvalue::BinaryOp(BinOp::Offset, ..)` r? ```@oli-obk``` or ```@tmiasko``` or ```@JakobDegen```
2 parents da2e202 + 02878e8 commit 593615a

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

core/src/intrinsics/mir.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,7 @@
232232
//! - `&`, `&mut`, `addr_of!`, and `addr_of_mut!` all work to create their associated rvalue.
233233
//! - [`Discriminant`] and [`Len`] have associated functions.
234234
//! - Unary and binary operations use their normal Rust syntax - `a * b`, `!c`, etc.
235+
//! - The binary operation `Offset` can be created via [`Offset`].
235236
//! - Checked binary operations are represented by wrapping the associated binop in [`Checked`].
236237
//! - Array repetition syntax (`[foo; 10]`) creates the associated rvalue.
237238
//!
@@ -289,6 +290,7 @@ define!(
289290
fn Discriminant<T>(place: T) -> <T as ::core::marker::DiscriminantKind>::Discriminant
290291
);
291292
define!("mir_set_discriminant", fn SetDiscriminant<T>(place: T, index: u32));
293+
define!("mir_offset", fn Offset<T, U>(ptr: T, count: U) -> T);
292294
define!(
293295
"mir_field",
294296
/// Access the field with the given index of some place.

0 commit comments

Comments
 (0)