Merge branch 'master' into issue2894

This commit is contained in:
Michael Wright 2018-07-28 08:41:10 +02:00
commit 8eeb3feadf
22 changed files with 129 additions and 121 deletions

View file

@ -507,7 +507,7 @@ All notable changes to this project will be documented in this file.
## 0.0.74 — 2016-06-07
* Fix bug with `cargo-clippy` JSON parsing
* Add the `CLIPPY_DISABLE_DOCS_LINKS` environment variable to deactivate the
“for further information visit *wiki-link*” message.
“for further information visit *lint-link*” message.
## 0.0.73 — 2016-06-05
* Fix false positives in [`useless_let_if_seq`]
@ -612,7 +612,7 @@ All notable changes to this project will be documented in this file.
[`AsRef`]: https://doc.rust-lang.org/std/convert/trait.AsRef.html
[configuration file]: ./rust-clippy#configuration
<!-- begin autogenerated links to wiki -->
<!-- begin autogenerated links to lint list -->
[`absurd_extreme_comparisons`]: https://rust-lang-nursery.github.io/rust-clippy/master/index.html#absurd_extreme_comparisons
[`almost_swapped`]: https://rust-lang-nursery.github.io/rust-clippy/master/index.html#almost_swapped
[`approx_constant`]: https://rust-lang-nursery.github.io/rust-clippy/master/index.html#approx_constant
@ -894,4 +894,4 @@ All notable changes to this project will be documented in this file.
[`zero_prefixed_literal`]: https://rust-lang-nursery.github.io/rust-clippy/master/index.html#zero_prefixed_literal
[`zero_ptr`]: https://rust-lang-nursery.github.io/rust-clippy/master/index.html#zero_ptr
[`zero_width_space`]: https://rust-lang-nursery.github.io/rust-clippy/master/index.html#zero_width_space
<!-- end autogenerated links to wiki -->
<!-- end autogenerated links to lint list -->

View file

@ -15,7 +15,11 @@ pub struct EtaPass;
/// **Why is this bad?** Needlessly creating a closure adds code for no benefit
/// and gives the optimizer more work.
///
/// **Known problems:** None.
/// **Known problems:** If creating the closure inside the closure has a side-
/// effect then moving the closure creation out will change when that side-
/// effect runs.
/// See https://github.com/rust-lang-nursery/rust-clippy/issues/1439 for more
/// details.
///
/// **Example:**
/// ```rust

View file

