about summary refs log tree commit diff
path: root/tests/ui/unsafe-binders
diff options
context:
space:
mode:
authorMichael Goulet <michael@errs.io>2025-03-01 19:28:04 +0000
committerMichael Goulet <michael@errs.io>2025-03-03 01:34:09 +0000
commit83fa2faf239b4bcde67eda7adf0a1a10dfca620d (patch)
tree26b960cb31d5e388b9f610c03fe33059434f0f59 /tests/ui/unsafe-binders
parentf4a216d28ee635afce685b4206e713579f66e130 (diff)
downloadrust-83fa2faf239b4bcde67eda7adf0a1a10dfca620d.tar.gz
rust-83fa2faf239b4bcde67eda7adf0a1a10dfca620d.zip
Fix pretty printing of unsafe binders
Diffstat (limited to 'tests/ui/unsafe-binders')
-rw-r--r--tests/ui/unsafe-binders/type-mismatch.rs9
-rw-r--r--tests/ui/unsafe-binders/type-mismatch.stderr34
2 files changed, 43 insertions, 0 deletions
diff --git a/tests/ui/unsafe-binders/type-mismatch.rs b/tests/ui/unsafe-binders/type-mismatch.rs
new file mode 100644
index 00000000000..9ac4e817c28
--- /dev/null
+++ b/tests/ui/unsafe-binders/type-mismatch.rs
@@ -0,0 +1,9 @@
+#![feature(unsafe_binders)]
+//~^ WARN the feature `unsafe_binders` is incomplete
+
+fn main() {
+    let x: unsafe<> i32 = 0;
+    //~^ ERROR mismatched types
+    let x: unsafe<'a> &'a i32 = &0;
+    //~^ ERROR mismatched types
+}
diff --git a/tests/ui/unsafe-binders/type-mismatch.stderr b/tests/ui/unsafe-binders/type-mismatch.stderr
new file mode 100644
index 00000000000..e694b5d464d
--- /dev/null
+++ b/tests/ui/unsafe-binders/type-mismatch.stderr
@@ -0,0 +1,34 @@
+warning: the feature `unsafe_binders` is incomplete and may not be safe to use and/or cause compiler crashes
+  --> $DIR/type-mismatch.rs:1:12
+   |
+LL | #![feature(unsafe_binders)]
+   |            ^^^^^^^^^^^^^^
+   |
+   = note: see issue #130516 <https://github.com/rust-lang/rust/issues/130516> for more information
+   = note: `#[warn(incomplete_features)]` on by default
+
+error[E0308]: mismatched types
+  --> $DIR/type-mismatch.rs:5:27
+   |
+LL |     let x: unsafe<> i32 = 0;
+   |            ------------   ^ expected `unsafe<> i32`, found integer
+   |            |
+   |            expected due to this
+   |
+   = note: expected unsafe binder `unsafe<> i32`
+                       found type `{integer}`
+
+error[E0308]: mismatched types
+  --> $DIR/type-mismatch.rs:7:33
+   |
+LL |     let x: unsafe<'a> &'a i32 = &0;
+   |            ------------------   ^^ expected `unsafe<'a> &i32`, found `&{integer}`
+   |            |
+   |            expected due to this
+   |
+   = note: expected unsafe binder `unsafe<'a> &'a i32`
+                  found reference `&{integer}`
+
+error: aborting due to 2 previous errors; 1 warning emitted
+
+For more information about this error, try `rustc --explain E0308`.