]> git.proxmox.com Git - rustc.git/blob - tests/ui/nll/user-annotations/method-call.rs
New upstream version 1.68.2+dfsg1
[rustc.git] / tests / ui / nll / user-annotations / method-call.rs
1 // Unit test for the "user substitutions" that are annotated on each
2 // node.
3
4 trait Bazoom<T> {
5 fn method<U>(&self, arg: T, arg2: U) { }
6 }
7
8 impl<T, U> Bazoom<U> for T {
9 }
10
11 fn no_annot() {
12 let a = 22;
13 let b = 44;
14 let c = 66;
15 a.method(b, &c); // OK
16 }
17
18 fn annot_underscore() {
19 let a = 22;
20 let b = 44;
21 let c = 66;
22 a.method::<_>(b, &c); // OK
23 }
24
25 fn annot_reference_any_lifetime() {
26 let a = 22;
27 let b = 44;
28 let c = 66;
29 a.method::<&u32>(b, &c); // OK
30 }
31
32 fn annot_reference_static_lifetime() {
33 let a = 22;
34 let b = 44;
35 let c = 66;
36 a.method::<&'static u32>(b, &c); //~ ERROR
37 }
38
39 fn annot_reference_named_lifetime<'a>(_d: &'a u32) {
40 let a = 22;
41 let b = 44;
42 let c = 66;
43 a.method::<&'a u32>(b, &c); //~ ERROR
44 }
45
46 fn annot_reference_named_lifetime_ok<'a>(c: &'a u32) {
47 let a = 22;
48 let b = 44;
49 a.method::<&'a u32>(b, c);
50 }
51
52 fn annot_reference_named_lifetime_in_closure<'a>(_: &'a u32) {
53 let a = 22;
54 let b = 44;
55 let _closure = || {
56 let c = 66;
57 a.method::<&'a u32>(b, &c); //~ ERROR
58 };
59 }
60
61 fn annot_reference_named_lifetime_in_closure_ok<'a>(c: &'a u32) {
62 let a = 22;
63 let b = 44;
64 let _closure = || {
65 a.method::<&'a u32>(b, c);
66 };
67 }
68
69 fn main() { }