Skip to content

Commit cc96cdd

Browse files
authored
Rollup merge of #104266 - compiler-errors:issue-102430, r=Mark-Simulacrum
Regression test for coercion of mut-ref to dyn-star Closes #102430
2 parents d76058d + 07aa592 commit cc96cdd

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

src/test/ui/dyn-star/issue-102430.rs

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
// check-pass
2+
3+
#![feature(dyn_star)]
4+
#![allow(incomplete_features)]
5+
6+
trait AddOne {
7+
fn add1(&mut self) -> usize;
8+
}
9+
10+
impl AddOne for usize {
11+
fn add1(&mut self) -> usize {
12+
*self += 1;
13+
*self
14+
}
15+
}
16+
17+
impl AddOne for &mut usize {
18+
fn add1(&mut self) -> usize {
19+
(*self).add1()
20+
}
21+
}
22+
23+
fn add_one(mut i: dyn* AddOne + '_) -> usize {
24+
i.add1()
25+
}
26+
27+
fn main() {
28+
let mut x = 42usize;
29+
let y = &mut x as (dyn* AddOne + '_);
30+
31+
println!("{}", add_one(y));
32+
}

0 commit comments

Comments
 (0)