Skip to content

Commit 5b72632

Browse files
committed
move to sus and fix dogfood
1 parent 4e6cf00 commit 5b72632

File tree

4 files changed

+14
-15
lines changed

4 files changed

+14
-15
lines changed

clippy_lints/src/lib.register_all.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,7 @@ store.register_group(true, "clippy::all", Some("clippy_all"), vec![
278278
LintId::of(self_assignment::SELF_ASSIGNMENT),
279279
LintId::of(self_named_constructors::SELF_NAMED_CONSTRUCTORS),
280280
LintId::of(serde_api::SERDE_API_MISUSE),
281+
LintId::of(significant_drop_in_scrutinee::SIGNIFICANT_DROP_IN_SCRUTINEE),
281282
LintId::of(single_component_path_imports::SINGLE_COMPONENT_PATH_IMPORTS),
282283
LintId::of(size_of_in_element_count::SIZE_OF_IN_ELEMENT_COUNT),
283284
LintId::of(slow_vector_initialization::SLOW_VECTOR_INITIALIZATION),

clippy_lints/src/lib.register_nursery.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ store.register_group(true, "clippy::nursery", Some("clippy_nursery"), vec![
2525
LintId::of(path_buf_push_overwrite::PATH_BUF_PUSH_OVERWRITE),
2626
LintId::of(redundant_pub_crate::REDUNDANT_PUB_CRATE),
2727
LintId::of(regex::TRIVIAL_REGEX),
28-
LintId::of(significant_drop_in_scrutinee::SIGNIFICANT_DROP_IN_SCRUTINEE),
2928
LintId::of(strings::STRING_LIT_AS_BYTES),
3029
LintId::of(suspicious_operation_groupings::SUSPICIOUS_OPERATION_GROUPINGS),
3130
LintId::of(trailing_empty_array::TRAILING_EMPTY_ARRAY),

clippy_lints/src/lib.register_suspicious.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ store.register_group(true, "clippy::suspicious", Some("clippy_suspicious"), vec!
2727
LintId::of(mut_key::MUTABLE_KEY_TYPE),
2828
LintId::of(octal_escapes::OCTAL_ESCAPES),
2929
LintId::of(rc_clone_in_vec_init::RC_CLONE_IN_VEC_INIT),
30+
LintId::of(significant_drop_in_scrutinee::SIGNIFICANT_DROP_IN_SCRUTINEE),
3031
LintId::of(suspicious_trait_impl::SUSPICIOUS_ARITHMETIC_IMPL),
3132
LintId::of(suspicious_trait_impl::SUSPICIOUS_OP_ASSIGN_IMPL),
3233
])

clippy_lints/src/significant_drop_in_scrutinee.rs

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ declare_clippy_lint! {
8383
/// ```
8484
#[clippy::version = "1.60.0"]
8585
pub SIGNIFICANT_DROP_IN_SCRUTINEE,
86-
nursery,
86+
suspicious,
8787
"warns when a temporary of a type with a drop with a significant side-effect might have a surprising lifetime"
8888
}
8989

@@ -99,7 +99,7 @@ impl<'tcx> LateLintPass<'tcx> for SignificantDropInScrutinee {
9999
found.found_span,
100100
"temporary with significant drop in match scrutinee",
101101
|diag| set_diagnostic(diag, cx, expr, found),
102-
)
102+
);
103103
}
104104
}
105105
}
@@ -148,8 +148,8 @@ fn set_diagnostic<'tcx>(diag: &mut Diagnostic, cx: &LateContext<'tcx>, expr: &'t
148148
);
149149
}
150150

151-
/// If the expression is an ExprKind::Match, check if the scrutinee has a significant drop that may
152-
/// have a surprising lifetime.
151+
/// If the expression is an `ExprKind::Match`, check if the scrutinee has a significant drop that
152+
/// may have a surprising lifetime.
153153
fn has_significant_drop_in_scrutinee<'tcx, 'a>(
154154
cx: &'a LateContext<'tcx>,
155155
expr: &'tcx Expr<'tcx>,
@@ -171,6 +171,7 @@ struct SigDropHelper<'a, 'tcx> {
171171
special_handling_for_binary_op: bool,
172172
}
173173

174+
#[expect(clippy::enum_variant_names)]
174175
#[derive(Debug, PartialEq, Eq, Clone, Copy)]
175176
enum LintSuggestion {
176177
MoveOnly,
@@ -213,7 +214,7 @@ impl<'a, 'tcx> SigDropHelper<'a, 'tcx> {
213214
}
214215

215216
/// This will try to set the current suggestion (so it can be moved into the suggestions vec
216-
/// later). If allow_move_and_clone is false, the suggestion *won't* be set -- this gives us
217+
/// later). If `allow_move_and_clone` is false, the suggestion *won't* be set -- this gives us
217218
/// an opportunity to look for another type in the chain that will be trivially copyable.
218219
/// However, if we are at the the end of the chain, we want to accept whatever is there. (The
219220
/// suggestion won't actually be output, but the diagnostic message will be output, so the user
@@ -313,10 +314,10 @@ impl<'a, 'tcx> SigDropHelper<'a, 'tcx> {
313314
}
314315
false
315316
},
316-
rustc_middle::ty::Array(ty, _) => self.has_sig_drop_attr(cx, *ty),
317-
rustc_middle::ty::RawPtr(TypeAndMut { ty, .. }) => self.has_sig_drop_attr(cx, *ty),
318-
rustc_middle::ty::Ref(_, ty, _) => self.has_sig_drop_attr(cx, *ty),
319-
rustc_middle::ty::Slice(ty) => self.has_sig_drop_attr(cx, *ty),
317+
rustc_middle::ty::Array(ty, _)
318+
| rustc_middle::ty::RawPtr(TypeAndMut { ty, .. })
319+
| rustc_middle::ty::Ref(_, ty, _)
320+
| rustc_middle::ty::Slice(ty) => self.has_sig_drop_attr(cx, *ty),
320321
_ => false,
321322
}
322323
}
@@ -332,15 +333,12 @@ impl<'a, 'tcx> Visitor<'tcx> for SigDropHelper<'a, 'tcx> {
332333

333334
match ex.kind {
334335
ExprKind::MethodCall(_, [ref expr, ..], _) => {
335-
self.visit_expr(expr)
336+
self.visit_expr(expr);
336337
}
337338
ExprKind::Binary(_, left, right) => {
338339
self.visit_exprs_for_binary_ops(left, right, false, ex.span);
339340
}
340-
ExprKind::Assign(left, right, _) => {
341-
self.visit_exprs_for_binary_ops(left, right, true, ex.span);
342-
}
343-
ExprKind::AssignOp(_, left, right) => {
341+
ExprKind::Assign(left, right, _) | ExprKind::AssignOp(_, left, right) => {
344342
self.visit_exprs_for_binary_ops(left, right, true, ex.span);
345343
}
346344
ExprKind::Tup(exprs) => {

0 commit comments

Comments
 (0)