diff options
| author | 许杰友 Jieyou Xu (Joe) <39484203+jieyouxu@users.noreply.github.com> | 2025-03-05 21:46:44 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-03-05 21:46:44 +0800 |
| commit | 257b4947ed14795a8411df53b6cf6d5a57b56240 (patch) | |
| tree | df8863d44248b0f11e9af01e2aa275fcb1475060 /tests/ui/cast | |
| parent | dac4ffd5c005ed6af0e34ce0620a6a366dd0081b (diff) | |
| parent | 68df70d510e2ff8a303d7b3c9c8b0cb3bce579f4 (diff) | |
| download | rust-257b4947ed14795a8411df53b6cf6d5a57b56240.tar.gz rust-257b4947ed14795a8411df53b6cf6d5a57b56240.zip | |
Rollup merge of #137728 - Darksonn:no-tuple-unsize, r=oli-obk
Remove unsizing coercions for tuples See https://github.com/rust-lang/rust/issues/42877#issuecomment-2686010847 and below comments for justification. Tracking issue: #42877 Fixes: #135217
Diffstat (limited to 'tests/ui/cast')
| -rw-r--r-- | tests/ui/cast/cast-rfc0401-vtable-kinds.rs | 16 | ||||
| -rw-r--r-- | tests/ui/cast/cast-rfc0401-vtable-kinds.stderr | 2 |
2 files changed, 1 insertions, 17 deletions
diff --git a/tests/ui/cast/cast-rfc0401-vtable-kinds.rs b/tests/ui/cast/cast-rfc0401-vtable-kinds.rs index 5704a33cc87..78f6dca1818 100644 --- a/tests/ui/cast/cast-rfc0401-vtable-kinds.rs +++ b/tests/ui/cast/cast-rfc0401-vtable-kinds.rs @@ -2,8 +2,6 @@ // Check that you can cast between different pointers to trait objects // whose vtable have the same kind (both lengths, or both trait pointers). -#![feature(unsized_tuple_coercion)] - trait Bar { //~ WARN trait `Bar` is never used fn bar(&self) { println!("Bar!"); } } @@ -19,10 +17,6 @@ fn foo_to_bar<T:?Sized>(u: *const FooS<T>) -> *const BarS<T> { u as *const BarS<T> } -fn tuple_i32_to_u32<T:?Sized>(u: *const (i32, T)) -> *const (u32, T) { - u as *const (u32, T) -} - fn main() { let s = FooS([0,1,2]); @@ -31,14 +25,4 @@ fn main() { let bar_ref : *const BarS<[u32]> = foo_to_bar(u); let z : &BarS<[u32]> = unsafe{&*bar_ref}; assert_eq!(&z.0, &[0,1,2]); - - // this assumes that tuple reprs for (i32, _) and (u32, _) are - // the same. - let s = (0i32, [0, 1, 2]); - let u: &(i32, [u8]) = &s; - let u: *const (i32, [u8]) = u; - let u_u32 : *const (u32, [u8]) = tuple_i32_to_u32(u); - unsafe { - assert_eq!(&(*u_u32).1, &[0, 1, 2]); - } } diff --git a/tests/ui/cast/cast-rfc0401-vtable-kinds.stderr b/tests/ui/cast/cast-rfc0401-vtable-kinds.stderr index 4f57e2e7df7..01277fd632e 100644 --- a/tests/ui/cast/cast-rfc0401-vtable-kinds.stderr +++ b/tests/ui/cast/cast-rfc0401-vtable-kinds.stderr @@ -1,5 +1,5 @@ warning: trait `Bar` is never used - --> $DIR/cast-rfc0401-vtable-kinds.rs:7:7 + --> $DIR/cast-rfc0401-vtable-kinds.rs:5:7 | LL | trait Bar { | ^^^ |
