Update from upstream.

This commit is contained in:
Matt Kraai 2017-07-24 06:37:12 -07:00 committed by Jay Hardee
parent f17def5801
commit 937a0aa20a
17 changed files with 78 additions and 74 deletions

View file

@ -1,6 +1,9 @@
# Change Log
All notable changes to this project will be documented in this file.
## 0.0.145
* Update to *rustc 1.20.0-nightly (afe145d22 2017-07-23)*
## 0.0.144
* Update to *rustc 1.20.0-nightly (086eaa78e 2017-07-15)*

View file

@ -1,6 +1,6 @@
[package]
name = "clippy"
version = "0.0.144"
version = "0.0.145"
authors = [
"Manish Goregaokar <manishsmail@gmail.com>",
"Andre Bogus <bogusandre@gmail.com>",
@ -32,7 +32,7 @@ path = "src/main.rs"
[dependencies]
# begin automatic update
clippy_lints = { version = "0.0.144", path = "clippy_lints" }
clippy_lints = { version = "0.0.145", path = "clippy_lints" }
# end automatic update
cargo_metadata = "0.2"

View file

@ -1,7 +1,7 @@
[package]
name = "clippy_lints"
# begin automatic update
version = "0.0.144"
version = "0.0.145"
# end automatic update
authors = [
"Manish Goregaokar <manishsmail@gmail.com>",

View file

@ -96,7 +96,7 @@ fn check_closure(cx: &LateContext, expr: &Expr) {
expr.span,
"redundant closure found",
|db| if let Some(snippet) = snippet_opt(cx, caller.span) {
db.span_suggestion(expr.span, "remove closure as shown:", snippet);
db.span_suggestion(expr.span, "remove closure as shown", snippet);
});
}
}

View file

@ -173,7 +173,7 @@ fn check_len_zero(cx: &LateContext, span: Span, name: Name, args: &[Expr], lit:
LEN_ZERO,
span,
"length comparison to zero",
"using `is_empty` is more concise:",
"using `is_empty` is more concise",
format!("{}{}.is_empty()", op, snippet(cx, args[0].span, "_")));
}
}

View file

@ -1233,7 +1233,7 @@ fn lint_single_char_pattern(cx: &LateContext, expr: &hir::Expr, arg: &hir::Expr)
SINGLE_CHAR_PATTERN,
arg.span,
"single-character string constant used as pattern",
|db| { db.span_suggestion(expr.span, "try using a char instead:", hint); });
|db| { db.span_suggestion(expr.span, "try using a char instead", hint); });
}
}
}

View file

@ -366,12 +366,12 @@ impl MiscEarly {
|db| {
db.span_suggestion(
lit.span,
"if you mean to use a decimal constant, remove the `0` to remove confusion:",
"if you mean to use a decimal constant, remove the `0` to remove confusion",
src.trim_left_matches('0').to_string(),
);
db.span_suggestion(
lit.span,
"if you mean to use an octal constant, use `0o`:",
"if you mean to use an octal constant, use `0o`",
format!("0o{}", src.trim_left_matches('0')),
);
});

View file

@ -126,7 +126,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for BoolComparison {
BOOL_COMPARISON,
e.span,
"equality checks against true are unnecessary",
"try simplifying it as shown:",
"try simplifying it as shown",
hint);
},
(Other, Bool(true)) => {
@ -135,7 +135,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for BoolComparison {
BOOL_COMPARISON,
e.span,
"equality checks against true are unnecessary",
"try simplifying it as shown:",
"try simplifying it as shown",
hint);
},
(Bool(false), Other) => {
@ -144,7 +144,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for BoolComparison {
BOOL_COMPARISON,
e.span,
"equality checks against false can be replaced by a negation",
"try simplifying it as shown:",
"try simplifying it as shown",
(!hint).to_string());
},
(Other, Bool(false)) => {
@ -153,7 +153,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for BoolComparison {
BOOL_COMPARISON,
e.span,
"equality checks against false can be replaced by a negation",
"try simplifying it as shown:",
"try simplifying it as shown",
(!hint).to_string());
},
_ => (),

View file

@ -97,7 +97,7 @@ impl ReturnPass {
ret_span,
"unneeded return statement",
|db| if let Some(snippet) = snippet_opt(cx, inner_span) {
db.span_suggestion(ret_span, "remove `return` as shown:", snippet);
db.span_suggestion(ret_span, "remove `return` as shown", snippet);
});
}

View file

@ -584,6 +584,7 @@ pub fn multispan_sugg(db: &mut DiagnosticBuilder, help_msg: String, sugg: Vec<(S
})
.collect(),
msg: help_msg,
show_code_when_inline: true,
};
db.suggestions.push(sugg);
}

