move to sus and fix dogfood
This commit is contained in:
parent
4e6cf0036e
commit
5b72632c98
@ -278,6 +278,7 @@ store.register_group(true, "clippy::all", Some("clippy_all"), vec![
|
||||
LintId::of(self_assignment::SELF_ASSIGNMENT),
|
||||
LintId::of(self_named_constructors::SELF_NAMED_CONSTRUCTORS),
|
||||
LintId::of(serde_api::SERDE_API_MISUSE),
|
||||
LintId::of(significant_drop_in_scrutinee::SIGNIFICANT_DROP_IN_SCRUTINEE),
|
||||
LintId::of(single_component_path_imports::SINGLE_COMPONENT_PATH_IMPORTS),
|
||||
LintId::of(size_of_in_element_count::SIZE_OF_IN_ELEMENT_COUNT),
|
||||
LintId::of(slow_vector_initialization::SLOW_VECTOR_INITIALIZATION),
|
||||
|
@ -25,7 +25,6 @@ store.register_group(true, "clippy::nursery", Some("clippy_nursery"), vec![
|
||||
LintId::of(path_buf_push_overwrite::PATH_BUF_PUSH_OVERWRITE),
|
||||
LintId::of(redundant_pub_crate::REDUNDANT_PUB_CRATE),
|
||||
LintId::of(regex::TRIVIAL_REGEX),
|
||||
LintId::of(significant_drop_in_scrutinee::SIGNIFICANT_DROP_IN_SCRUTINEE),
|
||||
LintId::of(strings::STRING_LIT_AS_BYTES),
|
||||
LintId::of(suspicious_operation_groupings::SUSPICIOUS_OPERATION_GROUPINGS),
|
||||
LintId::of(trailing_empty_array::TRAILING_EMPTY_ARRAY),
|
||||
|
@ -27,6 +27,7 @@ store.register_group(true, "clippy::suspicious", Some("clippy_suspicious"), vec!
|
||||
LintId::of(mut_key::MUTABLE_KEY_TYPE),
|
||||
LintId::of(octal_escapes::OCTAL_ESCAPES),
|
||||
LintId::of(rc_clone_in_vec_init::RC_CLONE_IN_VEC_INIT),
|
||||
LintId::of(significant_drop_in_scrutinee::SIGNIFICANT_DROP_IN_SCRUTINEE),
|
||||
LintId::of(suspicious_trait_impl::SUSPICIOUS_ARITHMETIC_IMPL),
|
||||
LintId::of(suspicious_trait_impl::SUSPICIOUS_OP_ASSIGN_IMPL),
|
||||
])
|
||||
|
@ -83,7 +83,7 @@ declare_clippy_lint! {
|
||||
/// ```
|
||||
#[clippy::version = "1.60.0"]
|
||||
pub SIGNIFICANT_DROP_IN_SCRUTINEE,
|
||||
nursery,
|
||||
suspicious,
|
||||
"warns when a temporary of a type with a drop with a significant side-effect might have a surprising lifetime"
|
||||
}
|
||||
|
||||
@ -99,7 +99,7 @@ impl<'tcx> LateLintPass<'tcx> for SignificantDropInScrutinee {
|
||||
found.found_span,
|
||||
"temporary with significant drop in match scrutinee",
|
||||
|diag| set_diagnostic(diag, cx, expr, found),
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -148,8 +148,8 @@ fn set_diagnostic<'tcx>(diag: &mut Diagnostic, cx: &LateContext<'tcx>, expr: &'t
|
||||
);
|
||||
}
|
||||
|
||||
/// If the expression is an ExprKind::Match, check if the scrutinee has a significant drop that may
|
||||
/// have a surprising lifetime.
|
||||
/// If the expression is an `ExprKind::Match`, check if the scrutinee has a significant drop that
|
||||
/// may have a surprising lifetime.
|
||||
fn has_significant_drop_in_scrutinee<'tcx, 'a>(
|
||||
cx: &'a LateContext<'tcx>,
|
||||
expr: &'tcx Expr<'tcx>,
|
||||
@ -171,6 +171,7 @@ struct SigDropHelper<'a, 'tcx> {
|
||||
special_handling_for_binary_op: bool,
|
||||
}
|
||||
|
||||
#[expect(clippy::enum_variant_names)]
|
||||
#[derive(Debug, PartialEq, Eq, Clone, Copy)]
|
||||
enum LintSuggestion {
|
||||
MoveOnly,
|
||||
@ -213,7 +214,7 @@ impl<'a, 'tcx> SigDropHelper<'a, 'tcx> {
|
||||
}
|
||||
|
||||
/// This will try to set the current suggestion (so it can be moved into the suggestions vec
|
||||
/// later). If allow_move_and_clone is false, the suggestion *won't* be set -- this gives us
|
||||
/// later). If `allow_move_and_clone` is false, the suggestion *won't* be set -- this gives us
|
||||
/// an opportunity to look for another type in the chain that will be trivially copyable.
|
||||
/// However, if we are at the the end of the chain, we want to accept whatever is there. (The
|
||||
/// 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> {
|
||||
}
|
||||
false
|
||||
},
|
||||
rustc_middle::ty::Array(ty, _) => self.has_sig_drop_attr(cx, *ty),
|
||||
rustc_middle::ty::RawPtr(TypeAndMut { ty, .. }) => self.has_sig_drop_attr(cx, *ty),
|
||||
rustc_middle::ty::Ref(_, ty, _) => self.has_sig_drop_attr(cx, *ty),
|
||||
rustc_middle::ty::Slice(ty) => self.has_sig_drop_attr(cx, *ty),
|
||||
rustc_middle::ty::Array(ty, _)
|
||||
| rustc_middle::ty::RawPtr(TypeAndMut { ty, .. })
|
||||
| rustc_middle::ty::Ref(_, ty, _)
|
||||
| rustc_middle::ty::Slice(ty) => self.has_sig_drop_attr(cx, *ty),
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
@ -332,15 +333,12 @@ impl<'a, 'tcx> Visitor<'tcx> for SigDropHelper<'a, 'tcx> {
|
||||
|
||||
match ex.kind {
|
||||
ExprKind::MethodCall(_, [ref expr, ..], _) => {
|
||||
self.visit_expr(expr)
|
||||
self.visit_expr(expr);
|
||||
}
|
||||
ExprKind::Binary(_, left, right) => {
|
||||
self.visit_exprs_for_binary_ops(left, right, false, ex.span);
|
||||
}
|
||||
ExprKind::Assign(left, right, _) => {
|
||||
self.visit_exprs_for_binary_ops(left, right, true, ex.span);
|
||||
}
|
||||
ExprKind::AssignOp(_, left, right) => {
|
||||
ExprKind::Assign(left, right, _) | ExprKind::AssignOp(_, left, right) => {
|
||||
self.visit_exprs_for_binary_ops(left, right, true, ex.span);
|
||||
}
|
||||
ExprKind::Tup(exprs) => {
|
||||
|
Loading…
x
Reference in New Issue
Block a user