From 0ca166277cb663465430d79e5311bd1ea97a27d5 Mon Sep 17 00:00:00 2001 From: Manish Goregaokar Date: Thu, 28 Sep 2017 07:11:34 -0700 Subject: [PATCH 1/5] Rust upgrade to rustc 1.22.0-nightly (0e6f4cf51 2017-09-27) --- clippy_lints/src/loops.rs | 2 +- clippy_lints/src/utils/sugg.rs | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/clippy_lints/src/loops.rs b/clippy_lints/src/loops.rs index a0300530a..76f1a603f 100644 --- a/clippy_lints/src/loops.rs +++ b/clippy_lints/src/loops.rs @@ -1604,7 +1604,7 @@ fn is_ref_iterable_type(cx: &LateContext, e: &Expr) -> bool { fn is_iterable_array(ty: Ty) -> bool { // IntoIterator is currently only implemented for array sizes <= 32 in rustc match ty.sty { - ty::TyArray(_, n) => (0...32).contains(const_to_u64(n)), + ty::TyArray(_, n) => (0..=32).contains(const_to_u64(n)), _ => false, } } diff --git a/clippy_lints/src/utils/sugg.rs b/clippy_lints/src/utils/sugg.rs index ec0a351b8..d376a6291 100644 --- a/clippy_lints/src/utils/sugg.rs +++ b/clippy_lints/src/utils/sugg.rs @@ -126,7 +126,7 @@ impl<'a> Sugg<'a> { ast::ExprKind::While(..) | ast::ExprKind::WhileLet(..) => Sugg::NonParen(snippet), ast::ExprKind::Range(.., RangeLimits::HalfOpen) => Sugg::BinOp(AssocOp::DotDot, snippet), - ast::ExprKind::Range(.., RangeLimits::Closed) => Sugg::BinOp(AssocOp::DotDotDot, snippet), + ast::ExprKind::Range(.., RangeLimits::Closed) => Sugg::BinOp(AssocOp::DotDotEq, snippet), ast::ExprKind::Assign(..) => Sugg::BinOp(AssocOp::Assign, snippet), ast::ExprKind::AssignOp(op, ..) => Sugg::BinOp(astbinop2assignop(op), snippet), ast::ExprKind::Binary(op, ..) => Sugg::BinOp(AssocOp::from_ast_binop(op.node), snippet), @@ -165,7 +165,7 @@ impl<'a> Sugg<'a> { pub fn range(self, end: Self, limit: ast::RangeLimits) -> Sugg<'static> { match limit { ast::RangeLimits::HalfOpen => make_assoc(AssocOp::DotDot, &self, &end), - ast::RangeLimits::Closed => make_assoc(AssocOp::DotDotDot, &self, &end), + ast::RangeLimits::Closed => make_assoc(AssocOp::DotDotEq, &self, &end), } } @@ -312,7 +312,7 @@ pub fn make_assoc(op: AssocOp, lhs: &Sugg, rhs: &Sugg) -> Sugg<'static> { AssocOp::AssignOp(op) => format!("{} {}= {}", lhs, token_to_string(&token::BinOp(op)), rhs), AssocOp::As => format!("{} as {}", lhs, rhs), AssocOp::DotDot => format!("{}..{}", lhs, rhs), - AssocOp::DotDotDot => format!("{}...{}", lhs, rhs), + AssocOp::DotDotEq => format!("{}...{}", lhs, rhs), AssocOp::Colon => format!("{}: {}", lhs, rhs), }; @@ -362,7 +362,7 @@ fn associativity(op: &AssocOp) -> Associativity { ShiftLeft | ShiftRight | Subtract => Associativity::Left, - DotDot | DotDotDot => Associativity::None, + DotDot | DotDotEq => Associativity::None, } } From 201b5c2f2444e242c9f96e732a3e4cc5e5cc4e8d Mon Sep 17 00:00:00 2001 From: Manish Goregaokar Date: Thu, 28 Sep 2017 10:35:14 -0700 Subject: [PATCH 2/5] Use ..= in the suggestion --- Cargo.lock | 6 +++--- clippy_lints/src/utils/sugg.rs | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 2a0b20d58..34be0d11a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1,6 +1,6 @@ [root] name = "clippy_lints" -version = "0.0.164" +version = "0.0.165" dependencies = [ "itertools 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", @@ -78,11 +78,11 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "clippy" -version = "0.0.164" +version = "0.0.165" dependencies = [ "cargo_metadata 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "clippy-mini-macro-test 0.1.0", - "clippy_lints 0.0.164", + "clippy_lints 0.0.165", "compiletest_rs 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)", "duct 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", diff --git a/clippy_lints/src/utils/sugg.rs b/clippy_lints/src/utils/sugg.rs index d376a6291..d811de598 100644 --- a/clippy_lints/src/utils/sugg.rs +++ b/clippy_lints/src/utils/sugg.rs @@ -312,7 +312,7 @@ pub fn make_assoc(op: AssocOp, lhs: &Sugg, rhs: &Sugg) -> Sugg<'static> { AssocOp::AssignOp(op) => format!("{} {}= {}", lhs, token_to_string(&token::BinOp(op)), rhs), AssocOp::As => format!("{} as {}", lhs, rhs), AssocOp::DotDot => format!("{}..{}", lhs, rhs), - AssocOp::DotDotEq => format!("{}...{}", lhs, rhs), + AssocOp::DotDotEq => format!("{}..={}", lhs, rhs), AssocOp::Colon => format!("{}: {}", lhs, rhs), }; From 3159a7f2a12c8e1b753598544c71be8ae8eae628 Mon Sep 17 00:00:00 2001 From: Manish Goregaokar Date: Thu, 28 Sep 2017 10:40:19 -0700 Subject: [PATCH 3/5] Update ... -> ..= in tests --- tests/ui/array_indexing.rs | 16 ++++++++-------- tests/ui/array_indexing.stderr | 16 ++++++++-------- tests/ui/copies.rs | 12 ++++++------ tests/ui/for_loop.rs | 8 ++++---- tests/ui/for_loop.stderr | 6 +++--- tests/ui/no_effect.rs | 2 +- tests/ui/no_effect.stderr | 2 +- tests/ui/range.rs | 2 +- tests/ui/range.stderr | 2 +- 9 files changed, 33 insertions(+), 33 deletions(-) diff --git a/tests/ui/array_indexing.rs b/tests/ui/array_indexing.rs index 34b422db6..c38342daf 100644 --- a/tests/ui/array_indexing.rs +++ b/tests/ui/array_indexing.rs @@ -13,8 +13,8 @@ fn main() { x[1 << 3]; &x[1..5]; &x[0..3]; - &x[0...4]; - &x[...4]; + &x[0..=4]; + &x[..=4]; &x[..]; &x[1..]; &x[4..]; @@ -26,19 +26,19 @@ fn main() { y[0]; &y[1..2]; &y[..]; - &y[0...4]; - &y[...4]; + &y[0..=4]; + &y[..=4]; let empty: [i8; 0] = []; empty[0]; &empty[1..5]; - &empty[0...4]; - &empty[...4]; + &empty[0..=4]; + &empty[..=4]; &empty[..]; &empty[0..]; &empty[0..0]; - &empty[0...0]; - &empty[...0]; + &empty[0..=0]; + &empty[..=0]; &empty[..0]; &empty[1..]; &empty[..4]; diff --git a/tests/ui/array_indexing.stderr b/tests/ui/array_indexing.stderr index ea95c3254..d730b0129 100644 --- a/tests/ui/array_indexing.stderr +++ b/tests/ui/array_indexing.stderr @@ -21,13 +21,13 @@ error: range is out of bounds error: range is out of bounds --> $DIR/array_indexing.rs:16:6 | -16 | &x[0...4]; +16 | &x[0..=4]; | ^^^^^^^^ error: range is out of bounds --> $DIR/array_indexing.rs:17:6 | -17 | &x[...4]; +17 | &x[..=4]; | ^^^^^^^ error: range is out of bounds @@ -59,13 +59,13 @@ error: slicing may panic error: slicing may panic --> $DIR/array_indexing.rs:29:6 | -29 | &y[0...4]; +29 | &y[0..=4]; | ^^^^^^^^ error: slicing may panic --> $DIR/array_indexing.rs:30:6 | -30 | &y[...4]; +30 | &y[..=4]; | ^^^^^^^ error: const index is out of bounds @@ -83,25 +83,25 @@ error: range is out of bounds error: range is out of bounds --> $DIR/array_indexing.rs:35:6 | -35 | &empty[0...4]; +35 | &empty[0..=4]; | ^^^^^^^^^^^^ error: range is out of bounds --> $DIR/array_indexing.rs:36:6 | -36 | &empty[...4]; +36 | &empty[..=4]; | ^^^^^^^^^^^ error: range is out of bounds --> $DIR/array_indexing.rs:40:6 | -40 | &empty[0...0]; +40 | &empty[0..=0]; | ^^^^^^^^^^^^ error: range is out of bounds --> $DIR/array_indexing.rs:41:6 | -41 | &empty[...0]; +41 | &empty[..=0]; | ^^^^^^^^^^^ error: range is out of bounds diff --git a/tests/ui/copies.rs b/tests/ui/copies.rs index a7b992527..652afac6c 100644 --- a/tests/ui/copies.rs +++ b/tests/ui/copies.rs @@ -1,4 +1,4 @@ -#![feature(plugin, inclusive_range_syntax)] +#![feature(plugin, dotdoteq_in_patterns, inclusive_range_syntax)] #![plugin(clippy)] #![allow(dead_code, no_effect, unnecessary_operation)] @@ -33,7 +33,7 @@ fn if_same_then_else() -> Result<&'static str, ()> { ..; 0..; ..10; - 0...10; + 0..=10; foo(); } else { @@ -42,7 +42,7 @@ fn if_same_then_else() -> Result<&'static str, ()> { ..; 0..; ..10; - 0...10; + 0..=10; foo(); } @@ -64,7 +64,7 @@ fn if_same_then_else() -> Result<&'static str, ()> { 0..10; } else { - 0...10; + 0..=10; } if true { @@ -161,7 +161,7 @@ fn if_same_then_else() -> Result<&'static str, ()> { let _ = match 42 { 42 => 1, a if a > 0 => 2, - 10...15 => 3, + 10..=15 => 3, _ => 4, }; } @@ -172,7 +172,7 @@ fn if_same_then_else() -> Result<&'static str, ()> { let _ = match 42 { 42 => 1, a if a > 0 => 2, - 10...15 => 3, + 10..=15 => 3, _ => 4, }; } diff --git a/tests/ui/for_loop.rs b/tests/ui/for_loop.rs index aa8b96322..95d15776a 100644 --- a/tests/ui/for_loop.rs +++ b/tests/ui/for_loop.rs @@ -125,7 +125,7 @@ fn main() { println!("{}", vec[i]); } - for i in 0...MAX_LEN { + for i in 0..=MAX_LEN { println!("{}", vec[i]); } @@ -133,7 +133,7 @@ fn main() { println!("{}", vec[i]); } - for i in 5...10 { + for i in 5..=10 { println!("{}", vec[i]); } @@ -149,7 +149,7 @@ fn main() { println!("{}", i); } - for i in 10...0 { + for i in 10..=0 { println!("{}", i); } @@ -161,7 +161,7 @@ fn main() { println!("{}", i); } - for i in 5...5 { + for i in 5..=5 { // not an error, this is the range with only one element “5” println!("{}", i); } diff --git a/tests/ui/for_loop.stderr b/tests/ui/for_loop.stderr index 79c6c781a..09c4deb49 100644 --- a/tests/ui/for_loop.stderr +++ b/tests/ui/for_loop.stderr @@ -178,7 +178,7 @@ help: consider using an iterator error: the loop variable `i` is only used to index `vec`. --> $DIR/for_loop.rs:128:5 | -128 | / for i in 0...MAX_LEN { +128 | / for i in 0..=MAX_LEN { 129 | | println!("{}", vec[i]); 130 | | } | |_____^ @@ -204,7 +204,7 @@ help: consider using an iterator error: the loop variable `i` is only used to index `vec`. --> $DIR/for_loop.rs:136:5 | -136 | / for i in 5...10 { +136 | / for i in 5..=10 { 137 | | println!("{}", vec[i]); 138 | | } | |_____^ @@ -257,7 +257,7 @@ help: consider using the following if you are attempting to iterate over this ra error: this range is empty so this for loop will never run --> $DIR/for_loop.rs:152:5 | -152 | / for i in 10...0 { +152 | / for i in 10..=0 { 153 | | println!("{}", i); 154 | | } | |_____^ diff --git a/tests/ui/no_effect.rs b/tests/ui/no_effect.rs index bef1fad4f..5c3a1a041 100644 --- a/tests/ui/no_effect.rs +++ b/tests/ui/no_effect.rs @@ -49,7 +49,7 @@ fn main() { 5..; ..5; 5..6; - 5...6; + 5..=6; [42, 55]; [42, 55][1]; (42, 55).1; diff --git a/tests/ui/no_effect.stderr b/tests/ui/no_effect.stderr index 590b1eab4..b6db8e749 100644 --- a/tests/ui/no_effect.stderr +++ b/tests/ui/no_effect.stderr @@ -111,7 +111,7 @@ error: statement with no effect error: statement with no effect --> $DIR/no_effect.rs:52:5 | -52 | 5...6; +52 | 5..=6; | ^^^^^^ error: statement with no effect diff --git a/tests/ui/range.rs b/tests/ui/range.rs index 4f4573d9e..bb1a04cfc 100644 --- a/tests/ui/range.rs +++ b/tests/ui/range.rs @@ -15,7 +15,7 @@ fn main() { let _ = (0..1).step_by(1); let _ = (1..).step_by(0); - let _ = (1...2).step_by(0); + let _ = (1..=2).step_by(0); let x = 0..1; let _ = x.step_by(0); diff --git a/tests/ui/range.stderr b/tests/ui/range.stderr index 772375c17..fc51f1a07 100644 --- a/tests/ui/range.stderr +++ b/tests/ui/range.stderr @@ -15,7 +15,7 @@ error: Iterator::step_by(0) will panic at runtime error: Iterator::step_by(0) will panic at runtime --> $DIR/range.rs:18:13 | -18 | let _ = (1...2).step_by(0); +18 | let _ = (1..=2).step_by(0); | ^^^^^^^^^^^^^^^^^^ error: Iterator::step_by(0) will panic at runtime From b1c62e12958170326e973c910d559bccea0f70ff Mon Sep 17 00:00:00 2001 From: Manish Goregaokar Date: Thu, 28 Sep 2017 10:44:26 -0700 Subject: [PATCH 4/5] Update changelog --- CHANGELOG.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c95d96c2c..0e3fb8be4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,8 @@ # Change Log All notable changes to this project will be documented in this file. -## Trunk +## 0.0.165 +* Rust upgrade to rustc 1.22.0-nightly (0e6f4cf51 2017-09-27) * New lint: [`mut_range_bound`] ## 0.0.164 From 02e7fada5cdcf4c8573ca5ab81037fd80fa6ca49 Mon Sep 17 00:00:00 2001 From: Manish Goregaokar Date: Thu, 28 Sep 2017 10:44:29 -0700 Subject: [PATCH 5/5] Bump to 0.0.165 --- Cargo.toml | 4 ++-- clippy_lints/Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 80ea4188c..f9c3fd0fd 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "clippy" -version = "0.0.164" +version = "0.0.165" authors = [ "Manish Goregaokar ", "Andre Bogus ", @@ -31,7 +31,7 @@ path = "src/main.rs" [dependencies] # begin automatic update -clippy_lints = { version = "0.0.164", path = "clippy_lints" } +clippy_lints = { version = "0.0.165", path = "clippy_lints" } # end automatic update cargo_metadata = "0.2" diff --git a/clippy_lints/Cargo.toml b/clippy_lints/Cargo.toml index ef1dcb238..85d65c791 100644 --- a/clippy_lints/Cargo.toml +++ b/clippy_lints/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "clippy_lints" # begin automatic update -version = "0.0.164" +version = "0.0.165" # end automatic update authors = [ "Manish Goregaokar ",