Skip to content

Commit a1364cd

Browse files
incr.comp.: Acknowledge the fact that shift operations can panic at runtime.
1 parent 3c6f620 commit a1364cd

File tree

2 files changed

+39
-4
lines changed

2 files changed

+39
-4
lines changed

src/librustc/ich/hcx.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,8 @@ impl<'gcx> StableHashingContext<'gcx> {
227227
match binop {
228228
hir::BiAdd |
229229
hir::BiSub |
230+
hir::BiShl |
231+
hir::BiShr |
230232
hir::BiMul => self.overflow_checks_enabled,
231233

232234
hir::BiDiv |
@@ -237,8 +239,6 @@ impl<'gcx> StableHashingContext<'gcx> {
237239
hir::BiBitXor |
238240
hir::BiBitAnd |
239241
hir::BiBitOr |
240-
hir::BiShl |
241-
hir::BiShr |
242242
hir::BiEq |
243243
hir::BiLt |
244244
hir::BiLe |

src/test/incremental/hashes/panic_exprs.rs

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,13 +152,48 @@ pub fn mod_by_zero(val: i32) -> i32 {
152152
}
153153

154154

155+
// shift left ------------------------------------------------------------------
156+
#[cfg(cfail1)]
157+
pub fn shift_left(val: i32, shift: usize) -> i32 {
158+
val << shift
159+
}
160+
161+
#[cfg(not(cfail1))]
162+
#[rustc_clean(label="Hir", cfg="cfail2")]
163+
#[rustc_clean(label="Hir", cfg="cfail3")]
164+
#[rustc_dirty(label="HirBody", cfg="cfail2")]
165+
#[rustc_clean(label="HirBody", cfg="cfail3")]
166+
#[rustc_metadata_clean(cfg="cfail2")]
167+
#[rustc_metadata_clean(cfg="cfail3")]
168+
pub fn shift_left(val: i32, shift: usize) -> i32 {
169+
val << shift
170+
}
171+
172+
173+
// shift right ------------------------------------------------------------------
174+
#[cfg(cfail1)]
175+
pub fn shift_right(val: i32, shift: usize) -> i32 {
176+
val >> shift
177+
}
178+
179+
#[cfg(not(cfail1))]
180+
#[rustc_clean(label="Hir", cfg="cfail2")]
181+
#[rustc_clean(label="Hir", cfg="cfail3")]
182+
#[rustc_dirty(label="HirBody", cfg="cfail2")]
183+
#[rustc_clean(label="HirBody", cfg="cfail3")]
184+
#[rustc_metadata_clean(cfg="cfail2")]
185+
#[rustc_metadata_clean(cfg="cfail3")]
186+
pub fn shift_right(val: i32, shift: usize) -> i32 {
187+
val >> shift
188+
}
189+
155190

156191
// THE FOLLOWING ITEMS SHOULD NOT BE INFLUENCED BY THEIR SOURCE LOCATION
157192

158193
// bitwise ---------------------------------------------------------------------
159194
#[cfg(cfail1)]
160195
pub fn bitwise(val: i32) -> i32 {
161-
!val & 0x101010101 | 0x45689 ^ 0x2372382 << 1 >> 1
196+
!val & 0x101010101 | 0x45689 ^ 0x2372382
162197
}
163198

164199
#[cfg(not(cfail1))]
@@ -169,7 +204,7 @@ pub fn bitwise(val: i32) -> i32 {
169204
#[rustc_metadata_clean(cfg="cfail2")]
170205
#[rustc_metadata_clean(cfg="cfail3")]
171206
pub fn bitwise(val: i32) -> i32 {
172-
!val & 0x101010101 | 0x45689 ^ 0x2372382 << 1 >> 1
207+
!val & 0x101010101 | 0x45689 ^ 0x2372382
173208
}
174209

175210

0 commit comments

Comments
 (0)