// Test when deferring repeat expr copy checks to end of typechecking whether they're // checked before integer fallback occurs or not. We accomplish this by having a repeat // count that can only be inferred after integer fallback has occured. This test will // pass if we were to check repeat exprs after integer fallback. use std::marker::PhantomData; struct Foo(PhantomData); // We impl Copy/Clone for multiple (but not all) substitutions // to ensure that `Foo: Copy` can't be proven on the basis // of there only being one applying impl. impl Clone for Foo { fn clone(&self) -> Self { Foo(PhantomData) } } impl Clone for Foo { fn clone(&self) -> Self { Foo(PhantomData) } } impl Copy for Foo {} impl Copy for Foo {} trait Trait {} // We impl `Trait` for both `i32` and `u32` to avoid being able // to prove `?int: Trait` from there only being one impl. impl Trait<1> for i32 {} impl Trait<2> for u32 {} fn tie_and_make_goal>(_: &T, _: &[Foo; N]) {} fn main() { let a = 1; // Deferred repeat expr `Foo; ?n` let b = [Foo(PhantomData); _]; //~^ ERROR: type annotations needed for `[Foo<{integer}>; _]` // Introduces a `?int: Trait` goal tie_and_make_goal(&a, &b); // If fallback doesn't occur: // - `Foo; ?n`is ambig as repeat count is unknown -> error // If fallback occurs: // - `?int` inferred to `i32` // - `?int: Trait` becomes `i32: Trait` wihhc infers `?n=1` // - Repeat expr check `Foo; ?n` is now `Foo; 1` // - `Foo; 1` doesn't require `Foo: Copy` }