2022-09-29 05:16:47 +00:00
|
|
|
#![allow(unused)]
|
2022-03-12 20:09:57 +00:00
|
|
|
fn main() {
|
2022-09-29 05:16:47 +00:00
|
|
|
let arr = &[0, 1, 2, 3];
|
|
|
|
for _i in 0..arr.len().rev() {
|
2022-10-02 20:22:59 +00:00
|
|
|
//~^ ERROR can't call method
|
2022-09-29 05:16:47 +00:00
|
|
|
//~| 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() {
|
2022-10-02 20:22:59 +00:00
|
|
|
//~^ ERROR can't call method
|
2022-09-29 05:16:47 +00:00
|
|
|
//~| HELP surround the range in parentheses
|
|
|
|
}
|
|
|
|
|
|
|
|
let end: usize = 10;
|
|
|
|
for i in 1..end.rev() {
|
2022-10-02 20:22:59 +00:00
|
|
|
//~^ ERROR can't call method
|
2022-09-29 05:16:47 +00:00
|
|
|
//~| HELP surround the range in parentheses
|
|
|
|
}
|
|
|
|
|
|
|
|
for i in 1..(end + 1).rev() {
|
2022-10-02 20:22:59 +00:00
|
|
|
//~^ ERROR can't call method
|
2022-09-29 05:16:47 +00:00
|
|
|
//~| HELP surround the range in parentheses
|
|
|
|
}
|
|
|
|
|
|
|
|
if 1..(end + 1).is_empty() {
|
2022-10-02 20:22:59 +00:00
|
|
|
//~^ ERROR can't call method
|
2022-09-29 05:16:47 +00:00
|
|
|
//~| ERROR mismatched types [E0308]
|
|
|
|
//~| HELP surround the range in parentheses
|
|
|
|
}
|
|
|
|
|
|
|
|
if 1..(end + 1).is_sorted() {
|
|
|
|
//~^ ERROR mismatched types [E0308]
|
2022-10-02 20:22:59 +00:00
|
|
|
//~| ERROR can't call method
|
2022-09-29 05:16:47 +00:00
|
|
|
//~| HELP surround the range in parentheses
|
|
|
|
}
|
|
|
|
|
|
|
|
let _res: i32 = 3..6.take(2).sum();
|
2022-10-02 20:22:59 +00:00
|
|
|
//~^ ERROR can't call method
|
2022-09-29 05:16:47 +00:00
|
|
|
//~| ERROR mismatched types [E0308]
|
|
|
|
//~| HELP surround the range in parentheses
|
|
|
|
|
|
|
|
let _sum: i32 = 3..6.sum();
|
2022-10-02 20:22:59 +00:00
|
|
|
//~^ ERROR can't call method
|
2022-09-29 05:16:47 +00:00
|
|
|
//~| 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() {
|
2022-10-02 20:22:59 +00:00
|
|
|
//~^ ERROR can't call method
|
2022-09-29 05:16:47 +00:00
|
|
|
//~| HELP surround the range in parentheses
|
|
|
|
}
|
|
|
|
|
|
|
|
let _res = ..10.contains(3);
|
2022-10-02 20:22:59 +00:00
|
|
|
//~^ ERROR can't call method
|
2022-09-29 05:16:47 +00:00
|
|
|
//~| 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;
|
2022-10-02 20:22:59 +00:00
|
|
|
//~^ ERROR `usize` is not an iterator
|
|
|
|
|
|
|
|
let _res: i32 = ..6.take(2).sum();
|
2022-12-30 18:40:16 +00:00
|
|
|
//~^ ERROR can't call method `take` on ambiguous numeric type
|
2022-10-02 20:22:59 +00:00
|
|
|
//~| HELP you must specify a concrete type for this numeric value
|
|
|
|
// Won't suggest because `RangeTo` dest not implemented `take`
|
2022-03-12 20:09:57 +00:00
|
|
|
}
|