Skip to content

Commit a661bd6

Browse files
committed
Adjust tests to be clearer about the type that results from a shift expression.
1 parent 705b92b commit a661bd6

File tree

2 files changed

+14
-10
lines changed

2 files changed

+14
-10
lines changed

src/test/compile-fail/shift-various-bad-types.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@ fn foo(p: &Panolpy) {
3333

3434
22 >> 1;
3535
// Integer literal types are OK
36+
37+
// Type of the result follows the LHS, not the RHS:
38+
let _: i32 = 22_i64 >> 1_i32;
39+
//~^ ERROR mismatched types: expected `i32`, found `i64`
3640
}
3741

3842
fn main() {

src/test/run-pass/shift-various-types.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,17 +25,17 @@ struct Panolpy {
2525
}
2626

2727
fn foo(p: &Panolpy) {
28-
assert_eq!(22 >> p.i8, 11_i8);
29-
assert_eq!(22 >> p.i16, 11_i16);
30-
assert_eq!(22 >> p.i32, 11_i32);
31-
assert_eq!(22 >> p.i64, 11_i64);
32-
assert_eq!(22 >> p.isize, 11_is);
28+
assert_eq!(22_i32 >> p.i8, 11_i32);
29+
assert_eq!(22_i32 >> p.i16, 11_i32);
30+
assert_eq!(22_i32 >> p.i32, 11_i32);
31+
assert_eq!(22_i32 >> p.i64, 11_i32);
32+
assert_eq!(22_i32 >> p.isize, 11_i32);
3333

34-
assert_eq!(22 >> p.u8, 11_u8);
35-
assert_eq!(22 >> p.u16, 11_u16);
36-
assert_eq!(22 >> p.u32, 11_u32);
37-
assert_eq!(22 >> p.u64, 11_u64);
38-
assert_eq!(22 >> p.usize, 11_us);
34+
assert_eq!(22_i32 >> p.u8, 11_i32);
35+
assert_eq!(22_i32 >> p.u16, 11_i32);
36+
assert_eq!(22_i32 >> p.u32, 11_i32);
37+
assert_eq!(22_i32 >> p.u64, 11_i32);
38+
assert_eq!(22_i32 >> p.usize, 11_i32);
3939
}
4040

4141
fn main() {

0 commit comments

Comments
 (0)