Skip to content

Commit

Permalink
fix dogfood
Browse files Browse the repository at this point in the history
  • Loading branch information
dnbln committed Nov 18, 2023
1 parent ece96a4 commit fea8899
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 20 deletions.
2 changes: 1 addition & 1 deletion clippy_lints/src/endian_bytes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ fn maybe_lint_endian_bytes(cx: &LateContext<'_>, expr: &Expr<'_>, prefix: Prefix
lint.as_name(prefix),
if prefix == Prefix::To { " method" } else { "" },
),
move |diag| {
|diag| {
if let Some(help) = help {
diag.help(help);
}
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/fallible_impl_from.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ fn lint_impl_body(cx: &LateContext<'_>, impl_span: Span, impl_items: &[hir::Impl
FALLIBLE_IMPL_FROM,
impl_span,
"consider implementing `TryFrom` instead",
move |diag| {
|diag| {
diag.help(
"`From` is intended for infallible conversions only. \
Use `TryFrom` if there's a possibility for the conversion to fail",
Expand Down
12 changes: 6 additions & 6 deletions clippy_lints/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -685,7 +685,7 @@ pub fn register_lints(store: &mut rustc_lint::LintStore, conf: &'static Conf) {
store.register_late_pass(move |_| Box::new(from_over_into::FromOverInto::new(msrv())));
store.register_late_pass(move |_| Box::new(use_self::UseSelf::new(msrv())));
store.register_late_pass(move |_| Box::new(missing_const_for_fn::MissingConstForFn::new(msrv())));
store.register_late_pass(move |_| Box::new(needless_question_mark::NeedlessQuestionMark));
store.register_late_pass(|_| Box::new(needless_question_mark::NeedlessQuestionMark));
store.register_late_pass(move |_| Box::new(casts::Casts::new(msrv())));
store.register_early_pass(move || Box::new(unnested_or_patterns::UnnestedOrPatterns::new(msrv())));
store.register_late_pass(|_| Box::new(size_of_in_element_count::SizeOfInElementCount));
Expand Down Expand Up @@ -752,7 +752,7 @@ pub fn register_lints(store: &mut rustc_lint::LintStore, conf: &'static Conf) {
store.register_late_pass(|_| Box::new(mixed_read_write_in_expression::EvalOrderDependence));
store.register_late_pass(move |_| Box::new(missing_doc::MissingDoc::new(missing_docs_in_crate_items)));
store.register_late_pass(|_| Box::new(missing_inline::MissingInline));
store.register_late_pass(move |_| Box::new(exhaustive_items::ExhaustiveItems));
store.register_late_pass(|_| Box::new(exhaustive_items::ExhaustiveItems));
store.register_late_pass(|_| Box::new(match_result_ok::MatchResultOk));
store.register_late_pass(|_| Box::new(partialeq_ne_impl::PartialEqNeImpl));
store.register_late_pass(|_| Box::new(unused_io_amount::UnusedIoAmount));
Expand Down Expand Up @@ -895,7 +895,7 @@ pub fn register_lints(store: &mut rustc_lint::LintStore, conf: &'static Conf) {
store.register_late_pass(|_| Box::new(from_str_radix_10::FromStrRadix10));
store.register_late_pass(move |_| Box::new(if_then_some_else_none::IfThenSomeElseNone::new(msrv())));
store.register_late_pass(|_| Box::new(bool_assert_comparison::BoolAssertComparison));
store.register_early_pass(move || Box::new(module_style::ModStyle));
store.register_early_pass(|| Box::new(module_style::ModStyle));
store.register_late_pass(|_| Box::<unused_async::UnusedAsync>::default());
store.register_late_pass(move |_| Box::new(disallowed_types::DisallowedTypes::new(disallowed_types.clone())));
store.register_late_pass(move |_| {
Expand All @@ -905,9 +905,9 @@ pub fn register_lints(store: &mut rustc_lint::LintStore, conf: &'static Conf) {
});
store.register_early_pass(move || Box::new(disallowed_script_idents::DisallowedScriptIdents::new(allowed_scripts)));
store.register_late_pass(|_| Box::new(strlen_on_c_strings::StrlenOnCStrings));
store.register_late_pass(move |_| Box::new(self_named_constructors::SelfNamedConstructors));
store.register_late_pass(move |_| Box::new(iter_not_returning_iterator::IterNotReturningIterator));
store.register_late_pass(move |_| Box::new(manual_assert::ManualAssert));
store.register_late_pass(|_| Box::new(self_named_constructors::SelfNamedConstructors));
store.register_late_pass(|_| Box::new(iter_not_returning_iterator::IterNotReturningIterator));
store.register_late_pass(|_| Box::new(manual_assert::ManualAssert));
store.register_late_pass(move |_| {
Box::new(non_send_fields_in_send_ty::NonSendFieldInSendTy::new(
enable_raw_pointer_heuristic_for_send,
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/loops/manual_memcpy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,7 @@ fn get_assignments<'a, 'tcx>(
// just increases complexity. (cc #3188 and #4193)
stmts
.iter()
.filter_map(move |stmt| match stmt.kind {
.filter_map(|stmt| match stmt.kind {
StmtKind::Local(..) | StmtKind::Item(..) => None,
StmtKind::Expr(e) | StmtKind::Semi(e) => Some(e),
})
Expand Down
18 changes: 10 additions & 8 deletions clippy_lints/src/needless_move.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use clippy_utils::sugg::DiagnosticExt;
use clippy_utils::ty::is_copy;
use rustc_data_structures::fx::FxIndexMap;
use rustc_errors::Applicability;
use rustc_hir::*;
use rustc_hir::{CaptureBy, Closure, Expr, ExprKind, HirId};
use rustc_hir_typeck::expr_use_visitor as euv;
use rustc_infer::infer::TyCtxtInferExt;
use rustc_lint::{LateContext, LateLintPass};
Expand Down Expand Up @@ -41,7 +41,7 @@ declare_clippy_lint! {
declare_lint_pass!(NeedlessMove => [NEEDLESS_MOVE]);

impl NeedlessMove {
fn check_closure<'tcx>(&self, cx: &LateContext<'tcx>, expr: &'tcx Expr<'tcx>, closure: &'tcx Closure<'tcx>) {
fn check_closure<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'tcx>, closure: &'tcx Closure<'tcx>) {
let CaptureBy::Value { move_kw } = closure.capture_clause else {
return;
};
Expand All @@ -58,8 +58,8 @@ impl NeedlessMove {
mut captured_vars,
} = {
let mut ctx = MovedVariablesCtxt {
captured_vars: Default::default(),
moved_vars: Default::default(),
captured_vars: FxIndexMap::default(),
moved_vars: FxIndexMap::default(),
};
let body = cx.tcx.hir().body(closure.body);
let infcx = cx.tcx.infer_ctxt().build();
Expand All @@ -70,7 +70,7 @@ impl NeedlessMove {

// Remove the captured vars which were also `move`d.
// See special case 1. below.
for (hir_id, _upvars) in moved_vars.iter() {
for (hir_id, _upvars) in &moved_vars {
let Some(vars) = captured_vars.get_mut(hir_id) else {
continue;
};
Expand Down Expand Up @@ -99,9 +99,11 @@ impl NeedlessMove {
};

match (moved_vars.is_empty(), captured_vars.is_empty()) {
(true, true) => lint("there were no captured variables, so the `move` is unnecessary"),
(true, true) => {
lint("there were no captured variables, so the `move` is unnecessary");
},
(false, true) => {
lint("there were consumed variables, but no borrowed variables, so the `move` is unnecessary")
lint("there were consumed variables, but no borrowed variables, so the `move` is unnecessary");
},
(_, false) => {
// captured_vars is not empty, so `move` actually makes a difference and we
Expand All @@ -121,7 +123,7 @@ impl<'tcx> LateLintPass<'tcx> for NeedlessMove {
return;
};

self.check_closure(cx, expr, closure);
Self::check_closure(cx, expr, closure);
}
}

Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/panic_in_result_fn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ fn lint_impl_body<'tcx>(cx: &LateContext<'tcx>, impl_span: Span, body: &'tcx hir
PANIC_IN_RESULT_FN,
impl_span,
"used `panic!()` or assertion in a function that returns `Result`",
move |diag| {
|diag| {
diag.help(
"`panic!()` or assertions should not be used in a function that returns `Result` as `Result` is expected to return an error instead of crashing",
);
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/unwrap_in_result.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ fn lint_impl_body<'tcx>(cx: &LateContext<'tcx>, impl_span: Span, impl_item: &'tc
UNWRAP_IN_RESULT,
impl_span,
"used unwrap or expect in a function that returns result or option",
move |diag| {
|diag| {
diag.help("unwrap and expect should not be used in a function that returns result or option");
diag.span_note(result, "potential non-recoverable error(s)");
},
Expand Down
2 changes: 1 addition & 1 deletion src/driver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ pub fn main() {
handler.note_without_error(format!("Clippy version: {version_info}"));
});

exit(rustc_driver::catch_with_exit_code(move || {
exit(rustc_driver::catch_with_exit_code(|| {
let mut orig_args: Vec<String> = env::args().collect();
let has_sysroot_arg = arg_value(&orig_args, "--sysroot", |_| true).is_some();

Expand Down

0 comments on commit fea8899

Please sign in to comment.