// { dg-additional-options "-frust-name-resolution-2.0 -frust-compile-until=lowering" } macro_rules! impl_fn_for_zst { ($( $( #[$attr: meta] )* struct $Name: ident impl$( <$( $lifetime : lifetime ),+> )? Fn = |$( $arg: ident: $ArgTy: ty ),*| -> $ReturnTy: ty $body: block; )+) => { $( $( #[$attr] )* struct $Name; impl $( <$( $lifetime ),+> )? Fn<($( $ArgTy, )*)> for $Name { #[inline] extern "rust-call" fn call(&self, ($( $arg, )*): ($( $ArgTy, )*)) -> $ReturnTy { $body } } impl $( <$( $lifetime ),+> )? FnMut<($( $ArgTy, )*)> for $Name { #[inline] extern "rust-call" fn call_mut( &mut self, ($( $arg, )*): ($( $ArgTy, )*) ) -> $ReturnTy { Fn::call(&*self, ($( $arg, )*)) } } impl $( <$( $lifetime ),+> )? FnOnce<($( $ArgTy, )*)> for $Name { type Output = $ReturnTy; #[inline] extern "rust-call" fn call_once(self, ($( $arg, )*): ($( $ArgTy, )*)) -> $ReturnTy { Fn::call(&self, ($( $arg, )*)) } } )+ } } #[lang = "sized"] trait Sized {} #[lang = "copy"] trait Copy {} #[lang = "fn"] pub trait Fn: FnMut { /// Performs the call operation. #[unstable(feature = "fn_traits", issue = "29625")] extern "rust-call" fn call(&self, args: Args) -> Self::Output; } #[lang = "fn_mut"] #[must_use = "closures are lazy and do nothing unless called"] pub trait FnMut: FnOnce { /// Performs the call operation. #[unstable(feature = "fn_traits", issue = "29625")] extern "rust-call" fn call_mut(&mut self, args: Args) -> Self::Output; } #[lang = "fn_once"] pub trait FnOnce { /// The returned type after the call operator is used. #[lang = "fn_once_output"] #[stable(feature = "fn_once_output", since = "1.12.0")] type Output; /// Performs the call operation. #[unstable(feature = "fn_traits", issue = "29625")] extern "rust-call" fn call_once(self, args: Args) -> Self::Output; } impl_fn_for_zst! { /// Documentation for the zst #[derive(Copy)] struct LinesAnyMap impl<'a> Fn = |line: &'a str| -> () { }; }