@@ -1644,16 +1644,15 @@ pub enum StatementKind<'tcx> {
1644
1644
/// statements are not required. If the entire MIR body contains no `StorageLive`/`StorageDead`
1645
1645
/// statements for a particular local, the local is always considered live.
1646
1646
///
1647
- /// More precisely, the MIR validator currently does a `MaybeLiveLocals ` analysis to check
1648
- /// validity of each use of a local. I believe this is equivalent to requiring for every use of
1649
- /// a local, there exist at least one path from the root to that use that contains a
1647
+ /// More precisely, the MIR validator currently does a `MaybeStorageLiveLocals ` analysis to
1648
+ /// check validity of each use of a local. I believe this is equivalent to requiring for every
1649
+ /// use of a local, there exist at least one path from the root to that use that contains a
1650
1650
/// `StorageLive` more recently than a `StorageDead`.
1651
1651
///
1652
- /// **Needs clarification**: Is it permitted to `StorageLive` a local for which we previously
1653
- /// executed `StorageDead`? How about two `StorageLive`s without an intervening `StorageDead`?
1654
- /// Two `StorageDead`s without an intervening `StorageLive`? LLVM says yes, poison, yes. If the
1655
- /// answer to any of these is "no," is breaking that rule UB or is it an error to have a path in
1656
- /// the CFG that might do this?
1652
+ /// **Needs clarification**: Is it permitted to have two `StorageLive`s without an intervening
1653
+ /// `StorageDead`? Two `StorageDead`s without an intervening `StorageLive`? LLVM says poison,
1654
+ /// yes. If the answer to any of these is "no," is breaking that rule UB or is it an error to
1655
+ /// have a path in the CFG that might do this?
1657
1656
StorageLive ( Local ) ,
1658
1657
1659
1658
/// See `StorageLive` above.
@@ -1666,7 +1665,7 @@ pub enum StatementKind<'tcx> {
1666
1665
/// <https://internals.rust-lang.org/t/stacked-borrows-an-aliasing-model-for-rust/8153/> for
1667
1666
/// more details.
1668
1667
///
1669
- /// For code that is not specific to stacked borrows, you should consider statements to read
1668
+ /// For code that is not specific to stacked borrows, you should consider retags to read
1670
1669
/// and modify the place in an opaque way.
1671
1670
Retag ( RetagKind , Box < Place < ' tcx > > ) ,
1672
1671
@@ -1695,7 +1694,7 @@ pub enum StatementKind<'tcx> {
1695
1694
/// executed.
1696
1695
Coverage ( Box < Coverage > ) ,
1697
1696
1698
- /// Denotes a call to the intrinsic function `copy_overlapping `.
1697
+ /// Denotes a call to the intrinsic function `copy_nonoverlapping `.
1699
1698
///
1700
1699
/// First, all three operands are evaluated. `src` and `dest` must each be a reference, pointer,
1701
1700
/// or `Box` pointing to the same type `T`. `count` must evaluate to a `usize`. Then, `src` and
@@ -1909,7 +1908,7 @@ pub struct CopyNonOverlapping<'tcx> {
1909
1908
/// **Needs clarification**: What about metadata resulting from dereferencing wide pointers (and
1910
1909
/// possibly from accessing unsized locals - not sure how those work)? That probably deserves to go
1911
1910
/// on the list above and be discussed too. It is also probably necessary for making the indexing
1912
- /// stuff lass hand-wavey.
1911
+ /// stuff less hand-wavey.
1913
1912
///
1914
1913
/// **Needs clarification**: When it says "part of memory" what does that mean precisely, and how
1915
1914
/// does it interact with the metadata?
@@ -2324,13 +2323,13 @@ pub struct SourceScopeLocalData {
2324
2323
///
2325
2324
/// The most common way to create values is via a place to value conversion. A place to value
2326
2325
/// conversion is an operation which reads the memory of the place and converts it to a value. This
2327
- /// is a fundamentally *typed* operation. Different types will do different things. These are some
2328
- /// possible examples of what Rust may - but will not necessarily - decide to do on place to value
2329
- /// conversions:
2326
+ /// is a fundamentally *typed* operation. The nature of the value produced depends on the type of
2327
+ /// the conversion. Furthermore, there may be other effects: if the type has a validity constraint
2328
+ /// the place to value conversion might be UB if the validity constraint is not met.
2330
2329
///
2331
- /// 1. Types with validity constraints cause UB if the validity constraint is not met
2332
- /// 2. References/pointers may have their provenance change or cause other provenance related
2333
- /// side-effects.
2330
+ /// **Needs clarification:** Ralf proposes that place to value conversions not have side-effects.
2331
+ /// This is what is implemented in miri today. Are these the semantics we want for MIR? Is this
2332
+ /// something we can even decide without knowing more about Rust's memory model?
2334
2333
///
2335
2334
/// A place to value conversion on a place that has its variant index set is not well-formed.
2336
2335
/// However, note that this rule only applies to places appearing in MIR bodies. Many functions,
@@ -2462,15 +2461,17 @@ impl<'tcx> Operand<'tcx> {
2462
2461
///
2463
2462
/// Not all of these are allowed at every [`MirPhase`] - when this is the case, it's stated below.
2464
2463
///
2465
- /// Computing any rvalue begins by evaluating the places and operands in the rvalue in the order in
2466
- /// which they appear . These are then used to produce a "value" - the same kind of value that an
2467
- /// [`Operand`] is.
2464
+ /// Computing any rvalue begins by evaluating the places and operands in some order (**Needs
2465
+ /// clarification**: Which order?) . These are then used to produce a "value" - the same kind of
2466
+ /// value that an [`Operand`] is.
2468
2467
pub enum Rvalue < ' tcx > {
2469
2468
/// Yields the operand unchanged
2470
2469
Use ( Operand < ' tcx > ) ,
2471
2470
2472
- /// Creates an array where each element is the value of the operand. This currently does not
2473
- /// drop the value even if the number of repetitions is zero, see [#74836].
2471
+ /// Creates an array where each element is the value of the operand.
2472
+ ///
2473
+ /// This is the cause of a bug in the case where the repetition count is zero because the value
2474
+ /// is not dropped, see [#74836].
2474
2475
///
2475
2476
/// Corresponds to source code like `[x; 32]`.
2476
2477
///
@@ -2524,12 +2525,12 @@ pub enum Rvalue<'tcx> {
2524
2525
Cast ( CastKind , Operand < ' tcx > , Ty < ' tcx > ) ,
2525
2526
2526
2527
/// * `Offset` has the same semantics as [`offset`](pointer::offset), except that the second
2527
- /// paramter may be a `usize` as well.
2528
+ /// parameter may be a `usize` as well.
2528
2529
/// * The comparison operations accept `bool`s, `char`s, signed or unsigned integers, floats,
2529
2530
/// raw pointers, or function pointers and return a `bool`.
2530
2531
/// * Left and right shift operations accept signed or unsigned integers not necessarily of the
2531
2532
/// same type and return a value of the same type as their LHS. For all other operations, the
2532
- /// types of the operands must match.
2533
+ /// types of the operands must match. Like in Rust, the RHS is truncated as needed.
2533
2534
/// * The `Bit*` operations accept signed integers, unsigned integers, or bools and return a
2534
2535
/// value of that type.
2535
2536
/// * The remaining operations accept signed integers, unsigned integers, or floats of any
@@ -2538,21 +2539,19 @@ pub enum Rvalue<'tcx> {
2538
2539
2539
2540
/// Same as `BinaryOp`, but yields `(T, bool)` instead of `T`. In addition to performing the
2540
2541
/// same computation as the matching `BinaryOp`, checks if the infinite precison result would be
2541
- /// unequal to the actual result and sets the `bool` if this is the case. `BinOp::Offset` is not
2542
- /// allowed here.
2542
+ /// unequal to the actual result and sets the `bool` if this is the case.
2543
2543
///
2544
- /// **FIXME**: What about division/modulo? Are they allowed here at all? Are zero divisors still
2545
- /// UB? Also, which other combinations of types are disallowed?
2544
+ /// This only supports addition, subtraction, multiplication, and shift operations.
2546
2545
CheckedBinaryOp ( BinOp , Box < ( Operand < ' tcx > , Operand < ' tcx > ) > ) ,
2547
2546
2548
- /// Yields the size or alignment of the type as a `usize` .
2547
+ /// Computes a value as described by the operation .
2549
2548
NullaryOp ( NullOp , Ty < ' tcx > ) ,
2550
2549
2551
2550
/// Exactly like `BinaryOp`, but less operands.
2552
2551
///
2553
- /// Also does two's-complement arithmetic. Negation requires a signed integer or a float; binary
2554
- /// not requires a signed integer, unsigned integer, or bool. Both operation kinds return a
2555
- /// value with the same type as their operand.
2552
+ /// Also does two's-complement arithmetic. Negation requires a signed integer or a float;
2553
+ /// bitwise not requires a signed integer, unsigned integer, or bool. Both operation kinds
2554
+ /// return a value with the same type as their operand.
2556
2555
UnaryOp ( UnOp , Operand < ' tcx > ) ,
2557
2556
2558
2557
/// Computes the discriminant of the place, returning it as an integer of type
0 commit comments