summaryrefslogtreecommitdiffstats
path: root/tests/ui/lint/rfc-2457-non-ascii-idents
diff options
context:
space:
mode:
Diffstat (limited to 'tests/ui/lint/rfc-2457-non-ascii-idents')
-rw-r--r--tests/ui/lint/rfc-2457-non-ascii-idents/lint-confusable-idents.rs16
-rw-r--r--tests/ui/lint/rfc-2457-non-ascii-idents/lint-confusable-idents.stderr26
-rw-r--r--tests/ui/lint/rfc-2457-non-ascii-idents/lint-mixed-script-confusables-2.rs19
-rw-r--r--tests/ui/lint/rfc-2457-non-ascii-idents/lint-mixed-script-confusables.rs14
-rw-r--r--tests/ui/lint/rfc-2457-non-ascii-idents/lint-mixed-script-confusables.stderr34
-rw-r--r--tests/ui/lint/rfc-2457-non-ascii-idents/lint-non-ascii-idents.rs12
-rw-r--r--tests/ui/lint/rfc-2457-non-ascii-idents/lint-non-ascii-idents.stderr26
-rw-r--r--tests/ui/lint/rfc-2457-non-ascii-idents/lint-uncommon-codepoints.rs13
-rw-r--r--tests/ui/lint/rfc-2457-non-ascii-idents/lint-uncommon-codepoints.stderr34
9 files changed, 194 insertions, 0 deletions
diff --git a/tests/ui/lint/rfc-2457-non-ascii-idents/lint-confusable-idents.rs b/tests/ui/lint/rfc-2457-non-ascii-idents/lint-confusable-idents.rs
new file mode 100644
index 000000000..e7da825ae
--- /dev/null
+++ b/tests/ui/lint/rfc-2457-non-ascii-idents/lint-confusable-idents.rs
@@ -0,0 +1,16 @@
+#![deny(confusable_idents)]
+#![allow(uncommon_codepoints, non_upper_case_globals)]
+
+const s: usize = 42;
+const s_s: usize = 42;
+
+fn main() {
+ let s = "rust"; //~ ERROR identifier pair considered confusable
+ let s_s = "rust2"; //~ ERROR identifier pair considered confusable
+ not_affected();
+}
+
+fn not_affected() {
+ let s1 = 1;
+ let sl = 'l';
+}
diff --git a/tests/ui/lint/rfc-2457-non-ascii-idents/lint-confusable-idents.stderr b/tests/ui/lint/rfc-2457-non-ascii-idents/lint-confusable-idents.stderr
new file mode 100644
index 000000000..e9906c83d
--- /dev/null
+++ b/tests/ui/lint/rfc-2457-non-ascii-idents/lint-confusable-idents.stderr
@@ -0,0 +1,26 @@
+error: identifier pair considered confusable between `s` and `s`
+ --> $DIR/lint-confusable-idents.rs:8:9
+ |
+LL | const s: usize = 42;
+ | -- this is where the previous identifier occurred
+...
+LL | let s = "rust";
+ | ^
+ |
+note: the lint level is defined here
+ --> $DIR/lint-confusable-idents.rs:1:9
+ |
+LL | #![deny(confusable_idents)]
+ | ^^^^^^^^^^^^^^^^^
+
+error: identifier pair considered confusable between `s_s` and `s_s`
+ --> $DIR/lint-confusable-idents.rs:9:9
+ |
+LL | const s_s: usize = 42;
+ | --- this is where the previous identifier occurred
+...
+LL | let s_s = "rust2";
+ | ^^^^^
+
+error: aborting due to 2 previous errors
+
diff --git a/tests/ui/lint/rfc-2457-non-ascii-idents/lint-mixed-script-confusables-2.rs b/tests/ui/lint/rfc-2457-non-ascii-idents/lint-mixed-script-confusables-2.rs
new file mode 100644
index 000000000..f62c8a190
--- /dev/null
+++ b/tests/ui/lint/rfc-2457-non-ascii-idents/lint-mixed-script-confusables-2.rs
@@ -0,0 +1,19 @@
+// check-pass
+#![deny(mixed_script_confusables)]
+
+struct ΑctuallyNotLatin;
+
+fn main() {
+ let λ = 42; // this usage of Greek confirms that Greek is used intentionally.
+}
+
+mod роре {
+ const エ: &'static str = "アイウ";
+
+ // this usage of Katakana confirms that Katakana is used intentionally.
+ fn ニャン() {
+ let д: usize = 100; // this usage of Cyrillic confirms that Cyrillic is used intentionally.
+
+ println!("meow!");
+ }
+}
diff --git a/tests/ui/lint/rfc-2457-non-ascii-idents/lint-mixed-script-confusables.rs b/tests/ui/lint/rfc-2457-non-ascii-idents/lint-mixed-script-confusables.rs
new file mode 100644
index 000000000..9d837d41f
--- /dev/null
+++ b/tests/ui/lint/rfc-2457-non-ascii-idents/lint-mixed-script-confusables.rs
@@ -0,0 +1,14 @@
+#![deny(mixed_script_confusables)]
+
+struct ΑctuallyNotLatin;
+//~^ ERROR the usage of Script Group `Greek` in this crate consists solely of
+
+fn main() {
+ let v = ΑctuallyNotLatin;
+}
+
+mod роре {
+//~^ ERROR the usage of Script Group `Cyrillic` in this crate consists solely of
+ const エ: &'static str = "アイウ";
+ //~^ ERROR the usage of Script Group `Japanese, Katakana` in this crate consists solely of
+}
diff --git a/tests/ui/lint/rfc-2457-non-ascii-idents/lint-mixed-script-confusables.stderr b/tests/ui/lint/rfc-2457-non-ascii-idents/lint-mixed-script-confusables.stderr
new file mode 100644
index 000000000..884a4a453
--- /dev/null
+++ b/tests/ui/lint/rfc-2457-non-ascii-idents/lint-mixed-script-confusables.stderr
@@ -0,0 +1,34 @@
+error: the usage of Script Group `Greek` in this crate consists solely of mixed script confusables
+ --> $DIR/lint-mixed-script-confusables.rs:3:8
+ |
+LL | struct ΑctuallyNotLatin;
+ | ^^^^^^^^^^^^^^^^
+ |
+ = note: the usage includes 'Α' (U+0391)
+ = note: please recheck to make sure their usages are indeed what you want
+note: the lint level is defined here
+ --> $DIR/lint-mixed-script-confusables.rs:1:9
+ |
+LL | #![deny(mixed_script_confusables)]
+ | ^^^^^^^^^^^^^^^^^^^^^^^^
+
+error: the usage of Script Group `Cyrillic` in this crate consists solely of mixed script confusables
+ --> $DIR/lint-mixed-script-confusables.rs:10:5
+ |
+LL | mod роре {
+ | ^^^^
+ |
+ = note: the usage includes 'е' (U+0435), 'о' (U+043E), 'р' (U+0440)
+ = note: please recheck to make sure their usages are indeed what you want
+
+error: the usage of Script Group `Japanese, Katakana` in this crate consists solely of mixed script confusables
+ --> $DIR/lint-mixed-script-confusables.rs:12:11
+ |
+LL | const エ: &'static str = "アイウ";
+ | ^^
+ |
+ = note: the usage includes 'エ' (U+30A8)
+ = note: please recheck to make sure their usages are indeed what you want
+
+error: aborting due to 3 previous errors
+
diff --git a/tests/ui/lint/rfc-2457-non-ascii-idents/lint-non-ascii-idents.rs b/tests/ui/lint/rfc-2457-non-ascii-idents/lint-non-ascii-idents.rs
new file mode 100644
index 000000000..8ae174409
--- /dev/null
+++ b/tests/ui/lint/rfc-2457-non-ascii-idents/lint-non-ascii-idents.rs
@@ -0,0 +1,12 @@
+#![deny(non_ascii_idents)]
+
+const חלודה: usize = 2; //~ ERROR identifier contains non-ASCII characters
+
+fn coöperation() {} //~ ERROR identifier contains non-ASCII characters
+
+fn main() {
+ let naïveté = 2; //~ ERROR identifier contains non-ASCII characters
+
+ // using the same identifier the second time won't trigger the lint.
+ println!("{}", naïveté);
+}
diff --git a/tests/ui/lint/rfc-2457-non-ascii-idents/lint-non-ascii-idents.stderr b/tests/ui/lint/rfc-2457-non-ascii-idents/lint-non-ascii-idents.stderr
new file mode 100644
index 000000000..8ed7f093c
--- /dev/null
+++ b/tests/ui/lint/rfc-2457-non-ascii-idents/lint-non-ascii-idents.stderr
@@ -0,0 +1,26 @@
+error: identifier contains non-ASCII characters
+ --> $DIR/lint-non-ascii-idents.rs:3:7
+ |
+LL | const חלודה: usize = 2;
+ | ^^^^^
+ |
+note: the lint level is defined here
+ --> $DIR/lint-non-ascii-idents.rs:1:9
+ |
+LL | #![deny(non_ascii_idents)]
+ | ^^^^^^^^^^^^^^^^
+
+error: identifier contains non-ASCII characters
+ --> $DIR/lint-non-ascii-idents.rs:5:4
+ |
+LL | fn coöperation() {}
+ | ^^^^^^^^^^^
+
+error: identifier contains non-ASCII characters
+ --> $DIR/lint-non-ascii-idents.rs:8:9
+ |
+LL | let naïveté = 2;
+ | ^^^^^^^
+
+error: aborting due to 3 previous errors
+
diff --git a/tests/ui/lint/rfc-2457-non-ascii-idents/lint-uncommon-codepoints.rs b/tests/ui/lint/rfc-2457-non-ascii-idents/lint-uncommon-codepoints.rs
new file mode 100644
index 000000000..ed8e7dddd
--- /dev/null
+++ b/tests/ui/lint/rfc-2457-non-ascii-idents/lint-uncommon-codepoints.rs
@@ -0,0 +1,13 @@
+#![deny(uncommon_codepoints)]
+
+const µ: f64 = 0.000001; //~ ERROR identifier contains uncommon Unicode codepoints
+//~| WARNING should have an upper case name
+
+fn dijkstra() {} //~ ERROR identifier contains uncommon Unicode codepoints
+
+fn main() {
+ let ㇻㇲㇳ = "rust"; //~ ERROR identifier contains uncommon Unicode codepoints
+
+ // using the same identifier the second time won't trigger the lint.
+ println!("{}", ㇻㇲㇳ);
+}
diff --git a/tests/ui/lint/rfc-2457-non-ascii-idents/lint-uncommon-codepoints.stderr b/tests/ui/lint/rfc-2457-non-ascii-idents/lint-uncommon-codepoints.stderr
new file mode 100644
index 000000000..0533da030
--- /dev/null
+++ b/tests/ui/lint/rfc-2457-non-ascii-idents/lint-uncommon-codepoints.stderr
@@ -0,0 +1,34 @@
+error: identifier contains uncommon Unicode codepoints
+ --> $DIR/lint-uncommon-codepoints.rs:3:7
+ |
+LL | const µ: f64 = 0.000001;
+ | ^
+ |
+note: the lint level is defined here
+ --> $DIR/lint-uncommon-codepoints.rs:1:9
+ |
+LL | #![deny(uncommon_codepoints)]
+ | ^^^^^^^^^^^^^^^^^^^
+
+error: identifier contains uncommon Unicode codepoints
+ --> $DIR/lint-uncommon-codepoints.rs:6:4
+ |
+LL | fn dijkstra() {}
+ | ^^^^^^^
+
+error: identifier contains uncommon Unicode codepoints
+ --> $DIR/lint-uncommon-codepoints.rs:9:9
+ |
+LL | let ㇻㇲㇳ = "rust";
+ | ^^^^^^
+
+warning: constant `µ` should have an upper case name
+ --> $DIR/lint-uncommon-codepoints.rs:3:7
+ |
+LL | const µ: f64 = 0.000001;
+ | ^ help: convert the identifier to upper case: `Μ`
+ |
+ = note: `#[warn(non_upper_case_globals)]` on by default
+
+error: aborting due to 3 previous errors; 1 warning emitted
+