use std::path::{Component, Path};
declare_clippy_lint! {
- /// **What it does:*** Checks for [push](https://doc.rust-lang.org/std/path/struct.PathBuf.html#method.push)
+ /// ### What it does
+ ///* Checks for [push](https://doc.rust-lang.org/std/path/struct.PathBuf.html#method.push)
/// calls on `PathBuf` that can cause overwrites.
///
- /// **Why is this bad?** Calling `push` with a root path at the start can overwrite the
+ /// ### Why is this bad?
+ /// Calling `push` with a root path at the start can overwrite the
/// previous defined path.
///
- /// **Known problems:** None.
- ///
- /// **Example:**
+ /// ### Example
/// ```rust
/// use std::path::PathBuf;
///
impl<'tcx> LateLintPass<'tcx> for PathBufPushOverwrite {
fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>) {
if_chain! {
- if let ExprKind::MethodCall(ref path, _, ref args, _) = expr.kind;
+ if let ExprKind::MethodCall(path, _, args, _) = expr.kind;
if path.ident.name == sym!(push);
if args.len() == 2;
if is_type_diagnostic_item(cx, cx.typeck_results().expr_ty(&args[0]).peel_refs(), sym::PathBuf);