2015-08-15 11:55:25 -05:00
|
|
|
#![feature(step_by)]
|
2016-04-26 06:31:52 -05:00
|
|
|
#![feature(inclusive_range_syntax)]
|
2015-08-15 11:55:25 -05:00
|
|
|
#![feature(plugin)]
|
|
|
|
#![plugin(clippy)]
|
|
|
|
|
|
|
|
struct NotARange;
|
|
|
|
impl NotARange {
|
|
|
|
fn step_by(&self, _: u32) {}
|
|
|
|
}
|
|
|
|
|
2017-05-17 07:19:44 -05:00
|
|
|
#[warn(range_step_by_zero, range_zip_with_len)]
|
2015-08-15 11:55:25 -05:00
|
|
|
fn main() {
|
2017-02-08 07:58:07 -06:00
|
|
|
(0..1).step_by(0);
|
2015-08-15 11:55:25 -05:00
|
|
|
// No warning for non-zero step
|
|
|
|
(0..1).step_by(1);
|
|
|
|
|
2017-02-08 07:58:07 -06:00
|
|
|
(1..).step_by(0);
|
|
|
|
(1...2).step_by(0);
|
2015-08-15 11:55:25 -05:00
|
|
|
|
|
|
|
let x = 0..1;
|
2017-02-08 07:58:07 -06:00
|
|
|
x.step_by(0);
|
2015-08-15 11:55:25 -05:00
|
|
|
|
|
|
|
// No error, not a range.
|
|
|
|
let y = NotARange;
|
|
|
|
y.step_by(0);
|
2015-11-03 08:42:52 -06:00
|
|
|
|
2015-12-12 23:35:35 -06:00
|
|
|
let v1 = vec![1,2,3];
|
|
|
|
let v2 = vec![4,5];
|
2017-02-08 07:58:07 -06:00
|
|
|
let _x = v1.iter().zip(0..v1.len());
|
2015-12-12 23:35:35 -06:00
|
|
|
let _y = v1.iter().zip(0..v2.len()); // No error
|
2015-08-15 11:55:25 -05:00
|
|
|
}
|