summaryrefslogtreecommitdiffstats
path: root/src/test/ui/codegen/issue-99551.rs
blob: f24874c992eafc0e39c7e45f7a4a3e7ff87d69d6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
// build-pass
#![feature(trait_upcasting)]
#![allow(incomplete_features)]

pub trait A {}
pub trait B {}

pub trait C: A + B {}
impl<X: A + B> C for X {}

pub fn test<'a, T>(view: T) -> Option<&'a mut dyn B>
where
    T: IntoIterator<Item = &'a mut dyn B>,
{
    return Some(view.into_iter().next().unwrap());
}

fn main() {
    let mut a: Vec<Box<dyn C>> = Vec::new();
    test(a.iter_mut().map(|c| c.as_mut() as &mut dyn B));
}