View file

@ -2,7 +2,7 @@ error: equality checks against true are unnecessary
--> bool_comparison.rs:7:8
|
7 | if x == true { "yes" } else { "no" };
| ^^^^^^^^^ help: try simplifying it as shown:: `x`
| ^^^^^^^^^ help: try simplifying it as shown: `x`
|
= note: `-D bool-comparison` implied by `-D warnings`
@ -10,19 +10,19 @@ error: equality checks against false can be replaced by a negation
--> bool_comparison.rs:8:8
|
8 | if x == false { "yes" } else { "no" };
| ^^^^^^^^^^ help: try simplifying it as shown:: `!x`
| ^^^^^^^^^^ help: try simplifying it as shown: `!x`
error: equality checks against true are unnecessary
--> bool_comparison.rs:9:8
|
9 | if true == x { "yes" } else { "no" };
| ^^^^^^^^^ help: try simplifying it as shown:: `x`
| ^^^^^^^^^ help: try simplifying it as shown: `x`
error: equality checks against false can be replaced by a negation
--> bool_comparison.rs:10:8
|
10 | if false == x { "yes" } else { "no" };
| ^^^^^^^^^^ help: try simplifying it as shown:: `!x`
| ^^^^^^^^^^ help: try simplifying it as shown: `!x`
error: aborting due to 4 previous errors

View file

@ -2,7 +2,7 @@ error: redundant closure found
--> eta.rs:7:27
|
7 | let a = Some(1u8).map(|a| foo(a));
| ^^^^^^^^^^ help: remove closure as shown:: `foo`
| ^^^^^^^^^^ help: remove closure as shown: `foo`
|
= note: `-D redundant-closure` implied by `-D warnings`
@ -10,13 +10,13 @@ error: redundant closure found
--> eta.rs:8:10
|
8 | meta(|a| foo(a));
| ^^^^^^^^^^ help: remove closure as shown:: `foo`
| ^^^^^^^^^^ help: remove closure as shown: `foo`
error: redundant closure found
--> eta.rs:9:27
|
9 | let c = Some(1u8).map(|a| {1+2; foo}(a));
| ^^^^^^^^^^^^^^^^^ help: remove closure as shown:: `{1+2; foo}`
| ^^^^^^^^^^^^^^^^^ help: remove closure as shown: `{1+2; foo}`
error: this expression borrows a reference that is immediately dereferenced by the compiler
--> eta.rs:11:21
@ -30,7 +30,7 @@ error: redundant closure found
--> eta.rs:18:27
|
18 | let e = Some(1u8).map(|a| generic(a));
| ^^^^^^^^^^^^^^ help: remove closure as shown:: `generic`
| ^^^^^^^^^^^^^^ help: remove closure as shown: `generic`
error: aborting due to 5 previous errors

View file

