about summary refs log tree commit diff
path: root/tests/ui
diff options
context:
space:
mode:
authorMatthias Krüger <476013+matthiaskrgr@users.noreply.github.com>2025-10-01 18:42:37 +0200
committerGitHub <noreply@github.com>2025-10-01 18:42:37 +0200
commitae60ebd46daace4af7eae5e254b39f55b8b51e92 (patch)
treeac6d4159e5987787bc5907097310baa51c09566b /tests/ui
parent4b905f9cb0ed7ddcde22f710f8d03733fe9b608b (diff)
parentb810a68197515bfbe5afd8557b566d6817035389 (diff)
downloadrust-ae60ebd46daace4af7eae5e254b39f55b8b51e92.tar.gz
rust-ae60ebd46daace4af7eae5e254b39f55b8b51e92.zip
Rollup merge of #147219 - Kivooeo:typeof-is-imposter, r=jdonszelmann
Add proper error handling for closure in impl

Fixes https://github.com/rust-lang/rust/issues/147146
Fixes https://github.com/rust-lang/rust/issues/146620

Not sure if it can cause any regressions or anything, as for test also have no idea where to store this one

cc ```@theemathas```

r? compiler
Diffstat (limited to 'tests/ui')
-rw-r--r--tests/ui/closures/impl-closure-147146.rs7
-rw-r--r--tests/ui/closures/impl-closure-147146.stderr15
2 files changed, 22 insertions, 0 deletions
diff --git a/tests/ui/closures/impl-closure-147146.rs b/tests/ui/closures/impl-closure-147146.rs
new file mode 100644
index 00000000000..b709e577354
--- /dev/null
+++ b/tests/ui/closures/impl-closure-147146.rs
@@ -0,0 +1,7 @@
+impl typeof(|| {}) {}
+//~^ ERROR `typeof` is a reserved keyword but unimplemented
+
+unsafe impl Send for typeof(|| {}) {}
+//~^ ERROR `typeof` is a reserved keyword but unimplemented
+
+fn main() {}
diff --git a/tests/ui/closures/impl-closure-147146.stderr b/tests/ui/closures/impl-closure-147146.stderr
new file mode 100644
index 00000000000..6da16b5d450
--- /dev/null
+++ b/tests/ui/closures/impl-closure-147146.stderr
@@ -0,0 +1,15 @@
+error[E0516]: `typeof` is a reserved keyword but unimplemented
+  --> $DIR/impl-closure-147146.rs:1:6
+   |
+LL | impl typeof(|| {}) {}
+   |      ^^^^^^^^^^^^^ reserved keyword
+
+error[E0516]: `typeof` is a reserved keyword but unimplemented
+  --> $DIR/impl-closure-147146.rs:4:22
+   |
+LL | unsafe impl Send for typeof(|| {}) {}
+   |                      ^^^^^^^^^^^^^ reserved keyword
+
+error: aborting due to 2 previous errors
+
+For more information about this error, try `rustc --explain E0516`.