Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rollup of 8 pull requests #126480

Closed
wants to merge 23 commits into from
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
c4c8bda
non_local_defs: indicate that the macro needs to change
Urgau May 29, 2024
b5d4867
non_local_defs: move cargo update suggestion upper
Urgau May 29, 2024
6d2493b
ci: Update centos:7 to use vault repos
cuviper Jun 12, 2024
54fa4b0
Use Variance glob import everywhere
compiler-errors Jun 12, 2024
4440f50
rustc_span: Add conveniences for working with span formats
petrochenkov Mar 3, 2024
6fea953
rustc_span: By-value interface for ctxt update
petrochenkov Jun 11, 2024
220f3ec
rustc_span: Remove transmutes from span encoding
petrochenkov Jun 13, 2024
669a400
MIR Shl/Shr: the offset can be computed with rem_euclid
RalfJung Jun 14, 2024
956370b
Use subtyping instead of equality, since method resolution also uses …
oli-obk Jun 10, 2024
ad787c1
build `libcxx-version` only when it doesn't exist
onur-ozkan Jun 14, 2024
e2e1afa
update libstdc++ compatibility error log
onur-ozkan Jun 14, 2024
584af35
Several fixes to the redox target specs
jackpot51 Jun 9, 2024
e14bf6c
Add i686-unknown-redox target
bjorn3 Jun 9, 2024
f9be8f2
Use Linux file locking on Redox
jackpot51 Feb 12, 2023
3b8cda5
Add dedicated platform support page for Redox OS
bjorn3 Jun 9, 2024
73f769e
Rollup merge of #125722 - Urgau:non_local_defs-macro-to-change, r=est…
matthiaskrgr Jun 14, 2024
94729f1
Rollup merge of #125829 - petrochenkov:upctxt2, r=michaelwoerister
matthiaskrgr Jun 14, 2024
d2b076c
Rollup merge of #126128 - oli-obk:method_ice, r=lcnr
matthiaskrgr Jun 14, 2024
889c1bf
Rollup merge of #126192 - bjorn3:redox_patches, r=petrochenkov
matthiaskrgr Jun 14, 2024
ee7180f
Rollup merge of #126352 - cuviper:centos7-vault, r=Kobzol
matthiaskrgr Jun 14, 2024
64d7035
Rollup merge of #126354 - compiler-errors:variance, r=lcnr
matthiaskrgr Jun 14, 2024
46aaef4
Rollup merge of #126469 - RalfJung:mir-shifts, r=scottmcm
matthiaskrgr Jun 14, 2024
51e5ebb
Rollup merge of #126472 - onur-ozkan:improve-libcxx-build, r=Kobzol
matthiaskrgr Jun 14, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 7 additions & 12 deletions compiler/rustc_const_eval/src/interpret/operator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,25 +112,20 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {

// Shift ops can have an RHS with a different numeric type.
if matches!(bin_op, Shl | ShlUnchecked | Shr | ShrUnchecked) {
let size = left.layout.size.bits();
let l_bits = left.layout.size.bits();
// Compute the equivalent shift modulo `size` that is in the range `0..size`. (This is
// the one MIR operator that does *not* directly map to a single LLVM operation.)
let (shift_amount, overflow) = if right.layout.abi.is_signed() {
let shift_amount = r_signed();
let overflow = shift_amount < 0 || shift_amount >= i128::from(size);
// Deliberately wrapping `as` casts: shift_amount *can* be negative, but the result
// of the `as` will be equal modulo `size` (since it is a power of two).
let masked_amount = (shift_amount as u128) % u128::from(size);
assert_eq!(overflow, shift_amount != i128::try_from(masked_amount).unwrap());
(masked_amount, overflow)
let rem = shift_amount.rem_euclid(l_bits.into());
// `rem` is guaranteed positive, so the `unwrap` cannot fail
(u128::try_from(rem).unwrap(), rem != shift_amount)
} else {
let shift_amount = r_unsigned();
let overflow = shift_amount >= u128::from(size);
let masked_amount = shift_amount % u128::from(size);
assert_eq!(overflow, shift_amount != masked_amount);
(masked_amount, overflow)
let rem = shift_amount.rem_euclid(l_bits.into());
(rem, rem != shift_amount)
};
let shift_amount = u32::try_from(shift_amount).unwrap(); // we masked so this will always fit
let shift_amount = u32::try_from(shift_amount).unwrap(); // we brought this in the range `0..size` so this will always fit
// Compute the shifted result.
let result = if left.layout.abi.is_signed() {
let l = l_signed();
Expand Down
6 changes: 4 additions & 2 deletions compiler/rustc_middle/src/mir/syntax.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1490,15 +1490,17 @@ pub enum BinOp {
BitOr,
/// The `<<` operator (shift left)
///
/// The offset is (uniquely) determined as follows:
/// The offset is given by `RHS.rem_euclid(LHS::BITS)`.
/// In other words, it is (uniquely) determined as follows:
/// - it is "equal modulo LHS::BITS" to the RHS
/// - it is in the range `0..LHS::BITS`
Shl,
/// Like `Shl`, but is UB if the RHS >= LHS::BITS or RHS < 0
ShlUnchecked,
/// The `>>` operator (shift right)
///
/// The offset is (uniquely) determined as follows:
/// The offset is given by `RHS.rem_euclid(LHS::BITS)`.
/// In other words, it is (uniquely) determined as follows:
/// - it is "equal modulo LHS::BITS" to the RHS
/// - it is in the range `0..LHS::BITS`
///
Expand Down