From 4547b622d8d29df964fa2914213088b148c498fc Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 17 Apr 2024 14:18:32 +0200 Subject: Merging upstream version 1.67.1+dfsg1. Signed-off-by: Daniel Baumann --- .../ui/dyn-star/dont-unsize-coerce-dyn-star.rs | 27 ++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 src/test/ui/dyn-star/dont-unsize-coerce-dyn-star.rs (limited to 'src/test/ui/dyn-star/dont-unsize-coerce-dyn-star.rs') diff --git a/src/test/ui/dyn-star/dont-unsize-coerce-dyn-star.rs b/src/test/ui/dyn-star/dont-unsize-coerce-dyn-star.rs new file mode 100644 index 000000000..c12b16f16 --- /dev/null +++ b/src/test/ui/dyn-star/dont-unsize-coerce-dyn-star.rs @@ -0,0 +1,27 @@ +// run-pass +// check-run-results + +#![feature(dyn_star)] +//~^ WARN the feature `dyn_star` is incomplete and may not be safe to use and/or cause compiler crashes + +trait AddOne { + fn add1(&mut self) -> usize; +} + +impl AddOne for usize { + fn add1(&mut self) -> usize { + *self += 1; + *self + } +} + +fn add_one(i: &mut (dyn* AddOne + '_)) -> usize { + i.add1() +} + +fn main() { + let mut x = 42usize as dyn* AddOne; + + println!("{}", add_one(&mut x)); + println!("{}", add_one(&mut x)); +} -- cgit v1.2.3