1 use crate::rustc::lint::{LateContext, LateLintPass, LintArray, LintPass};
2 use crate::rustc::{declare_tool_lint, lint_array};
3 use crate::rustc::hir::*;
4 use crate::utils::span_lint;
6 /// **What it does:** Checks for usage of blacklisted names for variables, such
9 /// **Why is this bad?** These names are usually placeholder names and should be
12 /// **Known problems:** None.
18 declare_clippy_lint! {
21 "usage of a blacklisted/placeholder name"
24 #[derive(Clone, Debug)]
25 pub struct BlackListedName {
26 blacklist: Vec<String>,
29 impl BlackListedName {
30 pub fn new(blacklist: Vec<String>) -> Self {
37 impl LintPass for BlackListedName {
38 fn get_lints(&self) -> LintArray {
39 lint_array!(BLACKLISTED_NAME)
43 impl<'a, 'tcx> LateLintPass<'a, 'tcx> for BlackListedName {
44 fn check_pat(&mut self, cx: &LateContext<'a, 'tcx>, pat: &'tcx Pat) {
45 if let PatKind::Binding(_, _, ident, _) = pat.node {
46 if self.blacklist.iter().any(|s| ident.name == *s) {
51 &format!("use of a blacklisted/placeholder name `{}`", ident.name),