Skip to content

Commit 8eeb3fe

Browse files
author
Michael Wright
committed
Merge branch 'master' into issue2894
2 parents 137f944 + b0dabce commit 8eeb3fe

22 files changed

+117
-109
lines changed

CHANGELOG.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -507,7 +507,7 @@ All notable changes to this project will be documented in this file.
507507
## 0.0.74 — 2016-06-07
508508
* Fix bug with `cargo-clippy` JSON parsing
509509
* Add the `CLIPPY_DISABLE_DOCS_LINKS` environment variable to deactivate the
510-
“for further information visit *wiki-link*” message.
510+
“for further information visit *lint-link*” message.
511511

512512
## 0.0.73 — 2016-06-05
513513
* Fix false positives in [`useless_let_if_seq`]
@@ -612,7 +612,7 @@ All notable changes to this project will be documented in this file.
612612
[`AsRef`]: https://doc.rust-lang.org/std/convert/trait.AsRef.html
613613
[configuration file]: ./rust-clippy#configuration
614614

615-
<!-- begin autogenerated links to wiki -->
615+
<!-- begin autogenerated links to lint list -->
616616
[`absurd_extreme_comparisons`]: https://rust-lang-nursery.github.io/rust-clippy/master/index.html#absurd_extreme_comparisons
617617
[`almost_swapped`]: https://rust-lang-nursery.github.io/rust-clippy/master/index.html#almost_swapped
618618
[`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.
894894
[`zero_prefixed_literal`]: https://rust-lang-nursery.github.io/rust-clippy/master/index.html#zero_prefixed_literal
895895
[`zero_ptr`]: https://rust-lang-nursery.github.io/rust-clippy/master/index.html#zero_ptr
896896
[`zero_width_space`]: https://rust-lang-nursery.github.io/rust-clippy/master/index.html#zero_width_space
897-
<!-- end autogenerated links to wiki -->
897+
<!-- end autogenerated links to lint list -->

clippy_lints/src/eta_reduction.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,11 @@ pub struct EtaPass;
1515
/// **Why is this bad?** Needlessly creating a closure adds code for no benefit
1616
/// and gives the optimizer more work.
1717
///
18-
/// **Known problems:** None.
18+
/// **Known problems:** If creating the closure inside the closure has a side-
19+
/// effect then moving the closure creation out will change when that side-
20+
/// effect runs.
21+
/// See https://github.com/rust-lang-nursery/rust-clippy/issues/1439 for more
22+
/// details.
1923
///
2024
/// **Example:**
2125
/// ```rust

clippy_lints/src/excessive_precision.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for ExcessivePrecision {
6565
}
6666

6767
impl ExcessivePrecision {
68-
// None if nothing to lint, Some(suggestion) if lint neccessary
68+
// None if nothing to lint, Some(suggestion) if lint necessary
6969
fn check(&self, sym: Symbol, fty: FloatTy) -> Option<String> {
7070
let max = max_digits(fty);
7171
let sym_str = sym.as_str();

clippy_lints/src/loops.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2217,7 +2217,7 @@ impl<'a, 'tcx> Visitor<'tcx> for VarCollectorVisitor<'a, 'tcx> {
22172217
fn visit_expr(&mut self, ex: &'tcx Expr) {
22182218
match ex.node {
22192219
ExprKind::Path(_) => self.insert_def_id(ex),
2220-
// If there is any fuction/method call… we just stop analysis
2220+
// If there is any function/method call… we just stop analysis
22212221
ExprKind::Call(..) | ExprKind::MethodCall(..) => self.skip = true,
22222222

22232223
_ => walk_expr(self, ex),

clippy_lints/src/matches.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -383,7 +383,7 @@ fn check_wild_err_arm(cx: &LateContext<'_, '_>, ex: &Expr, arms: &[Arm]) {
383383
arm.pats[0].span,
384384
"Err(_) will match all errors, maybe not a good idea",
385385
arm.pats[0].span,
386-
"to remove this warning, match each error seperately \
386+
"to remove this warning, match each error separately \
387387
or use unreachable macro");
388388
}
389389
}

clippy_lints/src/neg_cmp_op_on_partial_ord.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,21 @@ use if_chain::if_chain;
66
use crate::utils::{self, paths, span_lint};
77

88
/// **What it does:**
9-
/// Checks for the usage of negated comparision operators on types which only implement
9+
/// Checks for the usage of negated comparison operators on types which only implement
1010
/// `PartialOrd` (e.g. `f64`).
1111
///
1212
/// **Why is this bad?**
1313
/// These operators make it easy to forget that the underlying types actually allow not only three
14-
/// potential Orderings (Less, Equal, Greater) but also a forth one (Uncomparable). Escpeccially if
15-
/// the operator based comparision result is negated it is easy to miss that fact.
14+
/// potential Orderings (Less, Equal, Greater) but also a fourth one (Uncomparable). This is
15+
/// especially easy to miss if the operator based comparison result is negated.
1616
///
1717
/// **Known problems:** None.
1818
///
1919
/// **Example:**
2020
///
2121
/// ```rust
22-
/// use core::cmp::Ordering;
23-
///
22+
/// use std::cmp::Ordering;
23+
///
2424
/// // Bad
2525
/// let a = 1.0;
2626
/// let b = std::f64::NAN;
@@ -39,7 +39,7 @@ use crate::utils::{self, paths, span_lint};
3939
declare_clippy_lint! {
4040
pub NEG_CMP_OP_ON_PARTIAL_ORD,
4141
complexity,
42-
"The use of negated comparision operators on partially orded types may produce confusing code."
42+
"The use of negated comparison operators on partially ordered types may produce confusing code."
4343
}
4444

4545
pub struct NoNegCompOpForPartialOrd;
@@ -85,10 +85,10 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NoNegCompOpForPartialOrd {
8585
cx,
8686
NEG_CMP_OP_ON_PARTIAL_ORD,
8787
expr.span,
88-
"The use of negated comparision operators on partially orded \
88+
"The use of negated comparison operators on partially ordered \
8989
types produces code that is hard to read and refactor. Please \
90-
consider to use the `partial_cmp` instead, to make it clear \
91-
that the two values could be incomparable."
90+
consider using the `partial_cmp` method instead, to make it \
91+
clear that the two values could be incomparable."
9292
)
9393
}
9494
}

clippy_lints/src/types.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -700,7 +700,7 @@ declare_clippy_lint! {
700700

701701
/// **What it does:** Checks for casts of a function pointer to a numeric type not enough to store address.
702702
///
703-
/// **Why is this bad?** Casting a function pointer to not eligable type could truncate the address value.
703+
/// **Why is this bad?** Casting a function pointer to not eligible type could truncate the address value.
704704
///
705705
/// **Known problems:** None.
706706
///

clippy_lints/src/utils/sugg.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,7 @@ pub fn make_assoc(op: AssocOp, lhs: &Sugg<'_>, rhs: &Sugg<'_>) -> Sugg<'static>
334334
Sugg::BinOp(op, sugg.into())
335335
}
336336

337-
/// Convinience wrapper arround `make_assoc` and `AssocOp::from_ast_binop`.
337+
/// Convenience wrapper around `make_assoc` and `AssocOp::from_ast_binop`.
338338
pub fn make_binop(op: ast::BinOpKind, lhs: &Sugg<'_>, rhs: &Sugg<'_>) -> Sugg<'static> {
339339
make_assoc(AssocOp::from_ast_binop(op), lhs, rhs)
340340
}

clippy_lints/src/write.rs

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -290,22 +290,24 @@ fn check_tts(cx: &EarlyContext<'a>, tts: &ThinTokenStream, is_write: bool) -> Op
290290
idx += 1;
291291
},
292292
ExprKind::Assign(lhs, rhs) => {
293-
if let ExprKind::Path(_, p) = &lhs.node {
294-
let mut all_simple = true;
295-
let mut seen = false;
296-
for arg in &args {
297-
match arg.position {
298-
| ArgumentImplicitlyIs(_)
299-
| ArgumentIs(_)
300-
=> {},
301-
ArgumentNamed(name) => if *p == name {
302-
seen = true;
303-
all_simple &= arg.format == SIMPLE;
304-
},
293+
if let ExprKind::Lit(_) = rhs.node {
294+
if let ExprKind::Path(_, p) = &lhs.node {
295+
let mut all_simple = true;
296+
let mut seen = false;
297+
for arg in &args {
298+
match arg.position {
299+
| ArgumentImplicitlyIs(_)
300+
| ArgumentIs(_)
301+
=> {},
302+
ArgumentNamed(name) => if *p == name {
303+
seen = true;
304+
all_simple &= arg.format == SIMPLE;
305+
},
306+
}
307+
}
308+
if all_simple && seen {
309+
span_lint(cx, lint, rhs.span, "literal with an empty format string");
305310
}
306-
}
307-
if all_simple && seen {
308-
span_lint(cx, lint, rhs.span, "literal with an empty format string");
309311
}
310312
}
311313
},

tests/ui/booleans.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ fn warn_for_built_in_methods_with_negation() {
116116
}
117117

118118
#[allow(neg_cmp_op_on_partial_ord)]
119-
fn dont_warn_for_negated_partial_ord_comparision() {
119+
fn dont_warn_for_negated_partial_ord_comparison() {
120120
let a: f64 = unimplemented!();
121121
let b: f64 = unimplemented!();
122122
let _ = !(a < b);

tests/ui/checked_unwrap.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,11 @@ fn main() {
3131
if x.is_ok() {
3232
x = Err(());
3333
x.unwrap(); // not unnecessary because of mutation of x
34-
// it will always panic but the lint is not smart enoguh to see this (it only checks if conditions).
34+
// it will always panic but the lint is not smart enough to see this (it only checks if conditions).
3535
} else {
3636
x = Ok(());
3737
x.unwrap_err(); // not unnecessary because of mutation of x
38-
// it will always panic but the lint is not smart enoguh to see this (it only checks if conditions).
38+
// it will always panic but the lint is not smart enough to see this (it only checks if conditions).
3939
}
4040
}
4141

tests/ui/for_loop.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,7 @@ fn main() {
389389
let m: Rc<HashMap<u64, u64>> = Rc::new(HashMap::new());
390390
for (_, v) in &*m {
391391
let _v = v;
392-
// Here the `*` is not actually necesarry, but the test tests that we don't
392+
// Here the `*` is not actually necessary, but the test tests that we don't
393393
// suggest
394394
// `in *m.values()` as we used to
395395
}

tests/ui/infinite_loop.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ fn foob() -> bool { unimplemented!() }
99

1010
#[allow(many_single_char_names)]
1111
fn immutable_condition() {
12-
// Should warn when all vars mentionned are immutable
12+
// Should warn when all vars mentioned are immutable
1313
let y = 0;
1414
while y < 10 {
1515
println!("KO - y is immutable");
@@ -69,11 +69,11 @@ fn unused_var() {
6969

7070
while i < 3 {
7171
j = 3;
72-
println!("KO - i not mentionned");
72+
println!("KO - i not mentioned");
7373
}
7474

7575
while i < 3 && j > 0 {
76-
println!("KO - i and j not mentionned");
76+
println!("KO - i and j not mentioned");
7777
}
7878

7979
while i < 3 {
@@ -84,7 +84,7 @@ fn unused_var() {
8484

8585
while i < 3 && j > 0 {
8686
i = 5;
87-
println!("OK - i in cond and mentionned");
87+
println!("OK - i in cond and mentioned");
8888
}
8989
}
9090

tests/ui/matches.stderr

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ error: Err(_) will match all errors, maybe not a good idea
164164
| ^^^^^^
165165
|
166166
= note: `-D match-wild-err-arm` implied by `-D warnings`
167-
= note: to remove this warning, match each error seperately or use unreachable macro
167+
= note: to remove this warning, match each error separately or use unreachable macro
168168

169169
error: this `match` has identical arm bodies
170170
--> $DIR/matches.rs:131:18
@@ -191,7 +191,7 @@ error: Err(_) will match all errors, maybe not a good idea
191191
138 | Err(_) => {panic!()}
192192
| ^^^^^^
193193
|
194-
= note: to remove this warning, match each error seperately or use unreachable macro
194+
= note: to remove this warning, match each error separately or use unreachable macro
195195

196196
error: this `match` has identical arm bodies
197197
--> $DIR/matches.rs:137:18
@@ -217,7 +217,7 @@ error: Err(_) will match all errors, maybe not a good idea
217217
144 | Err(_) => {panic!();}
218218
| ^^^^^^
219219
|
220-
= note: to remove this warning, match each error seperately or use unreachable macro
220+
= note: to remove this warning, match each error separately or use unreachable macro
221221

222222
error: this `match` has identical arm bodies
223223
--> $DIR/matches.rs:143:18

tests/ui/neg_cmp_op_on_partial_ord.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,9 @@ fn main() {
5959

6060
// Issue 2856: False positive on assert!()
6161
//
62-
// The macro always negates the result of the given comparision in its
62+
// The macro always negates the result of the given comparison in its
6363
// internal check which automatically triggered the lint. As it's an
64-
// external macro there was no chance to do anything about it which lead
64+
// external macro there was no chance to do anything about it which led
6565
// to a whitelisting of all external macros.
6666
assert!(a_value < another_value);
6767
}

tests/ui/neg_cmp_op_on_partial_ord.stderr

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
1-
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.
1+
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.
22
--> $DIR/neg_cmp_op_on_partial_ord.rs:17:21
33
|
44
17 | let _not_less = !(a_value < another_value);
55
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
66
|
77
= note: `-D neg-cmp-op-on-partial-ord` implied by `-D warnings`
88

9-
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.
9+
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.
1010
--> $DIR/neg_cmp_op_on_partial_ord.rs:20:30
1111
|
1212
20 | let _not_less_or_equal = !(a_value <= another_value);
1313
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
1414

15-
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.
15+
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.
1616
--> $DIR/neg_cmp_op_on_partial_ord.rs:23:24
1717
|
1818
23 | let _not_greater = !(a_value > another_value);
1919
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
2020

21-
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.
21+
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.
2222
--> $DIR/neg_cmp_op_on_partial_ord.rs:26:33
2323
|
2424
26 | let _not_greater_or_equal = !(a_value >= another_value);

tests/ui/print_literal.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ fn main() {
88
println!("Hello");
99
let world = "world";
1010
println!("Hello {}", world);
11+
println!("Hello {world}", world=world);
1112
println!("3 in hex is {:X}", 3);
1213
println!("2 + 1 = {:.4}", 3);
1314
println!("2 + 1 = {:5.4}", 3);

0 commit comments

Comments
 (0)