// This test is a reduced version of a bug introduced during work on type-tests for Polonius. // The underlying problem is that the 'static bound is lost for a type parameter that is // threaded deeply enough, causing an error. // The bug was first observed in exr-1.4.1/src/image/read/mod.rs:124:5 during perf test. //@ check-pass use std::marker::PhantomData; struct ReadAllLayers { px: PhantomData, } trait ReadLayers<'s> {} impl<'s, C> ReadLayers<'s> for ReadAllLayers where C: ReadChannels<'s> {} fn make_builder( _: Set, ) -> ReadAllLayers> where Set: Fn(&mut Pixels), { todo!() } struct CollectPixels { px: PhantomData<(SetPixel, Pixel, PixelStorage)>, } impl<'s, PixelStorage, SetPixel: 's> ReadChannels<'s> for CollectPixels where SetPixel: Fn(&mut PixelStorage), { } trait ReadChannels<'s> {} fn from_file(_: L) where for<'s> L: ReadLayers<'s>, { } pub fn read_all_rgba_layers_from_file( set_pixel: Set, ) where Set: Fn(&mut Pixels), { from_file(make_builder(set_pixel)); // Error triggered. } pub fn main() {}