]> git.lizzy.rs Git - rust.git/blobdiff - src/tools/clippy/clippy_lints/src/returns.rs
Auto merge of #82680 - jturner314:div_euclid-docs, r=JohnTitor
[rust.git] / src / tools / clippy / clippy_lints / src / returns.rs
index e438f92b136ac453745d0f35cbfb85f52cf024da..40c0f1f45895ba0af5ed1341e12d21265bc6f637 100644 (file)
@@ -81,7 +81,7 @@ fn check_block(&mut self, cx: &LateContext<'tcx>, block: &'tcx Block<'_>) {
             if let Some(stmt) = block.stmts.iter().last();
             if let StmtKind::Local(local) = &stmt.kind;
             if local.ty.is_none();
-            if local.attrs.is_empty();
+            if cx.tcx.hir().attrs(local.hir_id).is_empty();
             if let Some(initexpr) = &local.init;
             if let PatKind::Binding(.., ident, _) = local.pat.kind;
             if let ExprKind::Path(qpath) = &retexpr.kind;
@@ -131,7 +131,7 @@ fn check_fn(
         _: HirId,
     ) {
         match kind {
-            FnKind::Closure(_) => {
+            FnKind::Closure => {
                 // when returning without value in closure, replace this `return`
                 // with an empty block to prevent invalid suggestion (see #6501)
                 let replacement = if let ExprKind::Ret(None) = &body.value.kind {
@@ -177,7 +177,8 @@ fn check_final_expr<'tcx>(
         // simple return is always "bad"
         ExprKind::Ret(ref inner) => {
             // allow `#[cfg(a)] return a; #[cfg(b)] return b;`
-            if !expr.attrs.iter().any(attr_is_cfg) {
+            let attrs = cx.tcx.hir().attrs(expr.hir_id);
+            if !attrs.iter().any(attr_is_cfg) {
                 let borrows = inner.map_or(false, |inner| last_statement_borrows(cx, inner));
                 if !borrows {
                     emit_return_lint(