use rustc_span::Span;
declare_clippy_lint! {
- /// **What it does:** Checks for usage of `panic!`.
+ /// ### What it does
+ /// Checks for usage of `panic!`.
///
- /// **Why is this bad?** `panic!` will stop the execution of the executable
+ /// ### Why is this bad?
+ /// `panic!` will stop the execution of the executable
///
- /// **Known problems:** None.
- ///
- /// **Example:**
+ /// ### Example
/// ```no_run
/// panic!("even with a good reason");
/// ```
}
declare_clippy_lint! {
- /// **What it does:** Checks for usage of `unimplemented!`.
- ///
- /// **Why is this bad?** This macro should not be present in production code
+ /// ### What it does
+ /// Checks for usage of `unimplemented!`.
///
- /// **Known problems:** None.
+ /// ### Why is this bad?
+ /// This macro should not be present in production code
///
- /// **Example:**
+ /// ### Example
/// ```no_run
/// unimplemented!();
/// ```
}
declare_clippy_lint! {
- /// **What it does:** Checks for usage of `todo!`.
+ /// ### What it does
+ /// Checks for usage of `todo!`.
///
- /// **Why is this bad?** This macro should not be present in production code
+ /// ### Why is this bad?
+ /// This macro should not be present in production code
///
- /// **Known problems:** None.
- ///
- /// **Example:**
+ /// ### Example
/// ```no_run
/// todo!();
/// ```
}
declare_clippy_lint! {
- /// **What it does:** Checks for usage of `unreachable!`.
- ///
- /// **Why is this bad?** This macro can cause code to panic
+ /// ### What it does
+ /// Checks for usage of `unreachable!`.
///
- /// **Known problems:** None.
+ /// ### Why is this bad?
+ /// This macro can cause code to panic
///
- /// **Example:**
+ /// ### Example
/// ```no_run
/// unreachable!();
/// ```
impl<'tcx> LateLintPass<'tcx> for PanicUnimplemented {
fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>) {
- if match_panic_call(cx, expr).is_some() && is_expn_of(expr.span, "debug_assert").is_none() {
+ if match_panic_call(cx, expr).is_some()
+ && (is_expn_of(expr.span, "debug_assert").is_none() && is_expn_of(expr.span, "assert").is_none())
+ {
let span = get_outer_span(expr);
if is_expn_of(expr.span, "unimplemented").is_some() {
span_lint(