@ -46,7 +46,7 @@ error: length comparison to zero
--> len_zero.rs:130:8
|
130 | if x.len() == 0 {
| ^^^^^^^^^^^^ help: using `is_empty` is more concise:: `x.is_empty()`
| ^^^^^^^^^^^^ help: using `is_empty` is more concise: `x.is_empty()`
|
= note: `-D len-zero` implied by `-D warnings`
@ -54,37 +54,37 @@ error: length comparison to zero
--> len_zero.rs:134:8
|
134 | if "".len() == 0 {
| ^^^^^^^^^^^^^ help: using `is_empty` is more concise:: `"".is_empty()`
| ^^^^^^^^^^^^^ help: using `is_empty` is more concise: `"".is_empty()`
error: length comparison to zero
--> len_zero.rs:148:8
|
148 | if has_is_empty.len() == 0 {
| ^^^^^^^^^^^^^^^^^^^^^^^ help: using `is_empty` is more concise:: `has_is_empty.is_empty()`
| ^^^^^^^^^^^^^^^^^^^^^^^ help: using `is_empty` is more concise: `has_is_empty.is_empty()`
error: length comparison to zero
--> len_zero.rs:151:8
|
151 | if has_is_empty.len() != 0 {
| ^^^^^^^^^^^^^^^^^^^^^^^ help: using `is_empty` is more concise:: `!has_is_empty.is_empty()`
| ^^^^^^^^^^^^^^^^^^^^^^^ help: using `is_empty` is more concise: `!has_is_empty.is_empty()`
error: length comparison to zero
--> len_zero.rs:154:8
|
154 | if has_is_empty.len() > 0 {
| ^^^^^^^^^^^^^^^^^^^^^^ help: using `is_empty` is more concise:: `!has_is_empty.is_empty()`
| ^^^^^^^^^^^^^^^^^^^^^^ help: using `is_empty` is more concise: `!has_is_empty.is_empty()`
error: length comparison to zero
--> len_zero.rs:160:8
|
160 | if with_is_empty.len() == 0 {
| ^^^^^^^^^^^^^^^^^^^^^^^^ help: using `is_empty` is more concise:: `with_is_empty.is_empty()`
| ^^^^^^^^^^^^^^^^^^^^^^^^ help: using `is_empty` is more concise: `with_is_empty.is_empty()`
error: length comparison to zero
--> len_zero.rs:172:8
|
172 | if b.len() != 0 {
| ^^^^^^^^^^^^ help: using `is_empty` is more concise:: `!b.is_empty()`
| ^^^^^^^^^^^^ help: using `is_empty` is more concise: `!b.is_empty()`
error: aborting due to 11 previous errors

View file

@ -33,11 +33,11 @@ error: this is a decimal constant
| ^^^^^^^^^^^^
|
= note: `-D zero-prefixed-literal` implied by `-D warnings`
help: if you mean to use a decimal constant, remove the `0` to remove confusion:
help: if you mean to use a decimal constant, remove the `0` to remove confusion
|
17 | let fail_multi_zero = _123usize;
| ^^^^^^^^^
help: if you mean to use an octal constant, use `0o`:
17 | let fail_multi_zero = 123usize;
| ^^^^^^^^
help: if you mean to use an octal constant, use `0o`
|
17 | let fail_multi_zero = 0o_123usize;
| ^^^^^^^^^^^
@ -78,11 +78,11 @@ error: this is a decimal constant
30 | let fail8 = 0123;
| ^^^^
|
help: if you mean to use a decimal constant, remove the `0` to remove confusion:
help: if you mean to use a decimal constant, remove the `0` to remove confusion
|
30 | let fail8 = 123;
| ^^^
help: if you mean to use an octal constant, use `0o`:
help: if you mean to use an octal constant, use `0o`
|
30 | let fail8 = 0o123;
| ^^^^^

View file

@ -504,7 +504,7 @@ error: single-character string constant used as pattern
--> methods.rs:475:13
|
475 | x.split("x");
| --------^^^- help: try using a char instead:: `x.split('x')`
| --------^^^- help: try using a char instead: `x.split('x')`
|
= note: `-D single-char-pattern` implied by `-D warnings`
@ -512,97 +512,97 @@ error: single-character string constant used as pattern
--> methods.rs:492:16
|
492 | x.contains("x");
| -----------^^^- help: try using a char instead:: `x.contains('x')`
| -----------^^^- help: try using a char instead: `x.contains('x')`
error: single-character string constant used as pattern
--> methods.rs:493:19
|
493 | x.starts_with("x");
| --------------^^^- help: try using a char instead:: `x.starts_with('x')`
| --------------^^^- help: try using a char instead: `x.starts_with('x')`
error: single-character string constant used as pattern
--> methods.rs:494:17
|
494 | x.ends_with("x");
| ------------^^^- help: try using a char instead:: `x.ends_with('x')`
| ------------^^^- help: try using a char instead: `x.ends_with('x')`
error: single-character string constant used as pattern
--> methods.rs:495:12
|
495 | x.find("x");
| -------^^^- help: try using a char instead:: `x.find('x')`
| -------^^^- help: try using a char instead: `x.find('x')`
error: single-character string constant used as pattern
--> methods.rs:496:13
|
496 | x.rfind("x");
| --------^^^- help: try using a char instead:: `x.rfind('x')`
| --------^^^- help: try using a char instead: `x.rfind('x')`
error: single-character string constant used as pattern
--> methods.rs:497:14
|
497 | x.rsplit("x");
| ---------^^^- help: try using a char instead:: `x.rsplit('x')`
| ---------^^^- help: try using a char instead: `x.rsplit('x')`
error: single-character string constant used as pattern
--> methods.rs:498:24
|
498 | x.split_terminator("x");
| -------------------^^^- help: try using a char instead:: `x.split_terminator('x')`
| -------------------^^^- help: try using a char instead: `x.split_terminator('x')`
error: single-character string constant used as pattern
--> methods.rs:499:25
|
499 | x.rsplit_terminator("x");
| --------------------^^^- help: try using a char instead:: `x.rsplit_terminator('x')`
| --------------------^^^- help: try using a char instead: `x.rsplit_terminator('x')`
error: single-character string constant used as pattern
--> methods.rs:500:17
|
500 | x.splitn(0, "x");
| ------------^^^- help: try using a char instead:: `x.splitn(0, 'x')`
| ------------^^^- help: try using a char instead: `x.splitn(0, 'x')`
error: single-character string constant used as pattern
--> methods.rs:501:18
|
501 | x.rsplitn(0, "x");
| -------------^^^- help: try using a char instead:: `x.rsplitn(0, 'x')`
| -------------^^^- help: try using a char instead: `x.rsplitn(0, 'x')`
error: single-character string constant used as pattern
--> methods.rs:502:15
|
502 | x.matches("x");
| ----------^^^- help: try using a char instead:: `x.matches('x')`
| ----------^^^- help: try using a char instead: `x.matches('x')`
error: single-character string constant used as pattern
--> methods.rs:503:16
|
503 | x.rmatches("x");
| -----------^^^- help: try using a char instead:: `x.rmatches('x')`
| -----------^^^- help: try using a char instead: `x.rmatches('x')`
error: single-character string constant used as pattern
--> methods.rs:504:21
|
504 | x.match_indices("x");
| ----------------^^^- help: try using a char instead:: `x.match_indices('x')`
| ----------------^^^- help: try using a char instead: `x.match_indices('x')`
error: single-character string constant used as pattern
--> methods.rs:505:22
|
505 | x.rmatch_indices("x");
| -----------------^^^- help: try using a char instead:: `x.rmatch_indices('x')`
| -----------------^^^- help: try using a char instead: `x.rmatch_indices('x')`
error: single-character string constant used as pattern
--> methods.rs:506:25
|
506 | x.trim_left_matches("x");
| --------------------^^^- help: try using a char instead:: `x.trim_left_matches('x')`
| --------------------^^^- help: try using a char instead: `x.trim_left_matches('x')`
error: single-character string constant used as pattern
--> methods.rs:507:26
|
507 | x.trim_right_matches("x");
| ---------------------^^^- help: try using a char instead:: `x.trim_right_matches('x')`
| ---------------------^^^- help: try using a char instead: `x.trim_right_matches('x')`
error: you are getting the inner pointer of a temporary `CString`
--> methods.rs:517:5

View file

@ -2,7 +2,7 @@ error: unneeded return statement
--> needless_return.rs:11:5
|
11 | return true;
| ^^^^^^^^^^^^ help: remove `return` as shown:: `true`
| ^^^^^^^^^^^^ help: remove `return` as shown: `true`
|
= note: `-D needless-return` implied by `-D warnings`
@ -10,43 +10,43 @@ error: unneeded return statement
--> needless_return.rs:15:5
|
15 | return true
| ^^^^^^^^^^^ help: remove `return` as shown:: `true`
| ^^^^^^^^^^^ help: remove `return` as shown: `true`
error: unneeded return statement
--> needless_return.rs:20:9
|
20 | return true;
| ^^^^^^^^^^^^ help: remove `return` as shown:: `true`
| ^^^^^^^^^^^^ help: remove `return` as shown: `true`
error: unneeded return statement
--> needless_return.rs:22:9
|
22 | return false;
| ^^^^^^^^^^^^^ help: remove `return` as shown:: `false`
| ^^^^^^^^^^^^^ help: remove `return` as shown: `false`
error: unneeded return statement
--> needless_return.rs:28:17
|
28 | true => return false,
| ^^^^^^^^^^^^ help: remove `return` as shown:: `false`
| ^^^^^^^^^^^^ help: remove `return` as shown: `false`
error: unneeded return statement
--> needless_return.rs:30:13
|
30 | return true;
| ^^^^^^^^^^^^ help: remove `return` as shown:: `true`
| ^^^^^^^^^^^^ help: remove `return` as shown: `true`
error: unneeded return statement
--> needless_return.rs:37:9
|
37 | return true;
| ^^^^^^^^^^^^ help: remove `return` as shown:: `true`
| ^^^^^^^^^^^^ help: remove `return` as shown: `true`
error: unneeded return statement
--> needless_return.rs:39:16
|
39 | let _ = || return true;
| ^^^^^^^^^^^ help: remove `return` as shown:: `true`
| ^^^^^^^^^^^ help: remove `return` as shown: `true`
error: aborting due to 8 previous errors

View file

@ -10,25 +10,25 @@ warning: transmute from a reference to a pointer
--> $DIR/transmute.rs:26:23
|
26 | let _: *const T = core::intrinsics::transmute(t);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try `t as *const T`
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `t as *const T`
warning: transmute from a reference to a pointer
--> $DIR/transmute.rs:28:21
|
28 | let _: *mut T = core::intrinsics::transmute(t);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try `t as *const T as *mut T`
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `t as *const T as *mut T`
warning: transmute from a reference to a pointer
--> $DIR/transmute.rs:30:23
|
30 | let _: *const U = core::intrinsics::transmute(t);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try `t as *const T as *const U`
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `t as *const T as *const U`
warning: transmute from a pointer type (`*const T`) to a reference type (`&T`)
--> $DIR/transmute.rs:35:17
|
35 | let _: &T = std::mem::transmute(p);
| ^^^^^^^^^^^^^^^^^^^^^^ help: try `&*p`
| ^^^^^^^^^^^^^^^^^^^^^^ help: try: `&*p`
|
= note: #[warn(transmute_ptr_to_ref)] on by default
@ -36,55 +36,55 @@ warning: transmute from a pointer type (`*mut T`) to a reference type (`&mut T`)
--> $DIR/transmute.rs:38:21
|
38 | let _: &mut T = std::mem::transmute(m);
| ^^^^^^^^^^^^^^^^^^^^^^ help: try `&mut *m`
| ^^^^^^^^^^^^^^^^^^^^^^ help: try: `&mut *m`
warning: transmute from a pointer type (`*mut T`) to a reference type (`&T`)
--> $DIR/transmute.rs:41:17
|
41 | let _: &T = std::mem::transmute(m);
| ^^^^^^^^^^^^^^^^^^^^^^ help: try `&*m`
| ^^^^^^^^^^^^^^^^^^^^^^ help: try: `&*m`
warning: transmute from a pointer type (`*mut T`) to a reference type (`&mut T`)
--> $DIR/transmute.rs:44:21
|
44 | let _: &mut T = std::mem::transmute(p as *mut T);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try `&mut *(p as *mut T)`
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&mut *(p as *mut T)`
warning: transmute from a pointer type (`*const U`) to a reference type (`&T`)
--> $DIR/transmute.rs:47:17
|
47 | let _: &T = std::mem::transmute(o);
| ^^^^^^^^^^^^^^^^^^^^^^ help: try `&*(o as *const T)`
| ^^^^^^^^^^^^^^^^^^^^^^ help: try: `&*(o as *const T)`
warning: transmute from a pointer type (`*mut U`) to a reference type (`&mut T`)
--> $DIR/transmute.rs:50:21
|
50 | let _: &mut T = std::mem::transmute(om);
| ^^^^^^^^^^^^^^^^^^^^^^^ help: try `&mut *(om as *mut T)`
| ^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&mut *(om as *mut T)`
warning: transmute from a pointer type (`*mut U`) to a reference type (`&T`)
--> $DIR/transmute.rs:53:17
|
53 | let _: &T = std::mem::transmute(om);
| ^^^^^^^^^^^^^^^^^^^^^^^ help: try `&*(om as *const T)`
| ^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&*(om as *const T)`
warning: transmute from a pointer type (`*const i32`) to a reference type (`&issue1231::Foo<'_, u8>`)
--> $DIR/transmute.rs:64:32
|
64 | let _: &Foo<u8> = unsafe { std::mem::transmute::<_, &Foo<_>>(raw) };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try `&*(raw as *const Foo<_>)`
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&*(raw as *const Foo<_>)`
warning: transmute from a pointer type (`*const i32`) to a reference type (`&issue1231::Foo<'_, &u8>`)
--> $DIR/transmute.rs:66:33
|
66 | let _: &Foo<&u8> = unsafe { std::mem::transmute::<_, &Foo<&_>>(raw) };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try `&*(raw as *const Foo<&_>)`
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&*(raw as *const Foo<&_>)`
warning: transmute from a pointer type (`*const i32`) to a reference type (`&u8`)
--> $DIR/transmute.rs:70:14
|
70 | unsafe { std::mem::transmute::<_, Bar>(raw) };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try `&*(raw as *const u8)`
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&*(raw as *const u8)`
warning: transmute from a type (`std::vec::Vec<i32>`) to itself
--> $DIR/transmute.rs:76:27
@ -120,13 +120,13 @@ warning: transmute from an integer to a pointer
--> $DIR/transmute.rs:92:31
|
92 | let _: *const usize = std::mem::transmute(5_isize);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try `5_isize as *const usize`
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `5_isize as *const usize`
warning: transmute from an integer to a pointer
--> $DIR/transmute.rs:96:31
|
96 | let _: *const usize = std::mem::transmute(1+1usize);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try `(1+1usize) as *const usize`
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `(1+1usize) as *const usize`
warning: transmute from a type (`*const Usize`) to the type that it points to (`Usize`)
--> $DIR/transmute.rs:111:24