mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-11-14 17:07:17 +00:00
Fix fallout from re-applying patches
This commit is contained in:
parent
fb6839db2d
commit
01b17af108
5 changed files with 15 additions and 19 deletions
|
@ -107,7 +107,8 @@ fn check_arm<'tcx>(
|
|||
(Some(a), Some(b)) => SpanlessEq::new(cx).eq_expr(a, b),
|
||||
};
|
||||
// the binding must not be used in the if guard
|
||||
if outer_guard.map_or(true, |(Guard::If(e) | Guard::IfLet(_, e))| !is_local_used(cx, *e, binding_id)); // ...or anywhere in the inner expression
|
||||
if outer_guard.map_or(true, |(Guard::If(e) | Guard::IfLet(_, e))| !is_local_used(cx, *e, binding_id));
|
||||
// ...or anywhere in the inner expression
|
||||
if match inner {
|
||||
IfLetOrMatch::IfLet(_, _, body, els) => {
|
||||
!is_local_used(cx, body, binding_id) && els.map_or(true, |e| !is_local_used(cx, e, binding_id))
|
||||
|
|
|
@ -2199,6 +2199,7 @@ pub fn register_renamed(ls: &mut rustc_lint::LintStore) {
|
|||
ls.register_renamed("clippy::temporary_cstring_as_ptr", "temporary_cstring_as_ptr");
|
||||
ls.register_renamed("clippy::panic_params", "non_fmt_panics");
|
||||
ls.register_renamed("clippy::unknown_clippy_lints", "unknown_lints");
|
||||
ls.register_renamed("clippy::invalid_atomic_ordering", "invalid_atomic_ordering");
|
||||
}
|
||||
|
||||
// only exists to let the dogfood integration test works.
|
||||
|
|
|
@ -3,7 +3,8 @@ use clippy_utils::higher;
|
|||
use clippy_utils::sugg::Sugg;
|
||||
use clippy_utils::ty::is_type_diagnostic_item;
|
||||
use clippy_utils::{
|
||||
can_move_expr_to_closure, eager_or_lazy, in_macro, is_else_clause, is_lang_ctor, peel_hir_expr_while, CaptureKind,
|
||||
can_move_expr_to_closure, eager_or_lazy, in_constant, in_macro, is_else_clause, is_lang_ctor, peel_hir_expr_while,
|
||||
CaptureKind,
|
||||
};
|
||||
use if_chain::if_chain;
|
||||
use rustc_errors::Applicability;
|
||||
|
@ -126,6 +127,7 @@ fn format_option_in_sugg(cx: &LateContext<'_>, cond_expr: &Expr<'_>, as_ref: boo
|
|||
fn detect_option_if_let_else<'tcx>(cx: &LateContext<'tcx>, expr: &Expr<'tcx>) -> Option<OptionIfLetElseOccurence> {
|
||||
if_chain! {
|
||||
if !in_macro(expr.span); // Don't lint macros, because it behaves weirdly
|
||||
if !in_constant(cx, expr.hir_id);
|
||||
if let Some(higher::IfLet { let_pat, let_expr, if_then, if_else: Some(if_else) })
|
||||
= higher::IfLet::hir(cx, expr);
|
||||
if !is_else_clause(cx.tcx, expr);
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
use clippy_utils::consts::{constant_simple, Constant};
|
||||
use clippy_utils::diagnostics::{span_lint, span_lint_and_help, span_lint_and_sugg, span_lint_and_then};
|
||||
use clippy_utils::higher;
|
||||
use clippy_utils::source::snippet;
|
||||
use clippy_utils::ty::match_type;
|
||||
use clippy_utils::{
|
||||
|
@ -17,8 +18,8 @@ use rustc_hir::def_id::DefId;
|
|||
use rustc_hir::hir_id::CRATE_HIR_ID;
|
||||
use rustc_hir::intravisit::{NestedVisitorMap, Visitor};
|
||||
use rustc_hir::{
|
||||
BinOpKind, Block, Crate, Expr, ExprKind, HirId, Item, Local, MatchSource, MutTy, Mutability, Node, Path, Stmt,
|
||||
StmtKind, Ty, TyKind, UnOp,
|
||||
BinOpKind, Block, Crate, Expr, ExprKind, HirId, Item, Local, MutTy, Mutability, Node, Path, Stmt, StmtKind, Ty,
|
||||
TyKind, UnOp,
|
||||
};
|
||||
use rustc_lint::{EarlyContext, EarlyLintPass, LateContext, LateLintPass, LintContext};
|
||||
use rustc_middle::hir::map::Map;
|
||||
|
@ -1106,16 +1107,10 @@ impl<'tcx> LateLintPass<'tcx> for IfChainStyle {
|
|||
}
|
||||
|
||||
fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx hir::Expr<'_>) {
|
||||
let (cond, then, els) = match expr.kind {
|
||||
ExprKind::If(cond, then, els) => (Some(cond), then, els.is_some()),
|
||||
ExprKind::Match(
|
||||
_,
|
||||
[arm, ..],
|
||||
MatchSource::IfLetDesugar {
|
||||
contains_else_clause: els,
|
||||
},
|
||||
) => (None, arm.body, els),
|
||||
_ => return,
|
||||
let (cond, then, els) = if let Some(higher::IfOrIfLet { cond, r#else, then }) = higher::IfOrIfLet::hir(expr) {
|
||||
(cond, then, r#else.is_some())
|
||||
} else {
|
||||
return;
|
||||
};
|
||||
let then_block = match then.kind {
|
||||
ExprKind::Block(block, _) => block,
|
||||
|
@ -1131,7 +1126,6 @@ impl<'tcx> LateLintPass<'tcx> for IfChainStyle {
|
|||
};
|
||||
// check for `if a && b;`
|
||||
if_chain! {
|
||||
if let Some(cond) = cond;
|
||||
if let ExprKind::Binary(op, _, _) = cond.kind;
|
||||
if op.node == BinOpKind::And;
|
||||
if cx.sess().source_map().is_multiline(cond.span);
|
||||
|
@ -1166,9 +1160,7 @@ fn check_nested_if_chains(
|
|||
_ => return,
|
||||
};
|
||||
if_chain! {
|
||||
if matches!(tail.kind,
|
||||
ExprKind::If(_, _, None)
|
||||
| ExprKind::Match(.., MatchSource::IfLetDesugar { contains_else_clause: false }));
|
||||
if let Some(higher::IfOrIfLet { r#else: None, .. }) = higher::IfOrIfLet::hir(tail);
|
||||
let sm = cx.sess().source_map();
|
||||
if head
|
||||
.iter()
|
||||
|
|
|
@ -329,7 +329,7 @@ fn has_enclosing_paren(sugg: impl AsRef<str>) -> bool {
|
|||
}
|
||||
}
|
||||
|
||||
// Copied from the rust standart library, and then edited
|
||||
/// Copied from the rust standard library, and then edited
|
||||
macro_rules! forward_binop_impls_to_ref {
|
||||
(impl $imp:ident, $method:ident for $t:ty, type Output = $o:ty) => {
|
||||
impl $imp<$t> for &$t {
|
||||
|
|
Loading…
Reference in a new issue