]> git.lizzy.rs Git - rust.git/blob - src/test/ui/nll/user-annotations/method-ufcs-3.rs
Auto merge of #53815 - F001:if-let-guard, r=petrochenkov
[rust.git] / src / test / ui / nll / user-annotations / method-ufcs-3.rs
1 // Copyright 2017 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
4 //
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
10
11 // Unit test for the "user substitutions" that are annotated on each
12 // node.
13
14 #![feature(nll)]
15
16 trait Bazoom<T> {
17     fn method<U>(&self, arg: T, arg2: U) { }
18 }
19
20 impl<T, U> Bazoom<U> for T {
21 }
22
23 fn no_annot() {
24     let a = 22;
25     let b = 44;
26     let c = 66;
27     <_ as Bazoom<_>>::method(&a, b, &c); // OK
28 }
29
30 fn annot_underscore() {
31     let a = 22;
32     let b = 44;
33     let c = 66;
34     <_ as Bazoom<_>>::method::<_>(&a, b, &c); // OK
35 }
36
37 fn annot_reference_any_lifetime() {
38     let a = 22;
39     let b = 44;
40     let c = 66;
41     <_ as Bazoom<_>>::method::<&u32>(&a, b, &c); // OK
42 }
43
44 fn annot_reference_static_lifetime() {
45     let a = 22;
46     let b = 44;
47     let c = 66;
48     <_ as Bazoom<_>>::method::<&'static u32>(&a, b, &c); //~ ERROR
49 }
50
51 fn annot_reference_named_lifetime<'a>(_d: &'a u32) {
52     let a = 22;
53     let b = 44;
54     let c = 66;
55     <_ as Bazoom<_>>::method::<&'a u32>(&a, b, &c); //~ ERROR
56 }
57
58 fn annot_reference_named_lifetime_ok<'a>(c: &'a u32) {
59     let a = 22;
60     let b = 44;
61     <_ as Bazoom<_>>::method::<&'a u32>(&a, b, c);
62 }
63
64 fn annot_reference_named_lifetime_in_closure<'a>(_: &'a u32) {
65     let a = 22;
66     let b = 44;
67     let _closure = || {
68         let c = 66;
69         <_ as Bazoom<_>>::method::<&'a u32>(&a, b, &c); //~ ERROR
70     };
71 }
72
73 fn annot_reference_named_lifetime_in_closure_ok<'a>(c: &'a u32) {
74     let a = 22;
75     let b = 44;
76     let _closure = || {
77         <_ as Bazoom<_>>::method::<&'a u32>(&a, b, c);
78     };
79 }
80
81 fn main() { }