summaryrefslogtreecommitdiffstats
path: root/src/test/ui/numeric/uppercase-base-prefix.rs
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:02:58 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:02:58 +0000
commit698f8c2f01ea549d77d7dc3338a12e04c11057b9 (patch)
tree173a775858bd501c378080a10dca74132f05bc50 /src/test/ui/numeric/uppercase-base-prefix.rs
parentInitial commit. (diff)
downloadrustc-698f8c2f01ea549d77d7dc3338a12e04c11057b9.tar.xz
rustc-698f8c2f01ea549d77d7dc3338a12e04c11057b9.zip
Adding upstream version 1.64.0+dfsg1.upstream/1.64.0+dfsg1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/test/ui/numeric/uppercase-base-prefix.rs')
-rw-r--r--src/test/ui/numeric/uppercase-base-prefix.rs77
1 files changed, 77 insertions, 0 deletions
diff --git a/src/test/ui/numeric/uppercase-base-prefix.rs b/src/test/ui/numeric/uppercase-base-prefix.rs
new file mode 100644
index 000000000..233d553da
--- /dev/null
+++ b/src/test/ui/numeric/uppercase-base-prefix.rs
@@ -0,0 +1,77 @@
+// run-rustfix
+// Checks that integers with an uppercase base prefix (0B, 0X, 0O) have a nice error
+#![allow(unused_variables)]
+
+fn main() {
+ let a = 0XABCDEF;
+ //~^ ERROR invalid base prefix for number literal
+ //~| NOTE base prefixes (`0xff`, `0b1010`, `0o755`) are lowercase
+ //~| HELP try making the prefix lowercase
+ //~| SUGGESTION 0xABCDEF
+
+ let b = 0O755;
+ //~^ ERROR invalid base prefix for number literal
+ //~| NOTE base prefixes (`0xff`, `0b1010`, `0o755`) are lowercase
+ //~| HELP try making the prefix lowercase
+ //~| SUGGESTION 0o755
+
+ let c = 0B10101010;
+ //~^ ERROR invalid base prefix for number literal
+ //~| NOTE base prefixes (`0xff`, `0b1010`, `0o755`) are lowercase
+ //~| HELP try making the prefix lowercase
+ //~| SUGGESTION 0b10101010
+
+ let d = 0XABC_DEF;
+ //~^ ERROR invalid base prefix for number literal
+ //~| NOTE base prefixes (`0xff`, `0b1010`, `0o755`) are lowercase
+ //~| HELP try making the prefix lowercase
+ //~| SUGGESTION 0xABC_DEF
+
+ let e = 0O7_55;
+ //~^ ERROR invalid base prefix for number literal
+ //~| NOTE base prefixes (`0xff`, `0b1010`, `0o755`) are lowercase
+ //~| HELP try making the prefix lowercase
+ //~| SUGGESTION 0o7_55
+
+ let f = 0B1010_1010;
+ //~^ ERROR invalid base prefix for number literal
+ //~| NOTE base prefixes (`0xff`, `0b1010`, `0o755`) are lowercase
+ //~| HELP try making the prefix lowercase
+ //~| SUGGESTION 0b1010_1010
+
+ let g = 0XABC_DEF_u64;
+ //~^ ERROR invalid base prefix for number literal
+ //~| NOTE base prefixes (`0xff`, `0b1010`, `0o755`) are lowercase
+ //~| HELP try making the prefix lowercase
+ //~| SUGGESTION 0xABC_DEF_u64
+
+ let h = 0O7_55_u32;
+ //~^ ERROR invalid base prefix for number literal
+ //~| NOTE base prefixes (`0xff`, `0b1010`, `0o755`) are lowercase
+ //~| HELP try making the prefix lowercase
+ //~| SUGGESTION 0o7_55_u32
+
+ let i = 0B1010_1010_u8;
+ //~^ ERROR invalid base prefix for number literal
+ //~| NOTE base prefixes (`0xff`, `0b1010`, `0o755`) are lowercase
+ //~| HELP try making the prefix lowercase
+ //~| SUGGESTION 0b1010_1010_u8
+ //
+ let j = 0XABCDEFu64;
+ //~^ ERROR invalid base prefix for number literal
+ //~| NOTE base prefixes (`0xff`, `0b1010`, `0o755`) are lowercase
+ //~| HELP try making the prefix lowercase
+ //~| SUGGESTION 0xABCDEFu64
+
+ let k = 0O755u32;
+ //~^ ERROR invalid base prefix for number literal
+ //~| NOTE base prefixes (`0xff`, `0b1010`, `0o755`) are lowercase
+ //~| HELP try making the prefix lowercase
+ //~| SUGGESTION 0o755u32
+
+ let l = 0B10101010u8;
+ //~^ ERROR invalid base prefix for number literal
+ //~| NOTE base prefixes (`0xff`, `0b1010`, `0o755`) are lowercase
+ //~| HELP try making the prefix lowercase
+ //~| SUGGESTION 0b10101010u8
+}