summaryrefslogtreecommitdiffstats
path: root/tests/ui/typeof
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:19:13 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:19:13 +0000
commit218caa410aa38c29984be31a5229b9fa717560ee (patch)
treec54bd55eeb6e4c508940a30e94c0032fbd45d677 /tests/ui/typeof
parentReleasing progress-linux version 1.67.1+dfsg1-1~progress7.99u1. (diff)
downloadrustc-218caa410aa38c29984be31a5229b9fa717560ee.tar.xz
rustc-218caa410aa38c29984be31a5229b9fa717560ee.zip
Merging upstream version 1.68.2+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/ui/typeof')
-rw-r--r--tests/ui/typeof/issue-100183.rs6
-rw-r--r--tests/ui/typeof/issue-100183.stderr14
-rw-r--r--tests/ui/typeof/issue-29184.rs3
-rw-r--r--tests/ui/typeof/issue-29184.stderr14
-rw-r--r--tests/ui/typeof/issue-42060.rs11
-rw-r--r--tests/ui/typeof/issue-42060.stderr32
-rw-r--r--tests/ui/typeof/type_mismatch.rs9
-rw-r--r--tests/ui/typeof/type_mismatch.stderr28
8 files changed, 117 insertions, 0 deletions
diff --git a/tests/ui/typeof/issue-100183.rs b/tests/ui/typeof/issue-100183.rs
new file mode 100644
index 000000000..13e9493ea
--- /dev/null
+++ b/tests/ui/typeof/issue-100183.rs
@@ -0,0 +1,6 @@
+struct Struct {
+ y: (typeof("hey"),),
+ //~^ ERROR `typeof` is a reserved keyword but unimplemented
+}
+
+fn main() {}
diff --git a/tests/ui/typeof/issue-100183.stderr b/tests/ui/typeof/issue-100183.stderr
new file mode 100644
index 000000000..01d3079b2
--- /dev/null
+++ b/tests/ui/typeof/issue-100183.stderr
@@ -0,0 +1,14 @@
+error[E0516]: `typeof` is a reserved keyword but unimplemented
+ --> $DIR/issue-100183.rs:2:9
+ |
+LL | y: (typeof("hey"),),
+ | ^^^^^^^^^^^^^ reserved keyword
+ |
+help: consider replacing `typeof(...)` with an actual type
+ |
+LL | y: (&'static str,),
+ | ~~~~~~~~~~~~
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0516`.
diff --git a/tests/ui/typeof/issue-29184.rs b/tests/ui/typeof/issue-29184.rs
new file mode 100644
index 000000000..c77e364c3
--- /dev/null
+++ b/tests/ui/typeof/issue-29184.rs
@@ -0,0 +1,3 @@
+fn main() {
+ let x: typeof(92) = 92; //~ ERROR `typeof` is a reserved keyword
+}
diff --git a/tests/ui/typeof/issue-29184.stderr b/tests/ui/typeof/issue-29184.stderr
new file mode 100644
index 000000000..75b6c64f2
--- /dev/null
+++ b/tests/ui/typeof/issue-29184.stderr
@@ -0,0 +1,14 @@
+error[E0516]: `typeof` is a reserved keyword but unimplemented
+ --> $DIR/issue-29184.rs:2:12
+ |
+LL | let x: typeof(92) = 92;
+ | ^^^^^^^^^^ reserved keyword
+ |
+help: consider replacing `typeof(...)` with an actual type
+ |
+LL | let x: i32 = 92;
+ | ~~~
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0516`.
diff --git a/tests/ui/typeof/issue-42060.rs b/tests/ui/typeof/issue-42060.rs
new file mode 100644
index 000000000..1740b2383
--- /dev/null
+++ b/tests/ui/typeof/issue-42060.rs
@@ -0,0 +1,11 @@
+fn main() {
+ let thing = ();
+ let other: typeof(thing) = thing; //~ ERROR attempt to use a non-constant value in a constant
+ //~^ ERROR `typeof` is a reserved keyword but unimplemented [E0516]
+}
+
+fn f(){
+ let q = 1;
+ <typeof(q)>::N //~ ERROR attempt to use a non-constant value in a constant
+ //~^ ERROR `typeof` is a reserved keyword but unimplemented [E0516]
+}
diff --git a/tests/ui/typeof/issue-42060.stderr b/tests/ui/typeof/issue-42060.stderr
new file mode 100644
index 000000000..effcbe4d7
--- /dev/null
+++ b/tests/ui/typeof/issue-42060.stderr
@@ -0,0 +1,32 @@
+error[E0435]: attempt to use a non-constant value in a constant
+ --> $DIR/issue-42060.rs:3:23
+ |
+LL | let thing = ();
+ | --------- help: consider using `const` instead of `let`: `const thing`
+LL | let other: typeof(thing) = thing;
+ | ^^^^^ non-constant value
+
+error[E0435]: attempt to use a non-constant value in a constant
+ --> $DIR/issue-42060.rs:9:13
+ |
+LL | let q = 1;
+ | ----- help: consider using `const` instead of `let`: `const q`
+LL | <typeof(q)>::N
+ | ^ non-constant value
+
+error[E0516]: `typeof` is a reserved keyword but unimplemented
+ --> $DIR/issue-42060.rs:3:16
+ |
+LL | let other: typeof(thing) = thing;
+ | ^^^^^^^^^^^^^ reserved keyword
+
+error[E0516]: `typeof` is a reserved keyword but unimplemented
+ --> $DIR/issue-42060.rs:9:6
+ |
+LL | <typeof(q)>::N
+ | ^^^^^^^^^ reserved keyword
+
+error: aborting due to 4 previous errors
+
+Some errors have detailed explanations: E0435, E0516.
+For more information about an error, try `rustc --explain E0435`.
diff --git a/tests/ui/typeof/type_mismatch.rs b/tests/ui/typeof/type_mismatch.rs
new file mode 100644
index 000000000..3f8339fa5
--- /dev/null
+++ b/tests/ui/typeof/type_mismatch.rs
@@ -0,0 +1,9 @@
+// Test that using typeof results in the correct type mismatch errors instead of always assuming
+// `usize`, in addition to the pre-existing "typeof is reserved and unimplemented" error
+fn main() {
+ const a: u8 = 1;
+ let b: typeof(a) = 1i8;
+ //~^ ERROR `typeof` is a reserved keyword but unimplemented
+ //~| ERROR mismatched types
+ //~| expected `u8`, found `i8`
+}
diff --git a/tests/ui/typeof/type_mismatch.stderr b/tests/ui/typeof/type_mismatch.stderr
new file mode 100644
index 000000000..e75214cd3
--- /dev/null
+++ b/tests/ui/typeof/type_mismatch.stderr
@@ -0,0 +1,28 @@
+error[E0516]: `typeof` is a reserved keyword but unimplemented
+ --> $DIR/type_mismatch.rs:5:12
+ |
+LL | let b: typeof(a) = 1i8;
+ | ^^^^^^^^^ reserved keyword
+ |
+help: consider replacing `typeof(...)` with an actual type
+ |
+LL | let b: u8 = 1i8;
+ | ~~
+
+error[E0308]: mismatched types
+ --> $DIR/type_mismatch.rs:5:24
+ |
+LL | let b: typeof(a) = 1i8;
+ | --------- ^^^ expected `u8`, found `i8`
+ | |
+ | expected due to this
+ |
+help: change the type of the numeric literal from `i8` to `u8`
+ |
+LL | let b: typeof(a) = 1u8;
+ | ~~
+
+error: aborting due to 2 previous errors
+
+Some errors have detailed explanations: E0308, E0516.
+For more information about an error, try `rustc --explain E0308`.