]> git.lizzy.rs Git - rust.git/blob - tests/ui/nll/user-annotations/method-ufcs-1.rs
Auto merge of #105716 - chriswailes:ndk-update-redux, r=pietroalbini
[rust.git] / tests / ui / nll / user-annotations / method-ufcs-1.rs
1 // Unit test for the "user substitutions" that are annotated on each
2 // node.
3
4 trait Bazoom<T>: Sized {
5     fn method<U>(self, arg: T, arg2: U) { }
6 }
7
8 impl<T, U> Bazoom<U> for T {
9 }
10
11 fn annot_underscore() {
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_reference_any_lifetime() {
19     let a = 22;
20     let b = 44;
21     let c = 66;
22     <&u32 as Bazoom<_>>::method(&a, b, c); // OK
23 }
24
25 fn annot_reference_static_lifetime() {
26     let a = 22;
27     let b = 44;
28     let c = 66;
29     let x = <&'static u32 as Bazoom<_>>::method;
30     x(&a, b, c); //~ ERROR
31 }
32
33 fn annot_reference_named_lifetime<'a>(_d: &'a u32) {
34     let a = 22;
35     let b = 44;
36     let c = 66;
37     <&'a u32 as Bazoom<_>>::method(&a, b, c); //~ ERROR
38 }
39
40 fn annot_reference_named_lifetime_ok<'a>(a: &'a u32) {
41     let b = 44;
42     let c = 66;
43     <&'a u32 as Bazoom<_>>::method(&a, b, c);
44 }
45
46 fn annot_reference_named_lifetime_in_closure<'a>(_: &'a u32) {
47     let a = 22;
48     let b = 44;
49     let _closure = || {
50         let c = 66;
51         <&'a u32 as Bazoom<_>>::method(&a, b, c); //~ ERROR
52     };
53 }
54
55 fn annot_reference_named_lifetime_in_closure_ok<'a>(a: &'a u32) {
56     let b = 44;
57     let c = 66;
58     let _closure = || {
59         <&'a u32 as Bazoom<_>>::method(&a, b, c);
60     };
61 }
62
63 fn main() { }