Skip to content

Commit 6c73f98

Browse files
committed
Fix missing_panics_doc warning on unreachable!.
1 parent 4bbd7e4 commit 6c73f98

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

clippy_lints/src/doc.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use crate::utils::{
2-
implements_trait, is_entrypoint_fn, is_type_diagnostic_item, match_panic_def_id, method_chain_args, return_ty,
3-
span_lint, span_lint_and_note,
2+
implements_trait, is_entrypoint_fn, is_expn_of, is_type_diagnostic_item, match_panic_def_id, method_chain_args,
3+
return_ty, span_lint, span_lint_and_note,
44
};
55
use if_chain::if_chain;
66
use itertools::Itertools;
@@ -699,6 +699,7 @@ impl<'a, 'tcx> Visitor<'tcx> for FindPanicUnwrap<'a, 'tcx> {
699699
if let ExprKind::Path(QPath::Resolved(_, ref path)) = func_expr.kind;
700700
if let Some(path_def_id) = path.res.opt_def_id();
701701
if match_panic_def_id(self.cx, path_def_id);
702+
if is_expn_of(expr.span, "unreachable").is_none();
702703
then {
703704
self.panic_span = Some(expr.span);
704705
}

tests/ui/doc_panics.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,3 +93,8 @@ fn inner_body_private(opt: Option<u32>) {
9393
}
9494
});
9595
}
96+
97+
/// This is okay because unreachable
98+
pub fn unreachable() {
99+
unreachable!("This function panics")
100+
}

0 commit comments

Comments
 (0)