Skip to content

Commit 327aa19

Browse files
committed
Improve the build_shift_expr_rhs comment
1 parent 0601f0c commit 327aa19

File tree

1 file changed

+7
-4
lines changed
  • compiler/rustc_codegen_ssa/src

1 file changed

+7
-4
lines changed

Diff for: compiler/rustc_codegen_ssa/src/base.rs

+7-4
Original file line numberDiff line numberDiff line change
@@ -300,12 +300,15 @@ pub fn coerce_unsized_into<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
300300
}
301301
}
302302

303-
/// Shifts in MIR are all allowed to have mismatched LHS & RHS types.
303+
/// Returns `rhs` sufficiently masked, truncated, and/or extended so that
304+
/// it can be used to shift `lhs`.
304305
///
305-
/// This does all the appropriate conversions needed to pass it to the builder's
306-
/// shift methods, which are UB for out-of-range shifts.
306+
/// Shifts in MIR are all allowed to have mismatched LHS & RHS types.
307+
/// The shift methods in `BuilderMethods`, however, are fully homogeneous
308+
/// (both parameters and the return type are all the same type).
307309
///
308-
/// If `is_unchecked` is false, this masks the RHS to ensure it stays in-bounds.
310+
/// If `is_unchecked` is false, this masks the RHS to ensure it stays in-bounds,
311+
/// as the `BuilderMethods` shifts are UB for out-of-bounds shift amounts.
309312
/// For 32- and 64-bit types, this matches the semantics
310313
/// of Java. (See related discussion on #1877 and #10183.)
311314
///

0 commit comments

Comments
 (0)