summary refs log tree commit diff
path: root/src/test/ui/impl-trait/issue-57979-impl-trait-in-path.rs
blob: 84fcb5e2880a79c017aac5e7bd209f5def992e42 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
// rust-lang/rust#57979 : the initial support for `impl Trait` didn't
// properly check syntax hidden behind an associated type projection.
// Here we test behavior of occurrences of `impl Trait` within a path
// component in that context.

mod allowed {
    #![allow(nested_impl_trait)]

    pub trait Bar { }
    pub trait Quux<T> { type Assoc; }
    pub fn demo(_: impl Quux<(), Assoc=<() as Quux<impl Bar>>::Assoc>) { }
    impl<T> Quux<T> for () { type Assoc = u32; }
}

mod warned {
    #![warn(nested_impl_trait)]

    pub trait Bar { }
    pub trait Quux<T> { type Assoc; }
    pub fn demo(_: impl Quux<(), Assoc=<() as Quux<impl Bar>>::Assoc>) { }
    //~^ WARN `impl Trait` is not allowed in path parameters
    //~| WARN will become a hard error in a future release!
    impl<T> Quux<T> for () { type Assoc = u32; }
}

mod denied {
    #![deny(nested_impl_trait)]

    pub trait Bar { }
    pub trait Quux<T> { type Assoc; }
    pub fn demo(_: impl Quux<(), Assoc=<() as Quux<impl Bar>>::Assoc>) { }
    //~^ ERROR `impl Trait` is not allowed in path parameters
    //~| WARN will become a hard error in a future release!
    impl<T> Quux<T> for () { type Assoc = u32; }
}

fn main() { }