Grammar summary
│ │ │The following is a summary of the grammar production rules. For details on the syntax of this grammar, see notation.grammar.syntax.
│ │ │ -Attributes summary
│ │ │ -Syntax
│ │ │ -
│ │ │ -ProcMacroDeriveAttribute →
proc_macro_derive ( DeriveMacroName ( , DeriveMacroAttributes )? ,? )
DeriveMacroAttributes →
attributes ( ( IDENTIFIER ( , IDENTIFIER )* ,? )? )
InnerAttribute → # ! [ Attr ]
│ │ │ -OuterAttribute → # [ Attr ]
│ │ │ -Attr →
SimplePath AttrInput?
| unsafe ( SimplePath AttrInput? )
AttrInput →
DelimTokenTree
| = Expression
MetaItem →
SimplePath
| SimplePath = Expression
| SimplePath ( MetaSeq? )
MetaSeq →
MetaItemInner ( , MetaItemInner )* ,?
MetaItemInner →
MetaItem
| Expression
MetaNameValueStr →
IDENTIFIER = ( STRING_LITERAL | RAW_STRING_LITERAL )
MetaListPaths →
IDENTIFIER ( ( SimplePath ( , SimplePath )* ,? )? )
MetaListIdents →
IDENTIFIER ( ( IDENTIFIER ( , IDENTIFIER )* ,? )? )
MetaListNameValueStr →
IDENTIFIER ( ( MetaNameValueStr ( , MetaNameValueStr )* ,? )? )
CollapseDebuginfoAttribute → collapse_debuginfo ( CollapseDebuginfoOption )
│ │ │ -CollapseDebuginfoOption →
yes
| no
| external
InlineAttribute →
inline ( always )
| inline ( never )
| inline
Configuration summary
│ │ │ -Syntax
│ │ │ -
│ │ │ -ConfigurationPredicate →
ConfigurationOption
| ConfigurationAll
| ConfigurationAny
| ConfigurationNot
| true
| false
ConfigurationOption →
IDENTIFIER ( = ( STRING_LITERAL | RAW_STRING_LITERAL ) )?
ConfigurationAll →
all ( ConfigurationPredicateList? )
ConfigurationAny →
any ( ConfigurationPredicateList? )
ConfigurationNot →
not ( ConfigurationPredicate )
ConfigurationPredicateList →
ConfigurationPredicate ( , ConfigurationPredicate )* ,?
CfgAttribute → cfg ( ConfigurationPredicate )
│ │ │ -CfgAttrAttribute → cfg_attr ( ConfigurationPredicate , CfgAttrs? )
│ │ │ -CfgAttrs → Attr ( , Attr )* ,?
│ │ │ - │ │ │ -CfgSelectArms →
CfgSelectConfigurationPredicate =>
(
{ ^ TokenTree } ,? CfgSelectArms?
| ExpressionWithBlockNoAttrs ,? CfgSelectArms?
| ExpressionWithoutBlockNoAttrs ( , CfgSelectArms? )?
)
CfgSelectConfigurationPredicate →
ConfigurationPredicate | _
Assembly summary
│ │ │ -Syntax
│ │ │ -
│ │ │ -AsmArgs → AsmAttrFormatString ( , AsmAttrFormatString )* ( , AsmAttrOperand )* ,?
FormatString → STRING_LITERAL | RAW_STRING_LITERAL | MacroInvocation
│ │ │ -AsmAttrFormatString → ( OuterAttribute )* FormatString
│ │ │ -AsmOperand →
ClobberAbi
| AsmOptions
| RegOperand
AsmAttrOperand → ( OuterAttribute )* AsmOperand
│ │ │ -ClobberAbi → clobber_abi ( Abi ( , Abi )* ,? )
│ │ │ -AsmOptions →
options ( ( AsmOption ( , AsmOption )* ,? )? )
AsmOption →
pure
| nomem
| readonly
| preserves_flags
| noreturn
| nostack
| att_syntax
| raw
RegOperand → ( ParamName = )?
(
DirSpec ( RegSpec ) Expression
| DualDirSpec ( RegSpec ) DualDirSpecExpression
| sym PathExpression
| const Expression
| label { Statements? }
)
ParamName → IDENTIFIER_OR_KEYWORD | RAW_IDENTIFIER
│ │ │ -DualDirSpecExpression →
Expression
| Expression => Expression
RegSpec → RegisterClass | ExplicitRegister
│ │ │ -RegisterClass → IDENTIFIER_OR_KEYWORD
│ │ │ -ExplicitRegister → STRING_LITERAL
│ │ │ -DirSpec →
in
| out
| lateout
DualDirSpec →
inout
| inlateout
Items summary
│ │ │Syntax
│ │ │
│ │ │ -Visibility →
pub
| pub ( crate )
| pub ( self )
| pub ( super )
| pub ( in SimplePath )
Item →
OuterAttribute* ( VisItem | MacroItem )
OuterAttribute* ( VisItem | MacroItem ) │ │ │
VisItem →
Visibility?
(
Module
| ExternCrate
| UseDeclaration
| Function
| TypeAlias
| Struct
| Enumeration
| Union
| ConstantItem
| StaticItem
| Trait
| Implementation
| ExternBlock
)
MacroItem →
MacroInvocationSemi
| MacroRulesDefinition
Crate →
InnerAttribute*
Item*
Visibility →
pub
| pub ( crate )
| pub ( self )
| pub ( super )
| pub ( in SimplePath )
Trait →
unsafe? trait IDENTIFIER GenericParams? ( : TypeParamBounds? )? WhereClause?
{
InnerAttribute*
AssociatedItem*
}
TypeAlias →
type IDENTIFIER GenericParams? ( : TypeParamBounds )?
WhereClause?
( = Type WhereClause? )? ;
ConstantItem →
const ( IDENTIFIER | _ ) : Type ( = Expression )? ;
Struct →
StructStruct
| TupleStruct
StructStruct →
struct IDENTIFIER GenericParams? WhereClause? ( { StructFields? } | ; )
TupleStruct →
struct IDENTIFIER GenericParams? ( TupleFields? ) WhereClause? ;
StructFields → StructField ( , StructField )* ,?
│ │ │StructField → OuterAttribute* Visibility? IDENTIFIER : Type
│ │ │TupleFields → TupleField ( , TupleField )* ,?
│ │ │TupleField → OuterAttribute* Visibility? Type
│ │ │ +Implementation → InherentImpl | TraitImpl
│ │ │ +InherentImpl →
impl GenericParams? Type WhereClause? {
InnerAttribute*
AssociatedItem*
}
TraitImpl →
unsafe? impl GenericParams? !? TypePath for Type
WhereClause?
{
InnerAttribute*
AssociatedItem*
}
Function →
FunctionQualifiers fn IDENTIFIER GenericParams?
( FunctionParameters? )
FunctionReturnType? WhereClause?
( BlockExpression | ; )
FunctionQualifiers → const? async? ItemSafety? ( extern Abi? )?
│ │ │ItemSafety → safe | unsafe
│ │ │Abi → STRING_LITERAL | RAW_STRING_LITERAL
│ │ │FunctionParameters →
SelfParam ,?
| ( SelfParam , )? FunctionParam ( , FunctionParam )* ,?
SelfParam → OuterAttribute* ( ShorthandSelf | TypedSelf )
│ │ │ShorthandSelf → ( & | & Lifetime )? mut? self
│ │ │ │ │ │FunctionParam → OuterAttribute* ( FunctionParamPattern | ... | Type )
│ │ │FunctionParamPattern → PatternNoTopAlt : ( Type | ... )
│ │ │FunctionReturnType → -> Type
│ │ │ -Implementation → InherentImpl | TraitImpl
│ │ │ -InherentImpl →
impl GenericParams? Type WhereClause? {
InnerAttribute*
AssociatedItem*
}
TraitImpl →
unsafe? impl GenericParams? !? TypePath for Type
WhereClause?
{
InnerAttribute*
AssociatedItem*
}
Enumeration →
enum IDENTIFIER GenericParams? WhereClause? { EnumVariants? }
EnumVariants → EnumVariant ( , EnumVariant )* ,?
│ │ │ -EnumVariant →
OuterAttribute* Visibility?
IDENTIFIER ( EnumVariantTuple | EnumVariantStruct )? EnumVariantDiscriminant?
EnumVariantTuple → ( TupleFields? )
│ │ │ -EnumVariantStruct → { StructFields? }
│ │ │ -EnumVariantDiscriminant → = Expression
│ │ │ -UseDeclaration → use UseTree ;
│ │ │ -UseTree →
( SimplePath? :: )? *
| ( SimplePath? :: )? { ( UseTree ( , UseTree )* ,? )? }
| SimplePath ( as ( IDENTIFIER | _ ) )?
Union →
union IDENTIFIER GenericParams? WhereClause? { StructFields? }
ConstantItem →
const ( IDENTIFIER | _ ) : Type ( = Expression )? ;
AssociatedItem →
OuterAttribute* (
MacroInvocationSemi
| ( Visibility? ( TypeAlias | ConstantItem | Function ) )
)
StaticItem →
ItemSafety? static mut? IDENTIFIER : Type ( = Expression )? ;
ExternBlock →
unsafe? extern Abi? {
InnerAttribute*
ExternalItem*
}
ExternalItem →
OuterAttribute* (
MacroInvocationSemi
| Visibility? StaticItem
| Visibility? Function
)
ExternCrate → extern crate CrateRef AsClause? ;
│ │ │ -CrateRef → IDENTIFIER | self
│ │ │ -AsClause → as ( IDENTIFIER | _ )
│ │ │ -TypeAlias →
type IDENTIFIER GenericParams? ( : TypeParamBounds )?
WhereClause?
( = Type WhereClause? )? ;
Module →
unsafe? mod IDENTIFIER ;
| unsafe? mod IDENTIFIER {
InnerAttribute*
Item*
}
GenericParams → < ( GenericParam ( , GenericParam )* ,? )? >
│ │ │GenericParam → OuterAttribute* ( LifetimeParam | TypeParam | ConstParam )
│ │ │LifetimeParam → Lifetime ( : LifetimeBounds )?
│ │ │TypeParam → IDENTIFIER ( : TypeParamBounds? )? ( = Type )?
│ │ │ConstParam →
const IDENTIFIER : Type
( = ( BlockExpression | IDENTIFIER | -? LiteralExpression ) )?
WhereClause → where ( WhereClauseItem , )* WhereClauseItem?
│ │ │WhereClauseItem →
LifetimeWhereClauseItem
| TypeBoundWhereClauseItem
LifetimeWhereClauseItem → Lifetime : LifetimeBounds
│ │ │TypeBoundWhereClauseItem → ForLifetimes? Type : TypeParamBounds?
│ │ │ +StaticItem →
ItemSafety? static mut? IDENTIFIER : Type ( = Expression )? ;
ExternCrate → extern crate CrateRef AsClause? ;
│ │ │ +CrateRef → IDENTIFIER | self
│ │ │ +AsClause → as ( IDENTIFIER | _ )
│ │ │ +AssociatedItem →
OuterAttribute* (
MacroInvocationSemi
| ( Visibility? ( TypeAlias | ConstantItem | Function ) )
)
ExternBlock →
unsafe? extern Abi? {
InnerAttribute*
ExternalItem*
}
ExternalItem →
OuterAttribute* (
MacroInvocationSemi
| Visibility? StaticItem
| Visibility? Function
)
Union →
union IDENTIFIER GenericParams? WhereClause? { StructFields? }
UseDeclaration → use UseTree ;
│ │ │ +UseTree →
( SimplePath? :: )? *
| ( SimplePath? :: )? { ( UseTree ( , UseTree )* ,? )? }
| SimplePath ( as ( IDENTIFIER | _ ) )?
Module →
unsafe? mod IDENTIFIER ;
| unsafe? mod IDENTIFIER {
InnerAttribute*
Item*
}
Enumeration →
enum IDENTIFIER GenericParams? WhereClause? { EnumVariants? }
EnumVariants → EnumVariant ( , EnumVariant )* ,?
│ │ │ +EnumVariant →
OuterAttribute* Visibility?
IDENTIFIER ( EnumVariantTuple | EnumVariantStruct )? EnumVariantDiscriminant?
EnumVariantTuple → ( TupleFields? )
│ │ │ +EnumVariantStruct → { StructFields? }
│ │ │ + │ │ │ │ │ │