//@ known-bug: rust-lang/rust#129214 //@ compile-flags: -Zvalidate-mir -Copt-level=3 --crate-type=lib trait to_str {} trait map { fn map(&self, f: F) -> Vec where F: FnMut(&Box) -> U; } impl map for Vec { fn map(&self, mut f: F) -> Vec where F: FnMut(&T) -> U, { let mut r = Vec::new(); for i in self { r.push(f(i)); } r } } fn foo>(x: T) -> Vec { x.map(|_e| "hi".to_string()) } pub fn main() { assert_eq!(foo(vec![1]), ["hi".to_string()]); }