1 use crate::utils::span_lint;
3 use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass};
4 use rustc::{declare_tool_lint, impl_lint_pass};
5 use rustc_data_structures::fx::FxHashSet;
8 /// **What it does:** Checks for usage of blacklisted names for variables, such
11 /// **Why is this bad?** These names are usually placeholder names and should be
14 /// **Known problems:** None.
22 "usage of a blacklisted/placeholder name"
25 #[derive(Clone, Debug)]
26 pub struct BlacklistedName {
27 blacklist: FxHashSet<String>,
30 impl BlacklistedName {
31 pub fn new(blacklist: FxHashSet<String>) -> Self {
36 impl_lint_pass!(BlacklistedName => [BLACKLISTED_NAME]);
38 impl<'a, 'tcx> LateLintPass<'a, 'tcx> for BlacklistedName {
39 fn check_pat(&mut self, cx: &LateContext<'a, 'tcx>, pat: &'tcx Pat) {
40 if let PatKind::Binding(.., ident, _) = pat.node {
41 if self.blacklist.contains(&ident.name.to_string()) {
46 &format!("use of a blacklisted/placeholder name `{}`", ident.name),