diff options
Diffstat (limited to 'tests/ui/fn/coerce-suggestion-infer-region.rs')
| -rw-r--r-- | tests/ui/fn/coerce-suggestion-infer-region.rs | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/tests/ui/fn/coerce-suggestion-infer-region.rs b/tests/ui/fn/coerce-suggestion-infer-region.rs new file mode 100644 index 00000000000..7edb828c973 --- /dev/null +++ b/tests/ui/fn/coerce-suggestion-infer-region.rs @@ -0,0 +1,26 @@ +//! Functions with a mismatch between the expected and found type where the difference is a +//! reference may trigger analysis for additional help. In this test the expected type will be +//! &'a Container<&'a u8> and the found type will be Container<&'?0 u8>. +//! +//! This test exercises a scenario where the found type being analyzed contains an inference region +//! variable ('?0). This cannot be used in comparisons because the variable no longer exists by the +//! time the later analysis is performed. +//! +//! This is a regression test of #140823 + +trait MyFn<P> {} + +struct Container<T> { + data: T, +} + +struct Desugared { + callback: Box<dyn for<'a> MyFn<&'a Container<&'a u8>>>, +} + +fn test(callback: Box<dyn for<'a> MyFn<Container<&'a u8>>>) -> Desugared { + Desugared { callback } + //~^ ERROR mismatched types +} + +fn main() {} |
