pub(crate) struct FnParseMode {
pub(super) req_name: fn(_: Edition) -> bool,
pub(super) req_body: bool,
}
Expand description
Parsing configuration for functions.
The syntax of function items is slightly different within trait definitions, impl blocks, and modules. It is still parsed using the same code, just with different flags set, so that even when the input is wrong and produces a parse error, it still gets into the AST and the rest of the parser and type checker can run.
Fields§
§req_name: fn(_: Edition) -> bool
A function pointer that decides if, per-parameter p
, p
must have a
pattern or just a type. This field affects parsing of the parameters list.
fn foo(alef: A) -> X { X::new() }
-----^^ affects parsing this part of the function signature
|
if req_name returns false, then this name is optional
fn bar(A) -> X;
^
|
if req_name returns true, this is an error
Calling this function pointer should only return false if:
- The item is being parsed inside of a trait definition. Within an impl block or a module, it should always evaluate to true.
- The span is from Edition 2015. In particular, you can get a 2015 span inside a 2021 crate using macros.
req_body: bool
If this flag is set to true
, then plain, semicolon-terminated function
prototypes are not allowed here.
fn foo(alef: A) -> X { X::new() }
^^^^^^^^^^^^
|
this is always allowed
fn bar(alef: A, bet: B) -> X;
^
|
if req_body is set to true, this is an error
This field should only be set to false if the item is inside of a trait definition or extern block. Within an impl block or a module, it should always be set to true.
Trait Implementations§
Source§impl Clone for FnParseMode
impl Clone for FnParseMode
Source§fn clone(&self) -> FnParseMode
fn clone(&self) -> FnParseMode
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreimpl Copy for FnParseMode
Auto Trait Implementations§
impl DynSend for FnParseMode
impl DynSync for FnParseMode
impl Freeze for FnParseMode
impl RefUnwindSafe for FnParseMode
impl Send for FnParseMode
impl Sync for FnParseMode
impl Unpin for FnParseMode
impl UnwindSafe for FnParseMode
Blanket Implementations§
Source§impl<'tcx, T> ArenaAllocatable<'tcx, IsCopy> for Twhere
T: Copy,
impl<'tcx, T> ArenaAllocatable<'tcx, IsCopy> for Twhere
T: Copy,
fn allocate_on(self, arena: &'tcx Arena<'tcx>) -> &'tcx mut T
fn allocate_from_iter( arena: &'tcx Arena<'tcx>, iter: impl IntoIterator<Item = T>, ) -> &'tcx mut [T]
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T, R> CollectAndApply<T, R> for T
impl<T, R> CollectAndApply<T, R> for T
Source§impl<T> Filterable for T
impl<T> Filterable for T
Source§fn filterable(
self,
filter_name: &'static str,
) -> RequestFilterDataProvider<T, fn(_: DataRequest<'_>) -> bool>
fn filterable( self, filter_name: &'static str, ) -> RequestFilterDataProvider<T, fn(_: DataRequest<'_>) -> bool>
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<I, T, U> Upcast<I, U> for Twhere
U: UpcastFrom<I, T>,
impl<I, T, U> Upcast<I, U> for Twhere
U: UpcastFrom<I, T>,
Source§impl<I, T> UpcastFrom<I, T> for T
impl<I, T> UpcastFrom<I, T> for T
fn upcast_from(from: T, _tcx: I) -> T
Source§impl<T> WithSubscriber for T
impl<T> WithSubscriber for T
Source§fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
Source§fn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
impl<'a, T> Captures<'a> for Twhere
T: ?Sized,
impl<T> ErasedDestructor for Twhere
T: 'static,
impl<T> MaybeSendSync for T
Layout§
Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...)
attributes. Please see the Rust Reference's “Type Layout” chapter for details on type layout guarantees.
Size: 16 bytes