diff --git a/CHANGELOG.md b/CHANGELOG.md index df19e84a1..4603c27e2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,9 @@ # Change Log All notable changes to this project will be documented in this file. +## 0.0.170 +* Rustup to *rustc 1.23.0-nightly (d6b06c63a 2017-11-09)* + ## 0.0.169 * Rustup to *rustc 1.23.0-nightly (3b82e4c74 2017-11-05)* * New lints: [`just_underscores_and_digits`], [`result_map_unwrap_or_else`], [`transmute_bytes_to_str`] diff --git a/Cargo.toml b/Cargo.toml index 2fbf6d17c..157a0d18a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "clippy" -version = "0.0.169" +version = "0.0.170" authors = [ "Manish Goregaokar ", "Andre Bogus ", @@ -37,7 +37,7 @@ path = "src/driver.rs" [dependencies] # begin automatic update -clippy_lints = { version = "0.0.169", path = "clippy_lints" } +clippy_lints = { version = "0.0.170", path = "clippy_lints" } # end automatic update cargo_metadata = "0.2" diff --git a/clippy_lints/Cargo.toml b/clippy_lints/Cargo.toml index 41803b6ee..e2b8d6546 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.169" +version = "0.0.170" # end automatic update authors = [ "Manish Goregaokar ", diff --git a/clippy_lints/src/methods.rs b/clippy_lints/src/methods.rs index 251c4ac3a..ee61920b4 100644 --- a/clippy_lints/src/methods.rs +++ b/clippy_lints/src/methods.rs @@ -888,9 +888,8 @@ fn lint_or_fun_call(cx: &LateContext, expr: &hir::Expr, name: &str, args: &[hir: } // don't lint for constant values - // FIXME: can we `expect` here instead of match? let owner_def = cx.tcx.hir.get_parent_did(arg.id); - let promotable = cx.tcx.rvalue_promotable_map(owner_def)[&arg.hir_id.local_id]; + let promotable = cx.tcx.rvalue_promotable_map(owner_def).contains(&arg.hir_id.local_id); if promotable { return; } diff --git a/clippy_lints/src/utils/mod.rs b/clippy_lints/src/utils/mod.rs index c557e856b..a0323df1f 100644 --- a/clippy_lints/src/utils/mod.rs +++ b/clippy_lints/src/utils/mod.rs @@ -620,14 +620,18 @@ where I: IntoIterator, { let sugg = rustc_errors::CodeSuggestion { - substitution_parts: sugg.into_iter() - .map(|(span, sub)| { - rustc_errors::Substitution { - span: span, - substitutions: vec![sub], - } - }) - .collect(), + substitutions: vec![ + rustc_errors::Substitution { + parts: sugg.into_iter() + .map(|(span, snippet)| { + rustc_errors::SubstitutionPart { + snippet, + span, + } + }) + .collect(), + } + ], msg: help_msg, show_code_when_inline: true, }; diff --git a/tests/ui/for_loop.stderr b/tests/ui/for_loop.stderr index 620c32b6a..f968e0888 100644 --- a/tests/ui/for_loop.stderr +++ b/tests/ui/for_loop.stderr @@ -82,7 +82,7 @@ error: the loop variable `i` is only used to index `vec`. help: consider using an iterator | 86 | for in &vec { - | ^^^^^^ + | error: the loop variable `i` is only used to index `vec`. --> $DIR/for_loop.rs:95:5 @@ -95,7 +95,7 @@ error: the loop variable `i` is only used to index `vec`. help: consider using an iterator | 95 | for in &vec { - | ^^^^^^ + | error: the loop variable `j` is only used to index `STATIC`. --> $DIR/for_loop.rs:100:5 @@ -108,7 +108,7 @@ error: the loop variable `j` is only used to index `STATIC`. help: consider using an iterator | 100 | for in STATIC.iter().take(4) { - | ^^^^^^ + | error: the loop variable `j` is only used to index `CONST`. --> $DIR/for_loop.rs:104:5 @@ -121,7 +121,7 @@ error: the loop variable `j` is only used to index `CONST`. help: consider using an iterator | 104 | for in CONST.iter().take(4) { - | ^^^^^^ + | error: the loop variable `i` is used to index `vec` --> $DIR/for_loop.rs:108:5 @@ -134,7 +134,7 @@ error: the loop variable `i` is used to index `vec` help: consider using an iterator | 108 | for (i, ) in vec.iter().enumerate() { - | ^^^^^^^^^^^ + | error: the loop variable `i` is only used to index `vec2`. --> $DIR/for_loop.rs:116:5 @@ -147,7 +147,7 @@ error: the loop variable `i` is only used to index `vec2`. help: consider using an iterator | 116 | for in vec2.iter().take(vec.len()) { - | ^^^^^^ + | error: the loop variable `i` is only used to index `vec`. --> $DIR/for_loop.rs:120:5 @@ -160,7 +160,7 @@ error: the loop variable `i` is only used to index `vec`. help: consider using an iterator | 120 | for in vec.iter().skip(5) { - | ^^^^^^ + | error: the loop variable `i` is only used to index `vec`. --> $DIR/for_loop.rs:124:5 @@ -173,7 +173,7 @@ error: the loop variable `i` is only used to index `vec`. help: consider using an iterator | 124 | for in vec.iter().take(MAX_LEN) { - | ^^^^^^ + | error: the loop variable `i` is only used to index `vec`. --> $DIR/for_loop.rs:128:5 @@ -186,7 +186,7 @@ error: the loop variable `i` is only used to index `vec`. help: consider using an iterator | 128 | for in vec.iter().take(MAX_LEN + 1) { - | ^^^^^^ + | error: the loop variable `i` is only used to index `vec`. --> $DIR/for_loop.rs:132:5 @@ -199,7 +199,7 @@ error: the loop variable `i` is only used to index `vec`. help: consider using an iterator | 132 | for in vec.iter().take(10).skip(5) { - | ^^^^^^ + | error: the loop variable `i` is only used to index `vec`. --> $DIR/for_loop.rs:136:5 @@ -212,7 +212,7 @@ error: the loop variable `i` is only used to index `vec`. help: consider using an iterator | 136 | for in vec.iter().take(10 + 1).skip(5) { - | ^^^^^^ + | error: the loop variable `i` is used to index `vec` --> $DIR/for_loop.rs:140:5 @@ -225,7 +225,7 @@ error: the loop variable `i` is used to index `vec` help: consider using an iterator | 140 | for (i, ) in vec.iter().enumerate().skip(5) { - | ^^^^^^^^^^^ + | error: the loop variable `i` is used to index `vec` --> $DIR/for_loop.rs:144:5 @@ -238,7 +238,7 @@ error: the loop variable `i` is used to index `vec` help: consider using an iterator | 144 | for (i, ) in vec.iter().enumerate().take(10).skip(5) { - | ^^^^^^^^^^^ + | error: this range is empty so this for loop will never run --> $DIR/for_loop.rs:148:5 @@ -448,7 +448,7 @@ error: you seem to want to iterate on a map's values help: use the corresponding method | 385 | for v in m.values() { - | ^ + | error: you seem to want to iterate on a map's values --> $DIR/for_loop.rs:390:5 @@ -464,7 +464,7 @@ error: you seem to want to iterate on a map's values help: use the corresponding method | 390 | for v in (*m).values() { - | ^ + | error: you seem to want to iterate on a map's values --> $DIR/for_loop.rs:398:5 @@ -477,7 +477,7 @@ error: you seem to want to iterate on a map's values help: use the corresponding method | 398 | for v in m.values_mut() { - | ^ + | error: you seem to want to iterate on a map's values --> $DIR/for_loop.rs:403:5 @@ -490,7 +490,7 @@ error: you seem to want to iterate on a map's values help: use the corresponding method | 403 | for v in (*m).values_mut() { - | ^ + | error: you seem to want to iterate on a map's keys --> $DIR/for_loop.rs:409:5 @@ -503,7 +503,7 @@ error: you seem to want to iterate on a map's keys help: use the corresponding method | 409 | for k in rm.keys() { - | ^ + | error: it looks like you're manually copying between slices --> $DIR/for_loop.rs:462:5 diff --git a/tests/ui/implicit_hasher.stderr b/tests/ui/implicit_hasher.stderr index 27d6e2cec..52b686bf8 100644 --- a/tests/ui/implicit_hasher.stderr +++ b/tests/ui/implicit_hasher.stderr @@ -8,11 +8,11 @@ error: impl for `HashMap` should be generalized over different hashers help: consider adding a type parameter | 11 | impl Foo for HashMap { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | help: ...and use generic constructor | 17 | (HashMap::default(), HashMap::with_capacity_and_hasher(10, Default::default())) - | ^^^^^^^^^^^^^^^^^^ + | error: impl for `HashMap` should be generalized over different hashers --> $DIR/implicit_hasher.rs:20:36 @@ -23,11 +23,11 @@ error: impl for `HashMap` should be generalized over different hashers help: consider adding a type parameter | 20 | impl Foo for (HashMap,) { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | help: ...and use generic constructor | 22 | ((HashMap::default(),), (HashMap::with_capacity_and_hasher(10, Default::default()),)) - | ^^^^^^^^^^^^^^^^^^ + | error: impl for `HashMap` should be generalized over different hashers --> $DIR/implicit_hasher.rs:25:19 @@ -38,11 +38,11 @@ error: impl for `HashMap` should be generalized over different hashers help: consider adding a type parameter | 25 | impl Foo for HashMap { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | help: ...and use generic constructor | 27 | (HashMap::default(), HashMap::with_capacity_and_hasher(10, Default::default())) - | ^^^^^^^^^^^^^^^^^^ + | error: impl for `HashSet` should be generalized over different hashers --> $DIR/implicit_hasher.rs:43:32 @@ -53,11 +53,11 @@ error: impl for `HashSet` should be generalized over different hashers help: consider adding a type parameter | 43 | impl Foo for HashSet { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | help: ...and use generic constructor | 45 | (HashSet::default(), HashSet::with_capacity_and_hasher(10, Default::default())) - | ^^^^^^^^^^^^^^^^^^ + | error: impl for `HashSet` should be generalized over different hashers --> $DIR/implicit_hasher.rs:48:19 @@ -68,11 +68,11 @@ error: impl for `HashSet` should be generalized over different hashers help: consider adding a type parameter | 48 | impl Foo for HashSet { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | help: ...and use generic constructor | 50 | (HashSet::default(), HashSet::with_capacity_and_hasher(10, Default::default())) - | ^^^^^^^^^^^^^^^^^^ + | error: parameter of type `HashMap` should be generalized over different hashers --> $DIR/implicit_hasher.rs:65:23 @@ -83,7 +83,7 @@ error: parameter of type `HashMap` should be generalized over different hashers help: consider adding a type parameter | 65 | pub fn foo(_map: &mut HashMap, _set: &mut HashSet) { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | error: parameter of type `HashSet` should be generalized over different hashers --> $DIR/implicit_hasher.rs:65:53 @@ -94,7 +94,7 @@ error: parameter of type `HashSet` should be generalized over different hashers help: consider adding a type parameter | 65 | pub fn foo(_map: &mut HashMap, _set: &mut HashSet) { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | error: impl for `HashMap` should be generalized over different hashers --> $DIR/implicit_hasher.rs:70:43 @@ -108,11 +108,11 @@ error: impl for `HashMap` should be generalized over different hashers help: consider adding a type parameter | 70 | impl Foo for HashMap { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | help: ...and use generic constructor | 72 | (HashMap::default(), HashMap::with_capacity_and_hasher(10, Default::default())) - | ^^^^^^^^^^^^^^^^^^ + | error: parameter of type `HashMap` should be generalized over different hashers --> $DIR/implicit_hasher.rs:78:33 @@ -126,7 +126,7 @@ error: parameter of type `HashMap` should be generalized over different hashers help: consider adding a type parameter | 78 | pub fn $name(_map: &mut HashMap, _set: &mut HashSet) { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | error: parameter of type `HashSet` should be generalized over different hashers --> $DIR/implicit_hasher.rs:78:63 @@ -140,5 +140,5 @@ error: parameter of type `HashSet` should be generalized over different hashers help: consider adding a type parameter | 78 | pub fn $name(_map: &mut HashMap, _set: &mut HashSet) { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | diff --git a/tests/ui/matches.stderr b/tests/ui/matches.stderr index 1c2452c46..7ff38a353 100644 --- a/tests/ui/matches.stderr +++ b/tests/ui/matches.stderr @@ -133,7 +133,7 @@ error: you don't need to add `&` to all patterns help: instead of prefixing all patterns with `&`, you can dereference the expression | 138 | match *v { .. } - | ^^^^^^^^^^^^^^^ + | error: you don't need to add `&` to all patterns --> $DIR/matches.rs:148:5 @@ -147,7 +147,7 @@ error: you don't need to add `&` to all patterns help: instead of prefixing all patterns with `&`, you can dereference the expression | 148 | match *tup { .. } - | ^^^^^^^^^^^^^^^^^ + | error: you don't need to add `&` to both the expression and the patterns --> $DIR/matches.rs:154:5 @@ -169,7 +169,7 @@ error: you don't need to add `&` to all patterns help: instead of prefixing all patterns with `&`, you can dereference the expression | 165 | if let .. = *a { .. } - | ^^^^^^^^^^^^^^^^^^^^^ + | error: you don't need to add `&` to both the expression and the patterns --> $DIR/matches.rs:170:5 diff --git a/tests/ui/needless_range_loop.stderr b/tests/ui/needless_range_loop.stderr index e2c3e18e8..e54c0e7d0 100644 --- a/tests/ui/needless_range_loop.stderr +++ b/tests/ui/needless_range_loop.stderr @@ -10,5 +10,5 @@ error: the loop variable `i` is only used to index `ns`. help: consider using an iterator | 8 | for in ns.iter().take(10).skip(3) { - | ^^^^^^ + | diff --git a/tests/ui/op_ref.stderr b/tests/ui/op_ref.stderr index dbe53933f..325969445 100644 --- a/tests/ui/op_ref.stderr +++ b/tests/ui/op_ref.stderr @@ -8,5 +8,5 @@ error: needlessly taken reference of both operands help: use the values directly | 13 | let foo = 5 - 6; - | ^ + | diff --git a/tests/ui/ptr_arg.stderr b/tests/ui/ptr_arg.stderr index 13be68d4c..9c6804cd9 100644 --- a/tests/ui/ptr_arg.stderr +++ b/tests/ui/ptr_arg.stderr @@ -35,7 +35,7 @@ help: change `x.clone()` to help: change `x.clone()` to | 46 | x.to_owned() - | ^^^^^^^^^^^^ + | error: writing `&String` instead of `&str` involves a new object where a slice will do. --> $DIR/ptr_arg.rs:49:18 @@ -58,7 +58,7 @@ help: change `x.clone()` to help: change `x.clone()` to | 56 | x.to_string() - | ^^^^^^^^^^^^^ + | error: writing `&String` instead of `&str` involves a new object where a slice will do. --> $DIR/ptr_arg.rs:59:44