1 // run-rustfix
2 // edition:2018
3
4 #![allow(unused)]
5 #![deny(elided_lifetimes_in_paths)]
6 //~^ NOTE the lint level is defined here
7
8 use std::cell::{RefCell, Ref};
9
10
11 struct Foo<'a> { x: &'a u32 }
12
foo(x: &Foo)13 fn foo(x: &Foo) {
14 //~^ ERROR hidden lifetime parameters in types are deprecated
15 //~| HELP indicate the anonymous lifetime
16 }
17
bar(x: &Foo<'_>)18 fn bar(x: &Foo<'_>) {}
19
20
21 struct Wrapped<'a>(&'a str);
22
23 struct WrappedWithBow<'a> {
24 gift: &'a str
25 }
26
27 struct MatchedSet<'a, 'b> {
28 one: &'a str,
29 another: &'b str,
30 }
31
wrap_gift(gift: &str) -> Wrapped32 fn wrap_gift(gift: &str) -> Wrapped {
33 //~^ ERROR hidden lifetime parameters in types are deprecated
34 //~| HELP indicate the anonymous lifetime
35 Wrapped(gift)
36 }
37
wrap_gift_with_bow(gift: &str) -> WrappedWithBow38 fn wrap_gift_with_bow(gift: &str) -> WrappedWithBow {
39 //~^ ERROR hidden lifetime parameters in types are deprecated
40 //~| HELP indicate the anonymous lifetime
41 WrappedWithBow { gift }
42 }
43
inspect_matched_set(set: MatchedSet)44 fn inspect_matched_set(set: MatchedSet) {
45 //~^ ERROR hidden lifetime parameters in types are deprecated
46 //~| HELP indicate the anonymous lifetime
47 println!("{} {}", set.one, set.another);
48 }
49
50 macro_rules! autowrapper {
51 ($type_name:ident, $fn_name:ident, $lt:lifetime) => {
52 struct $type_name<$lt> {
53 gift: &$lt str
54 }
55
56 fn $fn_name(gift: &str) -> $type_name {
57 //~^ ERROR hidden lifetime parameters in types are deprecated
58 //~| HELP indicate the anonymous lifetime
59 $type_name { gift }
60 }
61 }
62 }
63
64 autowrapper!(Autowrapped, autowrap_gift, 'a);
65 //~^ NOTE in this expansion of autowrapper!
66 //~| NOTE in this expansion of autowrapper!
67
68 macro_rules! anytuple_ref_ty {
69 ($($types:ty),*) => {
70 Ref<($($types),*)>
71 //~^ ERROR hidden lifetime parameters in types are deprecated
72 //~| HELP indicate the anonymous lifetime
73 }
74 }
75
main()76 fn main() {
77 let honesty = RefCell::new((4, 'e'));
78 let loyalty: Ref<(u32, char)> = honesty.borrow();
79 //~^ ERROR hidden lifetime parameters in types are deprecated
80 //~| HELP indicate the anonymous lifetime
81 let generosity = Ref::map(loyalty, |t| &t.0);
82
83 let laughter = RefCell::new((true, "magic"));
84 let yellow: anytuple_ref_ty!(bool, &str) = laughter.borrow();
85 //~^ NOTE in this expansion of anytuple_ref_ty!
86 //~| NOTE in this expansion of anytuple_ref_ty!
87 }
88