]> git.lizzy.rs Git - rust.git/blob - tests/ui/inference/infer-binary-operand-behind-reference.rs
Rollup merge of #106869 - notriddle:notriddle/item-decl-pre-rust, r=GuillaumeGomez
[rust.git] / tests / ui / inference / infer-binary-operand-behind-reference.rs
1 // check-pass
2
3 fn main() {
4     // Test that we can infer the type of binary operands when
5     // references are involved, on various types and operators.
6     let _: u8 = 0 + 0;
7     let _: u8 = 0 + &0;
8     let _: u8 = &0 + 0;
9     let _: u8 = &0 + &0;
10
11     let _: f32 = 0.0 + 0.0;
12     let _: f32 = 0.0 + &0.0;
13     let _: f32 = &0.0 + 0.0;
14     let _: f32 = &0.0 + &0.0;
15
16     let _: u8 = 0 << 0;
17     let _: u8 = 0 << &0;
18     let _: u8 = &0 << 0;
19     let _: u8 = &0 << &0;
20
21     // Test type inference when variable types are indirectly inferred.
22     let a = 22;
23     let _: usize = a + &44;
24
25     // When we have no expected type, the types of the operands is the default type.
26     let _ = 0 + 0;
27     let _ = 0 + &0;
28     let _ = &0 + 0;
29     let _ = &0 + &0;
30 }