blob: fbecaf9b971ffd0f5d18e0018da70943daabde85 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
|
#![allow(unused)]
fn main() {
let arr = &[0, 1, 2, 3];
for _i in 0..arr.len().rev() {
//~^ ERROR can't call method
//~| surround the range in parentheses
// The above error used to say “the method `rev` exists for type `usize`”.
// This regression test ensures it doesn't say that any more.
}
// Test for #102396
for i in 1..11.rev() {
//~^ ERROR can't call method
//~| HELP surround the range in parentheses
}
let end: usize = 10;
for i in 1..end.rev() {
//~^ ERROR can't call method
//~| HELP surround the range in parentheses
}
for i in 1..(end + 1).rev() {
//~^ ERROR can't call method
//~| HELP surround the range in parentheses
}
if 1..(end + 1).is_empty() {
//~^ ERROR can't call method
//~| ERROR mismatched types [E0308]
//~| HELP surround the range in parentheses
}
if 1..(end + 1).is_sorted() {
//~^ ERROR mismatched types [E0308]
//~| ERROR can't call method
//~| HELP surround the range in parentheses
}
let _res: i32 = 3..6.take(2).sum();
//~^ ERROR can't call method
//~| ERROR mismatched types [E0308]
//~| HELP surround the range in parentheses
let _sum: i32 = 3..6.sum();
//~^ ERROR can't call method
//~| ERROR mismatched types [E0308]
//~| HELP surround the range in parentheses
let a = 1 as usize;
let b = 10 as usize;
for _a in a..=b.rev() {
//~^ ERROR can't call method
//~| HELP surround the range in parentheses
}
let _res = ..10.contains(3);
//~^ ERROR can't call method
//~| HELP surround the range in parentheses
if 1..end.error_method() {
//~^ ERROR no method named `error_method`
//~| ERROR mismatched types [E0308]
// Won't suggest
}
let _res = b.take(1)..a;
//~^ ERROR `usize` is not an iterator
let _res: i32 = ..6.take(2).sum();
//~^ ERROR can't call method `take` on ambiguous numeric type
//~| HELP you must specify a concrete type for this numeric value
// Won't suggest because `RangeTo` dest not implemented `take`
}
|