about summary refs log tree commit diff
path: root/tests
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2024-12-23 01:18:40 +0000
committerbors <bors@rust-lang.org>2024-12-23 01:18:40 +0000
commit908af5ba4ad921fec81d95c97411c867cdcb33fa (patch)
treeefadfb9885dd79d1b94ff4d0f766036cd2e4f876 /tests
parent5a14967f7b0504d64fa51400c8776a1b55731c31 (diff)
parentd05edbe652172b84a884496599f95201bd05c997 (diff)
Auto merge of #134666 - matthiaskrgr:rollup-whe0chp, r=matthiaskrgr
Rollup of 6 pull requests

Successful merges:

 - #130289 (docs: Permissions.readonly() also ignores root user special permissions)
 - #134583 (docs: `transmute<&mut T, &mut MaybeUninit<T>>` is unsound when exposed to safe code)
 - #134611 (Align `{i686,x86_64}-win7-windows-msvc` to their parent targets)
 - #134629 (compiletest: Allow using a specific debugger when running debuginfo tests)
 - #134642 (Implement `PointerLike` for `isize`, `NonNull`, `Cell`, `UnsafeCell`, and `SyncUnsafeCell`.)
 - #134660 (Fix spacing of markdown code block fences in compiler rustdoc)

r? `@ghost`
`@rustbot` modify labels: rollup
Diffstat (limited to 'tests')
-rw-r--r--tests/ui/dyn-star/cell.rs34
-rw-r--r--tests/ui/dyn-star/error.rs2
-rw-r--r--tests/ui/dyn-star/float-as-dyn-star.stderr4
3 files changed, 38 insertions, 2 deletions
diff --git a/tests/ui/dyn-star/cell.rs b/tests/ui/dyn-star/cell.rs
new file mode 100644
index 00000000000..f4c7927a39d
--- /dev/null
+++ b/tests/ui/dyn-star/cell.rs
@@ -0,0 +1,34 @@
+// This test with Cell also indirectly exercises UnsafeCell in dyn*.
+//
+//@ run-pass
+
+#![feature(dyn_star)]
+#![allow(incomplete_features)]
+
+use std::cell::Cell;
+
+trait Rw<T> {
+    fn read(&self) -> T;
+    fn write(&self, v: T);
+}
+
+impl<T: Copy> Rw<T> for Cell<T> {
+    fn read(&self) -> T {
+        self.get()
+    }
+    fn write(&self, v: T) {
+        self.set(v)
+    }
+}
+
+fn make_dyn_star() -> dyn* Rw<usize> {
+    Cell::new(42usize) as dyn* Rw<usize>
+}
+
+fn main() {
+    let x = make_dyn_star();
+
+    assert_eq!(x.read(), 42);
+    x.write(24);
+    assert_eq!(x.read(), 24);
+}
diff --git a/tests/ui/dyn-star/error.rs b/tests/ui/dyn-star/error.rs
index 7288596f3fa..1d252d2ce42 100644
--- a/tests/ui/dyn-star/error.rs
+++ b/tests/ui/dyn-star/error.rs
@@ -6,7 +6,7 @@ use std::fmt::Debug;
 trait Foo {}
 
 fn make_dyn_star() {
-    let i = 42;
+    let i = 42usize;
     let dyn_i: dyn* Foo = i; //~ ERROR trait bound `usize: Foo` is not satisfied
 }
 
diff --git a/tests/ui/dyn-star/float-as-dyn-star.stderr b/tests/ui/dyn-star/float-as-dyn-star.stderr
index 9caba512e5f..06071a27afc 100644
--- a/tests/ui/dyn-star/float-as-dyn-star.stderr
+++ b/tests/ui/dyn-star/float-as-dyn-star.stderr
@@ -14,7 +14,9 @@ LL |     f32::from_bits(0x1) as f64
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^ `f64` needs to be a pointer-like type
    |
    = help: the trait `PointerLike` is not implemented for `f64`
-   = help: the trait `PointerLike` is implemented for `usize`
+   = help: the following other types implement trait `PointerLike`:
+             isize
+             usize
 
 error: aborting due to 1 previous error; 1 warning emitted