diff options
| author | Manish Goregaokar <manishsmail@gmail.com> | 2022-11-13 21:49:26 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-11-13 21:49:26 -0500 |
| commit | cc96cdd6969fdf4f043d713420c059567d89b35c (patch) | |
| tree | 08567c451c97c261011c06aef81a219e9db7aa68 | |
| parent | d76058d8b3fbc84633e5c706703fe9832f2f91dd (diff) | |
| parent | 07aa5925041b415b2727cfbb0d23cc3997bd7ad7 (diff) | |
| download | rust-cc96cdd6969fdf4f043d713420c059567d89b35c.tar.gz rust-cc96cdd6969fdf4f043d713420c059567d89b35c.zip | |
Rollup merge of #104266 - compiler-errors:issue-102430, r=Mark-Simulacrum
Regression test for coercion of mut-ref to dyn-star Closes #102430
| -rw-r--r-- | src/test/ui/dyn-star/issue-102430.rs | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/src/test/ui/dyn-star/issue-102430.rs b/src/test/ui/dyn-star/issue-102430.rs new file mode 100644 index 00000000000..244ecda6626 --- /dev/null +++ b/src/test/ui/dyn-star/issue-102430.rs @@ -0,0 +1,32 @@ +// check-pass + +#![feature(dyn_star)] +#![allow(incomplete_features)] + +trait AddOne { + fn add1(&mut self) -> usize; +} + +impl AddOne for usize { + fn add1(&mut self) -> usize { + *self += 1; + *self + } +} + +impl AddOne for &mut usize { + fn add1(&mut self) -> usize { + (*self).add1() + } +} + +fn add_one(mut i: dyn* AddOne + '_) -> usize { + i.add1() +} + +fn main() { + let mut x = 42usize; + let y = &mut x as (dyn* AddOne + '_); + + println!("{}", add_one(y)); +} |
