]> git.lizzy.rs Git - rust.git/blob - tests/ui/nll/user-annotations/dump-fn-method.rs
Rollup merge of #106946 - dtolnay:hashlinecolumn, r=m-ou-se
[rust.git] / tests / 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(rustc_attrs)]
7
8 // Note: we reference the names T and U in the comments below.
9 trait Bazoom<T> {
10     fn method<U>(&self, arg: T, arg2: U) { }
11 }
12
13 impl<S, T> Bazoom<T> for S {
14 }
15
16 fn foo<'a, T>(_: T) { }
17
18 #[rustc_dump_user_substs]
19 fn main() {
20     // Here: nothing is given, so we don't have any annotation.
21     let x = foo;
22     x(22);
23
24     // Here: `u32` is given, which doesn't contain any lifetimes, so we don't
25     // have any annotation.
26     let x = foo::<u32>;
27     x(22);
28
29     let x = foo::<&'static u32>; //~ ERROR [&ReStatic u32]
30     x(&22);
31
32     // Here: we only want the `T` to be given, the rest should be variables.
33     //
34     // (`T` refers to the declaration of `Bazoom`)
35     let x = <_ as Bazoom<u32>>::method::<_>; //~ ERROR [^0, u32, ^1]
36     x(&22, 44, 66);
37
38     // Here: all are given and definitely contain no lifetimes, so we
39     // don't have any annotation.
40     let x = <u8 as Bazoom<u16>>::method::<u32>;
41     x(&22, 44, 66);
42
43     // Here: all are given and we have a lifetime.
44     let x = <u8 as Bazoom<&'static u16>>::method::<u32>; //~ ERROR [u8, &ReStatic u16, u32]
45     x(&22, &44, 66);
46
47     // Here: we want in particular that *only* the method `U`
48     // annotation is given, the rest are variables.
49     //
50     // (`U` refers to the declaration of `Bazoom`)
51     let y = 22_u32;
52     y.method::<u32>(44, 66); //~ ERROR [^0, ^1, u32]
53
54     // Here: nothing is given, so we don't have any annotation.
55     let y = 22_u32;
56     y.method(44, 66);
57 }