diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-30 03:57:19 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-30 03:57:19 +0000 |
commit | a0b8f38ab54ac451646aa00cd5e91b6c76f22a84 (patch) | |
tree | fc451898ccaf445814e26b46664d78702178101d /tests/ui/coercion/issue-3794.rs | |
parent | Adding debian version 1.71.1+dfsg1-2. (diff) | |
download | rustc-a0b8f38ab54ac451646aa00cd5e91b6c76f22a84.tar.xz rustc-a0b8f38ab54ac451646aa00cd5e91b6c76f22a84.zip |
Merging upstream version 1.72.1+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/ui/coercion/issue-3794.rs')
-rw-r--r-- | tests/ui/coercion/issue-3794.rs | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/tests/ui/coercion/issue-3794.rs b/tests/ui/coercion/issue-3794.rs new file mode 100644 index 000000000..b1f028fbc --- /dev/null +++ b/tests/ui/coercion/issue-3794.rs @@ -0,0 +1,32 @@ +// run-pass +#![allow(dead_code)] + +trait T { + fn print(&self); +} + +#[derive(Debug)] +struct S { + s: isize, +} + +impl T for S { + fn print(&self) { + println!("{:?}", self); + } +} + +fn print_t(t: &dyn T) { + t.print(); +} + +fn print_s(s: &S) { + s.print(); +} + +pub fn main() { + let s: Box<S> = Box::new(S { s: 5 }); + print_s(&*s); + let t: Box<dyn T> = s as Box<dyn T>; + print_t(&*t); +} |