1 // Copyright 2018 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.
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.
12 // compile-flags: --edition 2018
15 #![deny(elided_lifetimes_in_paths)]
16 //~^ NOTE lint level defined here
18 use std::cell::{RefCell, Ref};
21 struct Foo<'a> { x: &'a u32 }
24 //~^ ERROR hidden lifetime parameters in types are deprecated
25 //~| HELP indicate the anonymous lifetime
28 fn bar(x: &Foo<'_>) {}
31 struct Wrapped<'a>(&'a str);
33 struct WrappedWithBow<'a> {
37 struct MatchedSet<'a, 'b> {
42 fn wrap_gift(gift: &str) -> Wrapped {
43 //~^ ERROR hidden lifetime parameters in types are deprecated
44 //~| HELP indicate the anonymous lifetime
48 fn wrap_gift_with_bow(gift: &str) -> WrappedWithBow {
49 //~^ ERROR hidden lifetime parameters in types are deprecated
50 //~| HELP indicate the anonymous lifetime
51 WrappedWithBow { gift }
54 fn inspect_matched_set(set: MatchedSet) {
55 //~^ ERROR hidden lifetime parameters in types are deprecated
56 //~| HELP indicate the anonymous lifetime
57 println!("{} {}", set.one, set.another);
60 macro_rules! autowrapper {
61 ($type_name:ident, $fn_name:ident, $lt:lifetime) => {
62 struct $type_name<$lt> {
66 fn $fn_name(gift: &str) -> $type_name {
67 //~^ ERROR hidden lifetime parameters in types are deprecated
68 //~| HELP indicate the anonymous lifetime
74 autowrapper!(Autowrapped, autowrap_gift, 'a);
75 //~^ NOTE in this expansion of autowrapper!
76 //~| NOTE in this expansion of autowrapper!
78 macro_rules! anytuple_ref_ty {
81 //~^ ERROR hidden lifetime parameters in types are deprecated
82 //~| HELP indicate the anonymous lifetime
87 let honesty = RefCell::new((4, 'e'));
88 let loyalty: Ref<(u32, char)> = honesty.borrow();
89 //~^ ERROR hidden lifetime parameters in types are deprecated
90 //~| HELP indicate the anonymous lifetime
91 let generosity = Ref::map(loyalty, |t| &t.0);
93 let laughter = RefCell::new((true, "magic"));
94 let yellow: anytuple_ref_ty!(bool, &str) = laughter.borrow();
95 //~^ NOTE in this expansion of anytuple_ref_ty!
96 //~| NOTE in this expansion of anytuple_ref_ty!