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