@ -65,7 +65,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for ExcessivePrecision {
}
impl ExcessivePrecision {
// None if nothing to lint, Some(suggestion) if lint neccessary
// None if nothing to lint, Some(suggestion) if lint necessary
fn check(&self, sym: Symbol, fty: FloatTy) -> Option<String> {
let max = max_digits(fty);
let sym_str = sym.as_str();

View file

@ -2217,7 +2217,7 @@ impl<'a, 'tcx> Visitor<'tcx> for VarCollectorVisitor<'a, 'tcx> {
fn visit_expr(&mut self, ex: &'tcx Expr) {
match ex.node {
ExprKind::Path(_) => self.insert_def_id(ex),
// If there is any fuction/method call… we just stop analysis
// If there is any function/method call… we just stop analysis
ExprKind::Call(..) | ExprKind::MethodCall(..) => self.skip = true,
_ => walk_expr(self, ex),

View file

@ -383,7 +383,7 @@ fn check_wild_err_arm(cx: &LateContext<'_, '_>, ex: &Expr, arms: &[Arm]) {
arm.pats[0].span,
"Err(_) will match all errors, maybe not a good idea",
arm.pats[0].span,
"to remove this warning, match each error seperately \
"to remove this warning, match each error separately \
or use unreachable macro");
}
}

View file

@ -6,21 +6,21 @@ use if_chain::if_chain;
use crate::utils::{self, paths, span_lint};
/// **What it does:**
/// Checks for the usage of negated comparision operators on types which only implement
/// Checks for the usage of negated comparison operators on types which only implement
/// `PartialOrd` (e.g. `f64`).
///
/// **Why is this bad?**
/// These operators make it easy to forget that the underlying types actually allow not only three
/// potential Orderings (Less, Equal, Greater) but also a forth one (Uncomparable). Escpeccially if
/// the operator based comparision result is negated it is easy to miss that fact.
/// potential Orderings (Less, Equal, Greater) but also a fourth one (Uncomparable). This is
/// especially easy to miss if the operator based comparison result is negated.
///
/// **Known problems:** None.
///
/// **Example:**
///
/// ```rust
/// use core::cmp::Ordering;
///
/// use std::cmp::Ordering;
///
/// // Bad
/// let a = 1.0;
/// let b = std::f64::NAN;
@ -39,7 +39,7 @@ use crate::utils::{self, paths, span_lint};
declare_clippy_lint! {
pub NEG_CMP_OP_ON_PARTIAL_ORD,
complexity,
"The use of negated comparision operators on partially orded types may produce confusing code."
"The use of negated comparison operators on partially ordered types may produce confusing code."
}
pub struct NoNegCompOpForPartialOrd;
@ -85,10 +85,10 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NoNegCompOpForPartialOrd {
cx,
NEG_CMP_OP_ON_PARTIAL_ORD,
expr.span,
"The use of negated comparision operators on partially orded \
"The use of negated comparison operators on partially ordered \
types produces code that is hard to read and refactor. Please \
consider to use the `partial_cmp` instead, to make it clear \
that the two values could be incomparable."
consider using the `partial_cmp` method instead, to make it \
clear that the two values could be incomparable."
)
}
}

View file

@ -700,7 +700,7 @@ declare_clippy_lint! {
/// **What it does:** Checks for casts of a function pointer to a numeric type not enough to store address.
///
/// **Why is this bad?** Casting a function pointer to not eligable type could truncate the address value.
/// **Why is this bad?** Casting a function pointer to not eligible type could truncate the address value.
///
/// **Known problems:** None.
///

View file

@ -334,7 +334,7 @@ pub fn make_assoc(op: AssocOp, lhs: &Sugg<'_>, rhs: &Sugg<'_>) -> Sugg<'static>
Sugg::BinOp(op, sugg.into())
}
/// Convinience wrapper arround `make_assoc` and `AssocOp::from_ast_binop`.
/// Convenience wrapper around `make_assoc` and `AssocOp::from_ast_binop`.
pub fn make_binop(op: ast::BinOpKind, lhs: &Sugg<'_>, rhs: &Sugg<'_>) -> Sugg<'static> {
make_assoc(AssocOp::from_ast_binop(op), lhs, rhs)
}

View file

