]> git.lizzy.rs Git - rust.git/blob - src/test/ui/nll/user-annotations/dump-fn-method.rs
7551a9474dc0865b086a345064e40da4ef3267e3
[rust.git] / src / test / ui / nll / user-annotations / dump-fn-method.rs
1 // Unit test for the "user substitutions" that are annotated on each
2 // node.
3
4 // compile-flags:-Zverbose
5
6 #![feature(nll)]
7 #![feature(rustc_attrs)]
8
9 // Note: we reference the names T and U in the comments below.
10 trait Bazoom<T> {
11     fn method<U>(&self, arg: T, arg2: U) { }
12 }
13
14 impl<T, U> Bazoom<U> for T {
15 }
16
17 fn foo<'a, T>(_: T) { }
18
19 #[rustc_dump_user_substs]
20 fn main() {
21     // Here: nothing is given, so we don't have any annotation.
22     let x = foo;
23     x(22);
24
25     // Here: `u32` is given.
26     let x = foo::<u32>; //~ ERROR [u32]
27     x(22);
28
29     // Here: we only want the `T` to be given, the rest should be variables.
30     //
31     // (`T` refers to the declaration of `Bazoom`)
32     let x = <_ as Bazoom<u32>>::method::<_>; //~ ERROR [^0, u32, ^1]
33     x(&22, 44, 66);
34
35     // Here: all are given
36     let x = <u8 as Bazoom<u16>>::method::<u32>; //~ ERROR [u8, u16, u32]
37     x(&22, 44, 66);
38
39     // Here: we want in particular that *only* the method `U`
40     // annotation is given, the rest are variables.
41     //
42     // (`U` refers to the declaration of `Bazoom`)
43     let y = 22_u32;
44     y.method::<u32>(44, 66); //~ ERROR [^0, ^1, u32]
45
46     // Here: nothing is given, so we don't have any annotation.
47     let y = 22_u32;
48     y.method(44, 66);
49 }