]> git.lizzy.rs Git - rust.git/blob - tests/ui/typeck/bad-type-in-vec-push.rs
Rollup merge of #107168 - Nilstrieb:if-a-tait-falls-in-the-forest,can-we-know-it...
[rust.git] / tests / ui / typeck / bad-type-in-vec-push.rs
1 // The error message here still is pretty confusing.
2
3 fn main() {
4     let mut result = vec![1];
5     // The type of `result` is constrained to be `Vec<{integer}>` here.
6     // But the logic we use to find what expression constrains a type
7     // is not sophisticated enough to know this.
8
9     let mut vector = Vec::new();
10     vector.sort();
11     result.push(vector);
12     //~^ ERROR mismatched types
13     // So it thinks that the type of `result` is constrained here.
14 }
15
16 fn example2() {
17     let mut x = vec![1];
18     x.push("");
19     //~^ ERROR mismatched types
20 }