missing_panics_doc: Ignore usage of debug_assert family
This commit is contained in:
parent
1f95940c24
commit
31afdfc12b
@ -715,6 +715,7 @@ impl<'a, 'tcx> Visitor<'tcx> for FindPanicUnwrap<'a, 'tcx> {
|
||||
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();
|
||||
if !is_expn_of_debug_assertions(expr.span);
|
||||
then {
|
||||
self.panic_span = Some(expr.span);
|
||||
}
|
||||
@ -738,3 +739,8 @@ impl<'a, 'tcx> Visitor<'tcx> for FindPanicUnwrap<'a, 'tcx> {
|
||||
NestedVisitorMap::OnlyBodies(self.cx.tcx.hir())
|
||||
}
|
||||
}
|
||||
|
||||
fn is_expn_of_debug_assertions(span: Span) -> bool {
|
||||
const MACRO_NAMES: &[&str] = &["debug_assert", "debug_assert_eq", "debug_assert_ne"];
|
||||
MACRO_NAMES.iter().any(|name| is_expn_of(span, name).is_some())
|
||||
}
|
||||
|
@ -112,3 +112,11 @@ fn inner_body_private(opt: Option<u32>) {
|
||||
pub fn unreachable() {
|
||||
unreachable!("This function panics")
|
||||
}
|
||||
|
||||
/// #6970.
|
||||
/// This is okay because it is expansion of `debug_assert` family.
|
||||
pub fn debug_assertions() {
|
||||
debug_assert!(false);
|
||||
debug_assert_eq!(1, 2);
|
||||
debug_assert_ne!(1, 2);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user