]> git.lizzy.rs Git - rust.git/blob - tests/ui/nll/user-annotations/method-ufcs-3.rs
Rollup merge of #106144 - tgross35:patch-1, r=Mark-Simulacrum
[rust.git] / tests / ui / nll / user-annotations / method-ufcs-3.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     <_ as Bazoom<_>>::method(&a, b, &c); // OK
16 }
17
18 fn annot_underscore() {
19     let a = 22;
20     let b = 44;
21     let c = 66;
22     <_ as Bazoom<_>>::method::<_>(&a, b, &c); // OK
23 }
24
25 fn annot_reference_any_lifetime() {
26     let a = 22;
27     let b = 44;
28     let c = 66;
29     <_ as Bazoom<_>>::method::<&u32>(&a, b, &c); // OK
30 }
31
32 fn annot_reference_static_lifetime() {
33     let a = 22;
34     let b = 44;
35     let c = 66;
36     <_ as Bazoom<_>>::method::<&'static u32>(&a, 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     <_ as Bazoom<_>>::method::<&'a u32>(&a, 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     <_ as Bazoom<_>>::method::<&'a u32>(&a, 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         <_ as Bazoom<_>>::method::<&'a u32>(&a, 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         <_ as Bazoom<_>>::method::<&'a u32>(&a, b, c);
66     };
67 }
68
69 fn main() { }