]> git.lizzy.rs Git - rust.git/blobdiff - clippy_lints/src/doc.rs
Auto merge of #6697 - camsteffen:vec-init-push-fp, r=flip1995
[rust.git] / clippy_lints / src / doc.rs
index 75e71eb1e4ce23158998b6bec356cf0e1f27780e..ae06c2c60be4bc287e93715a4858078ec92cd496 100644 (file)
@@ -1,6 +1,6 @@
 use crate::utils::{
-    implements_trait, is_entrypoint_fn, is_type_diagnostic_item, match_panic_def_id, method_chain_args, return_ty,
-    span_lint, span_lint_and_note,
+    implements_trait, is_entrypoint_fn, is_expn_of, is_type_diagnostic_item, match_panic_def_id, method_chain_args,
+    return_ty, span_lint, span_lint_and_note,
 };
 use if_chain::if_chain;
 use itertools::Itertools;
@@ -563,9 +563,7 @@ fn has_needless_main(code: &str, edition: Edition) -> bool {
                             | ItemKind::ExternCrate(..)
                             | ItemKind::ForeignMod(..) => return false,
                             // We found a main function ...
-                            ItemKind::Fn(box FnKind(_, sig, _, Some(block)))
-                                if item.ident.name == sym::main =>
-                            {
+                            ItemKind::Fn(box FnKind(_, sig, _, Some(block))) if item.ident.name == sym::main => {
                                 let is_async = matches!(sig.header.asyncness, Async::Yes { .. });
                                 let returns_nothing = match &sig.decl.output {
                                     FnRetTy::Default(..) => true,
@@ -701,6 +699,7 @@ fn visit_expr(&mut self, expr: &'tcx Expr<'_>) {
             if let ExprKind::Path(QPath::Resolved(_, ref path)) = func_expr.kind;
             if let Some(path_def_id) = path.res.opt_def_id();
             if match_panic_def_id(self.cx, path_def_id);
+            if is_expn_of(expr.span, "unreachable").is_none();
             then {
                 self.panic_span = Some(expr.span);
             }