Clippy lints / Restriction
Clippy lint · Restriction · checked with Clippy 0.1.99
clippy::disallowed_script_idents: identifier `счётчик` has a Unicode script that is not allowed by configuration: Cyrillic
What it meansChecks for usage of unicode scripts other than those explicitly allowed by the lint config. This lint doesn’t take into account non-text scripts such as Unknown and Linear_A. It also ignores the Common script type. While configuring, be sure to use official script name aliases from the list of supported scripts. See also: non_ascii_idents. It is in the restriction group and off by default.
What you see
warning: identifier `счётчик` has a Unicode script that is not allowed by configuration: Cyrillic --> main.rs:6:5 | 6 | let счётчик = 10; // OK, cyrillic is allowed. | ^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/stable/index.html#disallowed_script_idents = note: requested on the command line with `-W clippy::disallowed-script-idents`
Real output of Clippy 0.1.99 (Rust 1.99) on the example below. Names and line numbers in yours will differ.
Does it matter?
It may be not desired to have many different scripts for identifiers in the codebase. Note that if you only want to allow typical English, you might want to use built-in non_ascii_idents lint instead.
Lints that forbid language features for specific codebases (no unwrap, no indexing...). Off by default; pick them one by one, never the whole group.
How to fix it
Clippy does not fix this one automatically. Change the code by hand:
Flagged
// Assuming that `clippy.toml` contains the following line:
// allowed-scripts = ["Latin", "Cyrillic"]
let counter = 10; // OK, latin is allowed.
let счётчик = 10; // OK, cyrillic is allowed.
let zähler = 10; // OK, it's still latin.
let カウンタ = 10; // Will spawn the lint.
Turn it off, or on
It is off by default. To use it, set it to warn or deny:
Whole crate (Cargo.toml)
[lints.clippy]
disallowed_script_idents = "warn"In code
#![warn(clippy::disallowed_script_idents)]One run
cargo clippy -- -W clippy::disallowed-script-identsThe [lints] table needs Rust 1.74 or newer. In a workspace, put it under [workspace.lints.clippy] and add [lints] workspace = true to each member.
Settings in clippy.toml
allowed-scripts: The list of unicode scripts allowed to be used in the scope.
Clippy's own documentation
What it does
Checks for usage of unicode scripts other than those explicitly allowed by the lint config.
This lint doesn’t take into account non-text scripts such as Unknown and Linear_A.
It also ignores the Common script type.
While configuring, be sure to use official script name aliases from
the list of supported scripts.
See also: non_ascii_idents.
Why restrict this?
It may be not desired to have many different scripts for identifiers in the codebase.
Note that if you only want to allow typical English, you might want to use
built-in non_ascii_idents lint instead.
Example
// Assuming that `clippy.toml` contains the following line:
// allowed-scripts = ["Latin", "Cyrillic"]
let counter = 10; // OK, latin is allowed.
let счётчик = 10; // OK, cyrillic is allowed.
let zähler = 10; // OK, it's still latin.
let カウンタ = 10; // Will spawn the lint.
Configuration
-
allowed-scripts: The list of unicode scripts allowed to be used in the scope.(default:
["Latin"])
From the Clippy lint list (0.1.99), part of the Rust project, MIT or Apache-2.0. Official entry.
Related lints
- unwrap_usedChecks for .unwrap() or .unwrap_err() calls on Results and .unwrap() call on Options
- module_name_repetitionsDetects public item names that are prefixed or suffixed by the containing public module’s name
- expect_usedChecks for .expect() or .expect_err() calls on Results and .expect() call on Options
- default_union_representationthis union has the default representation
- definition_in_module_rootChecks for definitions (structs, functions, traits, etc.) in mod.rs files
- deref_by_slicingslicing when dereferencing would work
- doc_include_without_cfgChecks if included files in doc comments are included only for cfg(doc)
- doc_paragraphs_missing_punctuationChecks for doc comments whose paragraphs do not end with a period or another punctuation mark. Various Markdowns constructs are taken into account to avoid false positives
- else_if_without_else`if` expression with an `else if`, but without a final `else`
All 847 Clippy lints · Rust compiler errors · Cargo.toml checker
Up next
Related lintclippy::unwrap_usedChecks for .unwrap() or .unwrap_err() calls on Results and .unwrap() call on OptionsRead it next →Did this answer your question?