@ -290,22 +290,24 @@ fn check_tts(cx: &EarlyContext<'a>, tts: &ThinTokenStream, is_write: bool) -> Op
idx += 1;
},
ExprKind::Assign(lhs, rhs) => {
if let ExprKind::Path(_, p) = &lhs.node {
let mut all_simple = true;
let mut seen = false;
for arg in &args {
match arg.position {
| ArgumentImplicitlyIs(_)
| ArgumentIs(_)
=> {},
ArgumentNamed(name) => if *p == name {
seen = true;
all_simple &= arg.format == SIMPLE;
},
if let ExprKind::Lit(_) = rhs.node {
if let ExprKind::Path(_, p) = &lhs.node {
let mut all_simple = true;
let mut seen = false;
for arg in &args {
match arg.position {
| ArgumentImplicitlyIs(_)
| ArgumentIs(_)
=> {},
ArgumentNamed(name) => if *p == name {
seen = true;
all_simple &= arg.format == SIMPLE;
},
}
}
if all_simple && seen {
span_lint(cx, lint, rhs.span, "literal with an empty format string");
}
}
if all_simple && seen {
span_lint(cx, lint, rhs.span, "literal with an empty format string");
}
}
},

View file

@ -116,7 +116,7 @@ fn warn_for_built_in_methods_with_negation() {
}
#[allow(neg_cmp_op_on_partial_ord)]
fn dont_warn_for_negated_partial_ord_comparision() {
fn dont_warn_for_negated_partial_ord_comparison() {
let a: f64 = unimplemented!();
let b: f64 = unimplemented!();
let _ = !(a < b);

View file

@ -31,11 +31,11 @@ fn main() {
if x.is_ok() {
x = Err(());
x.unwrap(); // not unnecessary because of mutation of x
// it will always panic but the lint is not smart enoguh to see this (it only checks if conditions).
// it will always panic but the lint is not smart enough to see this (it only checks if conditions).
} else {
x = Ok(());
x.unwrap_err(); // not unnecessary because of mutation of x
// it will always panic but the lint is not smart enoguh to see this (it only checks if conditions).
// it will always panic but the lint is not smart enough to see this (it only checks if conditions).
}
}

View file

@ -389,7 +389,7 @@ fn main() {
let m: Rc<HashMap<u64, u64>> = Rc::new(HashMap::new());
for (_, v) in &*m {
let _v = v;
// Here the `*` is not actually necesarry, but the test tests that we don't
// Here the `*` is not actually necessary, but the test tests that we don't
// suggest
// `in *m.values()` as we used to
}

View file

@ -9,7 +9,7 @@ fn foob() -> bool { unimplemented!() }
#[allow(many_single_char_names)]
fn immutable_condition() {
// Should warn when all vars mentionned are immutable
// Should warn when all vars mentioned are immutable
let y = 0;
while y < 10 {
println!("KO - y is immutable");
@ -69,11 +69,11 @@ fn unused_var() {
while i < 3 {
j = 3;
println!("KO - i not mentionned");
println!("KO - i not mentioned");
}
while i < 3 && j > 0 {
println!("KO - i and j not mentionned");
println!("KO - i and j not mentioned");
}
while i < 3 {
@ -84,7 +84,7 @@ fn unused_var() {
while i < 3 && j > 0 {
i = 5;
println!("OK - i in cond and mentionned");
println!("OK - i in cond and mentioned");
}
}

View file

@ -164,7 +164,7 @@ error: Err(_) will match all errors, maybe not a good idea
| ^^^^^^
|
= note: `-D match-wild-err-arm` implied by `-D warnings`
= note: to remove this warning, match each error seperately or use unreachable macro
= note: to remove this warning, match each error separately or use unreachable macro
error: this `match` has identical arm bodies
--> $DIR/matches.rs:131:18
@ -191,7 +191,7 @@ error: Err(_) will match all errors, maybe not a good idea
138 | Err(_) => {panic!()}
| ^^^^^^
|
= note: to remove this warning, match each error seperately or use unreachable macro
= note: to remove this warning, match each error separately or use unreachable macro
error: this `match` has identical arm bodies
--> $DIR/matches.rs:137:18
@ -217,7 +217,7 @@ error: Err(_) will match all errors, maybe not a good idea
144 | Err(_) => {panic!();}
| ^^^^^^
|
= note: to remove this warning, match each error seperately or use unreachable macro
= note: to remove this warning, match each error separately or use unreachable macro
error: this `match` has identical arm bodies
--> $DIR/matches.rs:143:18

View file

@ -59,9 +59,9 @@ fn main() {
// Issue 2856: False positive on assert!()
//
// The macro always negates the result of the given comparision in its
// The macro always negates the result of the given comparison in its
// internal check which automatically triggered the lint. As it's an
// external macro there was no chance to do anything about it which lead
// external macro there was no chance to do anything about it which led
// to a whitelisting of all external macros.
assert!(a_value < another_value);
}

View file

@ -1,4 +1,4 @@
error: The use of negated comparision operators on partially orded types produces code that is hard to read and refactor. Please consider to use the `partial_cmp` instead, to make it clear that the two values could be incomparable.
error: The use of negated comparison operators on partially ordered types produces code that is hard to read and refactor. Please consider using the `partial_cmp` method instead, to make it clear that the two values could be incomparable.
--> $DIR/neg_cmp_op_on_partial_ord.rs:17:21
|
17 | let _not_less = !(a_value < another_value);
@ -6,19 +6,19 @@ error: The use of negated comparision operators on partially orded types produce
|
= note: `-D neg-cmp-op-on-partial-ord` implied by `-D warnings`
error: The use of negated comparision operators on partially orded types produces code that is hard to read and refactor. Please consider to use the `partial_cmp` instead, to make it clear that the two values could be incomparable.
error: The use of negated comparison operators on partially ordered types produces code that is hard to read and refactor. Please consider using the `partial_cmp` method instead, to make it clear that the two values could be incomparable.
--> $DIR/neg_cmp_op_on_partial_ord.rs:20:30
|
20 | let _not_less_or_equal = !(a_value <= another_value);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: The use of negated comparision operators on partially orded types produces code that is hard to read and refactor. Please consider to use the `partial_cmp` instead, to make it clear that the two values could be incomparable.
error: The use of negated comparison operators on partially ordered types produces code that is hard to read and refactor. Please consider using the `partial_cmp` method instead, to make it clear that the two values could be incomparable.
--> $DIR/neg_cmp_op_on_partial_ord.rs:23:24
|
23 | let _not_greater = !(a_value > another_value);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
error: The use of negated comparision operators on partially orded types produces code that is hard to read and refactor. Please consider to use the `partial_cmp` instead, to make it clear that the two values could be incomparable.
error: The use of negated comparison operators on partially ordered types produces code that is hard to read and refactor. Please consider using the `partial_cmp` method instead, to make it clear that the two values could be incomparable.
--> $DIR/neg_cmp_op_on_partial_ord.rs:26:33
|
26 | let _not_greater_or_equal = !(a_value >= another_value);

View file

@ -8,6 +8,7 @@ fn main() {
println!("Hello");
let world = "world";
println!("Hello {}", world);
println!("Hello {world}", world=world);
println!("3 in hex is {:X}", 3);
println!("2 + 1 = {:.4}", 3);
println!("2 + 1 = {:5.4}", 3);

View file

@ -1,87 +1,87 @@
error: literal with an empty format string
--> $DIR/print_literal.rs:23:71
--> $DIR/print_literal.rs:24:71
|
23 | println!("{} of {:b} people know binary, the other half doesn't", 1, 2);
24 | println!("{} of {:b} people know binary, the other half doesn't", 1, 2);
| ^
|
= note: `-D print-literal` implied by `-D warnings`
error: literal with an empty format string
--> $DIR/print_literal.rs:24:24
--> $DIR/print_literal.rs:25:24
|
24 | print!("Hello {}", "world");
25 | print!("Hello {}", "world");
| ^^^^^^^
error: literal with an empty format string
--> $DIR/print_literal.rs:25:36
--> $DIR/print_literal.rs:26:36
|
25 | println!("Hello {} {}", world, "world");
26 | println!("Hello {} {}", world, "world");
| ^^^^^^^
error: literal with an empty format string
--> $DIR/print_literal.rs:26:26
--> $DIR/print_literal.rs:27:26
|
26 | println!("Hello {}", "world");
27 | println!("Hello {}", "world");
| ^^^^^^^
error: literal with an empty format string
--> $DIR/print_literal.rs:27:30
--> $DIR/print_literal.rs:28:30
|
27 | println!("10 / 4 is {}", 2.5);
28 | println!("10 / 4 is {}", 2.5);
| ^^^
error: literal with an empty format string
--> $DIR/print_literal.rs:28:28
--> $DIR/print_literal.rs:29:28
|
28 | println!("2 + 1 = {}", 3);
29 | println!("2 + 1 = {}", 3);
| ^
error: literal with an empty format string
--> $DIR/print_literal.rs:33:25
|
33 | println!("{0} {1}", "hello", "world");
| ^^^^^^^
error: literal with an empty format string
--> $DIR/print_literal.rs:33:34
|
33 | println!("{0} {1}", "hello", "world");
| ^^^^^^^
error: literal with an empty format string
--> $DIR/print_literal.rs:34:25
|
34 | println!("{1} {0}", "hello", "world");
34 | println!("{0} {1}", "hello", "world");
| ^^^^^^^
error: literal with an empty format string
--> $DIR/print_literal.rs:34:34
|
34 | println!("{1} {0}", "hello", "world");
34 | println!("{0} {1}", "hello", "world");
| ^^^^^^^
error: literal with an empty format string
--> $DIR/print_literal.rs:37:33
--> $DIR/print_literal.rs:35:25
|
37 | println!("{foo} {bar}", foo="hello", bar="world");
| ^^^^^^^
35 | println!("{1} {0}", "hello", "world");
| ^^^^^^^
error: literal with an empty format string
--> $DIR/print_literal.rs:37:46
--> $DIR/print_literal.rs:35:34
|
37 | println!("{foo} {bar}", foo="hello", bar="world");
| ^^^^^^^
35 | println!("{1} {0}", "hello", "world");
| ^^^^^^^
error: literal with an empty format string
--> $DIR/print_literal.rs:38:33
|
38 | println!("{bar} {foo}", foo="hello", bar="world");
38 | println!("{foo} {bar}", foo="hello", bar="world");
| ^^^^^^^
error: literal with an empty format string
--> $DIR/print_literal.rs:38:46
|
38 | println!("{bar} {foo}", foo="hello", bar="world");
38 | println!("{foo} {bar}", foo="hello", bar="world");
| ^^^^^^^
error: literal with an empty format string
--> $DIR/print_literal.rs:39:33
|
39 | println!("{bar} {foo}", foo="hello", bar="world");
| ^^^^^^^
error: literal with an empty format string
--> $DIR/print_literal.rs:39:46
|
39 | println!("{bar} {foo}", foo="hello", bar="world");
| ^^^^^^^
error: aborting due to 14 previous errors

View file

@ -11,6 +11,7 @@ fn main() {
writeln!(&mut v, "Hello");
let world = "world";
writeln!(&mut v, "Hello {}", world);
writeln!(&mut v, "Hello {world}", world=world);
writeln!(&mut v, "3 in hex is {:X}", 3);
writeln!(&mut v, "2 + 1 = {:.4}", 3);
writeln!(&mut v, "2 + 1 = {:5.4}", 3);

View file

@ -1,87 +1,87 @@
error: literal with an empty format string
--> $DIR/write_literal.rs:26:79
--> $DIR/write_literal.rs:27:79
|
26 | writeln!(&mut v, "{} of {:b} people know binary, the other half doesn't", 1, 2);
27 | writeln!(&mut v, "{} of {:b} people know binary, the other half doesn't", 1, 2);
| ^
|
= note: `-D write-literal` implied by `-D warnings`
error: literal with an empty format string
--> $DIR/write_literal.rs:27:32
--> $DIR/write_literal.rs:28:32
|
27 | write!(&mut v, "Hello {}", "world");
28 | write!(&mut v, "Hello {}", "world");
| ^^^^^^^
error: literal with an empty format string
--> $DIR/write_literal.rs:28:44
--> $DIR/write_literal.rs:29:44
|
28 | writeln!(&mut v, "Hello {} {}", world, "world");
29 | writeln!(&mut v, "Hello {} {}", world, "world");
| ^^^^^^^
error: literal with an empty format string
--> $DIR/write_literal.rs:29:34
--> $DIR/write_literal.rs:30:34
|
29 | writeln!(&mut v, "Hello {}", "world");
30 | writeln!(&mut v, "Hello {}", "world");
| ^^^^^^^
error: literal with an empty format string
--> $DIR/write_literal.rs:30:38
--> $DIR/write_literal.rs:31:38
|
30 | writeln!(&mut v, "10 / 4 is {}", 2.5);
31 | writeln!(&mut v, "10 / 4 is {}", 2.5);
| ^^^
error: literal with an empty format string
--> $DIR/write_literal.rs:31:36
--> $DIR/write_literal.rs:32:36
|
31 | writeln!(&mut v, "2 + 1 = {}", 3);
32 | writeln!(&mut v, "2 + 1 = {}", 3);
| ^
error: literal with an empty format string
--> $DIR/write_literal.rs:36:33
|
36 | writeln!(&mut v, "{0} {1}", "hello", "world");
| ^^^^^^^
error: literal with an empty format string
--> $DIR/write_literal.rs:36:42
|
36 | writeln!(&mut v, "{0} {1}", "hello", "world");
| ^^^^^^^
error: literal with an empty format string
--> $DIR/write_literal.rs:37:33
|
37 | writeln!(&mut v, "{1} {0}", "hello", "world");
37 | writeln!(&mut v, "{0} {1}", "hello", "world");
| ^^^^^^^
error: literal with an empty format string
--> $DIR/write_literal.rs:37:42
|
37 | writeln!(&mut v, "{1} {0}", "hello", "world");
37 | writeln!(&mut v, "{0} {1}", "hello", "world");
| ^^^^^^^
error: literal with an empty format string
--> $DIR/write_literal.rs:40:41
--> $DIR/write_literal.rs:38:33
|
40 | writeln!(&mut v, "{foo} {bar}", foo="hello", bar="world");
| ^^^^^^^
38 | writeln!(&mut v, "{1} {0}", "hello", "world");
| ^^^^^^^
error: literal with an empty format string
--> $DIR/write_literal.rs:40:54
--> $DIR/write_literal.rs:38:42
|
40 | writeln!(&mut v, "{foo} {bar}", foo="hello", bar="world");
| ^^^^^^^
38 | writeln!(&mut v, "{1} {0}", "hello", "world");
| ^^^^^^^
error: literal with an empty format string
--> $DIR/write_literal.rs:41:41
|
41 | writeln!(&mut v, "{bar} {foo}", foo="hello", bar="world");
41 | writeln!(&mut v, "{foo} {bar}", foo="hello", bar="world");
| ^^^^^^^
error: literal with an empty format string
--> $DIR/write_literal.rs:41:54
|
41 | writeln!(&mut v, "{bar} {foo}", foo="hello", bar="world");
41 | writeln!(&mut v, "{foo} {bar}", foo="hello", bar="world");
| ^^^^^^^
error: literal with an empty format string
--> $DIR/write_literal.rs:42:41
|
42 | writeln!(&mut v, "{bar} {foo}", foo="hello", bar="world");
| ^^^^^^^
error: literal with an empty format string
--> $DIR/write_literal.rs:42:54
|
42 | writeln!(&mut v, "{bar} {foo}", foo="hello", bar="world");
| ^^^^^^^
error: aborting due to 14 previous errors

View file

@ -14,7 +14,7 @@
<body>
<div class="container" ng-app="clippy" ng-controller="docVersions">
<div class="page-header">
<h1>Clippy lints documention</h1>
<h1>Clippy lints documentation</h1>
</div>
<div ng-cloak>

View file

@ -192,8 +192,8 @@ def main(print_only=False, check=False):
# update the links in the CHANGELOG
changed |= replace_region(
'CHANGELOG.md',
"<!-- begin autogenerated links to wiki -->",
"<!-- end autogenerated links to wiki -->",
"<!-- begin autogenerated links to lint list -->",
"<!-- end autogenerated links to lint list -->",
lambda: ["[`{0}`]: {1}#{0}\n".format(l[1], docs_link) for l in
sorted(all_lints + deprecated_lints,
key=lambda l: l[1])],