fork/rust
git clone https://git.julia.blue/fork/rust
4fb7144ed15
1.43.0
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 8use std::cell::{RefCell, Ref}; 9 10 11struct Foo<'a> { x: &'a u32 } 12 13fn foo(x: &Foo<'_>) { 14 //~^ ERROR hidden lifetime parameters in types are deprecated 15 //~| HELP indicate the anonymous lifetime 16} 17 18fn bar(x: &Foo<'_>) {} 19 20 21struct Wrapped<'a>(&'a str); 22 23struct WrappedWithBow<'a> { 24 gift: &'a str 25} 26 27struct MatchedSet<'a, 'b> { 28 one: &'a str, 29 another: &'b str, 30} 31 32fn 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 38fn 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 44fn 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 50macro_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 64autowrapper!(Autowrapped, autowrap_gift, 'a); 65//~^ NOTE in this expansion of autowrapper! 66//~| NOTE in this expansion of autowrapper! 67 68macro_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 76fn 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}