Artifact Content
Not logged in

Artifact 1285e53f3021db20a629d56027511cf127131bed:


use crate::lint::{EarlyContext, EarlyLintPass, LintArray, LintContext, LintPass};
use syntax::ast;

declare_lint! {
    pub NON_ASCII_IDENTS,
    Allow,
    "detects non-ASCII identifiers"
}

declare_lint_pass!(NonAsciiIdents => [NON_ASCII_IDENTS]);

impl EarlyLintPass for NonAsciiIdents {
    fn check_ident(&mut self, cx: &EarlyContext<'_>, ident: ast::Ident) {
        if !ident.name.as_str().is_ascii() {
            cx.struct_span_lint(
                NON_ASCII_IDENTS,
                ident.span,
                "identifier contains non-ASCII characters",
            ).emit();
        }
    }
}