diff options
| author | Ding Xiang Fei <dingxiangfei2009@protonmail.ch> | 2025-08-12 06:39:50 +0800 |
|---|---|---|
| committer | Xiangfei Ding <dingxiangfei2009@protonmail.ch> | 2025-09-25 01:54:23 +0800 |
| commit | a86f14072714fb817a6f60fa20be5a4e875d049f (patch) | |
| tree | 9f42ebd49c3ced094501b1bb444a33fd0c404edc /tests | |
| parent | 15283f6fe95e5b604273d13a428bab5fc0788f5a (diff) | |
| download | rust-a86f14072714fb817a6f60fa20be5a4e875d049f.tar.gz rust-a86f14072714fb817a6f60fa20be5a4e875d049f.zip | |
do not materialise X in [X; 0] when X is unsizing a const
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/ui/coercion/no_local_for_coerced_const-issue-143671.rs | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/tests/ui/coercion/no_local_for_coerced_const-issue-143671.rs b/tests/ui/coercion/no_local_for_coerced_const-issue-143671.rs new file mode 100644 index 00000000000..eb814e9723c --- /dev/null +++ b/tests/ui/coercion/no_local_for_coerced_const-issue-143671.rs @@ -0,0 +1,30 @@ +//@ run-pass + +#![feature(unsize)] +#![feature(coerce_unsized)] + +use std::fmt::Display; +use std::marker::Unsize; +use std::ops::CoerceUnsized; + +#[repr(transparent)] +struct X<'a, T: ?Sized> { + f: &'a T, +} + +impl<'a, T: ?Sized> Drop for X<'a, T> { + fn drop(&mut self) { + panic!() + } +} + +impl<'a, T: ?Sized + Unsize<U>, U: ?Sized> CoerceUnsized<X<'a, U>> for X<'a, T> where + &'a T: CoerceUnsized<&'a U> +{ +} + +const Y: X<'static, i32> = X { f: &0 }; + +fn main() { + let _: [X<'static, dyn Display>; 0] = [Y; 0]; +} |
