Skip to content

Commit 01b17af

Browse files
committed
Fix fallout from re-applying patches
1 parent fb6839d commit 01b17af

File tree

5 files changed

+15
-19
lines changed

5 files changed

+15
-19
lines changed

clippy_lints/src/collapsible_match.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,8 @@ fn check_arm<'tcx>(
107107
(Some(a), Some(b)) => SpanlessEq::new(cx).eq_expr(a, b),
108108
};
109109
// the binding must not be used in the if guard
110-
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
110+
if outer_guard.map_or(true, |(Guard::If(e) | Guard::IfLet(_, e))| !is_local_used(cx, *e, binding_id));
111+
// ...or anywhere in the inner expression
111112
if match inner {
112113
IfLetOrMatch::IfLet(_, _, body, els) => {
113114
!is_local_used(cx, body, binding_id) && els.map_or(true, |e| !is_local_used(cx, e, binding_id))

clippy_lints/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -2199,6 +2199,7 @@ pub fn register_renamed(ls: &mut rustc_lint::LintStore) {
21992199
ls.register_renamed("clippy::temporary_cstring_as_ptr", "temporary_cstring_as_ptr");
22002200
ls.register_renamed("clippy::panic_params", "non_fmt_panics");
22012201
ls.register_renamed("clippy::unknown_clippy_lints", "unknown_lints");
2202+
ls.register_renamed("clippy::invalid_atomic_ordering", "invalid_atomic_ordering");
22022203
}
22032204

22042205
// only exists to let the dogfood integration test works.

clippy_lints/src/option_if_let_else.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ use clippy_utils::higher;
33
use clippy_utils::sugg::Sugg;
44
use clippy_utils::ty::is_type_diagnostic_item;
55
use clippy_utils::{
6-
can_move_expr_to_closure, eager_or_lazy, in_macro, is_else_clause, is_lang_ctor, peel_hir_expr_while, CaptureKind,
6+
can_move_expr_to_closure, eager_or_lazy, in_constant, in_macro, is_else_clause, is_lang_ctor, peel_hir_expr_while,
7+
CaptureKind,
78
};
89
use if_chain::if_chain;
910
use rustc_errors::Applicability;
@@ -126,6 +127,7 @@ fn format_option_in_sugg(cx: &LateContext<'_>, cond_expr: &Expr<'_>, as_ref: boo
126127
fn detect_option_if_let_else<'tcx>(cx: &LateContext<'tcx>, expr: &Expr<'tcx>) -> Option<OptionIfLetElseOccurence> {
127128
if_chain! {
128129
if !in_macro(expr.span); // Don't lint macros, because it behaves weirdly
130+
if !in_constant(cx, expr.hir_id);
129131
if let Some(higher::IfLet { let_pat, let_expr, if_then, if_else: Some(if_else) })
130132
= higher::IfLet::hir(cx, expr);
131133
if !is_else_clause(cx.tcx, expr);

clippy_lints/src/utils/internal_lints.rs

+8-16
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
use clippy_utils::consts::{constant_simple, Constant};
22
use clippy_utils::diagnostics::{span_lint, span_lint_and_help, span_lint_and_sugg, span_lint_and_then};
3+
use clippy_utils::higher;
34
use clippy_utils::source::snippet;
45
use clippy_utils::ty::match_type;
56
use clippy_utils::{
@@ -17,8 +18,8 @@ use rustc_hir::def_id::DefId;
1718
use rustc_hir::hir_id::CRATE_HIR_ID;
1819
use rustc_hir::intravisit::{NestedVisitorMap, Visitor};
1920
use rustc_hir::{
20-
BinOpKind, Block, Crate, Expr, ExprKind, HirId, Item, Local, MatchSource, MutTy, Mutability, Node, Path, Stmt,
21-
StmtKind, Ty, TyKind, UnOp,
21+
BinOpKind, Block, Crate, Expr, ExprKind, HirId, Item, Local, MutTy, Mutability, Node, Path, Stmt, StmtKind, Ty,
22+
TyKind, UnOp,
2223
};
2324
use rustc_lint::{EarlyContext, EarlyLintPass, LateContext, LateLintPass, LintContext};
2425
use rustc_middle::hir::map::Map;
@@ -1106,16 +1107,10 @@ impl<'tcx> LateLintPass<'tcx> for IfChainStyle {
11061107
}
11071108

11081109
fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx hir::Expr<'_>) {
1109-
let (cond, then, els) = match expr.kind {
1110-
ExprKind::If(cond, then, els) => (Some(cond), then, els.is_some()),
1111-
ExprKind::Match(
1112-
_,
1113-
[arm, ..],
1114-
MatchSource::IfLetDesugar {
1115-
contains_else_clause: els,
1116-
},
1117-
) => (None, arm.body, els),
1118-
_ => return,
1110+
let (cond, then, els) = if let Some(higher::IfOrIfLet { cond, r#else, then }) = higher::IfOrIfLet::hir(expr) {
1111+
(cond, then, r#else.is_some())
1112+
} else {
1113+
return;
11191114
};
11201115
let then_block = match then.kind {
11211116
ExprKind::Block(block, _) => block,
@@ -1131,7 +1126,6 @@ impl<'tcx> LateLintPass<'tcx> for IfChainStyle {
11311126
};
11321127
// check for `if a && b;`
11331128
if_chain! {
1134-
if let Some(cond) = cond;
11351129
if let ExprKind::Binary(op, _, _) = cond.kind;
11361130
if op.node == BinOpKind::And;
11371131
if cx.sess().source_map().is_multiline(cond.span);
@@ -1166,9 +1160,7 @@ fn check_nested_if_chains(
11661160
_ => return,
11671161
};
11681162
if_chain! {
1169-
if matches!(tail.kind,
1170-
ExprKind::If(_, _, None)
1171-
| ExprKind::Match(.., MatchSource::IfLetDesugar { contains_else_clause: false }));
1163+
if let Some(higher::IfOrIfLet { r#else: None, .. }) = higher::IfOrIfLet::hir(tail);
11721164
let sm = cx.sess().source_map();
11731165
if head
11741166
.iter()

clippy_utils/src/sugg.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,7 @@ fn has_enclosing_paren(sugg: impl AsRef<str>) -> bool {
329329
}
330330
}
331331

332-
// Copied from the rust standart library, and then edited
332+
/// Copied from the rust standard library, and then edited
333333
macro_rules! forward_binop_impls_to_ref {
334334
(impl $imp:ident, $method:ident for $t:ty, type Output = $o:ty) => {
335335
impl $imp<$t> for &$t {

0 commit comments

Comments
 (0)