Skip to content

Commit

Permalink
Rollup merge of #104266 - compiler-errors:issue-102430, r=Mark-Simula…
Browse files Browse the repository at this point in the history
…crum

Regression test for coercion of mut-ref to dyn-star

Closes #102430
  • Loading branch information
Manishearth authored Nov 14, 2022
2 parents d76058d + 07aa592 commit cc96cdd
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions src/test/ui/dyn-star/issue-102430.rs
Original file line number Diff line number Diff line change
@@ -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));
}

0 comments on commit cc96cdd

Please sign in to comment.