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