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

@ -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");
}
}
},